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 /// Substrate-canonical exhaustive accept-set on the [`DepList`]
3223 /// `:`-prefixed kebab-case tatara-lisp author-surface key axis —
3224 /// the closed two-arm roster of every byte-string [`Self::as_str`]
3225 /// returns, routed byte-for-byte through the paired
3226 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3227 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] lifted `pub const`
3228 /// scalars the [`Self::as_str`] emitter (and the
3229 /// [`std::fmt::Display`] / [`AsRef<str>`] / `From<{Self,&Self}> for
3230 /// {&'static str, String, Cow<'static, str>, Box<str>, Arc<str>}`
3231 /// trait triple + quintuple routed through it) walks, and the same
3232 /// two strings the paired [`Self::from_wire`] reverse projection
3233 /// accepts.
3234 ///
3235 /// Peer of the sibling [`crate::CaixaKind::WIRE_NAMES`] (bd708bd) /
3236 /// [`crate::supervisor::RestartStrategy::WIRE_NAMES`] (3033f45) /
3237 /// [`crate::supervisor::RestartPolicy::WIRE_NAMES`] (ce9412b) /
3238 /// [`crate::aplicacao::PlacementStrategy::WIRE_NAMES`] (3e5b194)
3239 /// rosters on the `PascalCase` wire byte-string axis, the sibling
3240 /// [`crate::CaixaKind::LABELS`] (427fe75) /
3241 /// [`crate::aplicacao::WitShape::LABELS`] (9d9f585) rosters on the
3242 /// lowercase kebab census-label byte-string axis, the sibling
3243 /// [`crate::aplicacao::RateLimitUnit::SUFFIXES`] (b553ec9) roster
3244 /// on the single-char canonical-suffix axis, and the sibling
3245 /// [`crate::upgrade::UpgradeInstruction::LISP_FORMS`] (1898d77) /
3246 /// [`crate::upgrade::UpgradeInstruction::WIRE_FORMS`] (cc42c0e)
3247 /// rosters on the OTP-appup discriminator's two-axis roster split
3248 /// — the same closed-set exhaustive-accept-set roster discipline
3249 /// extended here onto the outer-`Caixa` two-list dep-graph
3250 /// closed-set typed enum, the ninth substrate-side closed-set
3251 /// typed enum on the roster-discipline axis and the last unlifted
3252 /// `&'static str`-carrying closed-set typed enum on the top-level
3253 /// manifest surface (the sibling `AsRef<str>` doc block at
3254 /// [`AsRef<str>`] already names the two-list dep-graph as "the
3255 /// seventh (and last unlifted) closed-set typed enum on the caixa
3256 /// surface" for the trait-idiomatic projection family — the same
3257 /// closure applies here on the exhaustive-roster family).
3258 ///
3259 /// Downstream consumers of the closed accepted-key set — a future
3260 /// `feira dep --list <deps|deps-dev>` CLI arg-parse's "did you
3261 /// mean" hint that scans this slice rather than open-coding a
3262 /// two-string array literal, a future M4
3263 /// `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
3264 /// body enumerating the accepted `:deps` / `:deps-dev` author-
3265 /// surface keys verbatim on an unknown-key miss, a future
3266 /// `feira dep census` per-Caixa `:deps` / `:deps-dev` histogram
3267 /// column that walks the roster to render every arm's tally
3268 /// (including zero-count arms — a hand-rolled projection off
3269 /// [`Self::ALL`] alone would need a companion per-variant-to-key
3270 /// map at every consumer; this roster closes the two-axis walk in
3271 /// one lifted const), any future K8s CRD generation tool that
3272 /// emits the accepted-key enum on the Caixa CR schema, a future
3273 /// [`DepError`] widening that promotes the two `list: &'static
3274 /// str` fields to a typed `list: DepList` carry so downstream
3275 /// consumers dispatch on the enum rather than string-comparing
3276 /// the wire scalar — every consumer that wants to enumerate the
3277 /// closed dep-list author-key set outside caixa-core now reaches
3278 /// for one lifted substrate-primitive roster rather than open-
3279 /// coding a `[":deps", ":deps-dev"]` array-literal whose arm-set
3280 /// has no compile-time link back to the typed [`DepList`] enum.
3281 /// A future arm addition (a `:build-dep` third list once the
3282 /// substrate grows Cargo-style split-graphs, a `:tool-dep` for
3283 /// build-time-only tooling per the peer Cargo
3284 /// `[build-dependencies]` / `[target.<cfg>.dev-dependencies]`
3285 /// future admission surface — both trajectory items the sibling
3286 /// [`Self::from_wire`] doc block already names) extends this
3287 /// roster as a single edit — paired with the [`Self::as_str`]
3288 /// match's compiler-checked exhaustiveness on the new arm — and
3289 /// every consumer picks up the new key by construction rather
3290 /// than a coordinated array-literal rewrite across every
3291 /// downstream site.
3292 ///
3293 /// Length is pinned load-bearing at `DepList::ALL.len()` (two) by
3294 /// [`tests::dep_list_author_keys_covers_every_arm`], every
3295 /// variant's [`Self::as_str`] projection is pinned to a member of
3296 /// the roster on every arm so a silent skew between the emitter's
3297 /// arm-set and this const's arm-set trips at caixa-core test time
3298 /// rather than at a downstream consumer's accepted-set enumeration
3299 /// miss, and every entry is further pinned to open with the ASCII
3300 /// `:` byte (the tatara-lisp author-surface keyword marker) so a
3301 /// silent collapse with any hypothetical peer un-prefixed wire-form
3302 /// axis (an entry byte-identical to a sibling `deps` / `deps-dev`
3303 /// bare-kebab byte-string that would let an author-key-axis
3304 /// consumer accept the un-prefixed vocabulary) trips here rather
3305 /// than at a downstream K8s-CR round-trip miss.
3306 pub const AUTHOR_KEYS: &'static [&'static str] = &[
3307 crate::render::DEP_AUTHOR_KEY_DEPS,
3308 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3309 ];
3310
3311 /// Canonical author-surface tag every substrate consumer that
3312 /// names the offending dep-list in a diagnostic reaches for —
3313 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3314 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3315 /// the same `&'static str` payload the sibling
3316 /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3317 /// already carry. Routing every dep-list diagnostic through the
3318 /// closed-set enum's `as_str` closes the last `&'static str`-shape
3319 /// literal-carry axis on the two-list dep-graph surface — a
3320 /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3321 /// wire-format promotion (a distinct diagnostic form for the
3322 /// `Dev` arm) reaches every consumer through one edit on the
3323 /// canonical constant, not a coordinated rewrite across the
3324 /// substrate's dep-graph consumers.
3325 #[must_use]
3326 pub const fn as_str(self) -> &'static str {
3327 match self {
3328 Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3329 Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3330 }
3331 }
3332
3333 /// Substrate-canonical reverse projection on the two-list dep-graph
3334 /// axis — parses the author-surface wire tag back to the typed
3335 /// variant, or `None` when `s` is outside the closed-set arm-string
3336 /// set [`Self::as_str`] emits. Dispatches on the same lifted
3337 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3338 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3339 /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3340 /// the round-trip migrate through one caixa-core edit on any future
3341 /// list-axis addition.
3342 ///
3343 /// Prior to this lift the substrate carried only the forward
3344 /// `Self → &str` projection on the two-list dep-graph axis (the
3345 /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3346 /// through it, the two [`DepError::DuplicateNome`] /
3347 /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3348 /// as a `&'static str` `list:` field). Every future consumer that
3349 /// wanted to promote the wire tag back to the typed enum (a future
3350 /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3351 /// wire form into the typed enum before dispatching to
3352 /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3353 /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3354 /// wire re-parse of the per-list diagnostic body, a future
3355 /// [`DepError`] widening that promotes the two `list: &'static str`
3356 /// fields to a typed `list: DepList` carry so downstream consumers
3357 /// dispatch on the enum rather than string-comparing the wire
3358 /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3359 /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3360 /// compile-time link back to the typed [`DepList`] enum. A future
3361 /// variant addition (a `:build-dep` or `:test-dep` third list once
3362 /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3363 /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3364 /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3365 /// would silently split the wire byte-string the emitter walks from
3366 /// the parser's arm-set — the round-trip would carry the new list
3367 /// through the forward projection but land on the fallback silently
3368 /// at every non-updated reverse parser, far from the arm-addition
3369 /// commit that caused the drift. Lifting the resolver to a typed
3370 /// method on the substrate primitive closes the drift footgun by
3371 /// construction: the parser's accept-set is the same set the
3372 /// [`Self::as_str`] emitter walks (routed through the same lifted
3373 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3374 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3375 /// of the round-trip migrate through one caixa-core edit on any
3376 /// future list-axis addition.
3377 ///
3378 /// Same closed-set-reverse-projection discipline the sibling
3379 /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3380 /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3381 /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3382 /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3383 /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3384 /// carry on the peer wire-side `str → Self` axes — extended onto
3385 /// the two-list dep-graph closed-set axis, the sixth substrate-side
3386 /// closed-set typed enum on the caixa surface to converge on the
3387 /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3388 /// `from_str`) to match the peer shapes verbatim and side-step the
3389 /// derived [`std::str::FromStr`] impls the sibling
3390 /// [`gen_platform::FromStrKind`]-carrying axes install on their
3391 /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3392 /// (rather than `Result<Self, _>`) to match the peer shapes: the
3393 /// caller picks the diagnostic form appropriate for its use site —
3394 /// a future `feira dep --list …` arg-parse that surfaces
3395 /// `unknown list: <arg>` at the CLI builds one on top by iterating
3396 /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3397 /// path folds `None` onto its per-CR structured refusal body.
3398 #[must_use]
3399 pub fn from_wire(s: &str) -> Option<Self> {
3400 match s {
3401 crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3402 crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3403 _ => None,
3404 }
3405 }
3406}
3407
3408/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3409/// consumer that formats the axis as user-facing text (a future
3410/// `feira app graph` per-list summary, a future M4 admission-webhook
3411/// rejection body naming the offending list, this crate's own
3412/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3413/// typed [`DepList`]) lands on the same author-surface tag the
3414/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3415/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3416/// as-str-through-Display convergence discipline the sibling
3417/// [`crate::aplicacao::PlacementStrategy`],
3418/// [`crate::aplicacao::RateLimitUnit`],
3419/// [`crate::supervisor::RestartStrategy`],
3420/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3421/// closed-set typed enums carry.
3422impl std::fmt::Display for DepList {
3423 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3424 f.write_str(self.as_str())
3425 }
3426}
3427
3428/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3429/// dep-graph closed-set typed enum — routes through the same
3430/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3431/// [`std::fmt::Display`] impl already delegates through, so any future
3432/// consumer that binds a [`DepList`] through the standard-library
3433/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3434/// that composes the canonical author-surface tag into a
3435/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3436/// `tracing::field::Value::Str`-arm structured-log recorder on the
3437/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3438/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3439/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3440/// webhook's per-list rejection-body composition table) reaches the
3441/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3442/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3443/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3444/// re-inlining at every wire-up.
3445///
3446/// Same "route the trait impl through the substrate-primitive
3447/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3448/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3449/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3450/// [`AsRef<str>`] impl (cd2091f), the M3
3451/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3452/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3453/// [`AsRef<str>`] impl (419ea81), the M2
3454/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3455/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3456/// (16d5c7e) carry — closes the substrate primitive's
3457/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3458/// closed-set typed enum on the caixa surface: the two-list dep-graph
3459/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3460/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3461/// bound the enum through the standard-library `AsRef<str>` trait had
3462/// to reach the canonical byte-string through an open-coded
3463/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3464/// peer closed-set typed enums already admit.
3465///
3466/// Pinned load-bearing by
3467/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3468/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3469/// closed set) and
3470/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3471/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3472/// resolve to the same byte-string per arm) — any future silent detour
3473/// that routes the impl through a divergent projection (a per-arm
3474/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3475/// that opens a compile-time link to the un-lifted arm-literal, a
3476/// swap onto a second projection axis) trips at caixa-core test time
3477/// under `assert_eq!` rather than at a downstream
3478/// `impl AsRef<str>`-bound consumer's silent split.
3479impl AsRef<str> for DepList {
3480 fn as_ref(&self) -> &str {
3481 self.as_str()
3482 }
3483}
3484
3485/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3486/// [`DepList`] closed-set typed enum — routes through the paired
3487/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3488/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3489/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3490/// through, rather than an open-coded per-arm
3491/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3492/// has no compile-time link back to the substrate primitive.
3493///
3494/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3495/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3496/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3497/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3498/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3499/// which silently omitted [`DepList`] despite this enum being listed
3500/// as a sibling closed-set fieldless typed enum in every peer's
3501/// docstring). Every sibling closed-set fieldless typed enum on the
3502/// caixa surface now carries both trait-idiomatic axes
3503/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3504/// against the substrate-primitive canonical projection accessors
3505/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3506/// closed-set is the fifteenth and true-final peer.
3507///
3508/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3509/// `Option<Self>` return-shape's deliberate deferral of error typing:
3510/// the caller picks the diagnostic form appropriate for its use site
3511/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3512/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3513/// the M4 admission-webhook rejection body wraps `Err(())` with the
3514/// accepted-set enumeration).
3515///
3516/// Pinned load-bearing by
3517/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3518/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3519/// accept-set) and
3520/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3521/// (rejection witness against silent accept-set widening).
3522impl TryFrom<&str> for DepList {
3523 type Error = ();
3524
3525 fn try_from(s: &str) -> Result<Self, Self::Error> {
3526 Self::from_wire(s).ok_or(())
3527 }
3528}
3529
3530/// Trait-idiomatic *forward* projection on the two-list dep-graph
3531/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3532/// routes byte-for-byte through the paired substrate-primitive
3533/// [`DepList::as_str`] `pub const fn` accessor so
3534/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3535/// reaches the same two-arm lifted
3536/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3537/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3538/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3539/// surfaces already return.
3540///
3541/// Closes the substrate-wide trait-idiomatic forward-projection
3542/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3543/// via 523157d and traced through the 13 sibling closed-set typed
3544/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3545/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3546/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3547/// every peer's docstring naming it as a sibling. Paired with the
3548/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3549/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3550/// idiomatic axis pair, mirroring the pre-existing method-named
3551/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3552/// substrate-primitive axis pair.
3553///
3554/// The paired [`DepList::as_str`] returns `&'static str` by
3555/// construction — each arm resolves to a
3556/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3557/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3558/// static lifetime — so the trait's return-type promise is upheld
3559/// structurally.
3560///
3561/// Pinned load-bearing by
3562/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3563/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3564/// emit-set, plus a `const`-context materialization witness for the
3565/// `&'static str` lifetime promise) and
3566/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3567/// (partition pin + two-way round-trip through the paired
3568/// [`TryFrom<&str>`] axis).
3569impl From<DepList> for &'static str {
3570 fn from(list: DepList) -> &'static str {
3571 list.as_str()
3572 }
3573}
3574
3575/// Trait-idiomatic *forward* projection on the two-list dep-graph
3576/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3577/// `&'static str` axis — the borrowed-input companion to the paired
3578/// owned-input [`From<DepList> for &'static str`] impl immediately
3579/// above. Routes byte-for-byte through the same substrate-primitive
3580/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3581/// binds a `&DepList` through the standard-library `.into()` /
3582/// [`From<&Self> for &'static str`] axis (a
3583/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3584/// per-arm accept-set materializer that iterates the substrate-
3585/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3586/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3587/// forces every call site through an explicit `.copied()` /
3588/// dereference / [`Copy`]-bound restatement rather than the direct
3589/// trait-idiomatic projection; a future generic
3590/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3591/// that walks the `iter().map(Into::into)` shape verbatim; the future
3592/// M4 admission-webhook rejection body that composes the accepted-set
3593/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3594/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3595/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3596/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3597/// owned-input [`From<DepList> for &'static str`], the sibling
3598/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3599/// surfaces already return.
3600///
3601/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3602/// forward-projection family on the last-touched closed-set fieldless
3603/// typed enum — first-mover on the borrowed-input axis, mirroring the
3604/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3605/// input axis (523157d). Rust's `From` trait does not auto-derive the
3606/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3607/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3608/// in `core`), so every closed-set typed enum that carries the
3609/// owned-input axis but not the borrowed-input axis forces every
3610/// borrowed-input call site through a `.copied()` /
3611/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3612/// bounds have no compile-time link to the substrate primitive. The
3613/// remaining fourteen substrate-wide closed-set fieldless typed enum
3614/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3615/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3616/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3617/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3618/// of this campaign.
3619///
3620/// Pinned load-bearing by
3621/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3622/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3623/// emit-set via a borrowed input, plus a `const`-context materialization
3624/// witness) and
3625/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3626/// (cross-axis partition pin against the paired owned-input
3627/// [`From<DepList> for &'static str`] impl).
3628impl From<&DepList> for &'static str {
3629 fn from(list: &DepList) -> &'static str {
3630 list.as_str()
3631 }
3632}
3633
3634/// Trait-idiomatic *forward* projection on the two-list dep-graph
3635/// [`DepList`] closed-set typed enum from an *owned* input onto the
3636/// owned-[`String`] axis — routes byte-for-byte through the
3637/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor so
3638/// every consumer that binds a [`DepList`] through the standard-library
3639/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`])
3640/// axis reaches the same two-arm lifted
3641/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3642/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3643/// owned-input [`From<DepList> for &'static str`], the borrowed-input
3644/// [`From<&DepList> for &'static str`], the sibling [`std::fmt::Display`],
3645/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return.
3646///
3647/// Extends the trait-idiomatic *owned-[`String`]* forward-projection
3648/// family (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a —
3649/// the first-mover on the M2 OTP-shape sibling-restart-strategy axis,
3650/// extended onto [`crate::supervisor::RestartPolicy`] — 7851725 — the
3651/// second-of-two-in-M2 per-child restart-decision axis, then onto
3652/// [`crate::CaixaKind`] — 231a18c — the structurally most fundamental
3653/// closed-set fieldless typed enum on the caixa surface, then onto
3654/// [`crate::CaixaDialeto`] — 88942cd — the dialect-classification axis)
3655/// onto the fifth peer: the two-list dep-graph axis [`DepList`] carries.
3656/// Rust's standard library does not carry a blanket
3657/// `impl<T: AsRef<str>> From<T> for String` (nor an
3658/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
3659/// typed enum that carries the paired [`AsRef<str>`] / [`std::fmt::Display`] /
3660/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
3661/// quadruple but not the owned-[`String`] axis forces every owned-string
3662/// call site through a `.to_string()` / `.as_str().to_owned()` /
3663/// `String::from(list.as_str())` detour whose type bounds have no
3664/// compile-time link to the substrate primitive.
3665///
3666/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3667/// [`crate::supervisor::RestartPolicy`] / [`crate::CaixaDialeto`]
3668/// owned-[`String`] axis pairs (whose forward emit and reverse parse
3669/// share one vocabulary by construction — `PascalCase` on the three
3670/// prior peers, the `":deps"` / `":deps-dev"` leading-colon lispy
3671/// author-surface tags on this one), [`DepList`]'s [`DepList::as_str`]
3672/// emit and [`DepList::from_wire`] parse resolve through the same
3673/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3674/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3675/// (there is no wire/diagnostic axis split on this enum — both halves
3676/// of the round-trip route through the same two `pub const &str` values),
3677/// so the owned-[`String`] forward projection this impl exposes composes
3678/// directly with the paired trait-idiomatic reverse
3679/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3680/// borrow — no intermediate wire-vocab hop like the peer
3681/// [`crate::CaixaKind`] axis pair requires.
3682///
3683/// The remaining ten closed-set typed enums on the caixa substrate
3684/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
3685/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3686/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
3687/// this campaign — each carries the same paired [`AsRef<str>`] /
3688/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
3689/// [`From<&Self> for &'static str`] quadruple that this owned-[`String`]
3690/// axis extends onto.
3691///
3692/// Pinned load-bearing by
3693/// [`tests::dep_list_from_into_owned_string_routes_through_as_str_accessor`]
3694/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3695/// [`DepList::ALL`] emit-set plus a blanket `.into::<String>()` shape
3696/// witness) and
3697/// [`tests::dep_list_from_into_owned_string_and_static_str_agree_on_every_arm`]
3698/// (cross-axis partition against the sibling owned-`&'static str` axis
3699/// and the [`ToString::to_string`] surface, a
3700/// `.iter().copied().map(String::from)` pipe witness over
3701/// [`DepList::ALL`], plus a direct `Self → String → Self` round-trip
3702/// via [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3703/// borrow — composes directly without the wire-vocab intermediate hop
3704/// the peer [`crate::CaixaKind`] axis pair requires).
3705impl From<DepList> for String {
3706 fn from(list: DepList) -> String {
3707 list.as_str().to_owned()
3708 }
3709}
3710
3711/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
3712/// projection on the two-list dep-graph [`DepList`] closed-set typed
3713/// enum — the fourth (and closing) corner of the
3714/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3715/// projection family on this enum, mirror of the peer M2 OTP-shape
3716/// [`From<&RestartStrategy> for String`] (579385f) and
3717/// [`From<&RestartPolicy> for String`] (8465740) that opened and
3718/// closed the corner on the sibling supervisor-level restart-strategy
3719/// and per-child restart-decision enums. Routes byte-for-byte through
3720/// the substrate-primitive [`DepList::as_str`] `pub const fn` accessor
3721/// (via [`str::to_owned`]) so every consumer that holds a borrowed
3722/// [`&DepList`] and needs an owned [`String`] — a future
3723/// `serde_json::Value::String(String::from(&list))` structured-payload
3724/// composer over a borrowed field, a future `Iterator::map` over
3725/// `&[DepList]` that projects to owned keys through
3726/// `.iter().map(String::from)` (whose iterator yields `&DepList`, not
3727/// `DepList`, so the owned-input [`From<DepList> for String`] axis
3728/// alone forces every call site through an explicit `.copied()` /
3729/// spurious [`Copy`] deref restatement rather than the direct trait-
3730/// idiomatic projection), a future `HashMap::<String, DepList>::from_iter`
3731/// that keys off a borrowed-iteration axis where dereferencing the list
3732/// would force an unnecessary `Copy` at every step, the future
3733/// wasm-operator's per-manifest `list_axes.iter().map(String::from).collect()`
3734/// per-list author-surface-tag diagnostic emit whose iteration axis is
3735/// borrowed by construction — reaches the same two-arm lifted
3736/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3737/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3738/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], and the
3739/// three other trait-idiomatic forward-projection impls
3740/// ([`From<DepList> for &'static str`],
3741/// [`From<&DepList> for &'static str`],
3742/// [`From<DepList> for String`]) already return.
3743///
3744/// Third peer on the substrate-wide trait-idiomatic *borrowed-input,
3745/// owned-`String` output* forward-projection family opened on
3746/// [`crate::supervisor::RestartStrategy`] (579385f) and closed on
3747/// [`crate::supervisor::RestartPolicy`] (8465740) — extends the
3748/// `{Self, &Self} × {&'static str, String}` 2×2 projection corner off
3749/// the M2 OTP-shape axis pair onto the first non-M2 closed-set
3750/// fieldless typed enum peer (the two-list dep-graph axis). Rust's
3751/// standard library does not carry a blanket
3752/// `impl<T: AsRef<str>> From<&T> for String` (nor an
3753/// `impl<T: fmt::Display> From<&T> for String`), so every closed-set
3754/// typed enum that carries the paired `AsRef<str>` / `Display` /
3755/// `From<Self> for &'static str` / `From<&Self> for &'static str` /
3756/// `From<Self> for String` quintuple but not the borrowed-input owned-
3757/// [`String`] axis forces every borrowed-input owned-string call site
3758/// through a `list.as_str().to_owned()` / `String::from(*list)` (with a
3759/// spurious `Copy`) / `list.to_string()` (through `Display`) detour
3760/// whose type bounds have no compile-time link to the substrate
3761/// primitive.
3762///
3763/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3764/// [`crate::supervisor::RestartPolicy`] borrowed-input owned-[`String`]
3765/// axis pairs (whose forward emit and reverse parse share one
3766/// vocabulary by construction — `PascalCase` on the M2 OTP-shape
3767/// peers), [`DepList`]'s [`DepList::as_str`] emit and
3768/// [`DepList::from_wire`] parse resolve through the same lifted
3769/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3770/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3771/// (the `":deps"` / `":deps-dev"` leading-colon lispy author-surface
3772/// tags — there is no wire/diagnostic axis split on this enum), so the
3773/// borrowed-input owned-[`String`] projection this impl exposes
3774/// composes directly with the paired trait-idiomatic reverse
3775/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3776/// borrow — no intermediate wire-vocab hop like the peer
3777/// [`crate::CaixaKind`] axis pair requires.
3778///
3779/// The remaining ten closed-set typed enums on the caixa substrate
3780/// surface (`CaixaKind`, `CaixaDialeto`, `PlacementStrategy`,
3781/// `WitShape`, `RateLimitUnit`, `PathShapeViolation`, `InvariantKind`,
3782/// `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`, `FerriteRuntime`)
3783/// are the future targets of this 2×2-completion campaign — each
3784/// carries the same paired quintuple that this borrowed-input owned-
3785/// [`String`] axis extends onto.
3786///
3787/// Pinned load-bearing by
3788/// [`tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3789/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3790/// emit-set through the borrowed-input surface) and
3791/// [`tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3792/// (cross-axis partition pin against the paired owned-input owned-
3793/// [`String`] [`From<DepList> for String`] impl, the paired borrowed-
3794/// input owned-[`&'static str`] [`From<&DepList> for &'static str`]
3795/// impl, and the sibling [`ToString::to_string`] surface routed through
3796/// [`std::fmt::Display`], plus a direct round-trip witness through
3797/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3798/// borrow that closes the two-way `&Self → String → Self` round-trip
3799/// on the trait-idiomatic borrowed-input owned-[`String`] forward +
3800/// reverse axis pair).
3801impl From<&DepList> for String {
3802 fn from(list: &DepList) -> String {
3803 list.as_str().to_owned()
3804 }
3805}
3806
3807/// Trait-idiomatic *forward* projection on the two-list dep-graph
3808/// [`DepList`] closed-set typed enum from an *owned* input onto the
3809/// borrowed-heap-string [`std::borrow::Cow<'static, str>`] axis —
3810/// routes byte-for-byte through the substrate-primitive
3811/// [`DepList::as_str`] `pub const fn` accessor (via
3812/// [`std::borrow::Cow::Borrowed`]) so every consumer that binds a
3813/// [`DepList`] through the standard-library `.into()` /
3814/// [`From<Self> for std::borrow::Cow<'static, str>`] (equivalently
3815/// [`Into<std::borrow::Cow<'static, str>>`]) axis reaches the same
3816/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3817/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] canonical `pub const
3818/// &str` values the paired [`From<DepList> for &'static str`],
3819/// [`From<&DepList> for &'static str`], [`From<DepList> for String`],
3820/// and [`From<&DepList> for String`] 2×2 trait-idiomatic forward-
3821/// projection corners, the sibling [`std::fmt::Display`],
3822/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return,
3823/// rather than an open-coded per-call-site
3824/// `std::borrow::Cow::Borrowed(list.as_str())` /
3825/// `std::borrow::Cow::Owned(list.to_string())` composition whose
3826/// type bounds have no compile-time link back to the substrate
3827/// primitive.
3828///
3829/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3830/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3831/// [`DepList::as_str`] accessor's return carries the `&'static str`
3832/// lifetime by construction (each `match` arm resolves to one of
3833/// the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3834/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3835/// values with static lifetime), so the zero-alloc borrowed arm is
3836/// the type-correct projection with no runtime allocation. The
3837/// paired [`std::borrow::Cow::Owned`] arm stays reachable at the
3838/// call site through the existing [`From<DepList> for String`] axis
3839/// composed with [`std::borrow::Cow::from`] on the resulting owned
3840/// [`String`] — a caller who chose to mutate the projection lands
3841/// on the owned arm by their own composition, not by the substrate-
3842/// primitive projection silently allocating on their behalf.
3843///
3844/// Rust's standard library carries no blanket `impl<T: AsRef<str>>
3845/// From<T> for Cow<'static, str>` (nor an `impl<T: fmt::Display>
3846/// From<T> for Cow<'static, str>`), so the paired sibling
3847/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3848/// [`AsRef<str>`], and [`std::fmt::Display`] surfaces do not
3849/// implicitly extend to a [`std::borrow::Cow<'static, str>`]-bound
3850/// call site — every such site is forced through a
3851/// `Cow::Borrowed(list.as_str())` / `Cow::Owned(list.to_string())`
3852/// open-code whose type bounds have no compile-time link back to
3853/// the substrate primitive until this lift.
3854///
3855/// First-mover on the outside-M3 substrate-wide tier of the
3856/// substrate-wide trait-idiomatic [`std::borrow::Cow<'static, str>`]
3857/// forward-projection campaign, opening the tier on the first
3858/// caixa-core-internal closed-set fieldless typed enum peer outside
3859/// the M2 OTP-shape and M3 mesh-shape tiers. The
3860/// [`crate::CaixaKind`] top-level first-mover
3861/// (99c1735 owned-input, d45c409 borrowed-input) opened the axis on
3862/// the structurally most fundamental closed-set fieldless typed
3863/// enum; the paired M2 OTP-shape
3864/// [`crate::supervisor::RestartStrategy`] (7dd28b3, 9b3e4b3) and
3865/// [`crate::supervisor::RestartPolicy`] (0612398, ee577fd) closed
3866/// the M2 OTP-shape tier; the paired M3-mesh-shape
3867/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3868/// (8634dec, 25690ef), [`crate::aplicacao::PlacementStrategy`]
3869/// `:placement :estrategia` distribution-strategy (eee504d,
3870/// afdf0f4), and [`crate::aplicacao::RateLimitUnit`] `:politicas
3871/// :rate-limit` canonical-suffix (1d59925, `From<&RateLimitUnit>`
3872/// Cow closer) closed the M3-mesh-shape tier. The remaining
3873/// outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3874/// [`crate::render::PathShapeViolation`]) and the outside-
3875/// `caixa-core` peers (`InvariantKind`, `ArchVerdict`, `Severity`,
3876/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the remaining
3877/// future targets of this campaign; the paired borrowed-input
3878/// [`From<&DepList> for std::borrow::Cow<'static, str>`]
3879/// `{Self, &Self}`-closer on this outside-M3-tier-opening peer is
3880/// the next commit's target.
3881///
3882/// Same three-path convergence discipline as the paired sibling
3883/// [`From<DepList> for &'static str`] / [`From<DepList> for String`]
3884/// / [`std::fmt::Display`] / [`AsRef<str>`] surfaces (this
3885/// [`std::borrow::Cow<'static, str>`] axis, the paired sibling
3886/// surfaces, and [`DepList::as_str`] all route through the same two
3887/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3888/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3889/// values by construction), so a future variant addition, rename,
3890/// or per-arm wire-tag drift reaches every forward-projection path
3891/// through exactly one caixa-core edit at the [`DepList::as_str`]
3892/// `match` head.
3893///
3894/// Pinned load-bearing by
3895/// [`tests::dep_list_from_into_static_cow_str_routes_through_as_str_accessor`]
3896/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
3897/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`])
3898/// and
3899/// [`tests::dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
3900/// (cross-axis partition pin against the paired
3901/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3902/// and [`ToString`]-through-[`std::fmt::Display`] axes, plus a
3903/// `.iter().copied().map(Cow::from)` pipe witness over
3904/// [`DepList::ALL`] that materializes the two-arm accept-set through
3905/// the [`std::borrow::Cow<'static, str>`] axis alone and pins the
3906/// zero-alloc discipline on every element).
3907impl From<DepList> for std::borrow::Cow<'static, str> {
3908 fn from(list: DepList) -> std::borrow::Cow<'static, str> {
3909 std::borrow::Cow::Borrowed(list.as_str())
3910 }
3911}
3912
3913/// Trait-idiomatic *borrowed-input, [`std::borrow::Cow<'static, str>`]
3914/// output* forward projection on the two-list dep-graph [`DepList`]
3915/// closed-set typed enum — the borrowed-input companion to the paired
3916/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] impl
3917/// immediately above (6858bac). Routes byte-for-byte through the same
3918/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor (via
3919/// [`std::borrow::Cow::Borrowed`]) so every consumer that holds a
3920/// `&DepList` and needs a [`std::borrow::Cow<'static, str>`] — a
3921/// `DepList::ALL.iter().map(std::borrow::Cow::from).collect::<Vec<_>>()`
3922/// per-arm accept-set materializer whose iterator over
3923/// `&'static [DepList]` yields `&DepList` (not `DepList`, so the paired
3924/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] axis
3925/// alone forces every call site through an explicit `.copied()` /
3926/// dereference / [`Copy`]-bound restatement rather than the direct
3927/// trait-idiomatic projection), a future generic
3928/// `<T: for<'a> Into<std::borrow::Cow<'static, str>>>`-bound emitter on
3929/// a per-`:deps` / `:deps-dev` diagnostic column that walks the
3930/// `iter().map(Into::into)` shape verbatim, the future M4
3931/// `caixa.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection body
3932/// that composes the accepted-`:deps` / `:deps-dev` list-key enumeration
3933/// from an iterated `DepList::ALL.iter().map(|l| l.into())` pipe rather
3934/// than a per-arm `match l { … }` cascade — reaches the same two-arm
3935/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3936/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3937/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], the four
3938/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3939/// forward-projection corners, and the paired owned-input
3940/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl already
3941/// return.
3942///
3943/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3944/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3945/// [`DepList::as_str`] accessor's return carries the `&'static str`
3946/// lifetime by construction (each `match` arm resolves to one of the
3947/// two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3948/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3949/// byte-strings with static lifetime), so the zero-alloc borrowed arm
3950/// is the type-correct projection with no runtime allocation on the
3951/// borrowed-input surface just as on the paired owned-input surface.
3952///
3953/// Closes the `{Self, &Self}` input-shape corner on the outside-M3
3954/// caixa-core two-list dep-graph [`std::borrow::Cow<'static, str>`]
3955/// axis opened one commit prior (6858bac) on the paired owned-input
3956/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl — first
3957/// outside-M3 caixa-core peer on the axis, one commit after the paired
3958/// M3-mesh-shape [`crate::aplicacao::RateLimitUnit`] `:politicas
3959/// :rate-limit` canonical-suffix (1d59925), the paired M3-mesh-shape
3960/// [`crate::aplicacao::PlacementStrategy`] `:placement :estrategia`
3961/// distribution-strategy (eee504d + afdf0f4), the paired M3-mesh-shape
3962/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3963/// (8634dec + 25690ef), the paired M2 OTP-shape
3964/// [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3) and
3965/// [`crate::supervisor::RestartPolicy`] (0612398 + ee577fd), and the
3966/// paired top-level [`crate::CaixaKind`] (99c1735 + d45c409) peers
3967/// closed the M3-mesh-shape, M2-OTP-shape, and top-level tiers.
3968/// Rust's standard library does not carry a blanket
3969/// `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor an
3970/// `impl<T: fmt::Display> From<&T> for Cow<'static, str>`), so every
3971/// closed-set fieldless typed enum peer on the substrate that carries
3972/// the paired owned-input [`Cow<'static, str>`] axis but not the
3973/// borrowed-input axis forces every borrowed-input
3974/// [`Cow<'static, str>`]-parameterized call site through a spurious
3975/// [`Copy`] deref (`std::borrow::Cow::from(*list)`) or a
3976/// `std::borrow::Cow::Borrowed(list.as_str())` open-code whose type
3977/// bounds have no compile-time link to the substrate primitive.
3978///
3979/// The remaining outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3980/// [`crate::render::PathShapeViolation`]) and the outside-`caixa-core`
3981/// peers (`InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`,
3982/// `Semantic`, `FerriteRuntime`) are the remaining future targets of
3983/// the campaign; closing this borrowed-input corner on [`DepList`]
3984/// leaves [`crate::CaixaDialeto`] as the next outside-M3 caixa-core
3985/// closed-set fieldless typed enum peer target on the
3986/// [`std::borrow::Cow<'static, str>`] axis.
3987///
3988/// Same three-path convergence discipline as the paired sibling
3989/// [`From<&DepList> for &'static str`], [`From<&DepList> for String`],
3990/// [`std::fmt::Display`], and [`AsRef<str>`] surfaces (this borrowed-
3991/// input [`std::borrow::Cow<'static, str>`] axis, the paired owned-
3992/// input [`From<DepList> for std::borrow::Cow<'static, str>`] axis, the
3993/// paired sibling `{Self, &Self} × {&'static str, String}` 2×2 corners,
3994/// and [`DepList::as_str`] all route through the same two lifted
3995/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3996/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` values
3997/// by construction), so a future variant addition, rename, or per-arm
3998/// wire-tag drift reaches every forward-projection path through
3999/// exactly one caixa-core edit at the [`DepList::as_str`] `match` head.
4000///
4001/// Pinned load-bearing by
4002/// [`tests::dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`]
4003/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
4004/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`]
4005/// through the borrowed-input surface) and
4006/// [`tests::dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
4007/// (cross-axis partition pin against the paired owned-input
4008/// [`From<DepList> for std::borrow::Cow<'static, str>`], the paired
4009/// borrowed-input owned-`&'static str` [`From<&DepList> for &'static
4010/// str`], and the paired borrowed-input owned-`String` [`From<&DepList>
4011/// for String`] impls, plus a `.iter().map(std::borrow::Cow::from)`
4012/// pipe witness over [`DepList::ALL`] — whose iterator yields
4013/// `&DepList` by construction, so the borrowed-input
4014/// [`std::borrow::Cow<'static, str>`] axis is what routes the pipe
4015/// through the substrate-primitive [`DepList::as_str`] accessor with
4016/// the zero-alloc [`std::borrow::Cow::Borrowed`] arm by construction
4017/// and without a spurious [`Copy`] deref).
4018impl From<&DepList> for std::borrow::Cow<'static, str> {
4019 fn from(list: &DepList) -> std::borrow::Cow<'static, str> {
4020 std::borrow::Cow::Borrowed(list.as_str())
4021 }
4022}
4023
4024/// Trait-idiomatic *owned-input, [`Box<str>`] output* forward projection on
4025/// the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
4026/// fieldless typed enum. Routes byte-for-byte through the substrate-
4027/// primitive [`DepList::as_str`] `pub const fn` accessor via
4028/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
4029/// that binds a `let key: Box<str> = list.into();`-shaped call site — a
4030/// per-`:deps` / `:deps-dev` census-key materializer that stashes the
4031/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
4032/// cheap clone off an owned handle, a future M4
4033/// [`caixa.pleme.io/v1alpha1/Caixa`] CR materializer's per-list admission-
4034/// webhook rejection body whose per-arm [`Box<str>`] field composes from
4035/// an owned [`DepList`] handle naming the accepted-list-tag list, a future
4036/// `feira lint --explain-dep-list=<axis>` per-arm listing that stashes
4037/// each arm as an owned [`Box<str>`] label — reaches the same two lifted
4038/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4039/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4040/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
4041/// forward-projection corner already returns.
4042///
4043/// Rust's standard library carries `impl From<&str> for Box<str>` and
4044/// `impl From<String> for Box<str>` but no blanket
4045/// `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a distinct
4046/// trait-idiomatic surface that a downstream `DepList → Box<str>`
4047/// `.into()` reaches through this impl and no other — without a
4048/// `Box::from(list.as_str())` open-code whose type bounds have no
4049/// compile-time link back to the substrate primitive.
4050///
4051/// Extends the caixa-core-internal tier of the substrate-wide trait-
4052/// idiomatic [`Box<str>`] forward-projection campaign onto the second
4053/// caixa-core-internal peer, after the render-side path-shape-diagnostic
4054/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
4055/// one axis) opened the tier. Follows the M2 OTP-shape
4056/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
4057/// pair (59ae5dc + cb1d068), the M3 mesh-shape
4058/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
4059/// [`crate::aplicacao::RateLimitUnit`] triple (6d73e84 → df7040c) that
4060/// closed the M3 mesh-shape tier, and the outside-`caixa-core` tier
4061/// (`InvariantKind` 10613a7 + 5901887, `ArchVerdict` 3e08f5a + c4319a8,
4062/// `Severity` 5116c95, `FixSafety` cf0174b, `Semantic` 0cd7dc3,
4063/// `FerriteRuntime` 14886a8) that closed one tier prior. Same discipline
4064/// as those peers: forward emit (this impl, the sibling `{&'static str,
4065/// String, Cow<'static, str>}` forward-projection corner, [`std::fmt::Display`],
4066/// [`AsRef<str>`], [`DepList::as_str`]) and reverse parse
4067/// ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the same two
4068/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4069/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4070/// by construction, so the round-trip composes directly without the
4071/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
4072/// requires.
4073///
4074/// A future variant addition (a `Build` build-time-only dep-list axis the
4075/// CAIXA-SDLC hints name as a trajectory item once the Cargo
4076/// `[build-dependencies]` table gains substrate visibility) reaches the
4077/// paired [`Box<str>`] output axis through one match-arm edit on the
4078/// [`DepList::as_str`] `pub const fn` accessor, not a coordinated rewrite
4079/// of every downstream `Box::from(list.as_str())` open-code.
4080///
4081/// Pinned load-bearing by
4082/// [`tests::dep_list_from_into_box_str_routes_through_as_str_accessor`]
4083/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4084/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
4085/// derived [`Into`] shape witness).
4086impl From<DepList> for Box<str> {
4087 fn from(list: DepList) -> Box<str> {
4088 Box::<str>::from(list.as_str())
4089 }
4090}
4091
4092/// Trait-idiomatic *borrowed-input, [`Box<str>`] output* forward projection
4093/// on the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
4094/// fieldless typed enum. Routes byte-for-byte through the substrate-
4095/// primitive [`DepList::as_str`] `pub const fn` accessor via
4096/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
4097/// that binds a `let key: Box<str> = (&list).into();`-shaped call site or
4098/// a `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
4099/// iterator over `&'static [DepList]` yields `&DepList` by construction)
4100/// — a per-`:deps` / `:deps-dev` census-key materializer that stashes the
4101/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
4102/// cheap clone off a borrowed handle, a future M4 admission-webhook
4103/// rejection body whose per-arm [`Box<str>`] field composes from a
4104/// borrowed [`DepList`] handle off a `&DepList` borrow, a future
4105/// `feira lint --explain-dep-list` per-axis listing that iterates
4106/// [`DepList::ALL`] into per-arm owned [`Box<str>`] labels — reaches the
4107/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4108/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4109/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
4110/// forward-projection corner and the paired owned-input
4111/// [`From<DepList> for Box<str>`] already return.
4112///
4113/// Rust's standard library carries `impl From<&str> for Box<str>` and
4114/// `impl From<String> for Box<str>` but no blanket
4115/// `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
4116/// `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-input
4117/// axis is a distinct trait-idiomatic surface that the pipe shape
4118/// [`DepList::ALL`]`.iter().map(Box::<str>::from)` reaches through this
4119/// impl and no other — without it, the same pipe would force an explicit
4120/// `.copied()` restatement (`.iter().copied().map(Box::<str>::from)`)
4121/// whose type bounds have no compile-time link back to the substrate
4122/// primitive, and a `let key: Box<str> = (&list).into();`-shaped call
4123/// site would force an explicit `Copy` deref (`Box::<str>::from(*list)`)
4124/// or a `Box::<str>::from(list.as_str())` open-code with the same defect.
4125///
4126/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4127/// core-internal closed-set fieldless typed enum peer of the substrate-
4128/// wide trait-idiomatic [`Box<str>`] forward-projection campaign — one
4129/// commit after the paired render-side path-shape-diagnostic
4130/// [`crate::render::PathShapeViolation`] pair (0d87a72) opened the caixa-
4131/// core-internal tier — matching the trajectory the paired caixa-theme
4132/// [`caixa_theme::style::Semantic`] pair (0cd7dc3, both corners in one
4133/// axis), the caixa-provedor [`caixa_provedor::FerriteRuntime`] pair
4134/// (14886a8, both corners in one axis), and the render-side
4135/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
4136/// one axis) walked before it.
4137///
4138/// Same discipline as the paired outside-`caixa-core`,
4139/// [`crate::supervisor`], [`crate::aplicacao`], and [`crate::render`]
4140/// [`Box<str>`] `{Self, &Self}`-closers: forward emit (this impl, the
4141/// paired owned-input [`From<DepList> for Box<str>`] impl, the sibling
4142/// `{&'static str, String, Cow<'static, str>}` forward-projection corner,
4143/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`]) and reverse
4144/// parse ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the
4145/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4146/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4147/// by construction, so the round-trip composes directly without the
4148/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
4149/// requires.
4150///
4151/// Pinned load-bearing by
4152/// [`tests::dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor`]
4153/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4154/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4155/// blanket-derived [`Into`] shape witness, plus a
4156/// `.iter().map(Box::<str>::from)` pipe witness over [`DepList::ALL`] —
4157/// whose iterator yields `&DepList` by construction, so the borrowed-
4158/// input [`Box<str>`] axis is what routes the pipe through the substrate-
4159/// primitive [`DepList::as_str`] accessor without a spurious [`Copy`]
4160/// deref).
4161impl From<&DepList> for Box<str> {
4162 fn from(list: &DepList) -> Box<str> {
4163 Box::<str>::from(list.as_str())
4164 }
4165}
4166
4167/// Trait-idiomatic *owned-input, [`std::sync::Arc<str>`] output* forward
4168/// projection on the outside-M3 caixa-core two-list dep-graph [`DepList`]
4169/// closed-set fieldless typed enum. Routes byte-for-byte through the
4170/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor via
4171/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4172/// every consumer that binds a
4173/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4174/// the same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4175/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4176/// the sibling
4177/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4178/// forward-projection corner already returns.
4179///
4180/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4181/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4182/// `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
4183/// `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so this axis
4184/// is a distinct trait-idiomatic surface that a
4185/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4186/// through this impl and no other — a paired
4187/// `std::sync::Arc::<str>::from(list.as_str())` open-code has no compile-
4188/// time link back to the substrate primitive, and a two-step
4189/// `std::sync::Arc::<str>::from(String::from(list))` composition through
4190/// the owned-`String` axis allocates twice (once into the intermediate
4191/// `String`, once into the [`std::sync::Arc<str>`] on the `From<String>`
4192/// conversion) where the single-step trait impl allocates once. The
4193/// shared-ownership + [`Sync`] + [`Send`] contract [`std::sync::Arc<str>`]
4194/// provides is the distinct value the sibling [`Box<str>`] axis's owned-
4195/// move return-shape cannot provide — a per-`:deps` / `:deps-dev` census
4196/// key reachable from multiple concurrent per-Caixa reconcile / per-lint
4197/// tasks through the same two lifted
4198/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4199/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-strings, without a
4200/// `.clone()`-per-task materialization the owned-move [`Box<str>`] axis
4201/// would force.
4202///
4203/// Extends the caixa-core-internal tier of the substrate-wide trait-
4204/// idiomatic [`std::sync::Arc<str>`] forward-projection campaign onto the
4205/// second caixa-core-internal peer, after the top-level
4206/// [`crate::CaixaKind`] pair (c17be64, both corners in one axis) opened
4207/// the tier. Follows the M2 OTP-shape
4208/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
4209/// pair (bca2ec8 + b3e72d7 / b05724e + ea91551), the M3 mesh-shape
4210/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
4211/// [`crate::aplicacao::RateLimitUnit`] triple (977d577 → dae722f), and
4212/// the outside-`caixa-core` tier (`InvariantKind` 4e923c1 + 03c043f,
4213/// `ArchVerdict` 1682f8b + 92ddfb2, `Severity` a7a9a6d + 4f041e1,
4214/// `FixSafety` fb73edb + 822138e, `Semantic` 65dbcff + f3a55c7,
4215/// `FerriteRuntime` 938d915 + 0afef4b) that closed prior tiers on this
4216/// same Arc<str> axis. Same discipline as those peers: forward emit
4217/// (this impl, the sibling
4218/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4219/// forward-projection corner, [`std::fmt::Display`], [`AsRef<str>`],
4220/// [`DepList::as_str`]) and reverse parse ([`DepList::from_wire`],
4221/// [`TryFrom<&str>`]) route through the same two lifted
4222/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4223/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4224/// strings by construction, so the round-trip composes directly without
4225/// the wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis
4226/// pair requires.
4227///
4228/// A future variant addition (a `Build` build-time-only dep-list axis the
4229/// CAIXA-SDLC hints name as a trajectory item once the Cargo
4230/// `[build-dependencies]` table gains substrate visibility) reaches the
4231/// paired [`std::sync::Arc<str>`] output axis through one match-arm edit
4232/// on the [`DepList::as_str`] `pub const fn` accessor, not a coordinated
4233/// rewrite of every downstream
4234/// `std::sync::Arc::<str>::from(list.as_str())` open-code.
4235///
4236/// Pinned load-bearing by
4237/// [`tests::dep_list_from_into_arc_str_routes_through_as_str_accessor`]
4238/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4239/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
4240/// derived [`Into`] shape witness and cross-axis byte-parity pins against
4241/// the sibling owned-input
4242/// `{&'static str, String, Cow<'static, str>, Box<str>}` return-shape
4243/// axes).
4244impl From<DepList> for std::sync::Arc<str> {
4245 fn from(list: DepList) -> std::sync::Arc<str> {
4246 std::sync::Arc::<str>::from(list.as_str())
4247 }
4248}
4249
4250/// Trait-idiomatic *borrowed-input, [`std::sync::Arc<str>`] output*
4251/// forward projection on the outside-M3 caixa-core two-list dep-graph
4252/// [`DepList`] closed-set fieldless typed enum — the borrowed-input
4253/// companion to the paired owned-input
4254/// [`From<DepList> for std::sync::Arc<str>`] impl immediately above.
4255/// Routes byte-for-byte through the substrate-primitive
4256/// [`DepList::as_str`] `pub const fn` accessor via
4257/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4258/// every consumer that binds a
4259/// `let key: std::sync::Arc<str> = (&list).into();`-shaped call site or a
4260/// `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped pipe
4261/// (whose iterator over `&'static [DepList]` yields `&DepList` by
4262/// construction) reaches the same two lifted
4263/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4264/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4265/// strings the paired owned-input
4266/// [`From<DepList> for std::sync::Arc<str>`] and the sibling
4267/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4268/// forward-projection corner already return.
4269///
4270/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4271/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4272/// `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a `Copy`-
4273/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
4274/// input axis is a distinct trait-idiomatic surface that the pipe shape
4275/// [`DepList::ALL`]`.iter().map(std::sync::Arc::<str>::from)` reaches
4276/// through this impl and no other — without it, the same pipe would
4277/// force a spurious [`Copy`] deref
4278/// (`std::sync::Arc::<str>::from((*list).as_str())`) or a `.copied()`
4279/// restatement whose type bounds have no compile-time link back to the
4280/// substrate primitive.
4281///
4282/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4283/// core-internal closed-set fieldless typed enum peer of the substrate-
4284/// wide trait-idiomatic [`std::sync::Arc<str>`] forward-projection
4285/// campaign — one commit after the paired top-level [`crate::CaixaKind`]
4286/// pair (c17be64) opened the caixa-core-internal Arc<str> tier — matching
4287/// the trajectory the paired top-level [`crate::CaixaKind`] pair
4288/// (c17be64, both corners in one axis) walked before it. Leaves the
4289/// remaining caixa-core-internal closed-set fieldless typed enum peers
4290/// ([`crate::dialeto::CaixaDialeto`],
4291/// [`crate::render::PathShapeViolation`]) as the campaign's next multi-
4292/// peer targets on the caixa-core-internal tier of the Arc<str> axis.
4293///
4294/// Pinned load-bearing by
4295/// [`tests::dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor`]
4296/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4297/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4298/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
4299/// against the paired owned-input
4300/// [`From<DepList> for std::sync::Arc<str>`] and the sibling borrowed-
4301/// input `{&'static str, String, Cow<'static, str>, Box<str>}` return-
4302/// shape axes, and a `.iter().map(std::sync::Arc::<str>::from)` pipe
4303/// witness over [`DepList::ALL`] that resolves through the borrowed-
4304/// input axis without a spurious [`Copy`] deref).
4305impl From<&DepList> for std::sync::Arc<str> {
4306 fn from(list: &DepList) -> std::sync::Arc<str> {
4307 std::sync::Arc::<str>::from(list.as_str())
4308 }
4309}
4310
4311/// Errors raised by [`Dep::validate`].
4312///
4313/// Mirrors the per-axis error families the other `:versao`-carrying
4314/// typed surfaces expose
4315/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4316/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4317/// [`crate::SupervisorError::EmptyChildVersion`] /
4318/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4319/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4320#[derive(Debug, Error, PartialEq, Eq)]
4321pub enum DepError {
4322 #[error(
4323 ":deps entry has empty :nome (every dep must name a target caixa; \
4324 omit the entry instead of carrying an empty name)"
4325 )]
4326 NomeEmpty,
4327 #[error(
4328 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4329 (the value flows verbatim as the target caixa's `:nome`, the rendered \
4330 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4331 value, and the resolver's checkout-directory leaf — each apiserver-side \
4332 schema rejects non-DNS-1123 names at admission time; use a lowercase \
4333 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4334 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4335 )]
4336 NomeInvalid { nome: String, reason: String },
4337 #[error(
4338 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4339 constraint that resolves through the lacre pipeline)"
4340 )]
4341 VersaoEmpty { nome: String },
4342 #[error(
4343 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4344 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4345 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4346 and `:children :versao` carry; the lacre pipeline resolves all three \
4347 through the same parser)"
4348 )]
4349 VersaoInvalid {
4350 nome: String,
4351 versao: String,
4352 reason: String,
4353 },
4354 #[error(
4355 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4356 (every git source must name a repo — use a `github:org/repo` \
4357 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4358 entire :fonte block to fall back to the default-host resolver \
4359 convention)"
4360 )]
4361 FonteRepoEmpty { nome: String },
4362 #[error(
4363 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4364 invalid value-shape: {reason} (the value flows verbatim into the \
4365 caixa-resolver's `git clone <repo>` subprocess invocation; every \
4366 documented form carries a `:` separator and no whitespace / \
4367 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4368 an `https://host/path` / `ssh://[user@]host/path` / \
4369 `git://host/path` / `file:///path` URL, or the `git@host:path` \
4370 scp-style SSH form)"
4371 )]
4372 FonteRepoShape {
4373 nome: String,
4374 repo: String,
4375 reason: String,
4376 },
4377 #[error(
4378 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4379 (set exactly one of :tag, :rev, or :branch so the resolver \
4380 can pick a reproducible commit; omit the entire :fonte block \
4381 to fall back to the default-host resolver convention, which \
4382 resolves the latest tag matching :versao)"
4383 )]
4384 FontePinMissing { nome: String },
4385 #[error(
4386 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4387 set ({pins}); exactly one of :tag, :rev, or :branch must be \
4388 set so the resolver's checkout target is unambiguous (the \
4389 resolver's silent precedence is :rev > :tag > :branch — if \
4390 you intended one specifically, drop the others)"
4391 )]
4392 FontePinAmbiguous { nome: String, pins: String },
4393 #[error(
4394 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4395 (a set pin must name a non-empty git ref; drop the {pin} key \
4396 entirely to fall through to another pin axis)"
4397 )]
4398 FontePinEmpty { nome: String, pin: String },
4399 #[error(
4400 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4401 value-shape: {reason} (the git porcelain enforces the same shape at \
4402 `git fetch` / `git checkout` time on every pin; use a leaf refname \
4403 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4404 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4405 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4406 prepends at clone time, and avoid abbreviated SHAs which are \
4407 ambiguous across repository history)"
4408 )]
4409 FontePinShape {
4410 nome: String,
4411 pin: String,
4412 value: String,
4413 reason: String,
4414 },
4415 #[error(
4416 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4417 (every path source must name a non-empty filesystem path; \
4418 omit the entire :fonte block to fall back to the default-host \
4419 resolver convention)"
4420 )]
4421 FonteCaminhoEmpty { nome: String },
4422 #[error(
4423 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4424 absolute (the lacre pipeline embeds the value verbatim in its \
4425 per-dep content-address `path:{caminho}` at \
4426 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4427 BLAKE3 closure differ across machines — defeating the \
4428 reproducibility contract that's load-bearing for CSE; express \
4429 the path relative to the caixa.lisp location, e.g. \
4430 \"../caixa-teia\" for a sibling workspace dep)"
4431 )]
4432 FonteCaminhoAbsolute { nome: String, caminho: String },
4433 #[error(
4434 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4435 with `~` (the leading-tilde is a shell-expansion convention, not a \
4436 POSIX path component — `Path::is_absolute` returns false on it, so \
4437 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4438 pipeline embeds the value verbatim in its per-dep content-address \
4439 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4440 caixa-resolver folds it through `Path::join` without `~`-expansion, \
4441 so the build looks for a literal `./{caminho}` subdirectory and \
4442 fails at resolve time far from the source caixa.lisp; even worse, a \
4443 future caixa-resolver pass that *does* expand `~` would silently \
4444 re-open the host-layout-leak the b94fd83 absolute gate closes — \
4445 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4446 runners with different `$HOME` layouts resolve to two distinct paths \
4447 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4448 determinism contract; express the path relative to the caixa.lisp \
4449 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4450 spell out the full relative path explicitly if a workstation-rooted \
4451 dep is genuinely intended)"
4452 )]
4453 FonteCaminhoTildeExpansion { nome: String, caminho: String },
4454 #[error(
4455 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4456 with `$` (the leading-`$` is a shell-variable-expansion convention, \
4457 not a POSIX path component — `Path::is_absolute` returns false on it \
4458 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4459 embeds the value verbatim in its per-dep content-address \
4460 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4461 caixa-resolver folds it through `Path::join` without `$`-expansion, \
4462 so the build looks for a literal `./{caminho}` subdirectory and \
4463 fails at resolve time far from the source caixa.lisp; even worse, a \
4464 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4465 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4466 invites) would silently re-open the host-layout-leak the b94fd83 \
4467 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4468 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4469 layouts resolve to two distinct paths for the byte-identical caixa, \
4470 defeating the THEORY.md §V.2 render-determinism contract; express \
4471 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4472 for a sibling workspace dep, or spell out the full relative path \
4473 explicitly if a workstation-rooted dep is genuinely intended)"
4474 )]
4475 FonteCaminhoVarExpansion { nome: String, caminho: String },
4476 #[error(
4477 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4478 with a space (the leading ASCII space `0x20` is the orthogonal \
4479 paste-from-aligned-doc footgun that silently passes \
4480 `Path::is_absolute` and every prior leading-byte arm — \
4481 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4482 `./ ../caixa-teia` subdirectory the resolver fails to find at \
4483 resolve time with a non-self-locating `No such file or directory` \
4484 error far from the source caixa.lisp; the lacre pipeline embeds \
4485 the value verbatim in its per-dep content-address `path:{caminho}` \
4486 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4487 semantic-identical caixa values (` ../caixa-teia` vs \
4488 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4489 workstations whose authors differ only in paste-from-aligned- \
4490 caixa.lisp-doc whitespace habits — the most insidious failure \
4491 mode the typed slot can carry (no error surfaces; the divergence \
4492 is invisible until two machines compare lacres), defeating the \
4493 THEORY.md §V.2 render-determinism contract. The canonical \
4494 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4495 a multi-entry `:deps` block sits at the same column — an author \
4496 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4497 the rendered alignment into a fresh entry preserves the leading \
4498 whitespace verbatim); peer `:fonte :repo` axis already rejects \
4499 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4500 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4501 `is_chart_description_shape`, `:licenca` via \
4502 `is_spdx_expression_shape`. Drop the leading space; express the \
4503 path as a bare relative single-token like \"../caixa-teia\")"
4504 )]
4505 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4506 #[error(
4507 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4508 with `-` (the canonical CLI-argument-injection footgun on the \
4509 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4510 its per-dep content-address `path:{caminho}` at \
4511 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4512 through `Path::join` looking for a literal `./{caminho}` \
4513 subdirectory. Every downstream subprocess that consumes the resolved \
4514 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4515 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4516 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4517 value as a CLI flag rather than a positional path when the invocation \
4518 does not carry a `--` argument-list terminator between the flag block \
4519 and the path (the common case at every porcelain entry point). The \
4520 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4521 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4522 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4523 CLI-arg-injection vector at every git porcelain entry point that \
4524 consumes a path or URL argument, peer with is_git_repo_url's \
4525 leading-`-` arm on the sibling `:fonte :repo` axis), \
4526 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4527 POSIX `std::path::Path` treats a leading `-` as a literal filename \
4528 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4529 for a literal `./-rf` subdirectory that fails at resolve time with a \
4530 non-self-locating `No such file or directory` error far from the \
4531 source caixa.lisp — but on any downstream shell-out without `--` the \
4532 reinterpretation is silent and the failure mode is arbitrary-\
4533 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4534 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4535 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4536 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4537 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4538 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4539 `:children :caixa`, `:deps :nome`, cluster names); \
4540 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4541 the feira `init` / `add <nome>` positional gate (868c191) rejects \
4542 leading `-` on the CLI positional itself. Express the path as a bare \
4543 relative single-token like \"../caixa-teia\" — the sibling-workspace \
4544 directory name carries no leading-hyphen semantic, and `./` / `../` \
4545 prefixes structurally partition the leading-byte set to safe values.)"
4546 )]
4547 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4548 #[error(
4549 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4550 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4551 every `std::fs` syscall routes the path through `CString::new` which \
4552 fails with `NulError` at resolve time; the lacre pipeline embeds the \
4553 value verbatim in its per-dep content-address `path:{caminho}` at \
4554 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4555 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4556 determinism contract — the canonical paste-from-multiline-doc \
4557 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4558 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4559 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4560 already gates against. Express the path as a relative single-line ASCII \
4561 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4562 )]
4563 FonteCaminhoControlChar {
4564 nome: String,
4565 caminho: String,
4566 byte: u8,
4567 },
4568 #[error(
4569 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4570 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4571 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4572 not the parent's sibling — and the caixa-resolver folds the value through \
4573 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4574 resolve time with a non-self-locating `No such file or directory` error far \
4575 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4576 primary path separator equal to `/`, so byte-identical caixa.lisp values \
4577 resolve to two distinct directories across runner OSes — the lacre pipeline \
4578 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4579 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4580 determinism contract via the cross-host-OS-separator divergence vector. The \
4581 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4582 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4583 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4584 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4585 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4586 \"../caixa-teia\" for a sibling workspace dep)"
4587 )]
4588 FonteCaminhoBackslash { nome: String, caminho: String },
4589 #[error(
4590 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4591 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4592 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4593 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4594 paste-from-shell-pipeline footgun where an author copies a `command > log` \
4595 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4596 as literal path-component bytes, so the resolver folds the value through \
4597 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4598 subdirectory and fails at resolve time with a non-self-locating `No such \
4599 file or directory` error far from the source caixa.lisp. The lacre pipeline \
4600 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4601 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4602 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4603 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4604 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4605 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4606 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4607 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4608 RFC-3986-reserved set. Express the path as a bare relative single-token like \
4609 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4610 redirection semantic.",
4611 ch = *byte as char
4612 )]
4613 FonteCaminhoShellRedirection {
4614 nome: String,
4615 caminho: String,
4616 byte: u8,
4617 },
4618 #[error(
4619 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4620 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4621 `|` as the pipe operator that wires one command's stdout to the next command's \
4622 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4623 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4624 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4625 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4626 treats `|` as a literal path-component byte, so the resolver folds the value \
4627 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4628 subdirectory and fails at resolve time with a non-self-locating `No such file or \
4629 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4630 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4631 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4632 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4633 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4634 subprocess-argument / shell-metachar injection surface every peer single-token-\
4635 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4636 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4637 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4638 workspace directory name carries no shell-pipe semantic."
4639 )]
4640 FonteCaminhoShellPipe { nome: String, caminho: String },
4641 #[error(
4642 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4643 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4644 / nushell — lexes `;` as the sequential-command terminator that fires the next \
4645 command regardless of the prior command's exit status, so `:caminho \
4646 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4647 footgun where an author copies a `cd path; do-thing` chain without trimming \
4648 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4649 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4650 literal path-component byte, so the resolver folds the value through \
4651 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4652 subdirectory and fails at resolve time with a non-self-locating `No such file \
4653 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4654 the value verbatim in its per-dep content-address `path:{caminho}` at \
4655 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4656 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4657 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4658 canonical shell-metachar injection surface every peer single-token-shaped \
4659 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4660 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4661 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4662 workspace directory name carries no shell-command-separator semantic."
4663 )]
4664 FonteCaminhoShellSemicolon { nome: String, caminho: String },
4665 #[error(
4666 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4667 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4668 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4669 terminator detaching the prior command and returning control immediately to \
4670 the prompt, double `&&` as the logical-AND list operator firing the next \
4671 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4672 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4673 sleep 1` background-launch one-liner or a `cd path && make install` build-\
4674 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4675 05c358e closed the sequential-command-separator vector, this arm closes the \
4676 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4677 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4678 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4679 byte lands in the BLAKE3 closure and rides into every shell-spawned \
4680 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4681 future operator-side `nix` spawn) as the canonical shell-metachar injection \
4682 surface every peer single-token-shaped typed slot already closes. The peer \
4683 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4684 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4685 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4686 shell-background / logical-AND semantic."
4687 )]
4688 FonteCaminhoShellBackground { nome: String, caminho: String },
4689 #[error(
4690 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4691 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4692 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4693 wrapper that runs the enclosed command and substitutes its standard-output \
4694 verbatim into the surrounding word, so a backticked `whoami` expands to the \
4695 current user's name and a backticked `cat /etc/passwd` expands to the file's \
4696 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4697 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4698 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4699 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4700 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4701 background / logical-AND vector, this arm closes the orthogonal command-\
4702 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4703 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4704 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4705 value verbatim in its per-dep content-address `path:{caminho}` at \
4706 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4707 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4708 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4709 shell-metachar injection surface every peer single-token-shaped typed slot \
4710 already closes. The peer `:entrada :paths` axis rejects the byte via \
4711 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4712 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4713 directory name carries no shell-command-substitution semantic."
4714 )]
4715 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4716 #[error(
4717 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4718 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4719 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4720 expansion wildcards: `*` matches any sequence of characters in a path component \
4721 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4722 canonical paste-from-shell-listing footgun where an author copies a \
4723 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4724 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4725 `std::path::Path` treats both bytes as literal path-component bytes, so the \
4726 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4727 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4728 locating `No such file or directory` error far from the source caixa.lisp. The \
4729 lacre pipeline embeds the value verbatim in its per-dep content-address \
4730 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4731 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4732 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4733 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4734 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4735 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4736 reserved set. Express the path as a bare relative single-token like \
4737 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4738 / pathname-expansion semantic.",
4739 ch = *byte as char
4740 )]
4741 FonteCaminhoShellGlob {
4742 nome: String,
4743 caminho: String,
4744 byte: u8,
4745 },
4746 #[error(
4747 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4748 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4749 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4750 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4751 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4752 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4753 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4754 arm closes the leading byte of — together the two arms now structurally exclude the \
4755 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4756 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4757 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4758 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4759 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4760 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4761 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4762 self-locating `No such file or directory` error far from the source caixa.lisp. The \
4763 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4764 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4765 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4766 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4767 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4768 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4769 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4770 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4771 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4772 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4773 subshell-grouping semantic.",
4774 ch = *byte as char
4775 )]
4776 FonteCaminhoShellSubshellGrouping {
4777 nome: String,
4778 caminho: String,
4779 byte: u8,
4780 },
4781 #[error(
4782 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4783 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4784 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4785 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4786 comma-separated members and `{{1..10}}` expands to the integer range — the \
4787 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4788 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4789 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4790 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4791 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4792 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4793 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4794 `std::path::Path` treats the byte as a literal path-component byte, so a \
4795 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4796 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4797 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4798 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4799 silently passes every prior arm and the resolver folds the value through \
4800 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4801 resolve time with a non-self-locating `No such file or directory` error far from \
4802 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4803 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4804 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4805 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4806 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4807 expansion / URI-Template-placeholder surface every peer single-token-shaped \
4808 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4809 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4810 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4811 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4812 directory name carries no shell-brace-expansion / URI-Template-placeholder \
4813 semantic; if two siblings actually need pinning, author two separate `:deps` \
4814 entries rather than one brace-expanded `:caminho` value.",
4815 ch = *byte as char
4816 )]
4817 FonteCaminhoShellBraceExpansion {
4818 nome: String,
4819 caminho: String,
4820 byte: u8,
4821 },
4822 #[error(
4823 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4824 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4825 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4826 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4827 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4828 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4829 glob every shell-history block carries; the bracket pair additionally carries the \
4830 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4831 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4832 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4833 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4834 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4835 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4836 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4837 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4838 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4839 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4840 leak) silently passes every prior arm and the resolver folds the value through \
4841 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4842 resolve time with a non-self-locating `No such file or directory` error far from \
4843 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4844 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4845 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4846 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4847 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4848 surface every peer single-token-shaped typed slot already closes. Express the path \
4849 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4850 directory name carries no shell-bracket-expansion / glob-character-class / array-\
4851 literal semantic; if a family of sibling caixas actually needs pinning, author \
4852 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4853 ch = *byte as char
4854 )]
4855 FonteCaminhoShellBracketExpansion {
4856 nome: String,
4857 caminho: String,
4858 byte: u8,
4859 },
4860 #[error(
4861 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4862 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4863 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4864 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4865 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4866 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4867 every path-with-embedded-whitespace paste block carries and the symmetric \
4868 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4869 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4870 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4871 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4872 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4873 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4874 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4875 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4876 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4877 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4878 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4879 production. POSIX `std::path::Path` treats the byte as a literal path-component \
4880 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4881 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4882 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4883 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4884 shape) silently passes every prior arm and the resolver folds the value through \
4885 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4886 resolve time with a non-self-locating `No such file or directory` error far from \
4887 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4888 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4889 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4890 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4891 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4892 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4893 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4894 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4895 `is_git_repo_url`). Express the path as a bare relative single-token like \
4896 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4897 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4898 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4899 quoting on the outer syntactic layer, so an inner quote pair would nest and \
4900 desugar to a broken layer).",
4901 ch = *byte as char
4902 )]
4903 FonteCaminhoShellQuoteGrouping {
4904 nome: String,
4905 caminho: String,
4906 byte: u8,
4907 },
4908 #[error(
4909 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4910 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4911 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4912 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4913 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4914 discarding the byte and everything after it to the end of the physical line \
4915 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
4916 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4917 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4918 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
4919 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4920 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4921 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4922 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4923 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4924 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4925 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4926 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4927 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4928 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4929 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
4930 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4931 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4932 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4933 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4934 fails at resolve time with a non-self-locating `No such file or directory` \
4935 error far from the source caixa.lisp — while every downstream shell / YAML / \
4936 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4937 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4938 scalar disagree with the resolver on which directory the value names. The \
4939 lacre pipeline embeds the value verbatim in its per-dep content-address \
4940 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4941 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4942 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4943 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4944 fragment-delimiter surface every peer single-token-shaped typed slot already \
4945 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4946 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4947 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4948 workspace directory name carries no shell-comment / URL-fragment / YAML-\
4949 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4950 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4951 and drop any `#fragment` tail entirely (fragment identifiers select \
4952 renderings, not directories, and `:caminho` names a directory).",
4953 ch = *byte as char
4954 )]
4955 FonteCaminhoShellComment {
4956 nome: String,
4957 caminho: String,
4958 byte: u8,
4959 },
4960 #[error(
4961 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4962 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4963 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4964 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4965 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4966 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4967 literally inside a URL value. The canonical paste-from-browser-address-bar \
4968 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4969 encoded README hyperlink / browser address bar / percent-encoded permalink \
4970 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4971 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4972 what the author intended as the byte-identical sibling-workspace dep. POSIX \
4973 `std::path::Path` treats the byte as a literal path-component byte, so \
4974 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4975 resolve time with a non-self-locating `No such file or directory` error far \
4976 from the source caixa.lisp — while every downstream URL parser / shell printf \
4977 builtin / YAML directive parser silently reinterprets the byte to a different \
4978 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4979 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4980 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4981 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4982 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4983 recent job whose command started with `foo`\" — a future `kill %1` invocation \
4984 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4985 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4986 directive block cross-idiom leak); and the Windows-shell env-var-reference \
4987 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4988 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4989 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4990 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4991 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4992 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4993 printf-format-specifier / job-control-specifier surface every peer single-\
4994 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4995 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4996 `is_git_repo_url`). Express the path as a bare relative single-token like \
4997 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4998 percent-encoding-escape / format-specifier / job-control semantic; substitute \
4999 any `%20` percent-encoded-space with a literal space then reject the whole \
5000 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5001 directory name never carries an embedded space in practice); drop any \
5002 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5003 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5004 ch = *byte as char
5005 )]
5006 FonteCaminhoUrlPercentEncoding {
5007 nome: String,
5008 caminho: String,
5009 byte: u8,
5010 },
5011 #[error(
5012 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5013 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5014 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5015 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5016 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5017 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5018 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5019 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5020 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5021 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5022 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5023 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5024 the byte is a first-class parser byte in nearly every config / templating / \
5025 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5026 `std::path::Path` treats the byte as a literal path-component byte, so the \
5027 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5028 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5029 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5030 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5031 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5032 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5033 subdirectory that fails at resolve time with a non-self-locating `No such file \
5034 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5035 the value verbatim in its per-dep content-address `path:{caminho}` at \
5036 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5037 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5038 time lock to two distinct BLAKE3 closures across two workstations whose \
5039 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5040 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5041 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5042 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5043 is the canonical CWE-78 shell-command-injection surface every peer single-\
5044 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5045 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5046 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5047 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5048 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5049 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5050 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5051 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5052 so every position — leading and embedded — is structurally rejected. Substitute \
5053 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5054 time, or express the path as a bare relative single-token like \
5055 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5056 variable-expansion / command-substitution / arithmetic-expansion semantic.",
5057 ch = *byte as char
5058 )]
5059 FonteCaminhoShellVariableExpansion {
5060 nome: String,
5061 caminho: String,
5062 byte: u8,
5063 },
5064 #[error(
5065 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5066 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5067 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5068 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5069 reference §9.3: `!command` re-runs the most recent history entry beginning with \
5070 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5071 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5072 and the substitution fires at every history-expansion-enabled shell context — \
5073 `set -o histexpand` is bash's default for interactive sessions and the layer \
5074 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5075 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5076 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5077 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5078 encodes it inside a query component via the 'special-query percent-encode set' \
5079 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5080 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5081 prefix — the paste-from-source-code idiom where an author copies \
5082 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5083 the string-literal boundary); the canonical English-typography emphasis / \
5084 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5085 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5086 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5087 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5088 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5089 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5090 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5091 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5092 repeat-prior-command paste idiom), the English-typography `:caminho \
5093 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5094 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5095 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5096 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5097 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5098 subdirectory that fails at resolve time with a non-self-locating `No such file \
5099 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5100 the value verbatim in its per-dep content-address `path:{caminho}` at \
5101 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5102 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5103 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5104 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5105 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5106 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5107 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5108 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5109 name carries no shell-history-expansion / bang-operator semantic; drop any \
5110 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5111 idiom; and drop any trailing English-typography exclamation mark that pasted \
5112 from prose.",
5113 ch = *byte as char
5114 )]
5115 FonteCaminhoShellHistoryExpansion {
5116 nome: String,
5117 caminho: String,
5118 byte: u8,
5119 },
5120 #[error(
5121 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5122 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5123 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5124 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5125 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5126 substitution' history operator that rewrites the prior command's `old` string to \
5127 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5128 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5129 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5130 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5131 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5132 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5133 literal value diverges from every downstream `feira tofu` curl-invocation / \
5134 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5135 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5136 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5137 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5138 `std::path::Path` treats `^` as a literal path-component byte, so \
5139 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5140 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5141 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5142 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5143 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5144 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5145 that fails at resolve time with a non-self-locating `No such file or directory` \
5146 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5147 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5148 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5149 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5150 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5151 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5152 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5153 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5154 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5155 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5156 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5157 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5158 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5159 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5160 drop any trailing `^` history-substitution-open fragment.",
5161 ch = *byte as char
5162 )]
5163 FonteCaminhoShellHistorySubstitution {
5164 nome: String,
5165 caminho: String,
5166 byte: u8,
5167 },
5168 #[error(
5169 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5170 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5171 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5172 value verbatim in its per-dep content-address `path:{caminho}` at \
5173 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5174 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5175 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5176 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5177 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5178 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5179 trailing `/`; every `:caminho` value names a sibling-workspace directory \
5180 already, so the trailing separator carries no information. Use \
5181 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5182 )]
5183 FonteCaminhoTrailingSlash { nome: String, caminho: String },
5184 #[error(
5185 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5186 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5187 apply the same set-not-multiset discipline; one package per table), and \
5188 two entries naming the same caixa carry two version constraints / source \
5189 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5190 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5191 silently overwrites the first at the resolver-side `concrete_versao` step, \
5192 and the dropped entry's pin / features never reach the closure — far from \
5193 the source caixa.lisp, with no field naming which `:deps` entry was the \
5194 silent loser. If two version constraints are genuinely needed (the rare \
5195 multi-version closure case the lacre pipeline doesn't yet support), the \
5196 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5197 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5198 )]
5199 DuplicateNome { nome: String, list: &'static str },
5200 #[error(
5201 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5202 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5203 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5204 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5205 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5206 with the canonical kebab-case feature name the target caixa declares."
5207 )]
5208 CaracteristicaEmpty { nome: String },
5209 #[error(
5210 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5211 feature name: {reason} (the value flows verbatim into Cargo's \
5212 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5213 parser enforces the same shape at `cargo metadata` time; use a single-token \
5214 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5215 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5216 an ASCII alphanumeric or `_`)"
5217 )]
5218 CaracteristicaInvalid {
5219 nome: String,
5220 caracteristica: String,
5221 reason: String,
5222 },
5223 #[error(
5224 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5225 every feature-flag list keys its entries by name (Cargo's \
5226 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5227 per feature per dep), and two entries naming the same feature are a redundant \
5228 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5229 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5230 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5231 feature once regardless of declaration count, so the duplicate's pin / position never \
5232 reaches the closure with no field naming the silent loser. One entry per feature per \
5233 dep; if two distinct features are intended, name each verbatim."
5234 )]
5235 CaracteristicaDuplicate {
5236 nome: String,
5237 caracteristica: String,
5238 },
5239 #[error(
5240 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5241 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5242 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5243 rejects mid-traversal far from the source caixa.lisp or recurses on until \
5244 it exhausts its stack). Every :nome is globally-unique substrate identity, \
5245 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5246 *is* the parent itself, not a coincidentally-named peer. Drop the \
5247 self-referential dep entry — to reference code from this caixa, use \
5248 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5249 referencing the caixa's own code surface) instead."
5250 )]
5251 DepIsSelf { nome: String, list: &'static str },
5252}
5253
5254// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5255// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5256// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5257// variant — the paired `{ nome: String, caminho: String }` two-slot family
5258// on [`DepError`], sibling of the peer
5259// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5260// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5261// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5262// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5263// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5264// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5265// `{ de, para, wit, expected }`), and
5266// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5267// variants on `{ de, para, <field>: String, reason: String }`) on the
5268// `AplicacaoError` envelopes, the peer
5269// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5270// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5271// (0419438, 4 variants on `{ caixa, kind, slots }`),
5272// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5273// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5274// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5275// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5276// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5277// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5278// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5279// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5280//
5281// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5282// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5283// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5284// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5285// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5286// CommandSubstitution}` on the four single-byte shell operators; and the
5287// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5288// opened the identical `DepError::FonteCaminho<Variant> { nome:
5289// nome.to_string(), caminho: caminho.to_string() }` four-line
5290// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5291// — the exact "same block re-inlined at every consumer" shape the PRIME
5292// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5293// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5294// families each closed on their sibling envelopes. The eleven variants
5295// share one `{ nome: String, caminho: String }` shape, so the fold routes
5296// each wire-up site through one dispatch per typed variant.
5297//
5298// The macro below generates one `#[must_use]` inherent constructor per
5299// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5300// wire-up site collapses onto one dispatch:
5301// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5302// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5303// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5304// once — inside the macro — rather than at every wire-up site.
5305//
5306// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5307// shapes at the per-byte-classification arms — the
5308// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5309// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5310// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5311// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5312// cluster — carry an additional `byte: u8` naming the offending byte and
5313// so would break the uniform-two-field routing this macro promises. They
5314// instead fold onto the sibling three-field envelope through
5315// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5316// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5317// two-slot family is the `byte: u8` classification the arms carry. The
5318// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5319// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5320// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5321// envelope.
5322//
5323// Every future consumer that wants to construct one of these eleven
5324// variants outside the current in-crate [`DepSource::validate_caminho`]
5325// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5326// at lacre-resolve time re-checking the same value-shape axes the resolver
5327// consumes, a future `feira validate --deps` per-caixa admission verb
5328// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5329// rejecting a `:caminho` value against a cluster-local snapshot) now
5330// reaches each variant through one call rather than re-inlining the
5331// four-line struct-literal in lockstep with the eleven in-crate wire-up
5332// sites.
5333macro_rules! fonte_caminho_ctors {
5334 ($($ctor:ident => $variant:ident),* $(,)?) => {
5335 impl DepError {
5336 $(
5337 #[doc = concat!(
5338 "Construct a [`DepError::",
5339 stringify!($variant),
5340 "`] naming the offending `:deps :nome` + `:fonte ",
5341 "(:tipo path …) :caminho` pair. Folds the uniform ",
5342 "`Self::",
5343 stringify!($variant),
5344 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5345 "two-slot struct-literal onto one substrate primitive so ",
5346 "every [`DepSource::validate_caminho`] wire-up on this ",
5347 "variant reads through one dispatch rather than the ",
5348 "pre-lift four-line open-coded block."
5349 )]
5350 #[must_use]
5351 pub fn $ctor(nome: &str, caminho: &str) -> Self {
5352 Self::$variant {
5353 nome: nome.to_string(),
5354 caminho: caminho.to_string(),
5355 }
5356 }
5357 )*
5358 }
5359 };
5360}
5361
5362fonte_caminho_ctors! {
5363 fonte_caminho_absolute => FonteCaminhoAbsolute,
5364 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5365 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5366 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5367 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5368 fonte_caminho_backslash => FonteCaminhoBackslash,
5369 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5370 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5371 fonte_caminho_shell_background => FonteCaminhoShellBackground,
5372 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5373 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5374}
5375
5376// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5377// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5378// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5379// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5380// three-slot family on [`DepError`], strict sibling of the peer
5381// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5382// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5383// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5384// axis broke its uniform-two-field routing — the exact "future compounding
5385// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5386// here. Third fold family on this `DepError` envelope, sibling of the peer
5387// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5388// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5389// same enum.
5390//
5391// Each of the twelve wire-up sites on this shape (the control-byte arm
5392// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5393// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5394// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5395// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5396// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5397// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5398// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5399// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5400// `FonteCaminhoShellHistoryExpansion` on `!`, and
5401// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5402// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5403// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5404// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5405// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5406// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5407// closed on the sibling two-field envelope of this same enum. The twelve
5408// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5409// the fold routes each wire-up site through one dispatch per typed variant.
5410//
5411// The macro below generates one `#[must_use]` inherent constructor per
5412// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5413// so every wire-up site collapses onto one dispatch:
5414// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5415// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5416// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5417// `byte`) is spelled once — inside the macro — rather than at every wire-up
5418// site.
5419//
5420// Every future consumer that wants to construct one of these twelve
5421// variants outside the current in-crate [`DepSource::validate_caminho`]
5422// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5423// at lacre-resolve time re-checking the same value-shape axes the resolver
5424// consumes, a future `feira validate --deps` per-caixa admission verb
5425// re-checking the `:fonte :caminho` axis against the shell-metachar
5426// classification bytes this cluster catches, a per-lacre overlay resolver
5427// rejecting a `:caminho` value against a cluster-local snapshot) now
5428// reaches each variant through one call rather than re-inlining the
5429// five-line struct-literal in lockstep with the twelve in-crate wire-up
5430// sites.
5431macro_rules! fonte_caminho_byte_ctors {
5432 ($($ctor:ident => $variant:ident),* $(,)?) => {
5433 impl DepError {
5434 $(
5435 #[doc = concat!(
5436 "Construct a [`DepError::",
5437 stringify!($variant),
5438 "`] naming the offending `:deps :nome` + `:fonte ",
5439 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5440 "classification. Folds the uniform `Self::",
5441 stringify!($variant),
5442 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5443 "byte }` three-slot struct-literal onto one substrate ",
5444 "primitive so every [`DepSource::validate_caminho`] wire-up ",
5445 "on this variant reads through one dispatch rather than ",
5446 "the pre-lift five-line open-coded block."
5447 )]
5448 #[must_use]
5449 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5450 Self::$variant {
5451 nome: nome.to_string(),
5452 caminho: caminho.to_string(),
5453 byte,
5454 }
5455 }
5456 )*
5457 }
5458 };
5459}
5460
5461fonte_caminho_byte_ctors! {
5462 fonte_caminho_control_char => FonteCaminhoControlChar,
5463 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5464 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5465 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5466 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5467 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5468 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5469 fonte_caminho_shell_comment => FonteCaminhoShellComment,
5470 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5471 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5472 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5473 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5474}
5475
5476// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5477// single-slot struct-variant wire-up sites scattered across
5478// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5479// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5480// substrate primitive per typed variant — the paired `{ nome: String }`
5481// single-slot family on [`DepError`], sibling of the peer
5482// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5483// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5484// the same enum, and of the peer
5485// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5486// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5487// axis. Second fold family on this `DepError` envelope, and the first on
5488// the single-`{ nome }` shape.
5489//
5490// The five wire-up sites this fold closes each opened the identical
5491// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5492// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5493// local — the exact "same block re-inlined at every consumer" shape the
5494// PRIME DIRECTIVE names as a bug. The five variants share one
5495// `{ nome: String }` shape, so the fold routes each wire-up site through
5496// one dispatch per typed variant.
5497//
5498// The macro below generates one `#[must_use]` inherent constructor per
5499// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5500// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5501// pre-lift struct-literal on the same `&str` fixture. The uniform
5502// one-field construction (`nome.to_string()`) is spelled once — inside
5503// the macro — rather than at every wire-up site. Callers that hold a
5504// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5505// and lets the macro-owned `.to_string()` produce the fresh owning copy
5506// the enum variant needs; the semantics collapse onto the same
5507// `.clone()`-equivalent one this fold replaces at every site.
5508//
5509// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5510// on the same envelope stays on its pre-lift open-coded wire-up shape —
5511// it carries no `nome` field (the offending `:nome` value *is* the empty
5512// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5513// signature this macro promises does not apply. Every future consumer
5514// that wants to construct one of these five variants outside the current
5515// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5516// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5517// re-validator at lacre-resolve time, a future `feira validate --deps`
5518// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5519// these empty-value shapes against a cluster-local snapshot) now reaches
5520// each variant through one call rather than re-inlining the three-line
5521// struct-literal in lockstep with the five in-crate wire-up sites.
5522macro_rules! dep_nome_only_ctors {
5523 ($($ctor:ident => $variant:ident),* $(,)?) => {
5524 impl DepError {
5525 $(
5526 #[doc = concat!(
5527 "Construct a [`DepError::",
5528 stringify!($variant),
5529 "`] naming the offending `:deps :nome`. Folds the ",
5530 "uniform `Self::",
5531 stringify!($variant),
5532 " { nome: nome.to_string() }` one-field ",
5533 "struct-literal onto one substrate primitive so every ",
5534 "in-crate wire-up on this variant reads through one ",
5535 "dispatch rather than the pre-lift three-line ",
5536 "open-coded block."
5537 )]
5538 #[must_use]
5539 pub fn $ctor(nome: &str) -> Self {
5540 Self::$variant { nome: nome.to_string() }
5541 }
5542 )*
5543 }
5544 };
5545}
5546
5547dep_nome_only_ctors! {
5548 versao_empty => VersaoEmpty,
5549 fonte_repo_empty => FonteRepoEmpty,
5550 fonte_pin_missing => FontePinMissing,
5551 fonte_caminho_empty => FonteCaminhoEmpty,
5552 caracteristica_empty => CaracteristicaEmpty,
5553}
5554
5555// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5556// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5557// [`crate::manifest::Caixa::validate_deps`] +
5558// [`validate_no_self_dep`] onto one substrate-primitive family per
5559// typed variant — the `DepError`-side siblings of the peer
5560// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5561// on the `SupervisorError { caixa: String }` one-slot envelope and of
5562// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5563// `DepError { nome: String }` one-slot envelope. The two variants
5564// carry the same `{ nome: String, list: &'static str }` two-slot
5565// shape: the `nome` field names the offending dep the diagnostic
5566// points the author back at, and the `list` field carries the
5567// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5568// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5569// [`validate_deps`] arms, and via the paired
5570// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5571// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5572// canonicals on the [`validate_no_self_dep`] arm) so the author can
5573// grep their caixa.lisp for the offending list block in one edit.
5574//
5575// Each of the four wire-up sites opened the same struct-literal
5576// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5577// two-line block — the exact "same block re-inlined at every
5578// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5579// altitude the peer `DepError` / `SupervisorError` /
5580// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5581// already closed on their sibling envelopes. The two `#[must_use]`
5582// inherent constructors below fold each wire-up onto one dispatch:
5583// `DepError::duplicate_nome(<nome>, <list>)` and
5584// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5585// pre-lift struct-literal on the same scalar fixtures. The `list:
5586// &'static str` parameter (not `impl Into<String>`) preserves the
5587// exact wire tag every consumer already passes verbatim — no
5588// downstream diagnostic reshaping at the lift, matching the peer
5589// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5590// contract each wire-up site already keys off.
5591macro_rules! dep_nome_list_ctors {
5592 ($($ctor:ident => $variant:ident),* $(,)?) => {
5593 impl DepError {
5594 $(
5595 #[doc = concat!(
5596 "Construct a [`DepError::",
5597 stringify!($variant),
5598 "`] naming the offending `:deps :nome` and the ",
5599 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5600 "the diagnostic points the author back at. Folds ",
5601 "the uniform `Self::",
5602 stringify!($variant),
5603 " { nome: nome.to_string(), list }` two-field ",
5604 "struct-literal onto one substrate primitive so ",
5605 "every in-crate wire-up on this variant reads ",
5606 "through one dispatch rather than the pre-lift ",
5607 "open-coded struct-literal block."
5608 )]
5609 #[must_use]
5610 pub fn $ctor(nome: &str, list: &'static str) -> Self {
5611 Self::$variant { nome: nome.to_string(), list }
5612 }
5613 )*
5614 }
5615 };
5616}
5617
5618dep_nome_list_ctors! {
5619 duplicate_nome => DuplicateNome,
5620 dep_is_self => DepIsSelf,
5621}
5622
5623// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5624// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5625// <value>.to_string(), reason }` struct-variant wire-up sites at
5626// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5627// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5628// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5629// primitive family per typed variant — the `DepError`-side siblings of the
5630// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5631// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5632// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5633// the two-slot `{ nome, caminho }` envelope, and
5634// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5635// caminho, byte }` envelope. The three variants share the same
5636// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5637// the `nome` field names the offending dep the diagnostic points the
5638// author back at, the middle `<axis>: String` field carries the offending
5639// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5640// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5641// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5642// field carries the parser-shaped rejection sentence the paired
5643// [`crate::render::require_valid_versao_requirement`] /
5644// [`crate::render::is_git_repo_url`] /
5645// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5646// axis-field name differs across variants (`versao` / `repo` /
5647// `caracteristica`) so the ctor family below takes the axis field name as
5648// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5649// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5650// -> Self` inherent constructor per typed variant that spells the uniform
5651// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5652// `reason` forwarded owned) exactly once. Peer of the sibling
5653// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5654// family on the `AplicacaoError` envelope's mirror-symmetric
5655// `{ <field>: String, reason: String }` two-slot shape — same
5656// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5657// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5658// envelope keys off (every `DepError` variant carries the offending
5659// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5660// offending block in one edit).
5661//
5662// The three wire-up sites this fold closes are:
5663// - [`DepSource::validate`]'s `:repo` value-shape arm
5664// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5665// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5666// rejects the offending URL);
5667// - [`Dep::validate`]'s `:versao` requirement-shape arm
5668// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5669// self.versao_requirement().to_string(), reason }` inside the
5670// [`crate::render::require_valid_versao_requirement`] callback pair);
5671// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5672// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5673// caracteristica: c.clone(), reason })` after
5674// [`crate::render::is_cargo_feature_name`] rejects the offending
5675// feature-name).
5676//
5677// Each opened the identical five-line struct-literal against the same
5678// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5679// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5680// same altitude the peer four already-lifted `DepError` ctor families
5681// closed on their sibling shape-envelopes. The three variant / axis-field
5682// discriminators are the only things that vary between them; the rest of
5683// the struct-literal is a byte-for-byte re-inline.
5684//
5685// Every future consumer wanting to raise one of these three diagnostics
5686// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5687// time re-checking each declared dep against the same requirement +
5688// git-URL + feature-name value-shape cascade, a future `feira validate
5689// --deps` per-caixa admission verb re-running the shape gates on demand,
5690// a per-lacre overlay resolver rejecting an author-supplied dep against a
5691// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5692// the five-line struct-literal in lockstep with the three in-crate
5693// wire-up sites.
5694macro_rules! dep_nome_axis_reason_ctors {
5695 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5696 impl DepError {
5697 $(
5698 #[doc = concat!(
5699 "Construct a [`DepError::",
5700 stringify!($variant),
5701 "`] naming the offending `:deps :nome`, the offending ",
5702 "`:", stringify!($axis), "` axis value, and the ",
5703 "parser-shaped rejection `reason`. Folds the uniform ",
5704 "`Self::",
5705 stringify!($variant),
5706 " { nome: nome.to_string(), ",
5707 stringify!($axis),
5708 ": ",
5709 stringify!($axis),
5710 ".to_string(), reason }` three-field struct-literal ",
5711 "onto one substrate primitive so every in-crate ",
5712 "wire-up on this variant reads through one dispatch ",
5713 "rather than the pre-lift five-line open-coded block. ",
5714 "The `nome: &str` and `",
5715 stringify!($axis),
5716 ": &str` parameters accept `&str` literals and ",
5717 "`&String` (via Deref coercion) so every existing ",
5718 "wire-up threads through the ctor without a ",
5719 "pre-conversion; the `reason: String` parameter takes ",
5720 "an owned `String` (not `impl Into<String>`) matching ",
5721 "the paired `crate::render::*` predicate's ",
5722 "`Result<(), String>` return shape every wire-up ",
5723 "already holds owned at the call site."
5724 )]
5725 #[must_use]
5726 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5727 Self::$variant {
5728 nome: nome.to_string(),
5729 $axis: $axis.to_string(),
5730 reason,
5731 }
5732 }
5733 )*
5734 }
5735 };
5736}
5737
5738dep_nome_axis_reason_ctors! {
5739 versao_invalid => VersaoInvalid { versao },
5740 fonte_repo_shape => FonteRepoShape { repo },
5741 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5742}
5743
5744// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5745// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5746// <value>.to_string() }` struct-variant wire-up sites at
5747// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5748// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5749// per-entry set-not-multiset dedup closure onto one substrate-primitive
5750// family per typed variant — the missing two-slot rung on the
5751// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5752// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5753// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5754// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5755// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5756// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5757// symmetric sibling of the peer
5758// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5759// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5760// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5761// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5762// owned altitude the `DepError` envelope keys off (every `DepError`
5763// variant carries the offending `:deps :nome` verbatim so the author
5764// can grep their caixa.lisp for the offending block in one edit). The
5765// three variants share the same `{ nome: String, <axis>: String }`
5766// two-slot shape: the `nome` field names the offending dep the
5767// diagnostic points the author back at, and the middle `<axis>:
5768// String` field carries the offending per-envelope axis value verbatim
5769// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5770// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5771// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5772// The middle axis-field name differs across variants (`pin` / `pins` /
5773// `caracteristica`) so the ctor family below takes the axis field name
5774// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5775// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5776// Self` inherent constructor per typed variant that spells the
5777// uniform two-field construction (`nome.to_string()` /
5778// `<axis>.to_string()`) exactly once.
5779//
5780// The three wire-up sites this fold closes are:
5781// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5782// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5783// pin.to_string() });` inside the `set.len() == 1` branch after the
5784// `is_some_and(String::is_empty)` iterator);
5785// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5786// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5787// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5788// - [`Dep::validate_caracteristicas`]'s per-entry
5789// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5790// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5791// [`crate::render::insert_first_seen`]).
5792//
5793// Each opened the identical four-line struct-literal against the same
5794// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5795// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5796// same altitude the peer four already-lifted `DepError` ctor families
5797// closed on their sibling shape-envelopes. The three variant / axis-
5798// field discriminators are the only things that vary between them;
5799// the rest of the struct-literal is a byte-for-byte re-inline.
5800//
5801// Every future consumer wanting to raise one of these three
5802// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5803// at lacre-resolve time re-checking each declared dep against the
5804// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5805// set-not-multiset cascade, a future `feira validate --deps` per-
5806// caixa admission verb re-running the shape gates on demand, a
5807// per-lacre overlay resolver rejecting an author-supplied dep against
5808// a cluster-local snapshot the M4 CR materializer projects) now
5809// reaches one dispatch rather than re-inlining the four-line struct-
5810// literal in lockstep with the three in-crate wire-up sites.
5811macro_rules! dep_nome_axis_ctors {
5812 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5813 impl DepError {
5814 $(
5815 #[doc = concat!(
5816 "Construct a [`DepError::",
5817 stringify!($variant),
5818 "`] naming the offending `:deps :nome` and the ",
5819 "offending `:", stringify!($axis), "` axis value. ",
5820 "Folds the uniform `Self::",
5821 stringify!($variant),
5822 " { nome: nome.to_string(), ",
5823 stringify!($axis),
5824 ": ",
5825 stringify!($axis),
5826 ".to_string() }` two-field struct-literal onto one ",
5827 "substrate primitive so every in-crate wire-up on ",
5828 "this variant reads through one dispatch rather than ",
5829 "the pre-lift four-line open-coded block. Both `nome: ",
5830 "&str` and `",
5831 stringify!($axis),
5832 ": &str` parameters accept `&str` literals and ",
5833 "`&String` (via Deref coercion) so every existing ",
5834 "wire-up threads through the ctor without a pre-",
5835 "conversion."
5836 )]
5837 #[must_use]
5838 pub fn $ctor(nome: &str, $axis: &str) -> Self {
5839 Self::$variant {
5840 nome: nome.to_string(),
5841 $axis: $axis.to_string(),
5842 }
5843 }
5844 )*
5845 }
5846 };
5847}
5848
5849dep_nome_axis_ctors! {
5850 fonte_pin_empty => FontePinEmpty { pin },
5851 fonte_pin_ambiguous => FontePinAmbiguous { pins },
5852 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5853}
5854
5855// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5856// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5857// struct-variant wire-up sites at [`DepSource::validate`]'s
5858// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5859// the `DepError` envelope — the last open-coded ctor site remaining on
5860// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5861// carries, and the single-variant sibling of the peer four already-
5862// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5863// on the two-slot `{ nome, caminho }` envelope,
5864// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5865// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5866// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5867// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5868// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5869// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5870// `{ …, value: String, reason: String }` payload shape, one axis
5871// removed at the `nome`-only-owner altitude the `DepError` envelope
5872// keys off (no `edge_pair()` de/para pair).
5873//
5874// The two wire-up sites this fold closes are the paired refname-pin
5875// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5876// pin: pin.to_string(), value: v.clone(), reason }` inside the
5877// `[(":tag", tag), (":branch", branch)]` iterator against
5878// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5879// (`|| DepError::FontePinShape { nome: nome.to_string(),
5880// pin: ":rev".to_string(), value: v.clone(), reason }` against
5881// [`crate::render::is_git_oid`]) — each opened the identical
5882// `DepError::FontePinShape { … }` six-line struct-literal against the
5883// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5884// tuple, the exact "same block re-inlined at every consumer" shape
5885// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5886// the only thing that varies between them (`":tag"`/`":branch"` on
5887// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5888// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5889// route through the same ctor because their `pin` field carries the
5890// author-surface tag verbatim (matching the `FontePinEmpty` /
5891// `FontePinAmbiguous` sibling variants' `pin: String` axis
5892// convention), so the offending author can grep their caixa.lisp for
5893// the offending `:tag "<value>"` / `:branch "<value>"` /
5894// `:rev "<value>"` literal in one edit.
5895//
5896// The single ctor below folds each wire-up onto one dispatch:
5897// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5898// the pre-lift struct-literal on the same `(&str, &str, &str,
5899// String)` fixture. The uniform four-field construction
5900// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5901// `reason` forwarded owned) is spelled once here rather than at every
5902// wire-up site. The `reason: String` field takes an owned `String`
5903// (not `impl Into<String>`) matching the two call sites' pre-existing
5904// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5905// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5906// predicates return `Result<(), String>`, so the caller always holds
5907// an owned `String` at the wire-up site and threading it through the
5908// ctor without a `.into()` shim keeps the routing shape byte-equal to
5909// the pre-lift block. The `value: &str` parameter accepts both `&str`
5910// literals (unused today) and `&String` (from the caller-held
5911// `v: &String` on each arm, via Deref coercion), so every existing
5912// wire-up threads through the ctor without a pre-conversion.
5913//
5914// Every future consumer that wants to construct this variant outside
5915// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5916// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5917// re-checking the same value-shape axes the resolver consumes, a
5918// future `feira validate --deps` per-caixa admission verb re-checking
5919// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5920// resolver rejecting a git-pin value against a cluster-local
5921// snapshot) now reaches this variant through one call rather than
5922// re-inlining the six-line struct-literal in lockstep with the two
5923// in-crate wire-up sites.
5924impl DepError {
5925 /// Construct a [`DepError::FontePinShape`] naming the offending
5926 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5927 /// axis tag, the offending value, and the parser-shaped `reason`.
5928 /// Folds the uniform
5929 /// `Self::FontePinShape { nome: nome.to_string(),
5930 /// pin: pin.to_string(), value: value.to_string(), reason }`
5931 /// four-field struct-literal onto one substrate primitive so
5932 /// every [`DepSource::validate`] wire-up on this variant reads
5933 /// through one dispatch rather than the pre-lift six-line
5934 /// open-coded block. The `nome` string threads verbatim from
5935 /// [`Dep::nome`] at the call site; the `pin` string carries the
5936 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5937 /// `value` string carries the offending refname / hex-OID
5938 /// verbatim; and `reason` forwards the owned `String` returned
5939 /// by [`crate::render::is_git_ref_name`] /
5940 /// [`crate::render::is_git_oid`] without a `.into()` shim.
5941 #[must_use]
5942 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5943 Self::FontePinShape {
5944 nome: nome.to_string(),
5945 pin: pin.to_string(),
5946 value: value.to_string(),
5947 reason,
5948 }
5949 }
5950
5951 /// Construct a [`DepError::NomeInvalid`] naming the offending
5952 /// `:deps :nome` byte-string and the parser-shaped rejection
5953 /// `reason` returned by [`crate::render::is_dns_1123_label`].
5954 ///
5955 /// Folds the uniform
5956 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5957 /// struct-literal onto one substrate primitive so every wire-up on
5958 /// this variant reads through one dispatch rather than the pre-lift
5959 /// four-line open-coded `DepError::NomeInvalid { nome:
5960 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5961 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5962 /// ctor-family ladder (`{ nome }` one-slot →
5963 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5964 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5965 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5966 /// `{ nome, <axis>: String, reason: String }` three-slot →
5967 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5968 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5969 /// — the sole variant on the envelope carrying the
5970 /// `{ nome: String, reason: String }` two-slot shape without a
5971 /// middle axis, matching the peer
5972 /// [`crate::manifest::ManifestError::NomeInvalid`] +
5973 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5974 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5975 /// four-axis DNS-1123 caixa-identifier diagnostic family the
5976 /// existing `nome_invalid_diagnostic_carries_offending_name` test
5977 /// pins on this envelope.
5978 ///
5979 /// The `nome: &str` parameter accepts `&str` literals and `&String`
5980 /// (via Deref coercion) so the sole in-crate wire-up threads through
5981 /// the ctor without a pre-conversion; the `reason: String`
5982 /// parameter takes an owned `String` (not `impl Into<String>`)
5983 /// matching the [`crate::render::is_dns_1123_label`] predicate's
5984 /// `Result<(), String>` return shape the sole wire-up site already
5985 /// holds owned at the call site, keeping the routing byte-equal to
5986 /// the pre-lift block. Same owned-`String`-forward `reason` payload
5987 /// discipline as the sibling three-slot family
5988 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5989 /// and the four-slot [`DepError::fonte_pin_shape`] on
5990 /// `{ nome, pin, value, reason }`.
5991 ///
5992 /// Every future consumer that raises the same diagnostic outside
5993 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5994 /// re-validator at lacre-resolve time re-checking each declared
5995 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5996 /// side schema uses (the `:nome` value flows verbatim as the target
5997 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5998 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5999 /// checkout-directory leaf), a future `feira validate --deps`
6000 /// per-caixa admission verb re-running the shape gate on demand, a
6001 /// per-lacre overlay resolver rejecting an author-supplied dep's
6002 /// `:nome` against a cluster-local snapshot the M4 CR materializer
6003 /// projects, a future authoring-surface widening the field into a
6004 /// `(String, Vec<Suggestion>)` pair carrying a
6005 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6006 /// variant through one call rather than re-inlining the four-line
6007 /// struct-literal in lockstep with the one in-crate wire-up site.
6008 #[must_use]
6009 pub fn nome_invalid(nome: &str, reason: String) -> Self {
6010 Self::NomeInvalid {
6011 nome: nome.to_string(),
6012 reason,
6013 }
6014 }
6015}
6016
6017#[allow(clippy::trivially_copy_pass_by_ref)]
6018fn is_false(b: &bool) -> bool {
6019 !*b
6020}
6021
6022#[cfg(test)]
6023mod tests {
6024 use super::*;
6025
6026 #[test]
6027 fn registry_dep_is_minimal() {
6028 let d = Dep::simple("caixa-teia", "^0.1");
6029 assert_eq!(d.nome, "caixa-teia");
6030 assert_eq!(d.versao, "^0.1");
6031 assert!(d.fonte.is_none());
6032 assert!(!d.opcional());
6033 assert!(d.caracteristicas().is_empty());
6034 }
6035
6036 #[test]
6037 fn dep_string_scalar_accessor_pair_is_const_fn() {
6038 // Fail-before-pass-after pin on [`Dep::nome`] +
6039 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6040 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6041 // entry's [`String`] storage through the `pub const fn`
6042 // [`String::as_str`] (const-stable since Rust 1.87, well
6043 // within the workspace MSRV) — any future accidental
6044 // downgrade to non-`const` fails the corresponding
6045 // `<name>_via_const_fn` wrapper at caixa-core build time with
6046 // E0015 (`cannot call non-const method`), strictly stronger
6047 // than a runtime `assert!`. Sibling of the peer
6048 // per-M2/M3/universal-axis `String → &str` scalar-accessor
6049 // family pins on the sibling `const`-eval-surface passes
6050 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6051 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6052 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6053 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6054 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6055 // [`crate::aplicacao::Entrada::destination`] at the M3
6056 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6057 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6058 // M2 supervisor-tree axis,
6059 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6060 // M2 upgrade axis, and the per-`:contratos`
6061 // [`crate::aplicacao::WitContract::source`] /
6062 // [`crate::aplicacao::WitContract::destination`] /
6063 // [`crate::aplicacao::WitContract::world_ref`] trio the
6064 // sibling pin at 279823b already anchors).
6065 const fn nome_via_const_fn(d: &Dep) -> &str {
6066 d.nome()
6067 }
6068 const fn versao_via_const_fn(d: &Dep) -> &str {
6069 d.versao_requirement()
6070 }
6071 for (nome, versao) in [
6072 ("caixa-teia", "^0.1"),
6073 ("caixa-mesh", "~0.2.3"),
6074 ("caixa-helm", "*"),
6075 ] {
6076 let d = Dep::simple(nome, versao);
6077 assert_eq!(nome_via_const_fn(&d), d.nome());
6078 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6079 assert_eq!(d.nome(), nome);
6080 assert_eq!(d.versao_requirement(), versao);
6081 }
6082 }
6083
6084 #[test]
6085 fn dep_outer_accessor_family_is_const_fn() {
6086 // Fail-before-pass-after pin on [`Dep::fonte`] +
6087 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6088 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6089 // entry's composite / list storage through a `pub const fn`
6090 // stdlib method (`Option::<DepSource>::as_ref` /
6091 // `Vec::<String>::as_slice`, both const-stable since Rust
6092 // 1.83, well within the workspace MSRV). Any future
6093 // accidental downgrade to non-`const` fails the corresponding
6094 // `<name>_via_const_fn` wrapper at caixa-core build time with
6095 // E0015 (`cannot call non-const method`), strictly stronger
6096 // than a runtime `assert!` and side-stepping the destructor-
6097 // in-const restriction the `Dep` fixture's `String` /
6098 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6099 // direct-`const _: () = assert!(...)` residence.
6100 //
6101 // Peer of the sibling per-`Dep` scalar-accessor pair pin
6102 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6103 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6104 // the `const`-eval-surface discipline onto the composite-
6105 // reference and slice-return arms of the outer-`Dep` accessor
6106 // family, closing the four-slot outer surface (`:nome` +
6107 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6108 // posture. The `:opcional` `bool` arm already carries the
6109 // posture through [`Dep::opcional`]'s prior `pub const fn`
6110 // declaration, so this pin lands the last two unlifted
6111 // outer-`Dep` accessors and closes the family.
6112 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6113 d.fonte()
6114 }
6115 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6116 d.caracteristicas()
6117 }
6118 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6119 let empty = Dep::simple("caixa-teia", "^0.1");
6120 assert!(fonte_via_const_fn(&empty).is_none());
6121 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6122 assert!(caracteristicas_via_const_fn(&empty).is_empty());
6123 assert_eq!(
6124 caracteristicas_via_const_fn(&empty),
6125 empty.caracteristicas()
6126 );
6127 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6128 // still empty.
6129 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6130 assert!(fonte_via_const_fn(&git).is_some());
6131 assert_eq!(fonte_via_const_fn(&git), git.fonte());
6132 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6133 // Populated `:caracteristicas` — exercise the non-empty
6134 // slice-view arm to pin the accessor's borrow shape against
6135 // both a `Vec::new()` empty backing buffer and a populated one.
6136 let mut with_features = Dep::simple("caixa-teia", "^0.1");
6137 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6138 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6139 assert_eq!(
6140 caracteristicas_via_const_fn(&with_features),
6141 with_features.caracteristicas()
6142 );
6143 }
6144
6145 #[test]
6146 fn git_dep_carries_tag() {
6147 let d = Dep::git("t", "*", "github:o/r", "v1");
6148 match d.fonte {
6149 Some(DepSource::Git {
6150 ref repo, ref tag, ..
6151 }) => {
6152 assert_eq!(repo, "github:o/r");
6153 assert_eq!(tag.as_deref(), Some("v1"));
6154 }
6155 _ => panic!("expected Git source"),
6156 }
6157 }
6158
6159 #[test]
6160 fn validate_accepts_simple_dep() {
6161 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6162 }
6163
6164 #[test]
6165 fn validate_rejects_empty_nome() {
6166 // The fail-before-pass-after pin for `:nome ""`: the empty-name
6167 // arm fires first so the per-entry parse-side diagnostic doesn't
6168 // emit a useless `nome: ""` reference.
6169 let mut d = Dep::simple("placeholder", "^0.1");
6170 d.nome = String::new();
6171 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6172 }
6173
6174 #[test]
6175 fn validate_rejects_empty_versao() {
6176 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6177 // semver crate accepts the empty string as a wildcard match),
6178 // so the empty-`:versao` arm is structurally necessary even
6179 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6180 // `EmptyChildVersion` ordering on the other two `:versao` axes.
6181 let mut d = Dep::simple("caixa-teia", "ignored");
6182 d.versao = String::new();
6183 let err = d.validate().unwrap_err();
6184 assert!(
6185 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6186 "got {err:?}"
6187 );
6188 }
6189
6190 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6191
6192 #[test]
6193 fn validate_rejects_nome_with_uppercase() {
6194 // The fail-before-pass-after pin: a non-empty but uppercase
6195 // `:nome` silently passed `validate()` on every pre-gate
6196 // codebase because the prior shape only refused the empty
6197 // string. The DNS-1123 violation surfaced far downstream at
6198 // lacre-resolve time when the *target* caixa's `:nome` failed
6199 // its own gate — far from the `:deps` entry, with a diagnostic
6200 // naming the target rather than the dep entry that referenced
6201 // it. Same fail-before-pass-after fixture pinned for
6202 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6203 // and Caixa `:nome` (6c992f8).
6204 let d = Dep::simple("Caixa-Teia", "^0.1");
6205 let err = d.validate().unwrap_err();
6206 assert!(
6207 matches!(
6208 err,
6209 DepError::NomeInvalid { ref nome, ref reason }
6210 if nome == "Caixa-Teia" && reason.contains("uppercase")
6211 ),
6212 "got {err:?}"
6213 );
6214 }
6215
6216 #[test]
6217 fn validate_rejects_nome_with_underscore() {
6218 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6219 // "I'm thinking of Go module names / Python identifiers" leak.
6220 // Same fixture pinned for the peer caixa-identifier axes.
6221 let d = Dep::simple("caixa_teia", "^0.1");
6222 let err = d.validate().unwrap_err();
6223 assert!(
6224 matches!(
6225 err,
6226 DepError::NomeInvalid { ref nome, ref reason }
6227 if nome == "caixa_teia" && reason.contains('_')
6228 ),
6229 "got {err:?}"
6230 );
6231 }
6232
6233 #[test]
6234 fn validate_rejects_nome_with_dot() {
6235 // A `:deps :nome` is a single DNS-1123 *label*, not a
6236 // subdomain — dots are rejected. The `"caixa.teia"` shape is
6237 // the canonical "I confused the dep name with the FQDN /
6238 // namespace" footgun, distinct from the legitimate
6239 // `:fonte :repo "github:org/caixa-teia"` axis.
6240 let d = Dep::simple("caixa.teia", "^0.1");
6241 let err = d.validate().unwrap_err();
6242 assert!(
6243 matches!(
6244 err,
6245 DepError::NomeInvalid { ref nome, ref reason }
6246 if nome == "caixa.teia" && reason.contains('.')
6247 ),
6248 "got {err:?}"
6249 );
6250 }
6251
6252 #[test]
6253 fn validate_rejects_nome_with_leading_hyphen() {
6254 // RFC 1123 requires alphanumeric at both label boundaries.
6255 // Pinned in parity with the peer DNS-1123 fixtures.
6256 let d = Dep::simple("-caixa-teia", "^0.1");
6257 let err = d.validate().unwrap_err();
6258 assert!(
6259 matches!(
6260 err,
6261 DepError::NomeInvalid { ref nome, ref reason }
6262 if nome == "-caixa-teia" && reason.contains("alphanumeric")
6263 ),
6264 "got {err:?}"
6265 );
6266 }
6267
6268 #[test]
6269 fn validate_rejects_nome_with_trailing_hyphen() {
6270 let d = Dep::simple("caixa-teia-", "^0.1");
6271 let err = d.validate().unwrap_err();
6272 assert!(
6273 matches!(
6274 err,
6275 DepError::NomeInvalid { ref nome, ref reason }
6276 if nome == "caixa-teia-" && reason.contains("alphanumeric")
6277 ),
6278 "got {err:?}"
6279 );
6280 }
6281
6282 #[test]
6283 fn validate_rejects_nome_with_slash() {
6284 // The canonical "I copied the GitHub repo path into `:nome`
6285 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6286 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6287 // the local-name slot. Same fixture pinned for `:membros
6288 // :caixa` (3f9d7a0).
6289 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6290 let err = d.validate().unwrap_err();
6291 assert!(
6292 matches!(
6293 err,
6294 DepError::NomeInvalid { ref nome, ref reason }
6295 if nome == "pleme-io/caixa-teia" && reason.contains('/')
6296 ),
6297 "got {err:?}"
6298 );
6299 }
6300
6301 #[test]
6302 fn validate_rejects_nome_too_long() {
6303 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6304 // Built from a valid character set so the length-bound
6305 // diagnostic surfaces before any per-character check (the
6306 // order pin parallel to the per-character predicates inside
6307 // [`crate::render::is_dns_1123_label`]).
6308 let long = "a".repeat(64);
6309 let d = Dep::simple(&long, "^0.1");
6310 let err = d.validate().unwrap_err();
6311 assert!(
6312 matches!(
6313 err,
6314 DepError::NomeInvalid { ref nome, ref reason }
6315 if nome.len() == 64 && reason.contains("max length of 63")
6316 ),
6317 "got {err:?}"
6318 );
6319 }
6320
6321 #[test]
6322 fn validate_accepts_canonical_nome_labels() {
6323 // Positive-control sweep — every form the K8s apiserver
6324 // accepts as a DNS-1123 label must round-trip through
6325 // validate. Covers a hyphen-bearing label, a numeric-suffix
6326 // label, a leading-digit label, a single-character label, and
6327 // a 63-byte (exactly the cap) label — the same fixture set
6328 // the peer `:membros :caixa` / `:children :caixa` positive
6329 // controls pin.
6330 for nome in [
6331 "caixa-teia",
6332 "caixa-resolver2",
6333 "2nd-tier-cache",
6334 "x",
6335 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6336 ] {
6337 Dep::simple(nome, "^0.1")
6338 .validate()
6339 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6340 }
6341 }
6342
6343 #[test]
6344 fn nome_empty_takes_precedence_over_nome_invalid() {
6345 // Ordering pin: `NomeEmpty` is the more self-locating
6346 // diagnostic on `""` and must lead — `is_dns_1123_label` is
6347 // only reached after the empty-check fires at the call site.
6348 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6349 // (3f9d7a0) on the peer caixa-identifier axis.
6350 let mut d = Dep::simple("placeholder", "^0.1");
6351 d.nome = String::new();
6352 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6353 }
6354
6355 #[test]
6356 fn nome_invalid_fires_before_versao_empty() {
6357 // Ordering pin: a malformed `:nome` fires before any `:versao`
6358 // axis check on the *same* entry — the per-entry shape gates
6359 // run top-to-bottom (nome empty → nome shape → versao empty →
6360 // versao parse → fonte shape), so a one-entry caixa.lisp with
6361 // both wrong sees the name-side diagnostic first (the name is
6362 // the self-locating axis — without a valid name, the parse
6363 // diagnostic can't quote `:nome "<bad>"`). Same ordering
6364 // discipline as `membro_caixa_invalid_fires_before_versao_check`
6365 // (3f9d7a0).
6366 let mut d = Dep::simple("Caixa-Teia", "^0.1");
6367 d.versao = String::new();
6368 let err = d.validate().unwrap_err();
6369 assert!(
6370 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6371 "got {err:?}"
6372 );
6373 }
6374
6375 #[test]
6376 fn nome_invalid_fires_before_versao_invalid() {
6377 // Ordering pin: a malformed `:nome` fires before the `:versao`
6378 // parse-side check on the *same* entry. Pin separately from
6379 // the empty-versao ordering so a future re-ordering surfaces
6380 // here, parallel to the b0c8389 / c4213a4 trajectory.
6381 let d = Dep::simple("Caixa-Teia", "^^0.1");
6382 let err = d.validate().unwrap_err();
6383 assert!(
6384 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6385 "got {err:?}"
6386 );
6387 }
6388
6389 #[test]
6390 fn nome_invalid_fires_before_fonte_invalid() {
6391 // Ordering pin: a malformed `:nome` fires before the `:fonte`
6392 // shape check on the *same* entry. The `:fonte` diagnostic
6393 // names the offending dep's `:nome` verbatim (via
6394 // `DepSource::validate(&self.nome)`), so a non-self-locating
6395 // name would taint the downstream diagnostic too — the gate
6396 // ordering keeps both diagnostics individually self-locating.
6397 let mut d = Dep::simple("Caixa-Teia", "^0.1");
6398 d.fonte = Some(DepSource::Git {
6399 repo: String::new(),
6400 tag: None,
6401 rev: None,
6402 branch: None,
6403 });
6404 let err = d.validate().unwrap_err();
6405 assert!(
6406 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6407 "got {err:?}"
6408 );
6409 }
6410
6411 #[test]
6412 fn nome_invalid_diagnostic_carries_offending_name() {
6413 // The diagnostic-shape pin: the error names the offending
6414 // `:nome` value verbatim so the author can grep their
6415 // caixa.lisp without re-running the build, and carries a
6416 // non-empty `reason` from `is_dns_1123_label` so the
6417 // predicate's own wording flows through to the diagnostic.
6418 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6419 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6420 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6421 // share a structurally-equivalent diagnostic family.
6422 let d = Dep::simple("Caixa_Teia", "^0.1");
6423 let err = d.validate().unwrap_err();
6424 let DepError::NomeInvalid { nome, reason } = err else {
6425 panic!("expected NomeInvalid, got other variant");
6426 };
6427 assert_eq!(nome, "Caixa_Teia");
6428 assert!(
6429 !reason.is_empty(),
6430 "NomeInvalid `reason` must carry the predicate's wording verbatim"
6431 );
6432 }
6433
6434 #[test]
6435 fn validate_rejects_invalid_versao_requirement() {
6436 // The fail-before-pass-after pin: a non-empty but malformed
6437 // requirement (`"^bad-version"`) silently passed every pre-gate
6438 // codebase because `:deps :versao` wasn't validated. The parse
6439 // failure surfaced far downstream at lacre-resolve time with a
6440 // `semver::Error` that didn't name which `:deps` entry carried
6441 // the typo. The new gate moves the check to caixa-build time
6442 // at the source caixa.lisp.
6443 let d = Dep::simple("caixa-teia", "^bad-version");
6444 let err = d.validate().unwrap_err();
6445 assert!(
6446 matches!(
6447 err,
6448 DepError::VersaoInvalid { ref nome, ref versao, .. }
6449 if nome == "caixa-teia" && versao == "^bad-version"
6450 ),
6451 "got {err:?}"
6452 );
6453 }
6454
6455 #[test]
6456 fn validate_rejects_versao_with_double_caret_typo() {
6457 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6458 // Cargo-shaped requirement on first glance but fails the parser
6459 // because semver doesn't accept stacked operators. Pin this
6460 // adjacent-shape footgun explicitly so a future relaxation that
6461 // accepts "looks-canonical-but-isn't" forms surfaces here, in
6462 // parity with the `:membros` / `:children` fixtures.
6463 let d = Dep::simple("caixa-teia", "^^0.1");
6464 let err = d.validate().unwrap_err();
6465 assert!(
6466 matches!(
6467 err,
6468 DepError::VersaoInvalid { ref nome, ref versao, .. }
6469 if nome == "caixa-teia" && versao == "^^0.1"
6470 ),
6471 "got {err:?}"
6472 );
6473 }
6474
6475 #[test]
6476 fn validate_rejects_versao_with_v_prefixed_tag() {
6477 // `"v0.1"` is the canonical "git-tag-shape leaking into the
6478 // semver requirement slot" typo — an author copies the
6479 // publish-side git-tag string verbatim into `:versao`, but
6480 // Cargo's semver parser rejects the leading `v`. Same fixture
6481 // pinned for `:membros :versao` (9888b13) and `:children
6482 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6483 // are *accepted* by the semver crate as an `*` wildcard on the
6484 // patch axis — they're a Cargo-side valid shape, not a typo.)
6485 let d = Dep::simple("caixa-teia", "v0.1");
6486 let err = d.validate().unwrap_err();
6487 assert!(
6488 matches!(
6489 err,
6490 DepError::VersaoInvalid { ref nome, ref versao, .. }
6491 if nome == "caixa-teia" && versao == "v0.1"
6492 ),
6493 "got {err:?}"
6494 );
6495 }
6496
6497 #[test]
6498 fn validate_accepts_canonical_versao_forms() {
6499 // The five Cargo-shaped requirement forms `:membros :versao`
6500 // and `:children :versao` already accept via
6501 // `crate::parse_requirement` must pass the deps gate without
6502 // re-validating at the resolver layer. Pin every leg so a
6503 // future tightening of the canonical set surfaces here as a
6504 // test failure.
6505 for form in [
6506 "^0.1", // caret — minor-range pin (the most common shape)
6507 "~0.1.2", // tilde — patch-range pin
6508 "0.1.0", // exact — single-version pin
6509 "*", // wildcard — explicitly any-version
6510 ">=0.1, <2", // multi-range — comma-separated comparators
6511 ] {
6512 Dep::simple("caixa-teia", form)
6513 .validate()
6514 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6515 }
6516 }
6517
6518 #[test]
6519 fn versao_empty_takes_precedence_over_invalid() {
6520 // Order pin: the existing `VersaoEmpty` diagnostic (which
6521 // doesn't try to parse) fires before the new `VersaoInvalid`
6522 // parse-side diagnostic, so an empty `:versao` keeps its
6523 // narrower error message — `parse_requirement("")` would
6524 // otherwise return `Ok(STAR)` and silently pass, but the empty
6525 // arm catches it first.
6526 let mut d = Dep::simple("caixa-teia", "ignored");
6527 d.versao = String::new();
6528 let err = d.validate().unwrap_err();
6529 assert!(
6530 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6531 "got {err:?}"
6532 );
6533 }
6534
6535 #[test]
6536 fn nome_empty_takes_precedence_over_versao_invalid() {
6537 // Order pin: even when `:versao` is malformed and would raise
6538 // its own diagnostic, `:nome ""` fires first because the
6539 // per-entry parse diagnostic needs a non-empty name to be
6540 // self-locating. Mirrors the
6541 // `membros_validation_runs_before_contratos_membership_check`
6542 // ordering on the typed-graph layer.
6543 let mut d = Dep::simple("placeholder", "^bad");
6544 d.nome = String::new();
6545 let err = d.validate().unwrap_err();
6546 assert_eq!(err, DepError::NomeEmpty);
6547 }
6548
6549 #[test]
6550 fn versao_invalid_diagnostic_carries_offending_versao() {
6551 // The diagnostic-shape pin: the error names the offending
6552 // `:versao` value verbatim so the author can grep their
6553 // caixa.lisp without re-running the build, and carries a
6554 // non-empty `reason` from `semver::VersionReq::parse` so the
6555 // parser's own wording flows through to the diagnostic.
6556 let d = Dep::simple("caixa-teia", "not-a-req");
6557 let err = d.validate().unwrap_err();
6558 let DepError::VersaoInvalid {
6559 nome,
6560 versao,
6561 reason,
6562 } = err
6563 else {
6564 panic!("expected VersaoInvalid, got other variant");
6565 };
6566 assert_eq!(nome, "caixa-teia");
6567 assert_eq!(versao, "not-a-req");
6568 assert!(
6569 !reason.is_empty(),
6570 "VersaoInvalid `reason` must carry the parser's wording verbatim"
6571 );
6572 }
6573
6574 // -- :fonte value-shape gate ------------------------------------------
6575
6576 fn dep_with_fonte(fonte: DepSource) -> Dep {
6577 let mut d = Dep::simple("caixa-teia", "^0.1");
6578 d.fonte = Some(fonte);
6579 d
6580 }
6581
6582 #[test]
6583 fn validate_accepts_git_fonte_with_tag() {
6584 // The positive-control pin on the canonical git source — exactly
6585 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6586 // shape every existing caixa-resolver integration test uses.
6587 let d = dep_with_fonte(DepSource::Git {
6588 repo: "github:pleme-io/caixa-teia".into(),
6589 tag: Some("v0.1.0".into()),
6590 rev: None,
6591 branch: None,
6592 });
6593 d.validate().unwrap();
6594 }
6595
6596 #[test]
6597 fn validate_accepts_git_fonte_with_rev() {
6598 // Each of the three pin axes is independently a valid single-pin
6599 // shape; pin the :rev arm so a future relaxation that only
6600 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6601 // OID — the canonical `git rev-parse HEAD` emission shape the
6602 // `crate::render::is_git_oid` value-shape gate now requires;
6603 // abbreviated OIDs are ambiguous across repo history and
6604 // rejected at this gate (pinned separately by
6605 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6606 let d = dep_with_fonte(DepSource::Git {
6607 repo: "github:pleme-io/caixa-teia".into(),
6608 tag: None,
6609 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6610 branch: None,
6611 });
6612 d.validate().unwrap();
6613 }
6614
6615 #[test]
6616 fn validate_accepts_git_fonte_with_branch() {
6617 // The :branch arm is the third valid single-pin shape — pinned
6618 // separately so the gate-accepts-all-three-pin-axes contract is
6619 // a build-error to relax.
6620 let d = dep_with_fonte(DepSource::Git {
6621 repo: "github:pleme-io/caixa-teia".into(),
6622 tag: None,
6623 rev: None,
6624 branch: Some("main".into()),
6625 });
6626 d.validate().unwrap();
6627 }
6628
6629 #[test]
6630 fn validate_accepts_path_fonte() {
6631 // The positive-control pin on the path source — non-empty
6632 // :caminho, no pin axes (paths have no commit identity). Pinned
6633 // so a future "paths must also pin a rev" tightening surfaces
6634 // here as a structural decision, not a silent break.
6635 let d = dep_with_fonte(DepSource::Path {
6636 caminho: "../caixa-teia".into(),
6637 });
6638 d.validate().unwrap();
6639 }
6640
6641 #[test]
6642 fn validate_rejects_git_fonte_with_empty_repo() {
6643 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6644 // "v1")`: the empty-repo shape silently passed every pre-gate
6645 // codebase because `:fonte` wasn't validated. The git-clone
6646 // failure surfaced far downstream at lacre-resolve time with no
6647 // field naming which `:deps` entry carried the typo. The new
6648 // gate moves the check to caixa-build time at the source
6649 // caixa.lisp.
6650 let d = dep_with_fonte(DepSource::Git {
6651 repo: String::new(),
6652 tag: Some("v0.1.0".into()),
6653 rev: None,
6654 branch: None,
6655 });
6656 let err = d.validate().unwrap_err();
6657 assert!(
6658 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6659 "got {err:?}"
6660 );
6661 }
6662
6663 // -- :repo value-shape gate -------------------------------------------
6664 //
6665 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6666 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6667 // codebase admitted any non-empty string; the new
6668 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6669 // URL intersection-floor at validate time, peer with the three pin
6670 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6671 // `is_git_oid`). Every test in this section is a fail-before /
6672 // pass-after pin on a specific authoring footgun.
6673
6674 #[test]
6675 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6676 // The canonical paste-from-doc footgun on `:repo` — an author
6677 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6678 // a doc paragraph. Until this gate landed the empty-repo arm
6679 // passed (the string isn't empty), the resolver issued
6680 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6681 // surfaced at clone time with a quoting-confused error far from
6682 // the source caixa.lisp. Same paste-from-doc footgun the
6683 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6684 // axis — now closed on the `:repo` URL axis too.
6685 let d = dep_with_fonte(DepSource::Git {
6686 repo: "github:pleme-io/caixa-teia ".into(),
6687 tag: Some("v0.1.0".into()),
6688 rev: None,
6689 branch: None,
6690 });
6691 let err = d.validate().unwrap_err();
6692 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6693 panic!("expected FonteRepoShape, got other variant");
6694 };
6695 assert_eq!(nome, "caixa-teia");
6696 assert_eq!(repo, "github:pleme-io/caixa-teia ");
6697 assert!(
6698 reason.contains("whitespace"),
6699 "reason must surface the whitespace arm, got {reason:?}"
6700 );
6701 }
6702
6703 #[test]
6704 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6705 // The canonical CLI-argument-injection footgun at the `git clone`
6706 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6707 // argv parser read the value as a CLI flag, escaping the
6708 // subprocess argument boundary. The `--` separator workaround
6709 // does not fix the typed slot's accepted set; the gate rejects
6710 // the shape upstream at validate time so the resolver never
6711 // invokes a `git clone -…` subprocess.
6712 let d = dep_with_fonte(DepSource::Git {
6713 repo: "-upload-pack=evil".into(),
6714 tag: Some("v0.1.0".into()),
6715 rev: None,
6716 branch: None,
6717 });
6718 let err = d.validate().unwrap_err();
6719 let DepError::FonteRepoShape { repo, reason, .. } = err else {
6720 panic!("expected FonteRepoShape, got other variant");
6721 };
6722 assert_eq!(repo, "-upload-pack=evil");
6723 assert!(
6724 reason.contains("must not start with `-`"),
6725 "reason must surface the leading-`-` arm, got {reason:?}"
6726 );
6727 }
6728
6729 #[test]
6730 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6731 // The canonical paste-from-multiline-doc footgun — a `:repo`
6732 // string with an embedded `\n` silently breaks git's URL parser
6733 // and is a class of CRLF-injection at the subprocess-argument
6734 // boundary. Caught by the control-char arm (0x0A < 0x20).
6735 let d = dep_with_fonte(DepSource::Git {
6736 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6737 tag: Some("v0.1.0".into()),
6738 rev: None,
6739 branch: None,
6740 });
6741 let err = d.validate().unwrap_err();
6742 let DepError::FonteRepoShape { reason, .. } = err else {
6743 panic!("expected FonteRepoShape, got other variant");
6744 };
6745 assert!(
6746 reason.contains("control character"),
6747 "reason must surface the control-char arm, got {reason:?}"
6748 );
6749 }
6750
6751 #[test]
6752 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6753 // Tab is the sibling whitespace footgun (the canonical
6754 // copy-from-aligned-table paste); pinned separately from the
6755 // space arm so a future relaxation that only catches one
6756 // surfaces here.
6757 let d = dep_with_fonte(DepSource::Git {
6758 repo: "github:pleme-io/caixa-teia\t".into(),
6759 tag: Some("v0.1.0".into()),
6760 rev: None,
6761 branch: None,
6762 });
6763 let err = d.validate().unwrap_err();
6764 assert!(
6765 matches!(
6766 err,
6767 DepError::FonteRepoShape { ref reason, .. }
6768 if reason.contains("whitespace")
6769 ),
6770 "got {err:?}"
6771 );
6772 }
6773
6774 #[test]
6775 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6776 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6777 // non-ASCII silently breaks at git's URL parser and round-trips
6778 // inconsistently across NFC/NFD normalization on APFS /
6779 // case-folding filesystems. Same intersection-floor
6780 // [`is_git_ref_name`] enforces on the refname axes.
6781 let d = dep_with_fonte(DepSource::Git {
6782 repo: "https://github.com/pleme-io/café".into(),
6783 tag: Some("v0.1.0".into()),
6784 rev: None,
6785 branch: None,
6786 });
6787 let err = d.validate().unwrap_err();
6788 assert!(
6789 matches!(
6790 err,
6791 DepError::FonteRepoShape { ref reason, .. }
6792 if reason.contains("non-ASCII")
6793 ),
6794 "got {err:?}"
6795 );
6796 }
6797
6798 #[test]
6799 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6800 // The fail-before-pass-after pin for the canonical paste-from-
6801 // browser-address-bar footgun on `:repo`: an author copies a
6802 // GitHub permalink to a README anchor / line-permalink and
6803 // forgets to trim the `#fragment` tail. Until this arm landed
6804 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6805 // silently passed every prior arm (no whitespace, no control
6806 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6807 // or `:`), libcurl's URL parser stripped the `#readme` tail
6808 // before opening the HTTPS transport, and the lacre embedded
6809 // the value verbatim in its per-dep BLAKE3 closure — two
6810 // authors whose values differ only in their fragment anchor
6811 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6812 // `git clone` but lock to two distinct lacres, defeating the
6813 // THEORY.md §V.2 render-determinism contract. Same value-shape
6814 // axis-floor every peer typed surface enforces; peer `:fonte
6815 // :tag` / `:fonte :branch` already reject the byte-class through
6816 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6817 // URL grammar admitted) and `:entrada :paths` rejects `#` as
6818 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6819 let d = dep_with_fonte(DepSource::Git {
6820 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6821 tag: Some("v0.1.0".into()),
6822 rev: None,
6823 branch: None,
6824 });
6825 let err = d.validate().unwrap_err();
6826 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6827 panic!("expected FonteRepoShape, got other variant");
6828 };
6829 assert_eq!(nome, "caixa-teia");
6830 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6831 assert!(
6832 reason.contains("must not contain `#`"),
6833 "reason must surface the fragment-`#` arm, got {reason:?}"
6834 );
6835 assert!(
6836 reason.contains("fragment"),
6837 "reason must name the URL fragment grammar, got {reason:?}"
6838 );
6839 }
6840
6841 #[test]
6842 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6843 // The symmetric paste-from-Nix-flake-ref footgun — an author
6844 // confuses the Nix flake-reference idiom (`github:foo/
6845 // bar#packageName`, where `#packageName` selects a flake
6846 // output) with the bare git `:repo` shape. The pleme-io
6847 // substrate authors compose flakes downstream of caixa
6848 // (caixa-flake renders a flake.nix), so the cross-idiom leak
6849 // is the canonical near-miss: the author writes the
6850 // flake-ref shape into a git `:repo` slot. Pinned separately
6851 // from the HTTPS-anchor arm so a future relaxation that
6852 // narrows to one URL scheme surfaces here.
6853 let d = dep_with_fonte(DepSource::Git {
6854 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6855 tag: Some("v0.1.0".into()),
6856 rev: None,
6857 branch: None,
6858 });
6859 let err = d.validate().unwrap_err();
6860 let DepError::FonteRepoShape { reason, .. } = err else {
6861 panic!("expected FonteRepoShape, got other variant");
6862 };
6863 assert!(
6864 reason.contains("must not contain `#`"),
6865 "reason must surface the fragment-`#` arm, got {reason:?}"
6866 );
6867 assert!(
6868 reason.contains("Nix flake"),
6869 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6870 );
6871 }
6872
6873 #[test]
6874 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6875 // The fail-before-pass-after pin for the canonical paste-from-
6876 // browser-address-bar footgun on `:repo` (peer with the
6877 // a68f818 fragment-`#` arm on the same axis). An author
6878 // copies a GitHub tab deep-link out of the address bar and
6879 // forgets to trim the `?tab=…` query tail. Until this arm
6880 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6881 // silently passed every prior arm (no whitespace, no control
6882 // chars, no non-ASCII, no `#` fragment, contains a `:`,
6883 // doesn't start with `-` or `:`); GitHub silently ignored
6884 // the `?query` tail and served the same repo regardless;
6885 // the lacre embedded the value verbatim in its per-dep
6886 // BLAKE3 closure — two authors whose values differ only in
6887 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6888 // `?utm_source=twitter`) resolve to the byte-identical
6889 // upstream `git clone` but lock to two distinct lacres,
6890 // defeating the THEORY.md §V.2 render-determinism contract
6891 // on the same axis the `#` fragment arm closes. Same value-
6892 // shape axis-floor every peer typed surface enforces; peer
6893 // `:fonte :tag` / `:fonte :branch` already reject the byte-
6894 // class through `is_git_ref_name`'s alphabet (refspec glob
6895 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6896 // :paths` rejects `?` as the query separator in
6897 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6898 let d = dep_with_fonte(DepSource::Git {
6899 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6900 tag: Some("v0.1.0".into()),
6901 rev: None,
6902 branch: None,
6903 });
6904 let err = d.validate().unwrap_err();
6905 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6906 panic!("expected FonteRepoShape, got other variant");
6907 };
6908 assert_eq!(nome, "caixa-teia");
6909 assert_eq!(
6910 repo,
6911 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6912 );
6913 assert!(
6914 reason.contains("must not contain `?`"),
6915 "reason must surface the query-`?` arm, got {reason:?}"
6916 );
6917 assert!(
6918 reason.contains("query"),
6919 "reason must name the URL query grammar, got {reason:?}"
6920 );
6921 }
6922
6923 #[test]
6924 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6925 // The symmetric paste-from-social-share footgun — an author
6926 // copies a repo URL out of a Slack unfurl / Twitter share /
6927 // newsletter link / Discord embed and forgets to trim the
6928 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6929 // campaign-tracker tail. Every major social-share / unfurl /
6930 // newsletter platform appends these UTM parameters; the
6931 // canonical near-miss on the `:repo` axis. Pinned separately
6932 // from the GitHub-tab-deep-link arm so a future relaxation
6933 // that narrows to one query-parameter class surfaces here.
6934 let d = dep_with_fonte(DepSource::Git {
6935 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6936 .into(),
6937 tag: Some("v0.1.0".into()),
6938 rev: None,
6939 branch: None,
6940 });
6941 let err = d.validate().unwrap_err();
6942 let DepError::FonteRepoShape { reason, .. } = err else {
6943 panic!("expected FonteRepoShape, got other variant");
6944 };
6945 assert!(
6946 reason.contains("must not contain `?`"),
6947 "reason must surface the query-`?` arm, got {reason:?}"
6948 );
6949 assert!(
6950 reason.contains("campaign-tracker"),
6951 "reason must name the campaign-tracker paste footgun, got {reason:?}"
6952 );
6953 }
6954
6955 #[test]
6956 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6957 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6958 // both per-byte arms inside the same `for &b in s.as_bytes()`
6959 // loop, so the byte that appears first in the value's byte
6960 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6961 // (fragment before query — unusual URL-grammar but value-
6962 // disjoint at byte level) carries both `#` and `?`; the `#`
6963 // byte appears first, so the fragment-`#` arm fires, surfacing
6964 // the more self-locating diagnostic on the byte the author
6965 // pasted earliest in the URL. Mirrors the peer cascade
6966 // discipline `fonte_repo_control_char_fires_before_fragment`
6967 // pins on the prior `:repo` byte-class arm.
6968 let d = dep_with_fonte(DepSource::Git {
6969 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6970 tag: Some("v0.1.0".into()),
6971 rev: None,
6972 branch: None,
6973 });
6974 let err = d.validate().unwrap_err();
6975 let DepError::FonteRepoShape { reason, .. } = err else {
6976 panic!("expected FonteRepoShape, got other variant");
6977 };
6978 assert!(
6979 reason.contains("must not contain `#`"),
6980 "reason must surface the fragment-`#` arm (fires before query-`?` when \
6981 `#` byte appears first in value), got {reason:?}"
6982 );
6983 }
6984
6985 #[test]
6986 fn fonte_repo_control_char_fires_before_fragment() {
6987 // Cascade pin: the control-char arm structurally precedes the
6988 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6989 // positive on both arms (contains LF and `#`), but the narrower
6990 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6991 // (`control character`) wins so the author sees the more
6992 // self-locating arm first. Mirrors the peer cascade discipline
6993 // every prior `:repo` byte-class arm establishes.
6994 let d = dep_with_fonte(DepSource::Git {
6995 repo: "github:pleme-io/caixa-teia\n#readme".into(),
6996 tag: Some("v0.1.0".into()),
6997 rev: None,
6998 branch: None,
6999 });
7000 let err = d.validate().unwrap_err();
7001 let DepError::FonteRepoShape { reason, .. } = err else {
7002 panic!("expected FonteRepoShape, got other variant");
7003 };
7004 assert!(
7005 reason.contains("control character"),
7006 "reason must surface the control-char arm, got {reason:?}"
7007 );
7008 }
7009
7010 #[test]
7011 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7012 // The fail-before-pass-after pin for the canonical Windows-
7013 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7014 // backslash arm on the sibling `:caminho` path-fonte axis).
7015 // An author pastes a Windows Explorer address-bar / PowerShell
7016 // `Get-Location` output into a `file://` URL slot, producing
7017 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7018 // value silently passed every prior arm (no whitespace, no
7019 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7020 // with `-` or `:`); libcurl's URL parser silently translates
7021 // `\` → `/` on some platforms and refuses it on others, so
7022 // the byte rides verbatim into the lacre's per-dep content-
7023 // address but is silently rewritten / rejected at the wire —
7024 // two authors whose `:repo` values differ only in backslash-
7025 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7026 // resolve to the byte-identical local clone but lock to two
7027 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7028 // render-determinism contract on the same axis the `#`
7029 // fragment and `?` query arms close. Same value-shape axis-
7030 // floor every peer typed surface enforces; the `:caminho`
7031 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7032 let d = dep_with_fonte(DepSource::Git {
7033 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7034 tag: Some("v0.1.0".into()),
7035 rev: None,
7036 branch: None,
7037 });
7038 let err = d.validate().unwrap_err();
7039 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7040 panic!("expected FonteRepoShape, got other variant");
7041 };
7042 assert_eq!(nome, "caixa-teia");
7043 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7044 assert!(
7045 reason.contains("must not contain `\\`"),
7046 "reason must surface the backslash-`\\` arm, got {reason:?}"
7047 );
7048 assert!(
7049 reason.contains("Windows"),
7050 "reason must name the Windows-path-confusion footgun, got {reason:?}"
7051 );
7052 }
7053
7054 #[test]
7055 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7056 // The symmetric Win32-shell-mangled-slashes footgun — an author
7057 // copies `https://github.com/foo/bar` into a Win32 shell that
7058 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7059 // separator-coercion bug), pastes the result into a `:repo`
7060 // slot, and produces `https:\\github.com\foo\bar`. Pinned
7061 // separately from the `file://` Explorer-paste arm so a future
7062 // relaxation that narrows to one URL scheme surfaces here.
7063 let d = dep_with_fonte(DepSource::Git {
7064 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7065 tag: Some("v0.1.0".into()),
7066 rev: None,
7067 branch: None,
7068 });
7069 let err = d.validate().unwrap_err();
7070 let DepError::FonteRepoShape { reason, .. } = err else {
7071 panic!("expected FonteRepoShape, got other variant");
7072 };
7073 assert!(
7074 reason.contains("must not contain `\\`"),
7075 "reason must surface the backslash-`\\` arm, got {reason:?}"
7076 );
7077 assert!(
7078 reason.contains("path separator") || reason.contains("path-segment separator"),
7079 "reason must name the URL path-segment separator grammar, got {reason:?}"
7080 );
7081 }
7082
7083 #[test]
7084 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7085 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7086 // are both per-byte arms inside the same `for &b in s.as_bytes()`
7087 // loop, so the byte that appears first in the value's byte order
7088 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7089 // both `#` and `\`; the `#` byte appears first, so the fragment-
7090 // `#` arm fires, surfacing the more self-locating diagnostic on
7091 // the byte the author pasted earliest in the URL. Mirrors the
7092 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7093 // pins on the prior `:repo` byte-class arm.
7094 let d = dep_with_fonte(DepSource::Git {
7095 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7096 tag: Some("v0.1.0".into()),
7097 rev: None,
7098 branch: None,
7099 });
7100 let err = d.validate().unwrap_err();
7101 let DepError::FonteRepoShape { reason, .. } = err else {
7102 panic!("expected FonteRepoShape, got other variant");
7103 };
7104 assert!(
7105 reason.contains("must not contain `#`"),
7106 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7107 `#` byte appears first in value), got {reason:?}"
7108 );
7109 }
7110
7111 #[test]
7112 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7113 // The fail-before-pass-after pin for the canonical URI Template
7114 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7115 // README quick-start snippet / OpenAPI `servers:` URL / Helm
7116 // chart `home:` template that carries unresolved
7117 // `{org}` / `{repo}` placeholders and pastes the raw template
7118 // into the `:repo` slot, expecting the substrate to resolve the
7119 // placeholder downstream. Until this arm landed the value
7120 // silently passed every prior arm (no whitespace, no control
7121 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7122 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7123 // / `%7D` on the wire, so the byte rides verbatim into the
7124 // lacre's per-dep content-address but round-trips inconsistently
7125 // between the lacre's per-dep content-address and the
7126 // resolver's `git clone <repo>` invocation, defeating the
7127 // THEORY.md §V.2 render-determinism contract on the same axis
7128 // the `#` fragment, `?` query, and `\` backslash arms close;
7129 // every git porcelain entry-point additionally fetches a
7130 // nonexistent literal-`{placeholder}`-named path far from the
7131 // source caixa.lisp.
7132 let d = dep_with_fonte(DepSource::Git {
7133 repo: "https://github.com/{org}/caixa-teia".into(),
7134 tag: Some("v0.1.0".into()),
7135 rev: None,
7136 branch: None,
7137 });
7138 let err = d.validate().unwrap_err();
7139 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7140 panic!("expected FonteRepoShape, got other variant");
7141 };
7142 assert_eq!(nome, "caixa-teia");
7143 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7144 assert!(
7145 reason.contains("must not contain `{`"),
7146 "reason must surface the open-brace `{{` arm, got {reason:?}"
7147 );
7148 assert!(
7149 reason.contains("URI Template") || reason.contains("RFC 6570"),
7150 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7151 );
7152 }
7153
7154 #[test]
7155 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7156 // The symmetric Mustache / Handlebars doubled-brace
7157 // substitution-form footgun every CI / IaC templating engine
7158 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7159 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7160 // chart README quick-start snippet emits. Pinned separately
7161 // from the single-`{` `{org}` arm so a future relaxation that
7162 // narrows to one substitution-form surfaces here.
7163 let d = dep_with_fonte(DepSource::Git {
7164 repo: "https://github.com/{{org}}/caixa-teia".into(),
7165 tag: Some("v0.1.0".into()),
7166 rev: None,
7167 branch: None,
7168 });
7169 let err = d.validate().unwrap_err();
7170 let DepError::FonteRepoShape { reason, .. } = err else {
7171 panic!("expected FonteRepoShape, got other variant");
7172 };
7173 assert!(
7174 reason.contains("must not contain `{`"),
7175 "reason must surface the open-brace `{{` arm, got {reason:?}"
7176 );
7177 }
7178
7179 #[test]
7180 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7181 // Asymmetric `}`-only shape — covers the closing-brace-by-
7182 // itself footgun (an author truncated `{org}/{repo}` mid-edit
7183 // and left a trailing `}` from the prior template fragment,
7184 // or pasted a value that included a closing brace from a
7185 // surrounding shell context). Pinned to ensure the predicate
7186 // refuses each brace independently rather than only when both
7187 // appear — a future regression that ANDs the two byte tests
7188 // surfaces here.
7189 let d = dep_with_fonte(DepSource::Git {
7190 repo: "https://github.com/pleme-io/caixa-teia}".into(),
7191 tag: Some("v0.1.0".into()),
7192 rev: None,
7193 branch: None,
7194 });
7195 let err = d.validate().unwrap_err();
7196 let DepError::FonteRepoShape { reason, .. } = err else {
7197 panic!("expected FonteRepoShape, got other variant");
7198 };
7199 assert!(
7200 reason.contains("must not contain `}`"),
7201 "reason must surface the close-brace `}}` arm, got {reason:?}"
7202 );
7203 }
7204
7205 #[test]
7206 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7207 // Cascade pin: the fragment-`#` arm and the template-`{` /
7208 // `}` arm are both per-byte arms inside the same
7209 // `for &b in s.as_bytes()` loop, so the byte that appears
7210 // first in the value's byte order wins. A `:repo
7211 // "https://github.com/p/x#readme{org}"` carries both `#` and
7212 // `{`; the `#` byte appears first, so the fragment-`#` arm
7213 // fires, surfacing the more self-locating diagnostic on the
7214 // byte the author pasted earliest in the URL. Mirrors the
7215 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7216 // pins on the prior `:repo` byte-class arm.
7217 let d = dep_with_fonte(DepSource::Git {
7218 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7219 tag: Some("v0.1.0".into()),
7220 rev: None,
7221 branch: None,
7222 });
7223 let err = d.validate().unwrap_err();
7224 let DepError::FonteRepoShape { reason, .. } = err else {
7225 panic!("expected FonteRepoShape, got other variant");
7226 };
7227 assert!(
7228 reason.contains("must not contain `#`"),
7229 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7230 `#` byte appears first in value), got {reason:?}"
7231 );
7232 }
7233
7234 #[test]
7235 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7236 // The fail-before-pass-after pin for the canonical
7237 // shell-output-redirection footgun on `:repo`: an author
7238 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7239 // / `… >output.txt`) into the `:repo` slot without trimming
7240 // the redirect. Until this arm landed the value silently
7241 // passed every prior arm (no whitespace, no control chars,
7242 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7243 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7244 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7245 // percent-encode set maps `>` → `%3E` on the wire, so the
7246 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7247 // but is silently rewritten or rejected at libcurl's URL-
7248 // parser layer — two authors whose values differ only in
7249 // their redirect tail (`>build.log` vs nothing) resolve to
7250 // the byte-identical upstream `git clone` but lock to two
7251 // distinct lacres, defeating the THEORY.md §V.2 render-
7252 // determinism contract. Peer with the `:caminho` axis's
7253 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7254 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7255 // byte RFC-3986-reserved set on `:entrada :paths`.
7256 let d = dep_with_fonte(DepSource::Git {
7257 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7258 tag: Some("v0.1.0".into()),
7259 rev: None,
7260 branch: None,
7261 });
7262 let err = d.validate().unwrap_err();
7263 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7264 panic!("expected FonteRepoShape, got other variant");
7265 };
7266 assert_eq!(nome, "caixa-teia");
7267 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7268 assert!(
7269 reason.contains("must not contain `>`"),
7270 "reason must surface the output-redirection `>` arm, got {reason:?}"
7271 );
7272 assert!(
7273 reason.contains("redirection") || reason.contains("'delims'"),
7274 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7275 );
7276 }
7277
7278 #[test]
7279 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7280 // The symmetric shell-input-redirection footgun — an author
7281 // pastes a shell-pipeline head (`git clone <input.url` /
7282 // `cat <README.md`) into the `:repo` slot. Pinned separately
7283 // from the `>`-output arm so a future relaxation that only
7284 // catches one of the two redirect bytes surfaces here. Peer
7285 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7286 // arm which closes both `<` and `>` under the same banner.
7287 let d = dep_with_fonte(DepSource::Git {
7288 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7289 tag: Some("v0.1.0".into()),
7290 rev: None,
7291 branch: None,
7292 });
7293 let err = d.validate().unwrap_err();
7294 let DepError::FonteRepoShape { reason, .. } = err else {
7295 panic!("expected FonteRepoShape, got other variant");
7296 };
7297 assert!(
7298 reason.contains("must not contain `<`"),
7299 "reason must surface the input-redirection `<` arm, got {reason:?}"
7300 );
7301 assert!(
7302 reason.contains("RFC 3986") || reason.contains("'unwise'"),
7303 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7304 );
7305 }
7306
7307 #[test]
7308 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7309 // The fail-before-pass-after pin for the canonical
7310 // paste-from-shell-prompt-with-backticked-substitution footgun
7311 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7312 // `:caminho` path-fonte axis). An author pastes a URL whose
7313 // segment carries a backticked command-substitution wrapper
7314 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7315 // from a doc / README quick-start snippet that expected the
7316 // substrate to substitute the value downstream. Until this arm
7317 // landed the value silently passed every prior arm (no
7318 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7319 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7320 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7321 // 'unwise' set and the WHATWG URL spec's fragment percent-
7322 // encode set maps `` ` `` → `%60` on the wire, so the byte
7323 // rides verbatim into the lacre's per-dep BLAKE3 closure but
7324 // is silently rewritten or rejected at libcurl's URL-parser
7325 // layer — two authors whose values differ only in their
7326 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7327 // byte-identical upstream `git clone` but lock to two distinct
7328 // lacres, defeating the THEORY.md §V.2 render-determinism
7329 // contract. Peer with the `:caminho` axis's
7330 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7331 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7332 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7333 let d = dep_with_fonte(DepSource::Git {
7334 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7335 tag: Some("v0.1.0".into()),
7336 rev: None,
7337 branch: None,
7338 });
7339 let err = d.validate().unwrap_err();
7340 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7341 panic!("expected FonteRepoShape, got other variant");
7342 };
7343 assert_eq!(nome, "caixa-teia");
7344 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7345 assert!(
7346 reason.contains("must not contain `` ` ``"),
7347 "reason must surface the backtick command-substitution arm, got {reason:?}"
7348 );
7349 assert!(
7350 reason.contains("command-substitution") || reason.contains("'unwise'"),
7351 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7352 got {reason:?}"
7353 );
7354 }
7355
7356 #[test]
7357 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7358 // Cascade pin: the fragment-`#` arm and the backtick command-
7359 // substitution arm are both per-byte arms inside the same
7360 // `for &b in s.as_bytes()` loop, so the byte that appears first
7361 // in the value's byte order wins. A `:repo
7362 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7363 // and backtick; the `#` byte appears first, so the fragment-
7364 // `#` arm fires, surfacing the more self-locating diagnostic
7365 // on the byte the author pasted earliest in the URL. Mirrors
7366 // the peer cascade discipline
7367 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7368 // pins on the prior `:repo` byte-class arm.
7369 let d = dep_with_fonte(DepSource::Git {
7370 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
7371 tag: Some("v0.1.0".into()),
7372 rev: None,
7373 branch: None,
7374 });
7375 let err = d.validate().unwrap_err();
7376 let DepError::FonteRepoShape { reason, .. } = err else {
7377 panic!("expected FonteRepoShape, got other variant");
7378 };
7379 assert!(
7380 reason.contains("must not contain `#`"),
7381 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7382 appears first in value), got {reason:?}"
7383 );
7384 }
7385
7386 #[test]
7387 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7388 // Cascade pin: the shell-redirection `<` / `>` arm and the
7389 // backtick command-substitution arm are both per-byte arms
7390 // inside the same `for &b in s.as_bytes()` loop, so the byte
7391 // that appears first in the value's byte order wins. A `:repo
7392 // "https://github.com/p/x>build.log/`whoami`"` carries both
7393 // `>` and backtick; the `>` byte appears first, so the
7394 // shell-redirection arm fires, surfacing the more self-
7395 // locating diagnostic on the byte the author pasted earliest
7396 // in the URL. Pins the natural-order cascade so a future
7397 // reorder of the per-byte arms surfaces here.
7398 let d = dep_with_fonte(DepSource::Git {
7399 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7400 tag: Some("v0.1.0".into()),
7401 rev: None,
7402 branch: None,
7403 });
7404 let err = d.validate().unwrap_err();
7405 let DepError::FonteRepoShape { reason, .. } = err else {
7406 panic!("expected FonteRepoShape, got other variant");
7407 };
7408 assert!(
7409 reason.contains("must not contain `>`"),
7410 "reason must surface the shell-redirection `>` arm (fires before backtick when \
7411 `>` byte appears first in value), got {reason:?}"
7412 );
7413 }
7414
7415 #[test]
7416 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7417 // Cascade pin: the fragment-`#` arm and the shell-redirection
7418 // `<` / `>` arm are both per-byte arms inside the same
7419 // `for &b in s.as_bytes()` loop, so the byte that appears
7420 // first in the value's byte order wins. A `:repo
7421 // "https://github.com/p/x#readme>build.log"` carries both
7422 // `#` and `>`; the `#` byte appears first, so the fragment-
7423 // `#` arm fires, surfacing the more self-locating diagnostic
7424 // on the byte the author pasted earliest in the URL. Mirrors
7425 // the peer cascade discipline
7426 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7427 // pins on the prior `:repo` byte-class arm.
7428 let d = dep_with_fonte(DepSource::Git {
7429 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7430 tag: Some("v0.1.0".into()),
7431 rev: None,
7432 branch: None,
7433 });
7434 let err = d.validate().unwrap_err();
7435 let DepError::FonteRepoShape { reason, .. } = err else {
7436 panic!("expected FonteRepoShape, got other variant");
7437 };
7438 assert!(
7439 reason.contains("must not contain `#`"),
7440 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7441 `#` byte appears first in value), got {reason:?}"
7442 );
7443 }
7444
7445 #[test]
7446 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7447 // The fail-before-pass-after pin for the canonical
7448 // paste-from-shell-prompt-with-piped-pipeline footgun on
7449 // `:repo` (peer with the 124106f pipe arm on the sibling
7450 // `:caminho` path-fonte axis). An author pastes a shell
7451 // pipeline (`git clone <url> | tee build.log`,
7452 // `git ls-remote <url> | head`) into the `:repo` slot,
7453 // forgetting to trim the `| <consumer>` tail. Until this arm
7454 // landed the value silently passed every prior arm (no
7455 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7456 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7457 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7458 // 'unwise' set and the WHATWG URL spec's fragment percent-
7459 // encode set maps `|` → `%7C` on the wire, so the byte rides
7460 // verbatim into the lacre's per-dep BLAKE3 closure but is
7461 // silently rewritten or rejected at libcurl's URL-parser
7462 // layer — two authors whose values differ only in their pipe
7463 // tail (`|tee build.log` vs nothing) resolve to the byte-
7464 // identical upstream `git clone` but lock to two distinct
7465 // lacres, defeating the THEORY.md §V.2 render-determinism
7466 // contract. Peer with the `:caminho` axis's
7467 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7468 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7469 // RFC-3986-reserved set on `:entrada :paths`.
7470 let d = dep_with_fonte(DepSource::Git {
7471 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7472 tag: Some("v0.1.0".into()),
7473 rev: None,
7474 branch: None,
7475 });
7476 let err = d.validate().unwrap_err();
7477 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7478 panic!("expected FonteRepoShape, got other variant");
7479 };
7480 assert_eq!(nome, "caixa-teia");
7481 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7482 assert!(
7483 reason.contains("must not contain `|`"),
7484 "reason must surface the shell-pipe arm, got {reason:?}"
7485 );
7486 assert!(
7487 reason.contains("pipe") || reason.contains("'unwise'"),
7488 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7489 );
7490 }
7491
7492 #[test]
7493 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7494 // Cascade pin: the fragment-`#` arm and the pipe arm are both
7495 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7496 // so the byte that appears first in the value's byte order
7497 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7498 // both `#` and `|`; the `#` byte appears first, so the
7499 // fragment-`#` arm fires, surfacing the more self-locating
7500 // diagnostic on the byte the author pasted earliest in the
7501 // URL. Mirrors the peer cascade discipline
7502 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7503 // pins on the prior `:repo` byte-class arm.
7504 let d = dep_with_fonte(DepSource::Git {
7505 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7506 tag: Some("v0.1.0".into()),
7507 rev: None,
7508 branch: None,
7509 });
7510 let err = d.validate().unwrap_err();
7511 let DepError::FonteRepoShape { reason, .. } = err else {
7512 panic!("expected FonteRepoShape, got other variant");
7513 };
7514 assert!(
7515 reason.contains("must not contain `#`"),
7516 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7517 appears first in value), got {reason:?}"
7518 );
7519 }
7520
7521 #[test]
7522 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7523 // Cascade pin: the backtick arm and the pipe arm are both per-
7524 // byte arms inside the same `for &b in s.as_bytes()` loop, so
7525 // the byte that appears first in the value's byte order wins.
7526 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7527 // `` ` `` and `|`; the backtick byte appears first, so the
7528 // backtick arm fires, surfacing the more self-locating
7529 // diagnostic on the byte the author pasted earliest in the
7530 // URL. Pins the natural-order cascade so a future reorder of
7531 // the per-byte arms surfaces here.
7532 let d = dep_with_fonte(DepSource::Git {
7533 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7534 tag: Some("v0.1.0".into()),
7535 rev: None,
7536 branch: None,
7537 });
7538 let err = d.validate().unwrap_err();
7539 let DepError::FonteRepoShape { reason, .. } = err else {
7540 panic!("expected FonteRepoShape, got other variant");
7541 };
7542 assert!(
7543 reason.contains("must not contain `` ` ``"),
7544 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7545 appears first in value), got {reason:?}"
7546 );
7547 }
7548
7549 #[test]
7550 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7551 // The fail-before-pass-after pin for the canonical
7552 // paste-from-shell-prompt-with-sequential-command-tail footgun
7553 // on `:repo` (peer with the 05c358e `;` arm on the sibling
7554 // `:caminho` path-fonte axis). An author pastes a shell
7555 // one-liner that chained a cleanup tail after the URL
7556 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7557 // echo done`) into the `:repo` slot, forgetting to trim the
7558 // `; <cmd>` tail. Until this arm landed the value silently
7559 // passed every prior `is_git_repo_url` arm (no whitespace, no
7560 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7561 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7562 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7563 // reserved set and the WHATWG URL spec's fragment percent-
7564 // encode set maps `;` → `%3B` on the wire, so the byte rides
7565 // verbatim into the lacre's per-dep BLAKE3 closure but is
7566 // silently rewritten at libcurl's URL-parser layer — two
7567 // authors whose values differ only in their sequential-command
7568 // tail (`; rm -rf build` vs nothing) resolve to the byte-
7569 // identical upstream `git clone` but lock to two distinct
7570 // lacres, defeating the THEORY.md §V.2 render-determinism
7571 // contract. Peer with the `:caminho` axis's
7572 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7573 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7574 // byte RFC-3986-reserved set on `:entrada :paths`.
7575 let d = dep_with_fonte(DepSource::Git {
7576 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7577 tag: Some("v0.1.0".into()),
7578 rev: None,
7579 branch: None,
7580 });
7581 let err = d.validate().unwrap_err();
7582 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7583 panic!("expected FonteRepoShape, got other variant");
7584 };
7585 assert_eq!(nome, "caixa-teia");
7586 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7587 assert!(
7588 reason.contains("must not contain `;`"),
7589 "reason must surface the shell-command-separator arm, got {reason:?}"
7590 );
7591 assert!(
7592 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7593 "reason must name the shell-command-separator / RFC-3986-sub-delims \
7594 rationale, got {reason:?}"
7595 );
7596 }
7597
7598 #[test]
7599 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7600 // Cascade pin: the fragment-`#` arm and the semicolon arm are
7601 // both per-byte arms inside the same `for &b in s.as_bytes()`
7602 // loop, so the byte that appears first in the value's byte
7603 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7604 // carries both `#` and `;`; the `#` byte appears first, so the
7605 // fragment-`#` arm fires, surfacing the more self-locating
7606 // diagnostic on the byte the author pasted earliest in the URL.
7607 // Mirrors the peer cascade discipline
7608 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7609 // pins on the prior `:repo` byte-class arm.
7610 let d = dep_with_fonte(DepSource::Git {
7611 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7612 tag: Some("v0.1.0".into()),
7613 rev: None,
7614 branch: None,
7615 });
7616 let err = d.validate().unwrap_err();
7617 let DepError::FonteRepoShape { reason, .. } = err else {
7618 panic!("expected FonteRepoShape, got other variant");
7619 };
7620 assert!(
7621 reason.contains("must not contain `#`"),
7622 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7623 byte appears first in value), got {reason:?}"
7624 );
7625 }
7626
7627 #[test]
7628 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7629 // Cascade pin: the pipe arm and the semicolon arm are both
7630 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7631 // so the byte that appears first in the value's byte order
7632 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7633 // both `|` and `;`; the `|` byte appears first, so the
7634 // pipe arm fires, surfacing the more self-locating diagnostic
7635 // on the byte the author pasted earliest in the URL. Pins the
7636 // natural-order cascade so a future reorder of the per-byte
7637 // arms surfaces here.
7638 let d = dep_with_fonte(DepSource::Git {
7639 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7640 tag: Some("v0.1.0".into()),
7641 rev: None,
7642 branch: None,
7643 });
7644 let err = d.validate().unwrap_err();
7645 let DepError::FonteRepoShape { reason, .. } = err else {
7646 panic!("expected FonteRepoShape, got other variant");
7647 };
7648 assert!(
7649 reason.contains("must not contain `|`"),
7650 "reason must surface the pipe arm (fires before semicolon when `|` byte \
7651 appears first in value), got {reason:?}"
7652 );
7653 }
7654
7655 #[test]
7656 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7657 // The fail-before-pass-after pin for the canonical
7658 // paste-from-shell-prompt-with-background-launch-tail footgun
7659 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7660 // `:caminho` path-fonte axis). An author pastes a shell one-
7661 // liner that detached the clone into the background
7662 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7663 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7664 // `&& <cmd>` tail. Until this arm landed the value silently
7665 // passed every prior `is_git_repo_url` arm (no whitespace,
7666 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7667 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7668 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7669 // the 'sub-delims' / reserved set and the WHATWG URL spec's
7670 // fragment percent-encode set maps `&` → `%26` on the wire,
7671 // so the byte rides verbatim into the lacre's per-dep
7672 // BLAKE3 closure but is silently rewritten at libcurl's
7673 // URL-parser layer — two authors whose values differ only
7674 // in their background-launch tail (`& sleep 1` vs nothing)
7675 // resolve to the byte-identical upstream `git clone` but
7676 // lock to two distinct lacres, defeating the THEORY.md
7677 // §V.2 render-determinism contract. Peer with the
7678 // `:caminho` axis's `FonteCaminhoShellBackground` arm
7679 // (e12e4f3) on the sibling path-fonte axis, and
7680 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7681 // reserved set on `:entrada :paths`.
7682 let d = dep_with_fonte(DepSource::Git {
7683 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7684 tag: Some("v0.1.0".into()),
7685 rev: None,
7686 branch: None,
7687 });
7688 let err = d.validate().unwrap_err();
7689 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7690 panic!("expected FonteRepoShape, got other variant");
7691 };
7692 assert_eq!(nome, "caixa-teia");
7693 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7694 assert!(
7695 reason.contains("must not contain `&`"),
7696 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7697 );
7698 assert!(
7699 reason.contains("background-task") || reason.contains("'sub-delims'"),
7700 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7701 got {reason:?}"
7702 );
7703 }
7704
7705 #[test]
7706 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7707 // The fail-before-pass-after pin for the symmetric `&&`
7708 // logical-AND build-chain paste footgun: an author pastes
7709 // a `git clone <url> && cd <repo>` build-chain one-liner
7710 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7711 // is the same `&` byte twice in a row; the per-byte arm
7712 // fires on the first `&` it sees. Pinned separately from
7713 // the single-`&` background-launch shape so a future
7714 // diagnostic-surface change that special-cased the
7715 // doubled-byte form surfaces here.
7716 let d = dep_with_fonte(DepSource::Git {
7717 repo: "github:pleme-io/caixa-teia&&echo".into(),
7718 tag: Some("v0.1.0".into()),
7719 rev: None,
7720 branch: None,
7721 });
7722 let err = d.validate().unwrap_err();
7723 let DepError::FonteRepoShape { reason, .. } = err else {
7724 panic!("expected FonteRepoShape, got other variant");
7725 };
7726 assert!(
7727 reason.contains("must not contain `&`"),
7728 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7729 shape too, got {reason:?}"
7730 );
7731 }
7732
7733 #[test]
7734 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7735 // Cascade pin: the fragment-`#` arm and the background-`&`
7736 // arm are both per-byte arms inside the same `for &b in
7737 // s.as_bytes()` loop, so the byte that appears first in the
7738 // value's byte order wins. A `:repo
7739 // "https://github.com/p/x#readme & sleep"` carries both `#`
7740 // and `&`; the `#` byte appears first, so the fragment-`#`
7741 // arm fires, surfacing the more self-locating diagnostic on
7742 // the byte the author pasted earliest in the URL. Mirrors
7743 // the peer cascade discipline
7744 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7745 // on the prior `:repo` byte-class arm.
7746 let d = dep_with_fonte(DepSource::Git {
7747 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7748 tag: Some("v0.1.0".into()),
7749 rev: None,
7750 branch: None,
7751 });
7752 let err = d.validate().unwrap_err();
7753 let DepError::FonteRepoShape { reason, .. } = err else {
7754 panic!("expected FonteRepoShape, got other variant");
7755 };
7756 assert!(
7757 reason.contains("must not contain `#`"),
7758 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7759 byte appears first in value), got {reason:?}"
7760 );
7761 }
7762
7763 #[test]
7764 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7765 // Cascade pin: the semicolon arm and the background-`&` arm
7766 // are both per-byte arms inside the same `for &b in
7767 // s.as_bytes()` loop, so the byte that appears first in the
7768 // value's byte order wins. A `:repo
7769 // "https://github.com/p/x; rm & sleep"` carries both `;` and
7770 // `&`; the `;` byte appears first, so the semicolon arm
7771 // fires, surfacing the more self-locating diagnostic on the
7772 // byte the author pasted earliest in the URL. Pins the
7773 // natural-order cascade so a future reorder of the per-byte
7774 // arms surfaces here.
7775 let d = dep_with_fonte(DepSource::Git {
7776 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
7777 tag: Some("v0.1.0".into()),
7778 rev: None,
7779 branch: None,
7780 });
7781 let err = d.validate().unwrap_err();
7782 let DepError::FonteRepoShape { reason, .. } = err else {
7783 panic!("expected FonteRepoShape, got other variant");
7784 };
7785 assert!(
7786 reason.contains("must not contain `;`"),
7787 "reason must surface the semicolon arm (fires before background-`&` when `;` \
7788 byte appears first in value), got {reason:?}"
7789 );
7790 }
7791
7792 #[test]
7793 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7794 // The fail-before-pass-after pin for the canonical
7795 // paste-from-shell-prompt-with-unsubstituted-variable footgun
7796 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7797 // `:caminho` path-fonte axis). An author pastes a shell one-
7798 // liner that referenced an environment variable
7799 // (`git clone https://github.com/$ORG/x`, `git clone
7800 // github:$USER/repo`) into the `:repo` slot, forgetting to
7801 // substitute the literal value at author time. Until this arm
7802 // landed the value silently passed every prior
7803 // `is_git_repo_url` arm (no whitespace, no control chars, no
7804 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7805 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7806 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7807 // reserved set and the WHATWG URL spec's fragment percent-
7808 // encode set maps `$` → `%24` on the wire, so the byte rides
7809 // verbatim into the lacre's per-dep BLAKE3 closure but is
7810 // silently rewritten at libcurl's URL-parser layer — two
7811 // authors whose values differ only in their `$VAR` /
7812 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7813 // identical upstream `git clone` but lock to two distinct
7814 // lacres, defeating the THEORY.md §V.2 render-determinism
7815 // contract. Beyond determinism, the value is a structural
7816 // host-layout leak: two authors with the same `:repo` slot
7817 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7818 // different upstreams. Peer with the `:caminho` axis's
7819 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7820 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7821 // byte RFC-3986-reserved set on `:entrada :paths`.
7822 let d = dep_with_fonte(DepSource::Git {
7823 repo: "https://github.com/$ORG/caixa-teia".into(),
7824 tag: Some("v0.1.0".into()),
7825 rev: None,
7826 branch: None,
7827 });
7828 let err = d.validate().unwrap_err();
7829 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7830 panic!("expected FonteRepoShape, got other variant");
7831 };
7832 assert_eq!(nome, "caixa-teia");
7833 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7834 assert!(
7835 reason.contains("must not contain `$`"),
7836 "reason must surface the shell-variable-expansion arm, got {reason:?}"
7837 );
7838 assert!(
7839 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7840 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7841 rationale, got {reason:?}"
7842 );
7843 }
7844
7845 #[test]
7846 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7847 // The fail-before-pass-after pin for the symmetric POSIX-
7848 // shell braced `${VAR}` expansion paste footgun: an author
7849 // pastes a CI-manifest line `git clone
7850 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7851 // Actions / GitLab CI / Drone shape) and forgets to
7852 // substitute the literal value. The `${...}` shape is the
7853 // same `$` byte at the leading position of the expansion;
7854 // the per-byte arm fires on the `$`. Pinned separately from
7855 // the bare-`$VAR` shape so a future diagnostic-surface
7856 // change that special-cased the braced form surfaces here.
7857 let d = dep_with_fonte(DepSource::Git {
7858 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7859 tag: Some("v0.1.0".into()),
7860 rev: None,
7861 branch: None,
7862 });
7863 let err = d.validate().unwrap_err();
7864 let DepError::FonteRepoShape { reason, .. } = err else {
7865 panic!("expected FonteRepoShape, got other variant");
7866 };
7867 assert!(
7868 reason.contains("must not contain `$`"),
7869 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7870 shape too, got {reason:?}"
7871 );
7872 }
7873
7874 #[test]
7875 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7876 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7877 // arm are both per-byte arms inside the same `for &b in
7878 // s.as_bytes()` loop, so the byte that appears first in the
7879 // value's byte order wins. A `:repo
7880 // "https://github.com/p/x#readme$HOME"` carries both `#` and
7881 // `$`; the `#` byte appears first, so the fragment-`#` arm
7882 // fires, surfacing the more self-locating diagnostic on the
7883 // byte the author pasted earliest in the URL. Mirrors the
7884 // peer cascade discipline
7885 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7886 // on the prior `:repo` byte-class arm.
7887 let d = dep_with_fonte(DepSource::Git {
7888 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7889 tag: Some("v0.1.0".into()),
7890 rev: None,
7891 branch: None,
7892 });
7893 let err = d.validate().unwrap_err();
7894 let DepError::FonteRepoShape { reason, .. } = err else {
7895 panic!("expected FonteRepoShape, got other variant");
7896 };
7897 assert!(
7898 reason.contains("must not contain `#`"),
7899 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7900 `#` byte appears first in value), got {reason:?}"
7901 );
7902 }
7903
7904 #[test]
7905 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7906 // Cascade pin: the background-`&` arm and the
7907 // var-expansion-`$` arm are both per-byte arms inside the
7908 // same `for &b in s.as_bytes()` loop, so the byte that
7909 // appears first in the value's byte order wins. A `:repo
7910 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7911 // `$`; the `&` byte appears first, so the background arm
7912 // fires, surfacing the more self-locating diagnostic on the
7913 // byte the author pasted earliest in the URL. Pins the
7914 // natural-order cascade so a future reorder of the per-byte
7915 // arms surfaces here — `$` is the most recent byte-class arm,
7916 // so the cascade-pin sweep extends to cover every immediately
7917 // prior byte arm (`#`, `&`) firing first when ordered ahead
7918 // of `$` in the value.
7919 let d = dep_with_fonte(DepSource::Git {
7920 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7921 tag: Some("v0.1.0".into()),
7922 rev: None,
7923 branch: None,
7924 });
7925 let err = d.validate().unwrap_err();
7926 let DepError::FonteRepoShape { reason, .. } = err else {
7927 panic!("expected FonteRepoShape, got other variant");
7928 };
7929 assert!(
7930 reason.contains("must not contain `&`"),
7931 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7932 `&` byte appears first in value), got {reason:?}"
7933 );
7934 }
7935
7936 #[test]
7937 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7938 // The fail-before-pass-after pin for the canonical
7939 // paste-from-shell-prompt glob footgun on `:repo` (peer with
7940 // the cf9034b `*` / `?` arm on the sibling `:caminho`
7941 // path-fonte axis). An author pastes a shell one-liner that
7942 // referenced a glob expansion (`ls
7943 // github.com/pleme-io/caixa-*`, `git clone
7944 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7945 // to substitute the literal repo name. Until this arm landed
7946 // the `*` byte silently passed every prior `is_git_repo_url`
7947 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7948 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7949 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7950 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7951 // the WHATWG URL spec's special-query percent-encode set maps
7952 // `*` → `%2A` on the wire, so the byte rides verbatim into
7953 // the lacre's per-dep BLAKE3 closure but is silently
7954 // rewritten at libcurl's URL-parser layer — two authors
7955 // whose values differ only in their asterisk presence
7956 // resolve to the byte-identical upstream `git clone` but
7957 // lock to two distinct lacres, defeating the THEORY.md §V.2
7958 // render-determinism contract. Peer with the `:caminho`
7959 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7960 // sibling path-fonte axis, and the `is_git_ref_name`
7961 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7962 // axes.
7963 let d = dep_with_fonte(DepSource::Git {
7964 repo: "https://github.com/pleme-io/caixa-*".into(),
7965 tag: Some("v0.1.0".into()),
7966 rev: None,
7967 branch: None,
7968 });
7969 let err = d.validate().unwrap_err();
7970 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7971 panic!("expected FonteRepoShape, got other variant");
7972 };
7973 assert_eq!(nome, "caixa-teia");
7974 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7975 assert!(
7976 reason.contains("must not contain `*`"),
7977 "reason must surface the shell-glob arm, got {reason:?}"
7978 );
7979 assert!(
7980 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7981 "reason must name the shell-glob / pathname-expansion / \
7982 RFC-3986-sub-delims rationale, got {reason:?}"
7983 );
7984 }
7985
7986 #[test]
7987 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7988 // The fail-before-pass-after pin for the symmetric bash
7989 // `globstar` recursive-glob paste footgun: an author pastes
7990 // a `ls github.com/pleme-io/**/x` (the canonical
7991 // `globstar`-shopt-enabled recursive-listing tail) into the
7992 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7993 // the per-byte arm fires on the first `*`. Pinned
7994 // separately from the single-`*` shape so a future
7995 // diagnostic-surface change that special-cased the
7996 // double-`*` form surfaces here.
7997 let d = dep_with_fonte(DepSource::Git {
7998 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7999 tag: Some("v0.1.0".into()),
8000 rev: None,
8001 branch: None,
8002 });
8003 let err = d.validate().unwrap_err();
8004 let DepError::FonteRepoShape { reason, .. } = err else {
8005 panic!("expected FonteRepoShape, got other variant");
8006 };
8007 assert!(
8008 reason.contains("must not contain `*`"),
8009 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8010 got {reason:?}"
8011 );
8012 }
8013
8014 #[test]
8015 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8016 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8017 // both per-byte arms inside the same `for &b in s.as_bytes()`
8018 // loop, so the byte that appears first in the value's byte
8019 // order wins. A `:repo
8020 // "https://github.com/p/x#readme*tail"` carries both `#` and
8021 // `*`; the `#` byte appears first, so the fragment-`#` arm
8022 // fires, surfacing the more self-locating diagnostic on the
8023 // byte the author pasted earliest in the URL. Mirrors the
8024 // peer cascade discipline
8025 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8026 // on the prior `:repo` byte-class arm.
8027 let d = dep_with_fonte(DepSource::Git {
8028 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8029 tag: Some("v0.1.0".into()),
8030 rev: None,
8031 branch: None,
8032 });
8033 let err = d.validate().unwrap_err();
8034 let DepError::FonteRepoShape { reason, .. } = err else {
8035 panic!("expected FonteRepoShape, got other variant");
8036 };
8037 assert!(
8038 reason.contains("must not contain `#`"),
8039 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8040 appears first in value), got {reason:?}"
8041 );
8042 }
8043
8044 #[test]
8045 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8046 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8047 // arm are both per-byte arms inside the same `for &b in
8048 // s.as_bytes()` loop, so the byte that appears first in the
8049 // value's byte order wins. A `:repo
8050 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8051 // the `$` byte appears first, so the var-expansion arm
8052 // fires, surfacing the more self-locating diagnostic on the
8053 // byte the author pasted earliest in the URL. Pins the
8054 // natural-order cascade so a future reorder of the per-byte
8055 // arms surfaces here — `*` is the most recent byte-class
8056 // arm, so the cascade-pin sweep extends to cover the
8057 // immediately prior `$` byte arm firing first when ordered
8058 // ahead of `*` in the value.
8059 let d = dep_with_fonte(DepSource::Git {
8060 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
8061 tag: Some("v0.1.0".into()),
8062 rev: None,
8063 branch: None,
8064 });
8065 let err = d.validate().unwrap_err();
8066 let DepError::FonteRepoShape { reason, .. } = err else {
8067 panic!("expected FonteRepoShape, got other variant");
8068 };
8069 assert!(
8070 reason.contains("must not contain `$`"),
8071 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8072 byte appears first in value), got {reason:?}"
8073 );
8074 }
8075
8076 #[test]
8077 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8078 // The fail-before-pass-after pin for the canonical paste-from-
8079 // shell-prompt subshell-grouping footgun on `:repo`. An author
8080 // pastes a doc / README snippet carrying a regex-alternation
8081 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8082 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8083 // `:repo` slot, forgetting to substitute one literal org name.
8084 // Until this arm landed the `(` byte silently passed every
8085 // prior `is_git_repo_url` arm (no whitespace, no control
8086 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8087 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8088 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8089 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8090 // URL spec's special-query percent-encode set maps `(` →
8091 // `%28` and `)` → `%29` on the wire, so the byte rides
8092 // verbatim into the lacre's per-dep BLAKE3 closure but is
8093 // silently rewritten at libcurl's URL-parser layer —
8094 // defeating the THEORY.md §V.2 render-determinism contract on
8095 // the same axis the prior twelve byte-class arms close.
8096 let d = dep_with_fonte(DepSource::Git {
8097 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8098 tag: Some("v0.1.0".into()),
8099 rev: None,
8100 branch: None,
8101 });
8102 let err = d.validate().unwrap_err();
8103 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8104 panic!("expected FonteRepoShape, got other variant");
8105 };
8106 assert_eq!(nome, "caixa-teia");
8107 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8108 assert!(
8109 reason.contains("must not contain `(`"),
8110 "reason must surface the subshell-open-paren arm, got {reason:?}"
8111 );
8112 assert!(
8113 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8114 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8115 got {reason:?}"
8116 );
8117 }
8118
8119 #[test]
8120 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8121 // The symmetric arm pin on the closing `)` byte: an author
8122 // pastes a `$(date)` command-substitution wrapper or a
8123 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8124 // Pinned separately from the opening `(` shape so a future
8125 // diagnostic-surface change that only checked one boundary
8126 // surfaces here. The `(` byte appears earlier in the
8127 // canonical regex / subshell wrapper so the per-byte loop
8128 // fires on `(` first; this test exercises a `:repo` value
8129 // carrying only the closing `)` byte (no opening paren) so
8130 // the `)` arm fires directly — pinning the byte-class arm
8131 // independent of order.
8132 let d = dep_with_fonte(DepSource::Git {
8133 repo: "github:pleme-io/caixa-teia)tail".into(),
8134 tag: Some("v0.1.0".into()),
8135 rev: None,
8136 branch: None,
8137 });
8138 let err = d.validate().unwrap_err();
8139 let DepError::FonteRepoShape { reason, .. } = err else {
8140 panic!("expected FonteRepoShape, got other variant");
8141 };
8142 assert!(
8143 reason.contains("must not contain `)`"),
8144 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8145 got {reason:?}"
8146 );
8147 }
8148
8149 #[test]
8150 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8151 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8152 // are both per-byte arms inside the same `for &b in
8153 // s.as_bytes()` loop, so the byte that appears first in the
8154 // value's byte order wins. A `:repo
8155 // "https://github.com/p/x#readme(tail)"` carries both `#` and
8156 // `(`; the `#` byte appears first, so the fragment-`#` arm
8157 // fires, surfacing the more self-locating diagnostic on the
8158 // byte the author pasted earliest in the URL. Mirrors the
8159 // peer cascade discipline
8160 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8161 // on the prior `:repo` byte-class arm.
8162 let d = dep_with_fonte(DepSource::Git {
8163 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8164 tag: Some("v0.1.0".into()),
8165 rev: None,
8166 branch: None,
8167 });
8168 let err = d.validate().unwrap_err();
8169 let DepError::FonteRepoShape { reason, .. } = err else {
8170 panic!("expected FonteRepoShape, got other variant");
8171 };
8172 assert!(
8173 reason.contains("must not contain `#`"),
8174 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8175 byte appears first in value), got {reason:?}"
8176 );
8177 }
8178
8179 #[test]
8180 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8181 // Cascade pin: the glob-`*` arm (the immediate-predecessor
8182 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8183 // per-byte arms inside the same `for &b in s.as_bytes()`
8184 // loop, so the byte that appears first in the value's byte
8185 // order wins. A `:repo
8186 // "https://github.com/p/x-*-(date)"` carries both `*` and
8187 // `(`; the `*` byte appears first, so the glob arm fires,
8188 // surfacing the more self-locating diagnostic on the byte
8189 // the author pasted earliest in the URL. Pins the natural-
8190 // order cascade so a future reorder of the per-byte arms
8191 // surfaces here — `(` is the most recent byte-class arm,
8192 // so the cascade-pin sweep extends to cover the immediately
8193 // prior `*` byte arm firing first when ordered ahead of `(`
8194 // in the value.
8195 let d = dep_with_fonte(DepSource::Git {
8196 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8197 tag: Some("v0.1.0".into()),
8198 rev: None,
8199 branch: None,
8200 });
8201 let err = d.validate().unwrap_err();
8202 let DepError::FonteRepoShape { reason, .. } = err else {
8203 panic!("expected FonteRepoShape, got other variant");
8204 };
8205 assert!(
8206 reason.contains("must not contain `*`"),
8207 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8208 appears first in value), got {reason:?}"
8209 );
8210 }
8211
8212 #[test]
8213 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8214 // The fail-before-pass-after pin for the canonical paste-from-
8215 // doc-shell-quoting footgun on `:repo`. An author copies a
8216 // README quick-start snippet (`$ git clone "https://github.com/
8217 // foo/bar"`) and keeps the surrounding double-quote bytes when
8218 // pasting into the `:repo` slot — the doc wraps the URL in
8219 // double quotes so the shell doesn't re-lex metachars inside,
8220 // but the typed slot is itself a byte-level string parser, not
8221 // a shell context, so the quote bytes ride into the value
8222 // verbatim. Until this arm landed the `"` byte silently passed
8223 // every prior `is_git_repo_url` arm (no whitespace, no control
8224 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8225 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8226 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8227 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8228 // `` ` ``) every URL parser is required to refuse or percent-
8229 // encode, and the WHATWG URL spec's 'C0 control percent-encode
8230 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8231 // into the lacre's per-dep BLAKE3 closure but is silently
8232 // rewritten at libcurl's URL-parser layer, defeating the
8233 // THEORY.md §V.2 render-determinism contract.
8234 let d = dep_with_fonte(DepSource::Git {
8235 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8236 tag: Some("v0.1.0".into()),
8237 rev: None,
8238 branch: None,
8239 });
8240 let err = d.validate().unwrap_err();
8241 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8242 panic!("expected FonteRepoShape, got other variant");
8243 };
8244 assert_eq!(nome, "caixa-teia");
8245 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8246 assert!(
8247 reason.contains("must not contain `\"`"),
8248 "reason must surface the shell-double-quote arm, got {reason:?}"
8249 );
8250 assert!(
8251 reason.contains("double-quote") || reason.contains("'delims'"),
8252 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8253 got {reason:?}"
8254 );
8255 }
8256
8257 #[test]
8258 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8259 // The symmetric stray-quote tail pin: an author pastes only a
8260 // closing `"` from a shell-history line like `git clone
8261 // "https://github.com/foo/bar" && cd …` (the trim went too
8262 // far in one direction but not the other) into the `:repo`
8263 // slot. Pinned separately from the wrapped-quote shape so a
8264 // future diagnostic-surface change that only checked one
8265 // boundary (only leading, only trailing, only paired) surfaces
8266 // here — the per-byte arm fires anywhere `"` appears.
8267 let d = dep_with_fonte(DepSource::Git {
8268 repo: "github:pleme-io/caixa-teia\"".into(),
8269 tag: Some("v0.1.0".into()),
8270 rev: None,
8271 branch: None,
8272 });
8273 let err = d.validate().unwrap_err();
8274 let DepError::FonteRepoShape { reason, .. } = err else {
8275 panic!("expected FonteRepoShape, got other variant");
8276 };
8277 assert!(
8278 reason.contains("must not contain `\"`"),
8279 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8280 got {reason:?}"
8281 );
8282 }
8283
8284 #[test]
8285 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8286 // Cascade pin: the fragment-`#` arm and the double-quote arm
8287 // are both per-byte arms inside the same `for &b in
8288 // s.as_bytes()` loop, so the byte that appears first in the
8289 // value's byte order wins. A `:repo
8290 // "https://github.com/p/x#readme\"tail"` carries both `#` and
8291 // `"`; the `#` byte appears first, so the fragment-`#` arm
8292 // fires, surfacing the more self-locating diagnostic on the
8293 // byte the author pasted earliest in the URL.
8294 let d = dep_with_fonte(DepSource::Git {
8295 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8296 tag: Some("v0.1.0".into()),
8297 rev: None,
8298 branch: None,
8299 });
8300 let err = d.validate().unwrap_err();
8301 let DepError::FonteRepoShape { reason, .. } = err else {
8302 panic!("expected FonteRepoShape, got other variant");
8303 };
8304 assert!(
8305 reason.contains("must not contain `#`"),
8306 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8307 byte appears first in value), got {reason:?}"
8308 );
8309 }
8310
8311 #[test]
8312 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8313 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8314 // byte-class arm, 3b99147) and the double-quote arm are both
8315 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8316 // so the byte that appears first in the value's byte order
8317 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8318 // and `"`; the `(` byte appears first, so the subshell arm
8319 // fires, surfacing the more self-locating diagnostic on the
8320 // byte the author pasted earliest in the URL. Pins the natural-
8321 // order cascade so a future reorder of the per-byte arms
8322 // surfaces here — `"` is the most recent byte-class arm, so
8323 // the cascade-pin sweep extends to cover the immediately prior
8324 // `(` byte arm firing first when ordered ahead of `"` in the
8325 // value.
8326 let d = dep_with_fonte(DepSource::Git {
8327 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8328 tag: Some("v0.1.0".into()),
8329 rev: None,
8330 branch: None,
8331 });
8332 let err = d.validate().unwrap_err();
8333 let DepError::FonteRepoShape { reason, .. } = err else {
8334 panic!("expected FonteRepoShape, got other variant");
8335 };
8336 assert!(
8337 reason.contains("must not contain `(`"),
8338 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8339 byte appears first in value), got {reason:?}"
8340 );
8341 }
8342
8343 #[test]
8344 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8345 // The fail-before-pass-after pin for the canonical paste-from-
8346 // doc-strong-quoting footgun on `:repo`. An author copies a
8347 // security-conscious README quick-start snippet (`$ git clone
8348 // 'https://github.com/foo/bar'`) and keeps the surrounding
8349 // single-quote bytes when pasting into the `:repo` slot — the
8350 // doc strong-quotes the URL so the shell suppresses every form
8351 // of expansion on the bytes inside (no `$`, no backtick, no
8352 // glob, no word-splitting), but the typed slot is itself a
8353 // byte-level string parser, not a shell context, so the quote
8354 // bytes ride into the value verbatim. Until this arm landed the
8355 // `'` byte silently passed every prior `is_git_repo_url` arm
8356 // (no whitespace, no control chars, no non-ASCII, no `#`, no
8357 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8358 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8359 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8360 // set, peer with the `\"` 'delims' double-quote arm and the
8361 // partner ASCII shell-string-delimiter byte every byte-level
8362 // string parser sharing a value-shape with a shell argument
8363 // must refuse on a URL-shaped slot.
8364 let d = dep_with_fonte(DepSource::Git {
8365 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8366 tag: Some("v0.1.0".into()),
8367 rev: None,
8368 branch: None,
8369 });
8370 let err = d.validate().unwrap_err();
8371 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8372 panic!("expected FonteRepoShape, got other variant");
8373 };
8374 assert_eq!(nome, "caixa-teia");
8375 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8376 assert!(
8377 reason.contains("must not contain `'`"),
8378 "reason must surface the shell-single-quote arm, got {reason:?}"
8379 );
8380 assert!(
8381 reason.contains("single-quote") || reason.contains("strong-quote"),
8382 "reason must name the shell-single-quote / strong-quote rationale, \
8383 got {reason:?}"
8384 );
8385 }
8386
8387 #[test]
8388 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8389 // The symmetric English-typography pin: an author writes
8390 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8391 // from-prose idiom every README / commit-message / chat-thread
8392 // reference to a repo carries) expecting the substrate to
8393 // coerce it to a kebab-case slug — but the byte rides into the
8394 // lacre verbatim. Pinned separately from the wrapped-quote
8395 // shape so a future diagnostic-surface change that only checked
8396 // the boundary positions (only leading, only trailing, only
8397 // paired) surfaces here — the per-byte arm fires anywhere `'`
8398 // appears in the value.
8399 let d = dep_with_fonte(DepSource::Git {
8400 repo: "github:pleme-io/repo's-fork".into(),
8401 tag: Some("v0.1.0".into()),
8402 rev: None,
8403 branch: None,
8404 });
8405 let err = d.validate().unwrap_err();
8406 let DepError::FonteRepoShape { reason, .. } = err else {
8407 panic!("expected FonteRepoShape, got other variant");
8408 };
8409 assert!(
8410 reason.contains("must not contain `'`"),
8411 "reason must surface the shell-single-quote arm on the mid-string \
8412 apostrophe shape, got {reason:?}"
8413 );
8414 }
8415
8416 #[test]
8417 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8418 // Cascade pin: the fragment-`#` arm and the single-quote arm
8419 // are both per-byte arms inside the same `for &b in
8420 // s.as_bytes()` loop, so the byte that appears first in the
8421 // value's byte order wins. A `:repo
8422 // "https://github.com/p/x#readme'tail"` carries both `#` and
8423 // `'`; the `#` byte appears first, so the fragment-`#` arm
8424 // fires, surfacing the more self-locating diagnostic on the
8425 // byte the author pasted earliest in the URL.
8426 let d = dep_with_fonte(DepSource::Git {
8427 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8428 tag: Some("v0.1.0".into()),
8429 rev: None,
8430 branch: None,
8431 });
8432 let err = d.validate().unwrap_err();
8433 let DepError::FonteRepoShape { reason, .. } = err else {
8434 panic!("expected FonteRepoShape, got other variant");
8435 };
8436 assert!(
8437 reason.contains("must not contain `#`"),
8438 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8439 byte appears first in value), got {reason:?}"
8440 );
8441 }
8442
8443 #[test]
8444 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8445 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8446 // byte-class arm, 4267d8b) and the single-quote arm are both
8447 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8448 // so the byte that appears first in the value's byte order
8449 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8450 // `'`; the `"` byte appears first, so the double-quote arm
8451 // fires, surfacing the more self-locating diagnostic on the
8452 // byte the author pasted earliest in the URL. Pins the natural-
8453 // order cascade so a future reorder of the per-byte arms
8454 // surfaces here — `'` is the most recent byte-class arm, so
8455 // the cascade-pin sweep extends to cover the immediately prior
8456 // `"` byte arm firing first when ordered ahead of `'` in the
8457 // value.
8458 let d = dep_with_fonte(DepSource::Git {
8459 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8460 tag: Some("v0.1.0".into()),
8461 rev: None,
8462 branch: None,
8463 });
8464 let err = d.validate().unwrap_err();
8465 let DepError::FonteRepoShape { reason, .. } = err else {
8466 panic!("expected FonteRepoShape, got other variant");
8467 };
8468 assert!(
8469 reason.contains("must not contain `\"`"),
8470 "reason must surface the double-quote arm (fires before single-quote when `\"` \
8471 byte appears first in value), got {reason:?}"
8472 );
8473 }
8474
8475 #[test]
8476 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8477 // The fail-before-pass-after pin for the canonical paste-from-
8478 // shell-history footgun on `:repo`. An author copies a `git
8479 // clone <url>!sudo make install` one-liner from a README's
8480 // quick-start snippet, intending the trailing `!sudo` as a
8481 // shell-history-expansion reference but the typed slot is itself
8482 // a byte-level string parser, not a shell context, so the byte
8483 // rides into the value verbatim. Until this arm landed the `!`
8484 // byte silently passed every prior `is_git_repo_url` arm (no
8485 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8486 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8487 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8488 // start with `-` or `:`); bash with the default `histexpand`
8489 // mode rewrites `!command` to the most recent history entry
8490 // beginning with `command`, the canonical RCE-class injection
8491 // vector when the byte rides into a shell argument.
8492 let d = dep_with_fonte(DepSource::Git {
8493 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8494 tag: Some("v0.1.0".into()),
8495 rev: None,
8496 branch: None,
8497 });
8498 let err = d.validate().unwrap_err();
8499 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8500 panic!("expected FonteRepoShape, got other variant");
8501 };
8502 assert_eq!(nome, "caixa-teia");
8503 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8504 assert!(
8505 reason.contains("must not contain `!`"),
8506 "reason must surface the shell-history-expansion arm, got {reason:?}"
8507 );
8508 assert!(
8509 reason.contains("history-expansion") || reason.contains("bang"),
8510 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8511 );
8512 }
8513
8514 #[test]
8515 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8516 // The symmetric `!!` repeat-prior-command pin: an author paste-
8517 // trims a `git clone <url>` retry idiom from shell history that
8518 // expands to the previous command via `!!`. Pinned separately
8519 // from the wrapped `!command` shape so a future diagnostic-
8520 // surface change that only checked the leading or paired-bang
8521 // position surfaces here — the per-byte arm fires anywhere `!`
8522 // appears in the value.
8523 let d = dep_with_fonte(DepSource::Git {
8524 repo: "github:pleme-io/caixa-teia!!".into(),
8525 tag: Some("v0.1.0".into()),
8526 rev: None,
8527 branch: None,
8528 });
8529 let err = d.validate().unwrap_err();
8530 let DepError::FonteRepoShape { reason, .. } = err else {
8531 panic!("expected FonteRepoShape, got other variant");
8532 };
8533 assert!(
8534 reason.contains("must not contain `!`"),
8535 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8536 got {reason:?}"
8537 );
8538 }
8539
8540 #[test]
8541 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8542 // Cascade pin: the fragment-`#` arm and the bang arm are both
8543 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8544 // so the byte that appears first in the value's byte order
8545 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8546 // both `#` and `!`; the `#` byte appears first, so the
8547 // fragment-`#` arm fires, surfacing the more self-locating
8548 // diagnostic on the byte the author pasted earliest in the URL.
8549 let d = dep_with_fonte(DepSource::Git {
8550 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8551 tag: Some("v0.1.0".into()),
8552 rev: None,
8553 branch: None,
8554 });
8555 let err = d.validate().unwrap_err();
8556 let DepError::FonteRepoShape { reason, .. } = err else {
8557 panic!("expected FonteRepoShape, got other variant");
8558 };
8559 assert!(
8560 reason.contains("must not contain `#`"),
8561 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8562 appears first in value), got {reason:?}"
8563 );
8564 }
8565
8566 #[test]
8567 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8568 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8569 // byte-class arm, e7a109f) and the bang arm are both per-byte
8570 // arms inside the same `for &b in s.as_bytes()` loop, so the
8571 // byte that appears first in the value's byte order wins. A
8572 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8573 // `'` byte appears first, so the single-quote arm fires,
8574 // surfacing the more self-locating diagnostic on the byte the
8575 // author pasted earliest in the URL. Pins the natural-order
8576 // cascade so a future reorder of the per-byte arms surfaces
8577 // here — `!` is the most recent byte-class arm, so the
8578 // cascade-pin sweep extends to cover the immediately prior `'`
8579 // byte arm firing first when ordered ahead of `!` in the value.
8580 let d = dep_with_fonte(DepSource::Git {
8581 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8582 tag: Some("v0.1.0".into()),
8583 rev: None,
8584 branch: None,
8585 });
8586 let err = d.validate().unwrap_err();
8587 let DepError::FonteRepoShape { reason, .. } = err else {
8588 panic!("expected FonteRepoShape, got other variant");
8589 };
8590 assert!(
8591 reason.contains("must not contain `'`"),
8592 "reason must surface the single-quote arm (fires before bang when `'` byte \
8593 appears first in value), got {reason:?}"
8594 );
8595 }
8596
8597 #[test]
8598 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8599 // The fail-before-pass-after pin for the canonical
8600 // list-separator-belongs-to-list-grammar footgun on `:repo`.
8601 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8602 // one-liner from a multi-repo bootstrap doc, intending the
8603 // comma to separate multiple repo entries but the typed
8604 // `:repo` slot names *one* repo (the list-separator belongs
8605 // to the `:deps` list grammar, not to the value). Until this
8606 // arm landed the `,` byte silently passed every prior
8607 // `is_git_repo_url` arm (no whitespace, no control chars, no
8608 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8609 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8610 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8611 // `:`); the byte rode into the lacre's per-dep content-
8612 // address and the resolver's `git clone <repo>` subprocess
8613 // invocation, where no host's repo registry resolved the
8614 // comma-bearing slug.
8615 let d = dep_with_fonte(DepSource::Git {
8616 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8617 tag: Some("v0.1.0".into()),
8618 rev: None,
8619 branch: None,
8620 });
8621 let err = d.validate().unwrap_err();
8622 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8623 panic!("expected FonteRepoShape, got other variant");
8624 };
8625 assert_eq!(nome, "caixa-teia");
8626 assert_eq!(
8627 repo,
8628 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8629 );
8630 assert!(
8631 reason.contains("must not contain `,`"),
8632 "reason must surface the list-separator-comma arm, got {reason:?}"
8633 );
8634 assert!(
8635 reason.contains("list-separator") || reason.contains("sub-delims"),
8636 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8637 got {reason:?}"
8638 );
8639 }
8640
8641 #[test]
8642 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8643 // The symmetric trailing-`,` paste-from-prose pin: an author
8644 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8645 // comma every README-prose list-of-projects sentence carries,
8646 // mistakenly retained when the slug is pasted mid-sentence)
8647 // expecting the substrate to coerce it to a kebab-case slug.
8648 // Pinned separately from the wrapped mid-token shape so a
8649 // future diagnostic-surface change that only checked the
8650 // leading or paired-comma position surfaces here — the
8651 // per-byte arm fires anywhere `,` appears in the value.
8652 let d = dep_with_fonte(DepSource::Git {
8653 repo: "github:pleme-io/caixa-feira,".into(),
8654 tag: Some("v0.1.0".into()),
8655 rev: None,
8656 branch: None,
8657 });
8658 let err = d.validate().unwrap_err();
8659 let DepError::FonteRepoShape { reason, .. } = err else {
8660 panic!("expected FonteRepoShape, got other variant");
8661 };
8662 assert!(
8663 reason.contains("must not contain `,`"),
8664 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8665 got {reason:?}"
8666 );
8667 }
8668
8669 #[test]
8670 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8671 // Cascade pin: the fragment-`#` arm and the comma arm are
8672 // both per-byte arms inside the same `for &b in s.as_bytes()`
8673 // loop, so the byte that appears first in the value's byte
8674 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8675 // carries both `#` and `,`; the `#` byte appears first, so
8676 // the fragment-`#` arm fires, surfacing the more self-
8677 // locating diagnostic on the byte the author pasted earliest
8678 // in the URL.
8679 let d = dep_with_fonte(DepSource::Git {
8680 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8681 tag: Some("v0.1.0".into()),
8682 rev: None,
8683 branch: None,
8684 });
8685 let err = d.validate().unwrap_err();
8686 let DepError::FonteRepoShape { reason, .. } = err else {
8687 panic!("expected FonteRepoShape, got other variant");
8688 };
8689 assert!(
8690 reason.contains("must not contain `#`"),
8691 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8692 appears first in value), got {reason:?}"
8693 );
8694 }
8695
8696 #[test]
8697 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8698 // Cascade pin: the bang-`!` arm (the immediate-predecessor
8699 // byte-class arm, 7d53c68) and the comma arm are both
8700 // per-byte arms inside the same `for &b in s.as_bytes()`
8701 // loop, so the byte that appears first in the value's byte
8702 // order wins. A `:repo "github:p/x!mid,tail"` carries both
8703 // `!` and `,`; the `!` byte appears first, so the bang arm
8704 // fires, surfacing the more self-locating diagnostic on the
8705 // byte the author pasted earliest in the URL. Pins the
8706 // natural-order cascade so a future reorder of the per-byte
8707 // arms surfaces here — `,` is the most recent byte-class
8708 // arm, so the cascade-pin sweep extends to cover the
8709 // immediately prior `!` byte arm firing first when ordered
8710 // ahead of `,` in the value.
8711 let d = dep_with_fonte(DepSource::Git {
8712 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
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("must not contain `!`"),
8723 "reason must surface the bang arm (fires before comma when `!` byte \
8724 appears first in value), got {reason:?}"
8725 );
8726 }
8727
8728 #[test]
8729 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8730 // The fail-before-pass-after pin for the canonical
8731 // shell-env-var-assignment-belongs-to-shell-grammar footgun
8732 // on `:repo`. An author copies
8733 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8734 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8735 // git clone <url>`, etc. — the canonical
8736 // git-troubleshooting README idiom for a one-shot env-var
8737 // scoped to the `git clone` invocation) from a shell-prompt
8738 // one-liner, intending the `KEY=VALUE` prefix as a shell-
8739 // grammar env-var assignment but the typed `:repo` slot is
8740 // a value parser, not a shell context, so the bytes ride
8741 // into the value verbatim. Until this arm landed the `=`
8742 // byte silently passed every prior `is_git_repo_url` arm
8743 // (no whitespace, no control chars, no non-ASCII, no `#`,
8744 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8745 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8746 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8747 // the byte rode into the lacre's per-dep content-address
8748 // and the resolver's `git clone <repo>` subprocess
8749 // invocation, where the upstream host's git porcelain
8750 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8751 // path that no host's repo registry resolves.
8752 let d = dep_with_fonte(DepSource::Git {
8753 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8754 tag: Some("v0.1.0".into()),
8755 rev: None,
8756 branch: None,
8757 });
8758 let err = d.validate().unwrap_err();
8759 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8760 panic!("expected FonteRepoShape, got other variant");
8761 };
8762 assert_eq!(nome, "caixa-teia");
8763 assert_eq!(
8764 repo,
8765 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8766 );
8767 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8768 // appears before the ` ` byte at position 21, so the `=`
8769 // arm fires (not the whitespace arm) — both arms guard
8770 // the slot, but the per-byte for-loop scans left-to-right
8771 // and the first matching byte wins.
8772 assert!(
8773 reason.contains("must not contain `=`"),
8774 "reason must surface the equals-`=` arm on the env-var-assignment \
8775 paste shape, got {reason:?}"
8776 );
8777 assert!(
8778 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8779 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8780 );
8781 }
8782
8783 #[test]
8784 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8785 // The symmetric paste-from-gitconfig pin: an author copies
8786 // `url=https://github.com/p/x` from `git config --get-all
8787 // remote.origin.url` output, a `.gitconfig` `[remote
8788 // "origin"] url = https://…` ini-stanza paste, or a
8789 // `git config remote.origin.url <value>` doc snippet,
8790 // intending the `url=` prefix as the ini-key but the typed
8791 // `:repo` slot is a URL value parser, not a gitconfig
8792 // grammar. With no leading whitespace and no earlier-arm
8793 // bytes in the value, the `=` arm itself fires (rather
8794 // than cascading to the whitespace arm as in the env-var
8795 // paste shape). Pinned separately so a future diagnostic-
8796 // surface change that only checked the whitespace-leading
8797 // shape surfaces here — the per-byte arm fires anywhere
8798 // `=` appears in the value.
8799 let d = dep_with_fonte(DepSource::Git {
8800 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8801 tag: Some("v0.1.0".into()),
8802 rev: None,
8803 branch: None,
8804 });
8805 let err = d.validate().unwrap_err();
8806 let DepError::FonteRepoShape { reason, .. } = err else {
8807 panic!("expected FonteRepoShape, got other variant");
8808 };
8809 assert!(
8810 reason.contains("must not contain `=`"),
8811 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8812 paste shape, got {reason:?}"
8813 );
8814 assert!(
8815 reason.contains("key-value-separator") || reason.contains("sub-delims"),
8816 "reason must name the key-value-separator / RFC-3986-sub-delims \
8817 rationale, got {reason:?}"
8818 );
8819 }
8820
8821 #[test]
8822 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8823 // Cascade pin: the fragment-`#` arm and the `=` arm are
8824 // both per-byte arms inside the same `for &b in s.as_bytes()`
8825 // loop, so the byte that appears first in the value's byte
8826 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8827 // carries both `#` and `=`; the `#` byte appears first, so
8828 // the fragment-`#` arm fires, surfacing the more self-
8829 // locating diagnostic on the byte the author pasted earliest
8830 // in the URL.
8831 let d = dep_with_fonte(DepSource::Git {
8832 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8833 tag: Some("v0.1.0".into()),
8834 rev: None,
8835 branch: None,
8836 });
8837 let err = d.validate().unwrap_err();
8838 let DepError::FonteRepoShape { reason, .. } = err else {
8839 panic!("expected FonteRepoShape, got other variant");
8840 };
8841 assert!(
8842 reason.contains("must not contain `#`"),
8843 "reason must surface the fragment-`#` arm (fires before equals when \
8844 `#` byte appears first in value), got {reason:?}"
8845 );
8846 }
8847
8848 #[test]
8849 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8850 // Cascade pin: the comma-`,` arm (the immediate-predecessor
8851 // byte-class arm, 775b80e) and the `=` arm are both per-byte
8852 // arms inside the same `for &b in s.as_bytes()` loop, so
8853 // the byte that appears first in the value's byte order
8854 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8855 // and `=`; the `,` byte appears first, so the comma arm
8856 // fires, surfacing the more self-locating diagnostic on
8857 // the byte the author pasted earliest in the URL. Pins the
8858 // natural-order cascade so a future reorder of the per-byte
8859 // arms surfaces here — `=` is the most recent byte-class
8860 // arm, so the cascade-pin sweep extends to cover the
8861 // immediately prior `,` byte arm firing first when ordered
8862 // ahead of `=` in the value.
8863 let d = dep_with_fonte(DepSource::Git {
8864 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8865 tag: Some("v0.1.0".into()),
8866 rev: None,
8867 branch: None,
8868 });
8869 let err = d.validate().unwrap_err();
8870 let DepError::FonteRepoShape { reason, .. } = err else {
8871 panic!("expected FonteRepoShape, got other variant");
8872 };
8873 assert!(
8874 reason.contains("must not contain `,`"),
8875 "reason must surface the comma arm (fires before equals when `,` byte \
8876 appears first in value), got {reason:?}"
8877 );
8878 }
8879
8880 #[test]
8881 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8882 // The fail-before-pass-after pin for the canonical paste-from-
8883 // browser-address-bar percent-encoded-space footgun on `:repo`.
8884 // An author copies `https://github.com/p/x%20test` from a
8885 // browser address bar (or a percent-encoded README hyperlink,
8886 // or a `curl --data-urlencode` shell-pipeline output)
8887 // intending `%20` as the URL encoding of a literal space; the
8888 // typed `:repo` slot already rejects the literal space byte
8889 // (the whitespace arm at the top of `is_git_repo_url`), so an
8890 // author trying to express "I really meant a space" reaches
8891 // for percent-encoding. Until this arm landed the `%` byte
8892 // silently passed every prior `is_git_repo_url` arm and rode
8893 // verbatim into the lacre's per-dep content-address — but
8894 // libcurl re-percent-encodes `%` to `%25` on the wire (since
8895 // `%` is reserved as the escape-sequence lead-in), so the
8896 // wire request becomes `https://github.com/p/x%2520test`, a
8897 // path the lacre's content-address never names. The classic
8898 // render-determinism violation on the encoding-mechanism axis
8899 // itself.
8900 let d = dep_with_fonte(DepSource::Git {
8901 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8902 tag: Some("v0.1.0".into()),
8903 rev: None,
8904 branch: None,
8905 });
8906 let err = d.validate().unwrap_err();
8907 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8908 panic!("expected FonteRepoShape, got other variant");
8909 };
8910 assert_eq!(nome, "caixa-teia");
8911 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8912 assert!(
8913 reason.contains("must not contain `%`"),
8914 "reason must surface the percent-`%` arm on the percent-encoded-space \
8915 paste shape, got {reason:?}"
8916 );
8917 assert!(
8918 reason.contains("percent-encoding") || reason.contains("%25"),
8919 "reason must name the percent-encoding / `%25` re-encoding rationale, \
8920 got {reason:?}"
8921 );
8922 }
8923
8924 #[test]
8925 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8926 // The symmetric over-encoded-path-separator pin: an author
8927 // writes `:repo "https://github.com/p%2Fx"` intending the
8928 // `%2F` as the URL encoding of `/` (the canonical
8929 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8930 // footgun every API client library and OAuth redirect-URI
8931 // documentation surfaces — the `/` is the URL-path-separator
8932 // and some templates percent-encode it to escape interpretation
8933 // as a path separator). The GitHub Smart-HTTP transport
8934 // resolves the URL's path-segment grammar before the
8935 // percent-decoding pass, so the value identifies a different
8936 // resource on the wire than the literal-`/` form the lacre's
8937 // content-address must agree with — two authors whose `:repo`
8938 // values differ only in their `/` vs `%2F` presence lock to
8939 // two distinct BLAKE3 closures for the byte-identical upstream
8940 // `git clone`. Pinned separately so a future diagnostic
8941 // surface that only catches the `%20` shape surfaces here too.
8942 let d = dep_with_fonte(DepSource::Git {
8943 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8944 tag: Some("v0.1.0".into()),
8945 rev: None,
8946 branch: None,
8947 });
8948 let err = d.validate().unwrap_err();
8949 let DepError::FonteRepoShape { reason, .. } = err else {
8950 panic!("expected FonteRepoShape, got other variant");
8951 };
8952 assert!(
8953 reason.contains("must not contain `%`"),
8954 "reason must surface the percent-`%` arm on the over-encoded-path \
8955 shape, got {reason:?}"
8956 );
8957 assert!(
8958 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8959 "reason must name the render-determinism / BLAKE3-closure rationale, \
8960 got {reason:?}"
8961 );
8962 }
8963
8964 #[test]
8965 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8966 // Cascade pin: the fragment-`#` arm and the `%` arm are both
8967 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8968 // so the byte that appears first in the value's byte order
8969 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8970 // both `#` and `%`; the `#` byte appears first, so the
8971 // fragment-`#` arm fires, surfacing the more self-locating
8972 // diagnostic on the byte the author pasted earliest in the URL.
8973 let d = dep_with_fonte(DepSource::Git {
8974 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8975 tag: Some("v0.1.0".into()),
8976 rev: None,
8977 branch: None,
8978 });
8979 let err = d.validate().unwrap_err();
8980 let DepError::FonteRepoShape { reason, .. } = err else {
8981 panic!("expected FonteRepoShape, got other variant");
8982 };
8983 assert!(
8984 reason.contains("must not contain `#`"),
8985 "reason must surface the fragment-`#` arm (fires before percent when \
8986 `#` byte appears first in value), got {reason:?}"
8987 );
8988 }
8989
8990 #[test]
8991 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8992 // Cascade pin: the equals-`=` arm (the immediate-predecessor
8993 // byte-class arm, acf99af) and the `%` arm are both per-byte
8994 // arms inside the same `for &b in s.as_bytes()` loop, so the
8995 // byte that appears first in the value's byte order wins.
8996 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8997 // the `=` byte appears first, so the equals arm fires,
8998 // surfacing the more self-locating diagnostic on the byte the
8999 // author pasted earliest in the URL. Pins the natural-order
9000 // cascade so a future reorder of the per-byte arms surfaces
9001 // here — `%` is the most recent byte-class arm, so the
9002 // cascade-pin sweep extends to cover the immediately prior
9003 // `=` byte arm firing first when ordered ahead of `%` in the
9004 // value.
9005 let d = dep_with_fonte(DepSource::Git {
9006 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9007 tag: Some("v0.1.0".into()),
9008 rev: None,
9009 branch: None,
9010 });
9011 let err = d.validate().unwrap_err();
9012 let DepError::FonteRepoShape { reason, .. } = err else {
9013 panic!("expected FonteRepoShape, got other variant");
9014 };
9015 assert!(
9016 reason.contains("must not contain `=`"),
9017 "reason must surface the equals arm (fires before percent when `=` byte \
9018 appears first in value), got {reason:?}"
9019 );
9020 }
9021
9022 #[test]
9023 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9024 // The fail-before-pass-after pin for the canonical paste-from-
9025 // shell-history footgun on `:repo`. An author copies a
9026 // `git clone <url>` line from their terminal followed by a
9027 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9028 // history shorthand (the `^old^new^` form re-runs the prior
9029 // history entry with the first `old` substituted by `new`,
9030 // bash's default behavior on interactive sessions with
9031 // `set -o histexpand`), forgetting to trim the trailing
9032 // `^...^...` shell-history fragment from the URL value. The
9033 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9034 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9035 // classes), the WHATWG URL spec's 'fragment percent-encode
9036 // set' maps `^` → `%5E` on the wire, so the byte rides
9037 // verbatim into the lacre's per-dep content-address but
9038 // libcurl re-encodes it to `%5E` at `git clone` time — the
9039 // classic render-determinism violation on the same axis the
9040 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9041 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9042 // `#` arms close.
9043 let d = dep_with_fonte(DepSource::Git {
9044 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9045 tag: Some("v0.1.0".into()),
9046 rev: None,
9047 branch: None,
9048 });
9049 let err = d.validate().unwrap_err();
9050 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9051 panic!("expected FonteRepoShape, got other variant");
9052 };
9053 assert_eq!(nome, "caixa-teia");
9054 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9055 assert!(
9056 reason.contains("must not contain `^`"),
9057 "reason must surface the caret-`^` arm on the paste-from-shell-history \
9058 shape, got {reason:?}"
9059 );
9060 assert!(
9061 reason.contains("history-substitution") || reason.contains("%5E"),
9062 "reason must name the shell-history-substitution / `%5E` wire-encoding \
9063 rationale, got {reason:?}"
9064 );
9065 }
9066
9067 #[test]
9068 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9069 // The symmetric paste-from-doc-grep-pipeline footgun: an
9070 // author writes `:repo "github:p/^archived"` after copying a
9071 // `grep '^archived'` regex-anchor / negation idiom from a
9072 // doc / README quick-listing snippet, expecting the substrate
9073 // to coerce it to a literal repo name. The byte rides
9074 // verbatim into the lacre's per-dep content-address and
9075 // diverges from the byte-identical literal `archived` form
9076 // every other author authored — the canonical render-
9077 // determinism violation pin on the second footgun shape the
9078 // caret-`^` arm closes.
9079 let d = dep_with_fonte(DepSource::Git {
9080 repo: "github:pleme-io/^archived".into(),
9081 tag: Some("v0.1.0".into()),
9082 rev: None,
9083 branch: None,
9084 });
9085 let err = d.validate().unwrap_err();
9086 let DepError::FonteRepoShape { reason, .. } = err else {
9087 panic!("expected FonteRepoShape, got other variant");
9088 };
9089 assert!(
9090 reason.contains("must not contain `^`"),
9091 "reason must surface the caret-`^` arm on the regex-anchor shape, \
9092 got {reason:?}"
9093 );
9094 assert!(
9095 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9096 "reason must name the render-determinism / BLAKE3-closure rationale, \
9097 got {reason:?}"
9098 );
9099 }
9100
9101 #[test]
9102 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9103 // Cascade pin: the `%` arm (the immediate-predecessor byte-
9104 // class arm, a323db8) and the `^` arm are both per-byte arms
9105 // inside the same `for &b in s.as_bytes()` loop, so the byte
9106 // that appears first in the value's byte order wins. A
9107 // `:repo "https://github.com/p/x%20mid^tail"` carries both
9108 // `%` and `^`; the `%` byte appears first, so the percent
9109 // arm fires, surfacing the more self-locating diagnostic on
9110 // the byte the author pasted earliest in the URL. Pins the
9111 // natural-order cascade so a future reorder of the per-byte
9112 // arms surfaces here — `^` is the most recent byte-class arm,
9113 // so the cascade-pin sweep extends to cover the immediately
9114 // prior `%` byte arm firing first when ordered ahead of `^`
9115 // in the value.
9116 let d = dep_with_fonte(DepSource::Git {
9117 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9118 tag: Some("v0.1.0".into()),
9119 rev: None,
9120 branch: None,
9121 });
9122 let err = d.validate().unwrap_err();
9123 let DepError::FonteRepoShape { reason, .. } = err else {
9124 panic!("expected FonteRepoShape, got other variant");
9125 };
9126 assert!(
9127 reason.contains("must not contain `%`"),
9128 "reason must surface the percent arm (fires before caret when `%` byte \
9129 appears first in value), got {reason:?}"
9130 );
9131 }
9132
9133 #[test]
9134 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9135 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9136 // (no `github:` prefix, no scheme). Every documented form
9137 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9138 // `file://`, or `git@host:path`); a bare `org/repo` is
9139 // ambiguous (`git clone` reads as a relative filesystem path
9140 // rather than the GitHub-shorthand expansion the author
9141 // probably intended) and the gate rejects the shape upstream.
9142 let d = dep_with_fonte(DepSource::Git {
9143 repo: "pleme-io/caixa-teia".into(),
9144 tag: Some("v0.1.0".into()),
9145 rev: None,
9146 branch: None,
9147 });
9148 let err = d.validate().unwrap_err();
9149 let DepError::FonteRepoShape { reason, .. } = err else {
9150 panic!("expected FonteRepoShape, got other variant");
9151 };
9152 assert!(
9153 reason.contains("must contain a `:`"),
9154 "reason must surface the missing-`:` arm, got {reason:?}"
9155 );
9156 assert!(
9157 reason.contains("github:"),
9158 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9159 );
9160 }
9161
9162 #[test]
9163 fn validate_rejects_git_fonte_with_repo_leading_colon() {
9164 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9165 // scheme that no git porcelain entry-point accepts. Pinned
9166 // separately from the missing-`:` arm because a value with a
9167 // leading `:` does technically contain a `:` separator; the
9168 // shape gate rejects on a dedicated arm so the diagnostic
9169 // names the specific footgun.
9170 let d = dep_with_fonte(DepSource::Git {
9171 repo: ":pleme-io/caixa-teia".into(),
9172 tag: Some("v0.1.0".into()),
9173 rev: None,
9174 branch: None,
9175 });
9176 let err = d.validate().unwrap_err();
9177 let DepError::FonteRepoShape { reason, .. } = err else {
9178 panic!("expected FonteRepoShape, got other variant");
9179 };
9180 assert!(
9181 reason.contains("must not start with `:`"),
9182 "reason must surface the leading-`:` arm, got {reason:?}"
9183 );
9184 }
9185
9186 #[test]
9187 fn validate_rejects_git_fonte_with_repo_too_long() {
9188 // The cap arm — a `:repo` value longer than
9189 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9190 // structurally untenable on every realistic landing site (the
9191 // resolver's `git clone` invocation, the future M4 CR
9192 // materializer's per-dep `repo:` axis); a value of that length
9193 // is almost certainly a paste-from-binary slug.
9194 let too_long = format!(
9195 "github:pleme-io/{}",
9196 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9197 );
9198 let d = dep_with_fonte(DepSource::Git {
9199 repo: too_long.clone(),
9200 tag: Some("v0.1.0".into()),
9201 rev: None,
9202 branch: None,
9203 });
9204 let err = d.validate().unwrap_err();
9205 let DepError::FonteRepoShape { reason, .. } = err else {
9206 panic!("expected FonteRepoShape, got other variant");
9207 };
9208 assert!(
9209 reason.contains("2048"),
9210 "reason must name the cap, got {reason:?}"
9211 );
9212 }
9213
9214 #[test]
9215 fn validate_accepts_canonical_git_fonte_repo_shapes() {
9216 // The positive-control sweep: every documented author shape on
9217 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9218 // must pass the value-shape gate. Pinned so a future tightening
9219 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9220 // here as a structural decision. Each form is exercised with the
9221 // same canonical `:tag` pin so only the `:repo` axis varies.
9222 for repo in [
9223 // The pleme-io registry-shorthand convention — `github:org/repo`.
9224 "github:pleme-io/caixa-teia",
9225 // Other host-aliased shorthands (the resolver's pluggable
9226 // host-prefix table).
9227 "gitlab:pleme-io/caixa-teia",
9228 "codeberg:pleme-io/caixa-teia",
9229 "sourcehut:~pleme-io/caixa-teia",
9230 // Full HTTPS URL with and without `.git` suffix.
9231 "https://github.com/pleme-io/caixa-teia",
9232 "https://github.com/pleme-io/caixa-teia.git",
9233 // HTTP (rare; dev / mirror).
9234 "http://example.com/pleme-io/caixa-teia.git",
9235 // SSH URL.
9236 "ssh://git@github.com/pleme-io/caixa-teia.git",
9237 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9238 // Scp-style SSH — the canonical `git@host:path` short form.
9239 "git@github.com:pleme-io/caixa-teia.git",
9240 "git@git.example.com:team/private.git",
9241 // Anonymous git protocol.
9242 "git://git.example.com/pleme-io/caixa-teia.git",
9243 // Local file URL (dev path).
9244 "file:///tmp/caixa-teia",
9245 ] {
9246 let d = dep_with_fonte(DepSource::Git {
9247 repo: repo.into(),
9248 tag: Some("v0.1.0".into()),
9249 rev: None,
9250 branch: None,
9251 });
9252 d.validate()
9253 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9254 }
9255 }
9256
9257 #[test]
9258 fn fonte_repo_empty_takes_precedence_over_shape() {
9259 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9260 // diagnostic; doesn't try to parse the URL shape) fires before
9261 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9262 // keeps its narrower error message. Mirrors
9263 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9264 // on the ordering layer.
9265 let d = dep_with_fonte(DepSource::Git {
9266 repo: String::new(),
9267 tag: Some("v0.1.0".into()),
9268 rev: None,
9269 branch: None,
9270 });
9271 let err = d.validate().unwrap_err();
9272 assert!(
9273 matches!(err, DepError::FonteRepoEmpty { .. }),
9274 "got {err:?}"
9275 );
9276 }
9277
9278 #[test]
9279 fn fonte_repo_shape_fires_before_pin_missing() {
9280 // Order pin: a malformed `:repo` value on a dep with no pin set
9281 // surfaces the `:repo` shape diagnostic (the more self-locating
9282 // axis — the `:repo` is the load-bearing identity of the source;
9283 // a missing pin is downstream from "do we even know the repo")
9284 // rather than collapsing onto the pin-missing diagnostic. The
9285 // shape gate runs inline before the pin enumeration in
9286 // `DepSource::validate`.
9287 let d = dep_with_fonte(DepSource::Git {
9288 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9289 tag: None,
9290 rev: None,
9291 branch: None,
9292 });
9293 let err = d.validate().unwrap_err();
9294 assert!(
9295 matches!(err, DepError::FonteRepoShape { .. }),
9296 "got {err:?}"
9297 );
9298 }
9299
9300 #[test]
9301 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9302 // The diagnostic-shape pin: the error names the offending
9303 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9304 // so the author can grep their caixa.lisp without re-running
9305 // the build. Mirrors the diagnostic-shape sweep on every prior
9306 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9307 let d = dep_with_fonte(DepSource::Git {
9308 repo: "pleme-io/caixa-teia".into(),
9309 tag: Some("v0.1.0".into()),
9310 rev: None,
9311 branch: None,
9312 });
9313 let err = d.validate().unwrap_err();
9314 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9315 panic!("expected FonteRepoShape, got other variant");
9316 };
9317 assert_eq!(nome, "caixa-teia");
9318 assert_eq!(repo, "pleme-io/caixa-teia");
9319 assert!(
9320 !reason.is_empty(),
9321 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9322 );
9323 }
9324
9325 #[test]
9326 fn validate_rejects_git_fonte_with_no_pin() {
9327 // The fail-before-pass-after pin for the canonical
9328 // `(:tipo git :repo "github:pleme-io/x")` shape with no
9329 // :tag/:rev/:branch — until this gate landed the resolver's
9330 // ResolveError::MissingPin surfaced at fetch time, far from the
9331 // source caixa.lisp. The new gate moves the check to validate
9332 // time and names the offending dep.
9333 let d = dep_with_fonte(DepSource::Git {
9334 repo: "github:pleme-io/caixa-teia".into(),
9335 tag: None,
9336 rev: None,
9337 branch: None,
9338 });
9339 let err = d.validate().unwrap_err();
9340 assert!(
9341 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9342 "got {err:?}"
9343 );
9344 }
9345
9346 #[test]
9347 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9348 // The canonical "pin drift" footgun: an author writes
9349 // `:tag "v1"` and later adds `:branch "main"` without removing
9350 // the :tag, and the resolver silently picks :tag (precedence
9351 // :rev > :tag > :branch). The :branch was dropped with no
9352 // diagnostic. The gate now rejects multi-pin shapes so the
9353 // author makes the precedence explicit at the source.
9354 let d = dep_with_fonte(DepSource::Git {
9355 repo: "github:pleme-io/caixa-teia".into(),
9356 tag: Some("v0.1.0".into()),
9357 rev: None,
9358 branch: Some("main".into()),
9359 });
9360 let err = d.validate().unwrap_err();
9361 let DepError::FontePinAmbiguous { nome, pins } = err else {
9362 panic!("expected FontePinAmbiguous");
9363 };
9364 assert_eq!(nome, "caixa-teia");
9365 assert!(pins.contains(":tag"));
9366 assert!(pins.contains(":branch"));
9367 assert!(!pins.contains(":rev"));
9368 }
9369
9370 #[test]
9371 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9372 // Sibling arm of the pin-drift footgun: :tag + :rev set
9373 // simultaneously. Pinned separately so a future relaxation
9374 // that only catches the (:tag, :branch) pair surfaces here.
9375 let d = dep_with_fonte(DepSource::Git {
9376 repo: "github:pleme-io/caixa-teia".into(),
9377 tag: Some("v0.1.0".into()),
9378 rev: Some("c0ffee".into()),
9379 branch: None,
9380 });
9381 let err = d.validate().unwrap_err();
9382 let DepError::FontePinAmbiguous { nome, pins } = err else {
9383 panic!("expected FontePinAmbiguous");
9384 };
9385 assert_eq!(nome, "caixa-teia");
9386 assert!(pins.contains(":tag"));
9387 assert!(pins.contains(":rev"));
9388 }
9389
9390 #[test]
9391 fn validate_rejects_git_fonte_with_all_three_pins() {
9392 // The maximal ambiguity case — every pin axis set. Pinned so a
9393 // future relaxation that only catches pairs surfaces here. The
9394 // diagnostic must enumerate every offending axis so the author
9395 // sees the full set, not just the first match.
9396 let d = dep_with_fonte(DepSource::Git {
9397 repo: "github:pleme-io/caixa-teia".into(),
9398 tag: Some("v0.1.0".into()),
9399 rev: Some("c0ffee".into()),
9400 branch: Some("main".into()),
9401 });
9402 let err = d.validate().unwrap_err();
9403 let DepError::FontePinAmbiguous { nome, pins } = err else {
9404 panic!("expected FontePinAmbiguous");
9405 };
9406 assert_eq!(nome, "caixa-teia");
9407 assert!(pins.contains(":tag"));
9408 assert!(pins.contains(":rev"));
9409 assert!(pins.contains(":branch"));
9410 }
9411
9412 #[test]
9413 fn validate_rejects_git_fonte_with_empty_tag_pin() {
9414 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9415 // inner string is empty. Distinct from FontePinMissing (where
9416 // every axis is None) — pinned separately so a future
9417 // tightening collapsing them surfaces here as a structural
9418 // decision.
9419 let d = dep_with_fonte(DepSource::Git {
9420 repo: "github:pleme-io/caixa-teia".into(),
9421 tag: Some(String::new()),
9422 rev: None,
9423 branch: None,
9424 });
9425 let err = d.validate().unwrap_err();
9426 let DepError::FontePinEmpty { nome, pin } = err else {
9427 panic!("expected FontePinEmpty");
9428 };
9429 assert_eq!(nome, "caixa-teia");
9430 assert_eq!(pin, ":tag");
9431 }
9432
9433 #[test]
9434 fn validate_rejects_git_fonte_with_empty_rev_pin() {
9435 // Sibling arm — the empty-pin diagnostic names which axis
9436 // carries the empty value, so the author's grep target is
9437 // unambiguous.
9438 let d = dep_with_fonte(DepSource::Git {
9439 repo: "github:pleme-io/caixa-teia".into(),
9440 tag: None,
9441 rev: Some(String::new()),
9442 branch: None,
9443 });
9444 let err = d.validate().unwrap_err();
9445 let DepError::FontePinEmpty { nome, pin } = err else {
9446 panic!("expected FontePinEmpty");
9447 };
9448 assert_eq!(nome, "caixa-teia");
9449 assert_eq!(pin, ":rev");
9450 }
9451
9452 #[test]
9453 fn validate_rejects_path_fonte_with_empty_caminho() {
9454 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9455 // until this gate landed the resolver's
9456 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9457 // fetch time — not actionable. The new gate moves the check to
9458 // validate time and names the offending dep.
9459 let d = dep_with_fonte(DepSource::Path {
9460 caminho: String::new(),
9461 });
9462 let err = d.validate().unwrap_err();
9463 assert!(
9464 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9465 "got {err:?}"
9466 );
9467 }
9468
9469 #[test]
9470 fn validate_rejects_path_fonte_with_absolute_caminho() {
9471 // The fail-before-pass-after pin for the absolute-`:caminho`
9472 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9473 // Until this gate landed an absolute `:caminho` silently
9474 // passed validate; the lacre pipeline embedded the
9475 // host-specific filesystem path verbatim in its
9476 // content-address (`conteudo: format!("path:{caminho}")`,
9477 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9478 // differed per machine — the build succeeded but two CI
9479 // runners with different `${HOME}` layouts emitted two
9480 // distinct lacres for the byte-identical caixa, silently
9481 // breaking the THEORY.md §V.2 render-determinism contract
9482 // far from the source caixa.lisp. The new gate moves the
9483 // check to validate time and names the offending dep +
9484 // caminho verbatim.
9485 let d = dep_with_fonte(DepSource::Path {
9486 caminho: "/home/me/work/caixa-teia".into(),
9487 });
9488 let err = d.validate().unwrap_err();
9489 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9490 panic!("expected FonteCaminhoAbsolute, got other variant");
9491 };
9492 assert_eq!(nome, "caixa-teia");
9493 assert_eq!(caminho, "/home/me/work/caixa-teia");
9494 }
9495
9496 #[test]
9497 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9498 // The canonical sibling-workspace dep form
9499 // (`:caminho "../caixa-teia"`) remains accepted. The
9500 // absolute-path gate above is specifically narrower than the
9501 // shared [`crate::render::is_sandboxed_relative_path`]
9502 // predicate (which additionally forbids `..` traversal): a
9503 // local-path dep's canonical author surface is the in-tree
9504 // sibling-workspace path, so a full sandboxed-relative-path
9505 // lift would structurally reject every legitimate path-fonte
9506 // dep. Pinned so a future tightening to the full predicate
9507 // surfaces here as a structural decision, not a silent break.
9508 let d = dep_with_fonte(DepSource::Path {
9509 caminho: "../caixa-teia".into(),
9510 });
9511 d.validate().unwrap();
9512 }
9513
9514 #[test]
9515 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9516 // A multi-segment relative `:caminho`
9517 // (`"vendor/forks/caixa-teia"`) remains accepted — the
9518 // absolute-path gate brackets the host-layout-leaking shape
9519 // at the leading-`/` boundary only; every relative shape past
9520 // the empty arm continues to pass. Pinned alongside the
9521 // `..`-traversal positive control so a future tightening
9522 // surfaces the full set of legitimate relative forms here
9523 // rather than at a downstream consumer.
9524 let d = dep_with_fonte(DepSource::Path {
9525 caminho: "vendor/forks/caixa-teia".into(),
9526 });
9527 d.validate().unwrap();
9528 }
9529
9530 #[test]
9531 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9532 // The fail-before-pass-after pin for the tilde-expansion
9533 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9534 // Until this gate landed the b94fd83 absolute arm let `~/foo`
9535 // through (`Path::is_absolute` returns false on a leading `~`
9536 // — the tilde is a shell-expansion convention, not a POSIX
9537 // path component), so the lacre embedded the value verbatim
9538 // and the resolver folded it through `Path::join` without
9539 // expansion, looking for a literal `./~/work/caixa-teia`
9540 // subdirectory and failing at resolve time with a
9541 // `No such file or directory` error far from the source
9542 // caixa.lisp. The new gate moves the check to validate time
9543 // and names the offending dep + caminho verbatim.
9544 let d = dep_with_fonte(DepSource::Path {
9545 caminho: "~/work/caixa-teia".into(),
9546 });
9547 let err = d.validate().unwrap_err();
9548 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9549 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9550 };
9551 assert_eq!(nome, "caixa-teia");
9552 assert_eq!(caminho, "~/work/caixa-teia");
9553 }
9554
9555 #[test]
9556 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9557 // The bare `~` form (canonical "I meant `$HOME` and forgot
9558 // the rest"): both the leading-tilde arm catches it and the
9559 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9560 // sweeps through the same arm. Pinned both to ensure the
9561 // gate doesn't narrow to `~/` only.
9562 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9563 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9564 let err = d.validate().unwrap_err();
9565 assert!(
9566 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9567 "{s:?} → {err:?}",
9568 );
9569 }
9570 }
9571
9572 #[test]
9573 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9574 // The leading-`~` is the canonical shell-expansion footgun —
9575 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9576 // backup-file-suffix idiom) is a legitimate POSIX path byte
9577 // with no shell-expansion semantic at the leading position.
9578 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9579 // sweep that would break every legitimate-shape backup-file
9580 // path.
9581 let d = dep_with_fonte(DepSource::Path {
9582 caminho: "../foo~bar/caixa-teia".into(),
9583 });
9584 d.validate().unwrap();
9585 }
9586
9587 #[test]
9588 fn fonte_caminho_empty_fires_before_tilde_expansion() {
9589 // Cascade pin: the empty arm structurally precedes the
9590 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9591 // pin establishes the precedence at the diagnostic-shape
9592 // level should a future codec round-trip ever produce a
9593 // probe-as-both value. Mirrors the peer
9594 // `fonte_repo_empty_fires_before_pin_missing` cascade
9595 // discipline.
9596 let d = dep_with_fonte(DepSource::Path {
9597 caminho: String::new(),
9598 });
9599 let err = d.validate().unwrap_err();
9600 assert!(
9601 matches!(err, DepError::FonteCaminhoEmpty { .. }),
9602 "got {err:?}",
9603 );
9604 }
9605
9606 #[test]
9607 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9608 // Diagnostic-shape pin (peer with
9609 // `validate_rejects_path_fonte_with_absolute_caminho`'s
9610 // payload assertion): the error's Display surfaces both the
9611 // offending `:nome` and the offending `:caminho` verbatim
9612 // so a `feira lint` run can render the diagnostic without
9613 // re-parsing.
9614 let d = dep_with_fonte(DepSource::Path {
9615 caminho: "~alice/dev/caixa-teia".into(),
9616 });
9617 let rendered = d.validate().unwrap_err().to_string();
9618 assert!(
9619 rendered.contains("caixa-teia"),
9620 "diagnostic must name the offending dep: {rendered}",
9621 );
9622 assert!(
9623 rendered.contains("~alice/dev/caixa-teia"),
9624 "diagnostic must quote the offending caminho: {rendered}",
9625 );
9626 assert!(
9627 rendered.contains('~'),
9628 "diagnostic must reference the tilde footgun: {rendered}",
9629 );
9630 }
9631
9632 #[test]
9633 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9634 // The fail-before-pass-after pin for the shell-variable-
9635 // expansion `:caminho` shape: `(:tipo path :caminho
9636 // "$HOME/work/caixa-teia")`. Until this gate landed the
9637 // b94fd83 absolute arm + the a5c248e tilde arm both let
9638 // `$HOME/foo` through (`Path::is_absolute` returns false on
9639 // a leading `$` — the `$` is a shell convention, not a POSIX
9640 // path component; `starts_with('~')` returns false too), so
9641 // the lacre embedded the value verbatim and the resolver
9642 // folded it through `Path::join` without `$`-expansion,
9643 // looking for a literal `./$HOME/work/caixa-teia`
9644 // subdirectory and failing at resolve time with a
9645 // `No such file or directory` error far from the source
9646 // caixa.lisp. The new gate moves the check to validate time
9647 // and names the offending dep + caminho verbatim.
9648 let d = dep_with_fonte(DepSource::Path {
9649 caminho: "$HOME/work/caixa-teia".into(),
9650 });
9651 let err = d.validate().unwrap_err();
9652 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9653 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9654 };
9655 assert_eq!(nome, "caixa-teia");
9656 assert_eq!(caminho, "$HOME/work/caixa-teia");
9657 }
9658
9659 #[test]
9660 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9661 // Sweep over every leading-`$` shape: the `${VAR}`-braced
9662 // form (canonical "paste-from-CI-manifest" footgun every
9663 // GitHub Actions / GitLab CI / Drone manifest carries on
9664 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9665 // canonical "I'm referencing a per-user config dir"),
9666 // and the bare `$` (canonical "I meant `$HOME` and forgot
9667 // the rest"). All shapes route through the same gate's
9668 // byte check. Pinned so the gate doesn't narrow to a
9669 // single shape (e.g. `$HOME/` only).
9670 for s in [
9671 "${HOME}/work/caixa-teia",
9672 "${WORKSPACE}/caixa-teia",
9673 "$XDG_CONFIG_HOME/caixa",
9674 "$",
9675 ] {
9676 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9677 let err = d.validate().unwrap_err();
9678 assert!(
9679 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9680 "{s:?} → {err:?}",
9681 );
9682 }
9683 }
9684
9685 #[test]
9686 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9687 // The `$` byte is the canonical shell-variable-expansion /
9688 // command-substitution / arithmetic-expansion sentinel and
9689 // is rejected at *every* position on the `:caminho` axis: the
9690 // leading arm surfaces `FonteCaminhoVarExpansion`, the
9691 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9692 // (6620f39). Pinned so a future arm doesn't narrow the gate
9693 // back to the leading position and re-open the paste-from-
9694 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9695 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9696 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9697 // the lacre content-address (`path:{caminho}`,
9698 // caixa-resolver/src/resolve.rs:189).
9699 let d = dep_with_fonte(DepSource::Path {
9700 caminho: "../foo$bar/caixa-teia".into(),
9701 });
9702 let err = d.validate().unwrap_err();
9703 assert!(
9704 matches!(
9705 err,
9706 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9707 ),
9708 "got {err:?}",
9709 );
9710 }
9711
9712 #[test]
9713 fn fonte_caminho_tilde_fires_before_var_expansion() {
9714 // Cascade pin: the tilde arm structurally precedes the var
9715 // arm (the bytes `~` and `$` don't overlap at the leading
9716 // position), but the pin establishes the precedence at the
9717 // diagnostic-shape level should a future codec round-trip
9718 // ever produce a probe-as-both value. Mirrors the peer
9719 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9720 // discipline on the immediate-predecessor arm.
9721 let d = dep_with_fonte(DepSource::Path {
9722 caminho: "~/work/caixa-teia".into(),
9723 });
9724 let err = d.validate().unwrap_err();
9725 assert!(
9726 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9727 "got {err:?}",
9728 );
9729 }
9730
9731 #[test]
9732 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9733 // Diagnostic-shape pin (peer with
9734 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9735 // payload assertion on the immediate-predecessor arm): the
9736 // error's Display surfaces both the offending `:nome` and
9737 // the offending `:caminho` verbatim plus the `$` footgun
9738 // character itself so a `feira lint` run can render the
9739 // diagnostic without re-parsing.
9740 let d = dep_with_fonte(DepSource::Path {
9741 caminho: "${WORKSPACE}/caixa-teia".into(),
9742 });
9743 let rendered = d.validate().unwrap_err().to_string();
9744 assert!(
9745 rendered.contains("caixa-teia"),
9746 "diagnostic must name the offending dep: {rendered}",
9747 );
9748 assert!(
9749 rendered.contains("${WORKSPACE}/caixa-teia"),
9750 "diagnostic must quote the offending caminho: {rendered}",
9751 );
9752 assert!(
9753 rendered.contains('$'),
9754 "diagnostic must reference the dollar footgun: {rendered}",
9755 );
9756 }
9757
9758 #[test]
9759 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9760 // The fail-before-pass-after pin for the load-bearing NUL byte:
9761 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9762 // routes the path through `CString::new` which fails with
9763 // `NulError`); until this gate landed a `:caminho
9764 // "../caixa\0teia"` silently passed validate, the lacre
9765 // pipeline embedded the value verbatim, and the failure
9766 // surfaced at the resolver's `Path::join` → `CString::new`
9767 // boundary with a non-self-locating `NulError` far from the
9768 // source caixa.lisp. The new gate moves the check to validate
9769 // time and names the offending dep + caminho + offending byte
9770 // verbatim.
9771 let d = dep_with_fonte(DepSource::Path {
9772 caminho: "../caixa\0teia".into(),
9773 });
9774 let err = d.validate().unwrap_err();
9775 let DepError::FonteCaminhoControlChar {
9776 nome,
9777 caminho,
9778 byte,
9779 } = err
9780 else {
9781 panic!("expected FonteCaminhoControlChar, got {err:?}");
9782 };
9783 assert_eq!(nome, "caixa-teia");
9784 assert_eq!(caminho, "../caixa\0teia");
9785 assert_eq!(byte, 0x00);
9786 }
9787
9788 #[test]
9789 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9790 // The canonical paste-from-multiline-doc footgun on `:caminho`
9791 // — author copies `"../caixa-teia\n"` (trailing newline) out
9792 // of a multi-line code-fence or, worse, a `:caminho
9793 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9794 // injection sibling on the path axis the `is_git_repo_url`
9795 // control-char arm already closes on `:repo`). Pinned
9796 // separately from the NUL arm so a future relaxation that
9797 // catches one but not the other surfaces here.
9798 let d = dep_with_fonte(DepSource::Path {
9799 caminho: "../caixa-teia\n".into(),
9800 });
9801 let err = d.validate().unwrap_err();
9802 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9803 panic!("expected FonteCaminhoControlChar, got {err:?}");
9804 };
9805 assert_eq!(byte, 0x0A);
9806 }
9807
9808 #[test]
9809 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9810 // The CRLF sibling of the LF arm — Windows-line-ending
9811 // paste-from-multiline-doc on a `\r\n`-terminated buffer
9812 // leaves a stray `\r` mid-string after the LF strip. Pinned
9813 // separately from the LF arm so a future relaxation that
9814 // only catches LF surfaces here.
9815 let d = dep_with_fonte(DepSource::Path {
9816 caminho: "../caixa-teia\r".into(),
9817 });
9818 let err = d.validate().unwrap_err();
9819 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9820 panic!("expected FonteCaminhoControlChar, got {err:?}");
9821 };
9822 assert_eq!(byte, 0x0D);
9823 }
9824
9825 #[test]
9826 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9827 // The canonical paste-from-aligned-table footgun — a `\t`
9828 // mid-`:caminho` is invisible in most editors but rides
9829 // through the lacre's content-address verbatim, so two
9830 // paste-from-distinct-tables (one editor strips tabs, one
9831 // preserves them) yield divergent lacres for the byte-
9832 // identical-looking caixa. Pinned separately from the
9833 // whitespace-shaped LF/CR arms so a future relaxation that
9834 // narrows to line-terminator-only surfaces here.
9835 let d = dep_with_fonte(DepSource::Path {
9836 caminho: "../caixa\tteia".into(),
9837 });
9838 let err = d.validate().unwrap_err();
9839 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9840 panic!("expected FonteCaminhoControlChar, got {err:?}");
9841 };
9842 assert_eq!(byte, 0x09);
9843 }
9844
9845 #[test]
9846 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9847 // The DEL byte (`0x7F`) closes the upper-end paste-from-
9848 // binary-blob footgun — the gate's contract is `b < 0x20 ||
9849 // b == 0x7F`, matching the `is_git_repo_url` /
9850 // `is_git_ref_name` predicates' control-char arms. Pinned
9851 // separately from the lower-range arms so a future narrowing
9852 // to `< 0x20` only surfaces here.
9853 let d = dep_with_fonte(DepSource::Path {
9854 caminho: "../caixa\x7fteia".into(),
9855 });
9856 let err = d.validate().unwrap_err();
9857 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9858 panic!("expected FonteCaminhoControlChar, got {err:?}");
9859 };
9860 assert_eq!(byte, 0x7F);
9861 }
9862
9863 #[test]
9864 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9865 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9866 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9867 // are opaque byte sequences and UTF-8 multi-byte sequences
9868 // are a legitimate filename shape (the `café-teia/foo` idiom).
9869 // Pinned so the gate doesn't widen to a full ASCII-only sweep
9870 // that would break every legitimate-shape UTF-8 path.
9871 let d = dep_with_fonte(DepSource::Path {
9872 caminho: "../café-teia/foo".into(),
9873 });
9874 d.validate().unwrap();
9875 }
9876
9877 #[test]
9878 fn fonte_caminho_var_fires_before_control_char() {
9879 // Cascade pin: the var-expansion arm structurally precedes the
9880 // control-char arm. A value like `"$\n"` probes positive on
9881 // both arms (`starts_with('$')` and contains LF), but the
9882 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9883 // wins so the author sees the more self-locating shell-
9884 // expansion arm first. Mirrors the
9885 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9886 // discipline on the immediate-predecessor arm.
9887 let d = dep_with_fonte(DepSource::Path {
9888 caminho: "$HOME\n".into(),
9889 });
9890 let err = d.validate().unwrap_err();
9891 assert!(
9892 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9893 "got {err:?}",
9894 );
9895 }
9896
9897 #[test]
9898 fn validate_rejects_path_fonte_with_leading_space_caminho() {
9899 // The fail-before-pass-after pin for the leading ASCII space
9900 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9901 // Until this gate landed the b94fd83 absolute arm + the a5c248e
9902 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9903 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9904 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9905 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9906 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9907 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9908 // are caught, but the most common whitespace `0x20` space is
9909 // not). The lacre embedded the value verbatim and the resolver
9910 // folded it through `Path::join` looking for a literal `./ ../
9911 // caixa-teia` subdirectory and failing at resolve time with a
9912 // non-self-locating `No such file or directory` error far from
9913 // the source caixa.lisp. The new gate moves the check to
9914 // validate time and names the offending dep + caminho verbatim.
9915 let d = dep_with_fonte(DepSource::Path {
9916 caminho: " ../caixa-teia".into(),
9917 });
9918 let err = d.validate().unwrap_err();
9919 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9920 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9921 };
9922 assert_eq!(nome, "caixa-teia");
9923 assert_eq!(caminho, " ../caixa-teia");
9924 }
9925
9926 #[test]
9927 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9928 // The aligned-doc paste footgun sweep: more than one leading
9929 // space (`" ../caixa-teia"` — the canonical "I selected the
9930 // aligned column from a four-`:fonte`-entry `:deps` block"
9931 // paste) routes through the same gate's `starts_with(' ')`
9932 // byte check. Pinned so the gate doesn't narrow to a
9933 // single-space prefix.
9934 let d = dep_with_fonte(DepSource::Path {
9935 caminho: " ../caixa-teia".into(),
9936 });
9937 let err = d.validate().unwrap_err();
9938 assert!(
9939 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9940 "got {err:?}",
9941 );
9942 }
9943
9944 #[test]
9945 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9946 // The leading-space is the canonical paste-from-aligned-doc
9947 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9948 // canonical "I have a directory with a space in its name"
9949 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9950 // legitimate path with no whitespace-leak semantic at the
9951 // non-leading position. Pinned so the gate doesn't widen to a
9952 // full no-space-anywhere sweep that would break every
9953 // legitimate-shape space-in-filename path.
9954 let d = dep_with_fonte(DepSource::Path {
9955 caminho: "../my dir/caixa-teia".into(),
9956 });
9957 d.validate().unwrap();
9958 }
9959
9960 #[test]
9961 fn fonte_caminho_var_fires_before_leading_whitespace() {
9962 // Cascade pin: the var-expansion arm structurally precedes the
9963 // leading-whitespace arm. A value like `"$ "` would probe positive
9964 // on var (`starts_with('$')`) but the leading-byte arms walk
9965 // left-to-right so the var arm fires on the leading `$` before
9966 // the leading-whitespace arm probes. Mirrors the
9967 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9968 // discipline on the immediate-predecessor arms.
9969 let d = dep_with_fonte(DepSource::Path {
9970 caminho: "$VAR".into(),
9971 });
9972 let err = d.validate().unwrap_err();
9973 assert!(
9974 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9975 "got {err:?}",
9976 );
9977 }
9978
9979 #[test]
9980 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9981 // Cascade pin: the leading-whitespace arm structurally precedes
9982 // the control-char arm. A value like `" ../foo\n"` probes
9983 // positive on both (starts with space AND contains LF), but
9984 // the narrower leading-byte diagnostic
9985 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9986 // more self-locating paste-from-aligned-doc arm first. Mirrors
9987 // the `fonte_caminho_var_fires_before_control_char` cascade
9988 // discipline on the immediate-predecessor arm.
9989 let d = dep_with_fonte(DepSource::Path {
9990 caminho: " ../foo\n".into(),
9991 });
9992 let err = d.validate().unwrap_err();
9993 assert!(
9994 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9995 "got {err:?}",
9996 );
9997 }
9998
9999 #[test]
10000 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10001 // Diagnostic-shape pin (peer with
10002 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10003 // payload assertion on the immediate-predecessor arm): the
10004 // error's Display surfaces both the offending `:nome` and the
10005 // offending `:caminho` verbatim, so a `feira lint` run can
10006 // render the diagnostic without re-parsing and the author can
10007 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10008 // one edit.
10009 let d = dep_with_fonte(DepSource::Path {
10010 caminho: " ../caixa-teia".into(),
10011 });
10012 let rendered = d.validate().unwrap_err().to_string();
10013 assert!(
10014 rendered.contains("caixa-teia"),
10015 "diagnostic must name the offending dep: {rendered}",
10016 );
10017 assert!(
10018 rendered.contains(" ../caixa-teia"),
10019 "diagnostic must quote the offending caminho: {rendered}",
10020 );
10021 assert!(
10022 rendered.contains("space"),
10023 "diagnostic must name the space footgun: {rendered}",
10024 );
10025 }
10026
10027 #[test]
10028 fn fonte_caminho_absolute_fires_before_control_char() {
10029 // Cascade pin on the sibling leading-byte arm: a leading `/`
10030 // value with embedded control byte (`"/etc/passwd\n"`) routes
10031 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10032 // — the host-layout-leak diagnostic is the load-bearing axis,
10033 // the control byte is the secondary observation. Same precedence
10034 // logic on every prior leading-byte arm.
10035 let d = dep_with_fonte(DepSource::Path {
10036 caminho: "/etc/passwd\n".into(),
10037 });
10038 let err = d.validate().unwrap_err();
10039 assert!(
10040 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10041 "got {err:?}",
10042 );
10043 }
10044
10045 #[test]
10046 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10047 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10048 // injection `:caminho` shape sweep. Until this gate landed
10049 // every prior leading-byte arm passed a leading-`-` value
10050 // through: `Path::is_absolute` returns false on `-` (the
10051 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10052 // `starts_with('$')` / `starts_with(' ')` all return false,
10053 // and `0x2D` sits outside the control-byte set. The lacre
10054 // embedded the value verbatim and the resolver folded it
10055 // through `Path::join` looking for a literal `./-rf` /
10056 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10057 // `Path::join` time is non-self-locating but harmless, while
10058 // the failure at every downstream `git -C {caminho}` /
10059 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10060 // is arbitrary-CLI-arg-injection because none of those
10061 // porcelains carry a `--` argument-list terminator between
10062 // the flag block and the path argument. The new arm moves the
10063 // rejection to `Caixa::from_lisp` boundary time and names
10064 // the offending dep + caminho verbatim.
10065 //
10066 // Sweep spans the canonical CLI-arg-injection shapes matching
10067 // the peer sweep on the sibling `is_git_ref_name` /
10068 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10069 // `find -rf` reinterpretation vector), `-C` (the `git -C`
10070 // change-directory-config-injection paste), long-flag
10071 // `--upload-pack=cat /etc/passwd` (the canonical
10072 // arbitrary-command-execution vector on every git porcelain
10073 // entry point), git-config-injection `--config=core.merge=ours`,
10074 // and the degenerate single-byte `-` value.
10075 for caminho in [
10076 "-rf",
10077 "-C",
10078 "--upload-pack=cat /etc/passwd",
10079 "--config=core.merge=ours",
10080 "-",
10081 ] {
10082 let d = dep_with_fonte(DepSource::Path {
10083 caminho: caminho.into(),
10084 });
10085 let err = d.validate().unwrap_err();
10086 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10087 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10088 };
10089 assert_eq!(nome, "caixa-teia");
10090 assert_eq!(got, caminho);
10091 }
10092 }
10093
10094 #[test]
10095 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10096 // The leading-`-` is the canonical CLI-arg-injection footgun
10097 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10098 // canonical kebab-separator-between-alphanumeric-segments
10099 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10100 // — a mid-path segment starting with `-`, still a legitimate
10101 // POSIX filename byte at that non-leading position because the
10102 // subprocess reads the whole `{caminho}` value as one positional
10103 // argument, so only the very first byte of the composite path
10104 // string is at the CLI-arg-injection boundary) is a legitimate
10105 // path with no CLI-flag-reinterpretation semantic at the non-
10106 // leading position of the top-level value. Pinned so the gate
10107 // doesn't widen to a full no-`-`-anywhere sweep that would
10108 // break every legitimate-shape kebab-in-filename path (i.e.
10109 // essentially every sibling-workspace caixa dep).
10110 for caminho in [
10111 "../caixa-teia",
10112 "../caixa-teia/-hidden",
10113 "./my-lib",
10114 "../foo-bar/baz",
10115 ] {
10116 let d = dep_with_fonte(DepSource::Path {
10117 caminho: caminho.into(),
10118 });
10119 d.validate()
10120 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10121 }
10122 }
10123
10124 #[test]
10125 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10126 // Cascade pin: the leading-whitespace arm structurally precedes
10127 // the leading-hyphen arm. A value like `" -rf"` probes positive
10128 // on both (leading space AND, one byte in, a `-` — though the
10129 // leading-hyphen arm probes only the very first byte so it
10130 // wouldn't fire on this value; the pin instead documents the
10131 // arm order on the more common "leading space then a hyphen"
10132 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10133 // The narrower leading-space diagnostic (the paste-from-aligned-
10134 // doc footgun) wins so the author sees the more self-locating
10135 // whitespace arm first. Mirrors the
10136 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10137 // discipline on the immediate-predecessor arm.
10138 let d = dep_with_fonte(DepSource::Path {
10139 caminho: " -rf".into(),
10140 });
10141 let err = d.validate().unwrap_err();
10142 assert!(
10143 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10144 "got {err:?}",
10145 );
10146 }
10147
10148 #[test]
10149 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10150 // Cascade pin: the leading-hyphen arm structurally precedes
10151 // the control-char arm. A value like `"-rf\n"` probes positive
10152 // on both (starts with `-` AND contains LF), but the narrower
10153 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10154 // the author sees the more self-locating CLI-arg-injection arm
10155 // first. Mirrors the
10156 // `fonte_caminho_leading_whitespace_fires_before_control_char`
10157 // cascade discipline on the immediate-predecessor arm.
10158 let d = dep_with_fonte(DepSource::Path {
10159 caminho: "-rf\n".into(),
10160 });
10161 let err = d.validate().unwrap_err();
10162 assert!(
10163 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10164 "got {err:?}",
10165 );
10166 }
10167
10168 #[test]
10169 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10170 // Diagnostic-shape pin (peer with
10171 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10172 // payload assertion on the immediate-predecessor arm): the
10173 // error's Display surfaces both the offending `:nome` and the
10174 // offending `:caminho` verbatim plus the CLI-argument-injection
10175 // vocabulary, so a `feira lint` run can render the diagnostic
10176 // without re-parsing and the author can grep their caixa.lisp
10177 // for `:caminho "<value>"` and fix it in one edit.
10178 let d = dep_with_fonte(DepSource::Path {
10179 caminho: "--upload-pack=cat /etc/passwd".into(),
10180 });
10181 let rendered = d.validate().unwrap_err().to_string();
10182 assert!(
10183 rendered.contains("caixa-teia"),
10184 "diagnostic must name the offending dep: {rendered}",
10185 );
10186 assert!(
10187 rendered.contains("--upload-pack=cat /etc/passwd"),
10188 "diagnostic must quote the offending caminho: {rendered}",
10189 );
10190 assert!(
10191 rendered.contains("CLI-argument-injection"),
10192 "diagnostic must name the CLI-argument-injection vector: {rendered}",
10193 );
10194 assert!(
10195 rendered.contains("`-`"),
10196 "diagnostic must name the offending byte: {rendered}",
10197 );
10198 }
10199
10200 #[test]
10201 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10202 // Diagnostic-shape pin (peer with
10203 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10204 // payload assertion on the immediate-predecessor arm): the
10205 // error's Display surfaces the offending `:nome`, the
10206 // offending `:caminho` verbatim, and the offending byte in
10207 // hex form (`0x09` for tab) so a `feira lint` run can render
10208 // the diagnostic without re-parsing.
10209 let d = dep_with_fonte(DepSource::Path {
10210 caminho: "../caixa\tteia".into(),
10211 });
10212 let rendered = d.validate().unwrap_err().to_string();
10213 assert!(
10214 rendered.contains("caixa-teia"),
10215 "diagnostic must name the offending dep: {rendered}",
10216 );
10217 assert!(
10218 rendered.contains("../caixa\tteia"),
10219 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10220 );
10221 assert!(
10222 rendered.contains("0x09"),
10223 "diagnostic must name the offending byte in hex: {rendered:?}",
10224 );
10225 }
10226
10227 #[test]
10228 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10229 // The fail-before-pass-after pin for the canonical Windows-
10230 // path-separator paste footgun: an author who pastes a path
10231 // from Windows-Explorer's `Copy as path`, PowerShell's
10232 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10233 // produces `..\caixa-teia`-shape values that silently passed
10234 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10235 // false; `\` is neither a leading-byte sentinel nor a
10236 // control byte). On POSIX resolvers the value rides through
10237 // `Path::join` as a literal directory name and fails at
10238 // resolve time with `No such file or directory`; on Windows
10239 // resolvers the value resolves to the parent's sibling — two
10240 // distinct directories for the byte-identical caixa.lisp.
10241 // The new arm moves the rejection to validate time and names
10242 // the offending dep + caminho verbatim.
10243 let d = dep_with_fonte(DepSource::Path {
10244 caminho: "..\\caixa-teia".into(),
10245 });
10246 let err = d.validate().unwrap_err();
10247 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10248 panic!("expected FonteCaminhoBackslash, got {err:?}");
10249 };
10250 assert_eq!(nome, "caixa-teia");
10251 assert_eq!(caminho, "..\\caixa-teia");
10252 }
10253
10254 #[test]
10255 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10256 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10257 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10258 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10259 // false (POSIX absolute paths start with `/`, drive letters
10260 // are not a POSIX concept), so the b94fd83 absolute arm
10261 // doesn't fire; the value contains `\` bytes that this arm
10262 // now catches with the more self-locating Windows-path-
10263 // separator diagnostic. Pinned separately from the bare
10264 // `..\caixa-teia` shape so a future arm that targets only
10265 // leading-`..\` doesn't regress the drive-letter coverage.
10266 let d = dep_with_fonte(DepSource::Path {
10267 caminho: "C:\\work\\caixa-teia".into(),
10268 });
10269 let err = d.validate().unwrap_err();
10270 assert!(
10271 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10272 "got {err:?}",
10273 );
10274 }
10275
10276 #[test]
10277 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10278 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10279 // PowerShell tab-completion-on-a-directory append). Pinned
10280 // separately from the embedded-`\` shape so the gate's
10281 // contract is "any `\` anywhere", not "any `\` not at end".
10282 let d = dep_with_fonte(DepSource::Path {
10283 caminho: "..\\caixa-teia\\".into(),
10284 });
10285 let err = d.validate().unwrap_err();
10286 assert!(
10287 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10288 "got {err:?}",
10289 );
10290 }
10291
10292 #[test]
10293 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10294 // The positive-control pin: the gate targets `\` only,
10295 // never `/`. The canonical relative POSIX path
10296 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10297 // so legitimate nested-directory deps aren't broken. Pinned
10298 // so the gate doesn't accidentally widen to a "no path
10299 // separators at all" sweep.
10300 let d = dep_with_fonte(DepSource::Path {
10301 caminho: "../caixa-teia/foo/bar".into(),
10302 });
10303 d.validate().unwrap();
10304 }
10305
10306 #[test]
10307 fn fonte_caminho_control_char_fires_before_backslash() {
10308 // Cascade pin: the control-char arm structurally precedes the
10309 // backslash arm. A value like `"..\caixa\0teia"` probes
10310 // positive on both (`\` byte + NUL byte), but the control-
10311 // char diagnostic wins so the author sees the more self-
10312 // locating POSIX-syscall-rejected-byte diagnostic first
10313 // (NUL outright breaks `CString::new` at every `std::fs`
10314 // syscall boundary; the `\` divergence is the cross-OS-
10315 // separator axis). Mirrors the
10316 // `fonte_caminho_var_fires_before_control_char` cascade
10317 // discipline on the immediate-predecessor arm.
10318 let d = dep_with_fonte(DepSource::Path {
10319 caminho: "..\\caixa\0teia".into(),
10320 });
10321 let err = d.validate().unwrap_err();
10322 assert!(
10323 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10324 "got {err:?}",
10325 );
10326 }
10327
10328 #[test]
10329 fn fonte_caminho_absolute_fires_before_backslash() {
10330 // Cascade pin on the load-bearing leading-byte arm: a leading
10331 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10332 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10333 // — the host-layout-leak diagnostic is the load-bearing
10334 // axis, the `\` byte is the secondary observation. Same
10335 // precedence logic as every prior leading-byte arm.
10336 let d = dep_with_fonte(DepSource::Path {
10337 caminho: "/etc/passwd\\foo".into(),
10338 });
10339 let err = d.validate().unwrap_err();
10340 assert!(
10341 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10342 "got {err:?}",
10343 );
10344 }
10345
10346 #[test]
10347 fn fonte_caminho_var_fires_before_backslash() {
10348 // Cascade pin on the var-expansion arm: a leading-`$` value
10349 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10350 // PowerShell-env-var paste-from-CI-manifest footgun) routes
10351 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10352 // The shell-expansion diagnostic is the more self-locating
10353 // axis since both the leading `$` and the embedded `\`
10354 // are Windows-shell artifacts but the `$` is the root-cause
10355 // surface (an author who removes the `$` is likely to leave
10356 // the `\` too).
10357 let d = dep_with_fonte(DepSource::Path {
10358 caminho: "$WORKSPACE\\caixa-teia".into(),
10359 });
10360 let err = d.validate().unwrap_err();
10361 assert!(
10362 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10363 "got {err:?}",
10364 );
10365 }
10366
10367 #[test]
10368 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10369 // Diagnostic-shape pin (peer with the prior
10370 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10371 // on every preceding arm): the error's Display surfaces the
10372 // offending `:nome` and the offending `:caminho` verbatim
10373 // so a `feira lint` run can render the diagnostic without
10374 // re-parsing.
10375 let d = dep_with_fonte(DepSource::Path {
10376 caminho: "..\\caixa-teia".into(),
10377 });
10378 let rendered = d.validate().unwrap_err().to_string();
10379 assert!(
10380 rendered.contains("caixa-teia"),
10381 "diagnostic must name the offending dep: {rendered}",
10382 );
10383 assert!(
10384 rendered.contains("..\\caixa-teia"),
10385 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10386 );
10387 assert!(
10388 rendered.contains('\\'),
10389 "diagnostic must reference the backslash footgun: {rendered:?}",
10390 );
10391 }
10392
10393 #[test]
10394 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10395 // The fail-before-pass-after pin for the canonical trailing-`/`
10396 // paste footgun: an author who shell-tab-completes a sibling
10397 // directory (every interactive shell — bash/zsh/fish/nushell —
10398 // appends `/` on tab-completing a directory) produces
10399 // `"../caixa-teia/"`-shape values that silently passed every
10400 // prior arm (the leading byte is `.`, no control bytes, no
10401 // backslash). `Path::join` resolves both shapes to the same
10402 // directory at the resolver, but the lacre embeds the value
10403 // verbatim and the BLAKE3 closures diverge across two
10404 // workstations whose authors differ only in tab-completion
10405 // habits.
10406 let d = dep_with_fonte(DepSource::Path {
10407 caminho: "../caixa-teia/".into(),
10408 });
10409 let err = d.validate().unwrap_err();
10410 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10411 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10412 };
10413 assert_eq!(nome, "caixa-teia");
10414 assert_eq!(caminho, "../caixa-teia/");
10415 }
10416
10417 #[test]
10418 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10419 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10420 // directory and tab-completed it" footgun). Pinned separately
10421 // from the canonical `"../caixa-teia/"` shape so the gate's
10422 // contract is "any trailing `/`", not "trailing `/` after a leaf
10423 // name".
10424 let d = dep_with_fonte(DepSource::Path {
10425 caminho: "./".into(),
10426 });
10427 let err = d.validate().unwrap_err();
10428 assert!(
10429 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10430 "got {err:?}",
10431 );
10432 }
10433
10434 #[test]
10435 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10436 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10437 // that double-templated `${VAR}/` over an already-`/`-suffixed
10438 // path" footgun). The gate fires on the last byte being `/`
10439 // regardless of how many `/` precede it; the arm contract is
10440 // "the value ends with `/`", structurally.
10441 let d = dep_with_fonte(DepSource::Path {
10442 caminho: "../caixa-teia//".into(),
10443 });
10444 let err = d.validate().unwrap_err();
10445 assert!(
10446 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10447 "got {err:?}",
10448 );
10449 }
10450
10451 #[test]
10452 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10453 // The `"../"` shape (the canonical "I want the parent" tab-
10454 // completion footgun on a bare `..` path). Pinned separately so
10455 // the gate doesn't accidentally narrow to "trailing `/` only on
10456 // multi-segment paths".
10457 let d = dep_with_fonte(DepSource::Path {
10458 caminho: "../".into(),
10459 });
10460 let err = d.validate().unwrap_err();
10461 assert!(
10462 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10463 "got {err:?}",
10464 );
10465 }
10466
10467 #[test]
10468 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10469 // The positive-control pin: the gate targets the trailing byte
10470 // only, never internal `/` separators. The canonical nested
10471 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10472 // to validate cleanly so legitimate deeply-nested deps aren't
10473 // broken. Pinned so the gate doesn't accidentally widen to a
10474 // "no `/` separators anywhere" sweep that would defeat the
10475 // entire path-fonte author surface.
10476 let d = dep_with_fonte(DepSource::Path {
10477 caminho: "../caixa-teia/foo/bar".into(),
10478 });
10479 d.validate().unwrap();
10480 }
10481
10482 #[test]
10483 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10484 // The positive-control pin on the degenerate single-`.` shape
10485 // (the canonical "the caixa.lisp's own directory" idiom). The
10486 // gate fires on the trailing byte being `/`, not on the path
10487 // being short, so `"."` (one byte, not `/`) must continue to
10488 // validate cleanly.
10489 let d = dep_with_fonte(DepSource::Path {
10490 caminho: ".".into(),
10491 });
10492 d.validate().unwrap();
10493 }
10494
10495 #[test]
10496 fn fonte_caminho_control_char_fires_before_trailing_slash() {
10497 // Cascade pin: the control-char arm structurally precedes the
10498 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10499 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10500 // (control bytes are the paste-from-multiline-doc footgun the
10501 // d624c8d arm already closes). Mirrors the
10502 // `fonte_caminho_control_char_fires_before_backslash` cascade
10503 // discipline on the immediate-predecessor arm.
10504 let d = dep_with_fonte(DepSource::Path {
10505 caminho: "../foo\n/".into(),
10506 });
10507 let err = d.validate().unwrap_err();
10508 assert!(
10509 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10510 "got {err:?}",
10511 );
10512 }
10513
10514 #[test]
10515 fn fonte_caminho_backslash_fires_before_trailing_slash() {
10516 // Cascade pin on the backslash arm: a value like `"..\foo/"`
10517 // ends in `/` but the embedded `\` is the load-bearing
10518 // diagnostic (the cross-host-OS-separator divergence vector
10519 // the 3a4e1d7 arm closes). Same precedence logic as the prior
10520 // narrower-diagnostic-first cascade.
10521 let d = dep_with_fonte(DepSource::Path {
10522 caminho: "..\\caixa-teia/".into(),
10523 });
10524 let err = d.validate().unwrap_err();
10525 assert!(
10526 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10527 "got {err:?}",
10528 );
10529 }
10530
10531 #[test]
10532 fn fonte_caminho_absolute_fires_before_trailing_slash() {
10533 // Cascade pin on the load-bearing leading-byte arm: a leading
10534 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10535 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10536 // — the host-layout-leak diagnostic is the load-bearing axis,
10537 // the trailing `/` is the secondary observation. Same
10538 // precedence logic as every prior leading-byte arm.
10539 let d = dep_with_fonte(DepSource::Path {
10540 caminho: "/etc/passwd/".into(),
10541 });
10542 let err = d.validate().unwrap_err();
10543 assert!(
10544 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10545 "got {err:?}",
10546 );
10547 }
10548
10549 #[test]
10550 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10551 // Diagnostic-shape pin (peer with the prior
10552 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10553 // every preceding arm): the error's Display surfaces the
10554 // offending `:nome` and the offending `:caminho` verbatim so a
10555 // `feira lint` run can render the diagnostic without re-parsing.
10556 let d = dep_with_fonte(DepSource::Path {
10557 caminho: "../caixa-teia/".into(),
10558 });
10559 let rendered = d.validate().unwrap_err().to_string();
10560 assert!(
10561 rendered.contains("caixa-teia"),
10562 "diagnostic must name the offending dep: {rendered}",
10563 );
10564 assert!(
10565 rendered.contains("../caixa-teia/"),
10566 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10567 );
10568 assert!(
10569 rendered.contains("trailing"),
10570 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10571 );
10572 }
10573
10574 // -- :caminho shell-redirection metacharacter arm -----------------------
10575
10576 #[test]
10577 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10578 // The fail-before-pass-after pin for the canonical output-redirection
10579 // paste footgun: an author copies a shell pipeline tail
10580 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10581 // line including the `> build.log` redirect" idiom) and silently
10582 // passed every prior arm (`Path::is_absolute` false on `..`, no
10583 // control bytes, no backslash, doesn't end in `/`). The lacre
10584 // embedded the value verbatim, the resolver folded it through
10585 // `Path::join` looking for a literal `./../caixa-teia>build.log`
10586 // subdirectory, and the failure surfaced at resolve time with a
10587 // non-self-locating `No such file or directory` error. The new arm
10588 // moves the rejection to validate time and names the offending dep
10589 // + caminho + byte verbatim.
10590 let d = dep_with_fonte(DepSource::Path {
10591 caminho: "../caixa-teia>build.log".into(),
10592 });
10593 let err = d.validate().unwrap_err();
10594 let DepError::FonteCaminhoShellRedirection {
10595 nome,
10596 caminho,
10597 byte,
10598 } = err
10599 else {
10600 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10601 };
10602 assert_eq!(nome, "caixa-teia");
10603 assert_eq!(caminho, "../caixa-teia>build.log");
10604 assert_eq!(byte, b'>');
10605 }
10606
10607 #[test]
10608 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10609 // The symmetric input-redirection paste shape
10610 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10611 // `command < input.lisp` line from a tatara-lisp REPL log"
10612 // idiom). Pinned separately from the `>` shape so the gate's
10613 // contract is "any `<` or `>` anywhere", not single-byte coverage.
10614 let d = dep_with_fonte(DepSource::Path {
10615 caminho: "../caixa-teia<input.lisp".into(),
10616 });
10617 let err = d.validate().unwrap_err();
10618 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10619 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10620 };
10621 assert_eq!(byte, b'<');
10622 }
10623
10624 #[test]
10625 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10626 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10627 // "I forgot the source side of the redirect" idiom). Pinned
10628 // separately from the embedded-byte shapes so the gate covers
10629 // every position, not only mid-path.
10630 let d = dep_with_fonte(DepSource::Path {
10631 caminho: ">../caixa-teia".into(),
10632 });
10633 let err = d.validate().unwrap_err();
10634 assert!(
10635 matches!(
10636 err,
10637 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10638 ),
10639 "got {err:?}",
10640 );
10641 }
10642
10643 #[test]
10644 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10645 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10646 // the canonical "I copied a `>>` append redirect" idiom). The arm
10647 // fires on the first `>` encountered; pinned so a future arm that
10648 // tries to distinguish `>` from `>>` doesn't break the broader
10649 // contract.
10650 let d = dep_with_fonte(DepSource::Path {
10651 caminho: "../caixa-teia>>build.log".into(),
10652 });
10653 let err = d.validate().unwrap_err();
10654 assert!(
10655 matches!(
10656 err,
10657 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10658 ),
10659 "got {err:?}",
10660 );
10661 }
10662
10663 #[test]
10664 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10665 // The positive-control pin: the gate targets only `<` / `>`,
10666 // never adjacent printable ASCII or POSIX-valid bytes. The
10667 // canonical relative POSIX path (`"../caixa-teia"`) and a
10668 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10669 // continue to validate cleanly so the gate doesn't widen to a
10670 // "no printable punctuation anywhere" sweep that would defeat
10671 // the entire path-fonte author surface.
10672 let d = dep_with_fonte(DepSource::Path {
10673 caminho: "../caixa-teia/foo/bar".into(),
10674 });
10675 d.validate().unwrap();
10676 }
10677
10678 #[test]
10679 fn fonte_caminho_backslash_fires_before_shell_redirection() {
10680 // Cascade pin on the immediate-predecessor arm: a value carrying
10681 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10682 // canonical "I pasted a Windows-shell command with output
10683 // redirect" footgun) routes through `FonteCaminhoBackslash` not
10684 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10685 // divergence is the load-bearing axis (an author who removes
10686 // the `\` is the root-cause edit; the `>` falls away in the
10687 // same edit since it's downstream of the Windows-shell
10688 // convention).
10689 let d = dep_with_fonte(DepSource::Path {
10690 caminho: "..\\caixa-teia>build.log".into(),
10691 });
10692 let err = d.validate().unwrap_err();
10693 assert!(
10694 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10695 "got {err:?}",
10696 );
10697 }
10698
10699 #[test]
10700 fn fonte_caminho_control_char_fires_before_shell_redirection() {
10701 // Cascade pin on the embedded-control-byte arm: a value carrying
10702 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10703 // canonical paste-from-multiline-doc footgun where a newline
10704 // landed mid-caminho) routes through `FonteCaminhoControlChar`
10705 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10706 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10707 // load-bearing axis on every value that probes positive for
10708 // both — mirrors the cascade discipline on every prior arm.
10709 let d = dep_with_fonte(DepSource::Path {
10710 caminho: "../foo\n>bar".into(),
10711 });
10712 let err = d.validate().unwrap_err();
10713 assert!(
10714 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10715 "got {err:?}",
10716 );
10717 }
10718
10719 #[test]
10720 fn fonte_caminho_absolute_fires_before_shell_redirection() {
10721 // Cascade pin on the load-bearing leading-byte arm: a leading
10722 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10723 // routes through `FonteCaminhoAbsolute` not
10724 // `FonteCaminhoShellRedirection` — the host-layout-leak
10725 // diagnostic is the load-bearing axis, the `>` byte is the
10726 // secondary observation. Same precedence logic as every prior
10727 // leading-byte arm.
10728 let d = dep_with_fonte(DepSource::Path {
10729 caminho: "/etc/passwd>out".into(),
10730 });
10731 let err = d.validate().unwrap_err();
10732 assert!(
10733 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10734 "got {err:?}",
10735 );
10736 }
10737
10738 #[test]
10739 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10740 // Cascade pin on the immediate-successor arm: a value carrying
10741 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10742 // canonical "I tab-completed a path that already had a
10743 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10744 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10745 // the more semantic-locating axis (an author who removes the
10746 // `<` / `>` typically also drops the trailing separator since
10747 // both are paste-from-shell artifacts).
10748 let d = dep_with_fonte(DepSource::Path {
10749 caminho: "../foo></".into(),
10750 });
10751 let err = d.validate().unwrap_err();
10752 assert!(
10753 matches!(
10754 err,
10755 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10756 ),
10757 "got {err:?}",
10758 );
10759 }
10760
10761 #[test]
10762 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10763 // Diagnostic-shape pin (peer with
10764 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10765 // payload assertion on the closest peer arm that also carries a
10766 // `byte` field): the error's Display surfaces the offending
10767 // `:nome`, the offending `:caminho` verbatim, and the offending
10768 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10769 // run can render the diagnostic without re-parsing.
10770 let d = dep_with_fonte(DepSource::Path {
10771 caminho: "../caixa-teia>build.log".into(),
10772 });
10773 let rendered = d.validate().unwrap_err().to_string();
10774 assert!(
10775 rendered.contains("caixa-teia"),
10776 "diagnostic must name the offending dep: {rendered}",
10777 );
10778 assert!(
10779 rendered.contains("../caixa-teia>build.log"),
10780 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10781 );
10782 assert!(
10783 rendered.contains("0x3e"),
10784 "diagnostic must name the offending byte in hex: {rendered:?}",
10785 );
10786 assert!(
10787 rendered.contains("redirection"),
10788 "diagnostic must name the shell-redirection footgun: {rendered:?}",
10789 );
10790 }
10791
10792 // -- :caminho shell-pipe metacharacter arm ----------------------------
10793
10794 #[test]
10795 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10796 // The fail-before-pass-after pin for the canonical shell-pipe
10797 // paste footgun: an author copies a shell-history line
10798 // (`"../caixa-teia | grep foo"` — the canonical "I selected
10799 // the whole `ls dir | grep` line out of zsh history") and
10800 // silently passed every prior arm (`Path::is_absolute` false
10801 // on `..`, no control bytes, no backslash, no `<` / `>`,
10802 // doesn't end in `/`). The lacre embedded the value verbatim,
10803 // the resolver folded it through `Path::join` looking for a
10804 // literal `./../caixa-teia | grep foo` subdirectory, and the
10805 // failure surfaced at resolve time with a non-self-locating
10806 // `No such file or directory` error. The new arm moves the
10807 // rejection to validate time and names the offending dep +
10808 // caminho verbatim.
10809 let d = dep_with_fonte(DepSource::Path {
10810 caminho: "../caixa-teia | grep foo".into(),
10811 });
10812 let err = d.validate().unwrap_err();
10813 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10814 panic!("expected FonteCaminhoShellPipe, got {err:?}");
10815 };
10816 assert_eq!(nome, "caixa-teia");
10817 assert_eq!(caminho, "../caixa-teia | grep foo");
10818 }
10819
10820 #[test]
10821 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10822 // Leading-position `|` shape (`"|../caixa-teia"` — the
10823 // degenerate "I forgot the source side of the pipe" idiom).
10824 // Pinned separately from the embedded-byte shape so the gate
10825 // covers every position, not only mid-path.
10826 let d = dep_with_fonte(DepSource::Path {
10827 caminho: "|../caixa-teia".into(),
10828 });
10829 let err = d.validate().unwrap_err();
10830 assert!(
10831 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10832 "got {err:?}",
10833 );
10834 }
10835
10836 #[test]
10837 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10838 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10839 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10840 // idiom). The arm fires on the first `|` encountered; pinned
10841 // so a future arm that tries to distinguish `|` from `||`
10842 // doesn't break the broader contract.
10843 let d = dep_with_fonte(DepSource::Path {
10844 caminho: "../caixa-teia||fallback".into(),
10845 });
10846 let err = d.validate().unwrap_err();
10847 assert!(
10848 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10849 "got {err:?}",
10850 );
10851 }
10852
10853 #[test]
10854 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10855 // The positive-control pin: the gate targets only `|`, never
10856 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10857 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10858 // pathed variant with adjacent printable punctuation
10859 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10860 // cleanly so the gate doesn't widen to a "no printable
10861 // punctuation anywhere" sweep that would defeat the entire
10862 // path-fonte author surface.
10863 let d = dep_with_fonte(DepSource::Path {
10864 caminho: "../caixa-teia/sub-dir.v2".into(),
10865 });
10866 d.validate().unwrap();
10867 }
10868
10869 #[test]
10870 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10871 // Cascade pin on the immediate-predecessor arm: a value carrying
10872 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10873 // canonical "I pasted a `cmd < input | tee` pipeline tail"
10874 // footgun) routes through `FonteCaminhoShellRedirection` not
10875 // `FonteCaminhoShellPipe`. The input/output redirection
10876 // metachar carries the more self-locating `byte: u8` payload
10877 // (it names which of `<` or `>` triggered), so the prior arm
10878 // wins on every probe-as-both value — same cascade discipline
10879 // every prior `:caminho` arm establishes.
10880 let d = dep_with_fonte(DepSource::Path {
10881 caminho: "../caixa-teia<input|tee".into(),
10882 });
10883 let err = d.validate().unwrap_err();
10884 assert!(
10885 matches!(
10886 err,
10887 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10888 ),
10889 "got {err:?}",
10890 );
10891 }
10892
10893 #[test]
10894 fn fonte_caminho_backslash_fires_before_shell_pipe() {
10895 // Cascade pin on the upstream backslash arm: a value carrying
10896 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10897 // "I pasted a Windows-shell command with pipe to tee"
10898 // footgun) routes through `FonteCaminhoBackslash` not
10899 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10900 // divergence is the load-bearing axis on every probe-as-both
10901 // value (an author who removes the `\` is the root-cause edit;
10902 // the `|` falls away in the same edit since it's downstream of
10903 // the Windows-shell convention).
10904 let d = dep_with_fonte(DepSource::Path {
10905 caminho: "..\\caixa-teia|tee".into(),
10906 });
10907 let err = d.validate().unwrap_err();
10908 assert!(
10909 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10910 "got {err:?}",
10911 );
10912 }
10913
10914 #[test]
10915 fn fonte_caminho_control_char_fires_before_shell_pipe() {
10916 // Cascade pin on the embedded-control-byte arm: a value
10917 // carrying both a control byte and `|` (`"../foo\n|bar"` —
10918 // the canonical paste-from-multiline-doc footgun where a
10919 // newline landed mid-caminho) routes through
10920 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10921 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10922 // diagnostic is the load-bearing axis on every value that
10923 // probes positive for both — mirrors the cascade discipline
10924 // on every prior arm.
10925 let d = dep_with_fonte(DepSource::Path {
10926 caminho: "../foo\n|bar".into(),
10927 });
10928 let err = d.validate().unwrap_err();
10929 assert!(
10930 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10931 "got {err:?}",
10932 );
10933 }
10934
10935 #[test]
10936 fn fonte_caminho_absolute_fires_before_shell_pipe() {
10937 // Cascade pin on the load-bearing leading-byte arm: a leading
10938 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10939 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10940 // — the host-layout-leak diagnostic is the load-bearing axis,
10941 // the `|` byte is the secondary observation. Same precedence
10942 // logic as every prior leading-byte arm.
10943 let d = dep_with_fonte(DepSource::Path {
10944 caminho: "/etc/passwd|tee".into(),
10945 });
10946 let err = d.validate().unwrap_err();
10947 assert!(
10948 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10949 "got {err:?}",
10950 );
10951 }
10952
10953 #[test]
10954 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10955 // Cascade pin on the immediate-successor arm: a value carrying
10956 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10957 // "I tab-completed a path that already had a pipeline tail"
10958 // footgun) routes through `FonteCaminhoShellPipe` not
10959 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10960 // the more semantic-locating axis (an author who removes the
10961 // `|` typically also drops the trailing separator since both
10962 // are paste-from-shell artifacts).
10963 let d = dep_with_fonte(DepSource::Path {
10964 caminho: "../foo|tee/".into(),
10965 });
10966 let err = d.validate().unwrap_err();
10967 assert!(
10968 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10969 "got {err:?}",
10970 );
10971 }
10972
10973 #[test]
10974 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10975 // Diagnostic-shape pin (peer with
10976 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10977 // on the closest single-byte peer arm): the error's Display
10978 // surfaces the offending `:nome` and the offending `:caminho`
10979 // verbatim, and names the shell-pipe footgun explicitly so a
10980 // `feira lint` run can render the diagnostic without
10981 // re-parsing.
10982 let d = dep_with_fonte(DepSource::Path {
10983 caminho: "../caixa-teia | grep foo".into(),
10984 });
10985 let rendered = d.validate().unwrap_err().to_string();
10986 assert!(
10987 rendered.contains("caixa-teia"),
10988 "diagnostic must name the offending dep: {rendered}",
10989 );
10990 assert!(
10991 rendered.contains("../caixa-teia | grep foo"),
10992 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10993 );
10994 assert!(
10995 rendered.contains('|'),
10996 "diagnostic must reference the pipe footgun: {rendered:?}",
10997 );
10998 assert!(
10999 rendered.contains("pipe"),
11000 "diagnostic must name the shell-pipe footgun: {rendered:?}",
11001 );
11002 }
11003
11004 // -- :caminho shell-command-separator metacharacter arm ---------------
11005
11006 #[test]
11007 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11008 // The fail-before-pass-after pin for the canonical shell-command-
11009 // separator paste footgun: an author copies a shell one-liner
11010 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11011 // whole `cd path; do-thing` chain out of a shell-history block")
11012 // and silently passed every prior arm (`Path::is_absolute` false
11013 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11014 // doesn't end in `/`). The lacre embedded the value verbatim, the
11015 // resolver folded it through `Path::join` looking for a literal
11016 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11017 // surfaced at resolve time with a non-self-locating `No such file
11018 // or directory` error. The new arm moves the rejection to validate
11019 // time and names the offending dep + caminho verbatim.
11020 let d = dep_with_fonte(DepSource::Path {
11021 caminho: "../caixa-teia; rm -rf build".into(),
11022 });
11023 let err = d.validate().unwrap_err();
11024 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11025 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11026 };
11027 assert_eq!(nome, "caixa-teia");
11028 assert_eq!(caminho, "../caixa-teia; rm -rf build");
11029 }
11030
11031 #[test]
11032 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11033 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11034 // "I forgot the prior command side of the separator" idiom).
11035 // Pinned separately from the embedded-byte shape so the gate
11036 // covers every position, not only mid-path.
11037 let d = dep_with_fonte(DepSource::Path {
11038 caminho: ";../caixa-teia".into(),
11039 });
11040 let err = d.validate().unwrap_err();
11041 assert!(
11042 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11043 "got {err:?}",
11044 );
11045 }
11046
11047 #[test]
11048 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11049 // The POSIX `case` arm `;;` terminator shape
11050 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11051 // arm tail" idiom). The arm fires on the first `;` encountered;
11052 // pinned so a future arm that tries to distinguish `;` from `;;`
11053 // doesn't break the broader contract.
11054 let d = dep_with_fonte(DepSource::Path {
11055 caminho: "../caixa-teia;;next".into(),
11056 });
11057 let err = d.validate().unwrap_err();
11058 assert!(
11059 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11060 "got {err:?}",
11061 );
11062 }
11063
11064 #[test]
11065 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11066 // The positive-control pin: the gate targets only `;`, never
11067 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11068 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11069 // pathed variant with adjacent printable punctuation
11070 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11071 // cleanly so the gate doesn't widen to a "no printable
11072 // punctuation anywhere" sweep that would defeat the entire
11073 // path-fonte author surface.
11074 let d = dep_with_fonte(DepSource::Path {
11075 caminho: "../caixa-teia/sub-dir.v2".into(),
11076 });
11077 d.validate().unwrap();
11078 }
11079
11080 #[test]
11081 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11082 // Cascade pin on the immediate-predecessor arm: a value carrying
11083 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11084 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11085 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11086 // pipeline-tail paste is the load-bearing root-cause edit on
11087 // every probe-as-both value (an author who removes the `|`
11088 // typically also drops the trailing `; cleanup` since both are
11089 // the same paste-from-shell-history artifact) — same cascade
11090 // discipline every prior `:caminho` arm establishes.
11091 let d = dep_with_fonte(DepSource::Path {
11092 caminho: "../caixa-teia | tee; rm".into(),
11093 });
11094 let err = d.validate().unwrap_err();
11095 assert!(
11096 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11097 "got {err:?}",
11098 );
11099 }
11100
11101 #[test]
11102 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11103 // Cascade pin on the upstream shell-redirection arm: a value
11104 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11105 // the canonical "I pasted a `cmd > log; cleanup` chain"
11106 // footgun) routes through `FonteCaminhoShellRedirection` not
11107 // `FonteCaminhoShellSemicolon`. The input/output redirection
11108 // metachar carries the more self-locating `byte: u8` payload
11109 // (it names which of `<` or `>` triggered), so the prior arm
11110 // wins on every probe-as-both value.
11111 let d = dep_with_fonte(DepSource::Path {
11112 caminho: "../caixa-teia>log; rm".into(),
11113 });
11114 let err = d.validate().unwrap_err();
11115 assert!(
11116 matches!(
11117 err,
11118 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11119 ),
11120 "got {err:?}",
11121 );
11122 }
11123
11124 #[test]
11125 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11126 // Cascade pin on the upstream backslash arm: a value carrying
11127 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11128 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11129 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11130 // The cross-host-OS-separator divergence is the load-bearing axis
11131 // on every probe-as-both value (an author who removes the `\` is
11132 // the root-cause edit; the `;` falls away in the same edit since
11133 // it's downstream of the Windows-shell convention).
11134 let d = dep_with_fonte(DepSource::Path {
11135 caminho: "..\\caixa-teia;rm".into(),
11136 });
11137 let err = d.validate().unwrap_err();
11138 assert!(
11139 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11140 "got {err:?}",
11141 );
11142 }
11143
11144 #[test]
11145 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11146 // Cascade pin on the embedded-control-byte arm: a value carrying
11147 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11148 // paste-from-multiline-doc footgun where a newline landed mid-
11149 // caminho) routes through `FonteCaminhoControlChar` not
11150 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11151 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11152 // on every value that probes positive for both — mirrors the
11153 // cascade discipline on every prior arm.
11154 let d = dep_with_fonte(DepSource::Path {
11155 caminho: "../foo\n;bar".into(),
11156 });
11157 let err = d.validate().unwrap_err();
11158 assert!(
11159 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11160 "got {err:?}",
11161 );
11162 }
11163
11164 #[test]
11165 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11166 // Cascade pin on the load-bearing leading-byte arm: a leading
11167 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11168 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11169 // — the host-layout-leak diagnostic is the load-bearing axis,
11170 // the `;` byte is the secondary observation. Same precedence
11171 // logic as every prior leading-byte arm.
11172 let d = dep_with_fonte(DepSource::Path {
11173 caminho: "/etc/passwd;rm".into(),
11174 });
11175 let err = d.validate().unwrap_err();
11176 assert!(
11177 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11178 "got {err:?}",
11179 );
11180 }
11181
11182 #[test]
11183 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11184 // Cascade pin on the immediate-successor arm: a value carrying
11185 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11186 // "I tab-completed a path that already had a `; cleanup` tail"
11187 // footgun) routes through `FonteCaminhoShellSemicolon` not
11188 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11189 // the more semantic-locating axis (an author who removes the
11190 // `;` typically also drops the trailing separator since both
11191 // are paste-from-shell artifacts).
11192 let d = dep_with_fonte(DepSource::Path {
11193 caminho: "../foo;rm/".into(),
11194 });
11195 let err = d.validate().unwrap_err();
11196 assert!(
11197 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11198 "got {err:?}",
11199 );
11200 }
11201
11202 #[test]
11203 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11204 // Diagnostic-shape pin (peer with
11205 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11206 // on the closest single-byte peer arm): the error's Display
11207 // surfaces the offending `:nome` and the offending `:caminho`
11208 // verbatim, and names the shell-command-separator footgun
11209 // explicitly so a `feira lint` run can render the diagnostic
11210 // without re-parsing.
11211 let d = dep_with_fonte(DepSource::Path {
11212 caminho: "../caixa-teia; rm -rf build".into(),
11213 });
11214 let rendered = d.validate().unwrap_err().to_string();
11215 assert!(
11216 rendered.contains("caixa-teia"),
11217 "diagnostic must name the offending dep: {rendered}",
11218 );
11219 assert!(
11220 rendered.contains("../caixa-teia; rm -rf build"),
11221 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11222 );
11223 assert!(
11224 rendered.contains(';'),
11225 "diagnostic must reference the semicolon footgun: {rendered:?}",
11226 );
11227 assert!(
11228 rendered.contains("command-separator"),
11229 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11230 );
11231 }
11232
11233 #[test]
11234 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11235 // The fail-before-pass-after pin for the canonical shell-
11236 // background-task paste footgun: an author copies a shell one-
11237 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11238 // the whole `cd path & sleep 1` background-launch out of a
11239 // shell-history block") and silently passed every prior arm
11240 // (`Path::is_absolute` false on `..`, no control bytes, no
11241 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11242 // The lacre embedded the value verbatim, the resolver folded it
11243 // through `Path::join` looking for a literal `./../caixa-teia &
11244 // sleep 1` subdirectory, and the failure surfaced at resolve
11245 // time with a non-self-locating `No such file or directory`
11246 // error. The new arm moves the rejection to validate time and
11247 // names the offending dep + caminho verbatim.
11248 let d = dep_with_fonte(DepSource::Path {
11249 caminho: "../caixa-teia & sleep 1".into(),
11250 });
11251 let err = d.validate().unwrap_err();
11252 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11253 panic!("expected FonteCaminhoShellBackground, got {err:?}");
11254 };
11255 assert_eq!(nome, "caixa-teia");
11256 assert_eq!(caminho, "../caixa-teia & sleep 1");
11257 }
11258
11259 #[test]
11260 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11261 // Leading-position `&` shape (`"&../caixa-teia"` — the
11262 // degenerate "I forgot the prior command side of the
11263 // background terminator" idiom). Pinned separately from the
11264 // embedded-byte shape so the gate covers every position, not
11265 // only mid-path.
11266 let d = dep_with_fonte(DepSource::Path {
11267 caminho: "&../caixa-teia".into(),
11268 });
11269 let err = d.validate().unwrap_err();
11270 assert!(
11271 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11272 "got {err:?}",
11273 );
11274 }
11275
11276 #[test]
11277 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11278 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11279 // canonical "I copied a `cd path && make` build chain" idiom
11280 // every Makefile / shell-script wraps). The arm fires on the
11281 // first `&` encountered; pinned so a future arm that tries to
11282 // distinguish `&` from `&&` doesn't break the broader contract.
11283 let d = dep_with_fonte(DepSource::Path {
11284 caminho: "../caixa-teia && make".into(),
11285 });
11286 let err = d.validate().unwrap_err();
11287 assert!(
11288 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11289 "got {err:?}",
11290 );
11291 }
11292
11293 #[test]
11294 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11295 // The positive-control pin: the gate targets only `&`, never
11296 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11297 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11298 // pathed variant with adjacent printable punctuation
11299 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11300 // cleanly so the gate doesn't widen to a "no printable
11301 // punctuation anywhere" sweep that would defeat the entire
11302 // path-fonte author surface.
11303 let d = dep_with_fonte(DepSource::Path {
11304 caminho: "../caixa-teia/sub-dir.v2".into(),
11305 });
11306 d.validate().unwrap();
11307 }
11308
11309 #[test]
11310 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11311 // Cascade pin on the immediate-predecessor arm: a value carrying
11312 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11313 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11314 // routes through `FonteCaminhoShellSemicolon` not
11315 // `FonteCaminhoShellBackground`. The sequential-command-
11316 // separator paste is the more common shell-history paste idiom
11317 // on every probe-as-both value (an author who removes the `;`
11318 // typically also drops the trailing `& sleep` since both are
11319 // paste-from-shell-history artifacts) — same cascade discipline
11320 // every prior `:caminho` arm establishes.
11321 let d = dep_with_fonte(DepSource::Path {
11322 caminho: "../caixa-teia; rm & sleep".into(),
11323 });
11324 let err = d.validate().unwrap_err();
11325 assert!(
11326 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11327 "got {err:?}",
11328 );
11329 }
11330
11331 #[test]
11332 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11333 // Cascade pin on the upstream shell-pipe arm: a value carrying
11334 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11335 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11336 // chain" footgun) routes through `FonteCaminhoShellPipe` not
11337 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11338 // load-bearing root-cause edit on every probe-as-both value.
11339 let d = dep_with_fonte(DepSource::Path {
11340 caminho: "../caixa-teia | tee & sleep".into(),
11341 });
11342 let err = d.validate().unwrap_err();
11343 assert!(
11344 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11345 "got {err:?}",
11346 );
11347 }
11348
11349 #[test]
11350 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11351 // Cascade pin on the upstream shell-redirection arm: a value
11352 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11353 // the canonical "I pasted a `cmd > log & sleep` background-
11354 // redirect chain" footgun) routes through
11355 // `FonteCaminhoShellRedirection` not
11356 // `FonteCaminhoShellBackground`. The input/output redirection
11357 // metachar carries the more self-locating `byte: u8` payload
11358 // (it names which of `<` or `>` triggered), so the prior arm
11359 // wins on every probe-as-both value.
11360 let d = dep_with_fonte(DepSource::Path {
11361 caminho: "../caixa-teia>log & sleep".into(),
11362 });
11363 let err = d.validate().unwrap_err();
11364 assert!(
11365 matches!(
11366 err,
11367 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11368 ),
11369 "got {err:?}",
11370 );
11371 }
11372
11373 #[test]
11374 fn fonte_caminho_backslash_fires_before_shell_background() {
11375 // Cascade pin on the upstream backslash arm: a value carrying
11376 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11377 // "I pasted a Windows-shell `cd ..\path & sleep` background-
11378 // launch chain") routes through `FonteCaminhoBackslash` not
11379 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11380 // divergence is the load-bearing axis on every probe-as-both
11381 // value (an author who removes the `\` is the root-cause edit;
11382 // the `&` falls away in the same edit since it's downstream of
11383 // the Windows-shell convention).
11384 let d = dep_with_fonte(DepSource::Path {
11385 caminho: "..\\caixa-teia & sleep".into(),
11386 });
11387 let err = d.validate().unwrap_err();
11388 assert!(
11389 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11390 "got {err:?}",
11391 );
11392 }
11393
11394 #[test]
11395 fn fonte_caminho_control_char_fires_before_shell_background() {
11396 // Cascade pin on the embedded-control-byte arm: a value
11397 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11398 // the canonical paste-from-multiline-doc footgun where a
11399 // newline landed mid-caminho) routes through
11400 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11401 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11402 // diagnostic is the load-bearing axis on every value that
11403 // probes positive for both — mirrors the cascade discipline on
11404 // every prior arm.
11405 let d = dep_with_fonte(DepSource::Path {
11406 caminho: "../foo\n&sleep".into(),
11407 });
11408 let err = d.validate().unwrap_err();
11409 assert!(
11410 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11411 "got {err:?}",
11412 );
11413 }
11414
11415 #[test]
11416 fn fonte_caminho_absolute_fires_before_shell_background() {
11417 // Cascade pin on the load-bearing leading-byte arm: a leading
11418 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11419 // through `FonteCaminhoAbsolute` not
11420 // `FonteCaminhoShellBackground` — the host-layout-leak
11421 // diagnostic is the load-bearing axis, the `&` byte is the
11422 // secondary observation. Same precedence logic as every prior
11423 // leading-byte arm.
11424 let d = dep_with_fonte(DepSource::Path {
11425 caminho: "/etc/passwd & sleep".into(),
11426 });
11427 let err = d.validate().unwrap_err();
11428 assert!(
11429 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11430 "got {err:?}",
11431 );
11432 }
11433
11434 #[test]
11435 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11436 // Cascade pin on the immediate-successor arm: a value carrying
11437 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11438 // canonical "I tab-completed a path that already had a `&
11439 // sleep` background-launch tail" footgun) routes through
11440 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11441 // The embedded shell-metachar is the more semantic-locating
11442 // axis (an author who removes the `&` typically also drops
11443 // the trailing separator since both are paste-from-shell
11444 // artifacts).
11445 let d = dep_with_fonte(DepSource::Path {
11446 caminho: "../foo&sleep/".into(),
11447 });
11448 let err = d.validate().unwrap_err();
11449 assert!(
11450 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11451 "got {err:?}",
11452 );
11453 }
11454
11455 #[test]
11456 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11457 // Diagnostic-shape pin (peer with
11458 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11459 // on the closest single-byte peer arm): the error's Display
11460 // surfaces the offending `:nome` and the offending `:caminho`
11461 // verbatim, and names the shell-background / logical-AND
11462 // footgun explicitly so a `feira lint` run can render the
11463 // diagnostic without re-parsing.
11464 let d = dep_with_fonte(DepSource::Path {
11465 caminho: "../caixa-teia & sleep 1".into(),
11466 });
11467 let rendered = d.validate().unwrap_err().to_string();
11468 assert!(
11469 rendered.contains("caixa-teia"),
11470 "diagnostic must name the offending dep: {rendered}",
11471 );
11472 assert!(
11473 rendered.contains("../caixa-teia & sleep 1"),
11474 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11475 );
11476 assert!(
11477 rendered.contains('&'),
11478 "diagnostic must reference the ampersand footgun: {rendered:?}",
11479 );
11480 assert!(
11481 rendered.contains("background") || rendered.contains("list-AND"),
11482 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11483 );
11484 }
11485
11486 #[test]
11487 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11488 // The fail-before-pass-after pin for the canonical shell-
11489 // command-substitution paste footgun: an author copies a
11490 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11491 // — the canonical "I pasted a path that included a `pwd`
11492 // / `whoami` / `date` legacy command-substitution expansion
11493 // out of a shell-history block") and silently passed every
11494 // prior arm (`Path::is_absolute` false on `..`, no control
11495 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11496 // end in `/`). The lacre embedded the value verbatim, the
11497 // resolver folded it through `Path::join` looking for a
11498 // literal `./../caixa-teia/`whoami`` subdirectory, and the
11499 // failure surfaced at resolve time with a non-self-locating
11500 // `No such file or directory` error. The new arm moves the
11501 // rejection to validate time and names the offending dep +
11502 // caminho verbatim.
11503 let d = dep_with_fonte(DepSource::Path {
11504 caminho: "../caixa-teia/`whoami`".into(),
11505 });
11506 let err = d.validate().unwrap_err();
11507 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11508 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11509 };
11510 assert_eq!(nome, "caixa-teia");
11511 assert_eq!(caminho, "../caixa-teia/`whoami`");
11512 }
11513
11514 #[test]
11515 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11516 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11517 // the canonical `<backtick>pwd<backtick>/path` working-
11518 // directory expansion shape every shell-side path-composition
11519 // idiom carries). Pinned separately from the embedded-byte
11520 // shape so the gate covers every position, not only mid-path.
11521 let d = dep_with_fonte(DepSource::Path {
11522 caminho: "`pwd`/caixa-teia".into(),
11523 });
11524 let err = d.validate().unwrap_err();
11525 assert!(
11526 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11527 "got {err:?}",
11528 );
11529 }
11530
11531 #[test]
11532 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11533 // Trailing-position backtick shape (`"../caixa-teia`"` — the
11534 // degenerate "I selected an unbalanced backtick out of a
11535 // shell-history block" idiom that probes for the cascade's
11536 // last-byte handling). The trailing-`/` arm fires only on
11537 // last-byte `/`; an unbalanced trailing backtick must route
11538 // through this arm regardless of position.
11539 let d = dep_with_fonte(DepSource::Path {
11540 caminho: "../caixa-teia`".into(),
11541 });
11542 let err = d.validate().unwrap_err();
11543 assert!(
11544 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11545 "got {err:?}",
11546 );
11547 }
11548
11549 #[test]
11550 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11551 // The canonical balanced-pair shape (``"../<backtick>cat
11552 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11553 // command-injection paste idiom every shell-side hardening
11554 // guide enumerates first). The arm fires on the first
11555 // backtick encountered; pinned so a future arm that tries to
11556 // distinguish the opening from the closing byte doesn't break
11557 // the broader contract.
11558 let d = dep_with_fonte(DepSource::Path {
11559 caminho: "../`cat /etc/passwd`".into(),
11560 });
11561 let err = d.validate().unwrap_err();
11562 assert!(
11563 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11564 "got {err:?}",
11565 );
11566 }
11567
11568 #[test]
11569 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11570 // The positive-control pin: the gate targets only the
11571 // backtick byte, never adjacent printable ASCII or POSIX-
11572 // valid bytes. The canonical relative POSIX path
11573 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11574 // adjacent printable punctuation
11575 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11576 // cleanly so the gate doesn't widen to a "no printable
11577 // punctuation anywhere" sweep that would defeat the entire
11578 // path-fonte author surface.
11579 let d = dep_with_fonte(DepSource::Path {
11580 caminho: "../caixa-teia/sub-dir.v2".into(),
11581 });
11582 d.validate().unwrap();
11583 }
11584
11585 #[test]
11586 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11587 // Cascade pin on the immediate-predecessor arm: a value
11588 // carrying both `&` and a backtick (``"../caixa-teia &
11589 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11590 // `cmd & <backtick>sleep N<backtick>` background-launch +
11591 // command-substitution chain" footgun) routes through
11592 // `FonteCaminhoShellBackground` not
11593 // `FonteCaminhoShellCommandSubstitution`. The background-
11594 // launch tail is the more common shell-history paste idiom
11595 // on every probe-as-both value — same cascade discipline
11596 // every prior `:caminho` arm establishes.
11597 let d = dep_with_fonte(DepSource::Path {
11598 caminho: "../caixa-teia & `sleep 1`".into(),
11599 });
11600 let err = d.validate().unwrap_err();
11601 assert!(
11602 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11603 "got {err:?}",
11604 );
11605 }
11606
11607 #[test]
11608 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11609 // Cascade pin on the upstream shell-semicolon arm: a value
11610 // carrying both `;` and a backtick (``"../caixa-teia;
11611 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11612 // `cmd; <backtick>follow-up<backtick>` sequential-chain
11613 // footgun) routes through `FonteCaminhoShellSemicolon` not
11614 // `FonteCaminhoShellCommandSubstitution`. The sequential-
11615 // command-separator paste is the load-bearing root-cause
11616 // edit on every probe-as-both value.
11617 let d = dep_with_fonte(DepSource::Path {
11618 caminho: "../caixa-teia; `whoami`".into(),
11619 });
11620 let err = d.validate().unwrap_err();
11621 assert!(
11622 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11623 "got {err:?}",
11624 );
11625 }
11626
11627 #[test]
11628 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11629 // Cascade pin on the upstream shell-pipe arm: a value
11630 // carrying both `|` and a backtick (``"../caixa-teia |
11631 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11632 // command-substitution paste idiom) routes through
11633 // `FonteCaminhoShellPipe` not
11634 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11635 // paste is the load-bearing root-cause edit on every
11636 // probe-as-both value.
11637 let d = dep_with_fonte(DepSource::Path {
11638 caminho: "../caixa-teia | `tee log`".into(),
11639 });
11640 let err = d.validate().unwrap_err();
11641 assert!(
11642 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11643 "got {err:?}",
11644 );
11645 }
11646
11647 #[test]
11648 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11649 // Cascade pin on the upstream shell-redirection arm: a value
11650 // carrying both `>` and a backtick (``"../caixa-teia>log
11651 // <backtick>date<backtick>"`` — the canonical "I pasted a
11652 // `cmd > log <backtick>date<backtick>` redirect-plus-
11653 // substitution chain" footgun) routes through
11654 // `FonteCaminhoShellRedirection` not
11655 // `FonteCaminhoShellCommandSubstitution`. The input/output
11656 // redirection metachar carries the more self-locating `byte`
11657 // payload (it names which of `<` or `>` triggered), so the
11658 // prior arm wins on every probe-as-both value.
11659 let d = dep_with_fonte(DepSource::Path {
11660 caminho: "../caixa-teia>log `date`".into(),
11661 });
11662 let err = d.validate().unwrap_err();
11663 assert!(
11664 matches!(
11665 err,
11666 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11667 ),
11668 "got {err:?}",
11669 );
11670 }
11671
11672 #[test]
11673 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11674 // Cascade pin on the upstream backslash arm: a value
11675 // carrying both `\` and a backtick (``"..\caixa-teia
11676 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11677 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11678 // chain") routes through `FonteCaminhoBackslash` not
11679 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11680 // separator divergence is the load-bearing axis on every
11681 // probe-as-both value (an author who removes the `\` is the
11682 // root-cause edit; the backtick falls away in the same edit
11683 // since it's downstream of the Windows-shell convention).
11684 let d = dep_with_fonte(DepSource::Path {
11685 caminho: "..\\caixa-teia `whoami`".into(),
11686 });
11687 let err = d.validate().unwrap_err();
11688 assert!(
11689 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11690 "got {err:?}",
11691 );
11692 }
11693
11694 #[test]
11695 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11696 // Cascade pin on the embedded-control-byte arm: a value
11697 // carrying both a control byte and a backtick (`"../foo\n
11698 // `whoami`"` — the canonical paste-from-multiline-doc
11699 // footgun where a newline landed mid-caminho between two
11700 // paste fragments) routes through `FonteCaminhoControlChar`
11701 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11702 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11703 // is the load-bearing axis on every value that probes
11704 // positive for both — mirrors the cascade discipline on
11705 // every prior arm.
11706 let d = dep_with_fonte(DepSource::Path {
11707 caminho: "../foo\n`whoami`".into(),
11708 });
11709 let err = d.validate().unwrap_err();
11710 assert!(
11711 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11712 "got {err:?}",
11713 );
11714 }
11715
11716 #[test]
11717 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11718 // Cascade pin on the load-bearing leading-byte arm: a
11719 // leading `/` value with embedded backtick (``"/etc/passwd
11720 // <backtick>whoami<backtick>"``) routes through
11721 // `FonteCaminhoAbsolute` not
11722 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11723 // leak diagnostic is the load-bearing axis, the backtick
11724 // byte is the secondary observation. Same precedence logic
11725 // as every prior leading-byte arm.
11726 let d = dep_with_fonte(DepSource::Path {
11727 caminho: "/etc/passwd `whoami`".into(),
11728 });
11729 let err = d.validate().unwrap_err();
11730 assert!(
11731 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11732 "got {err:?}",
11733 );
11734 }
11735
11736 #[test]
11737 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11738 // Cascade pin on the immediate-successor arm: a value
11739 // carrying both a backtick and a trailing `/`
11740 // (``"../`whoami`/"`` — the canonical "I tab-completed a
11741 // path that already had a backticked `whoami` substitution
11742 // tail" footgun) routes through
11743 // `FonteCaminhoShellCommandSubstitution` not
11744 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11745 // is the more semantic-locating axis (an author who removes
11746 // the backtick typically also drops the trailing separator
11747 // since both are paste-from-shell artifacts).
11748 let d = dep_with_fonte(DepSource::Path {
11749 caminho: "../`whoami`/".into(),
11750 });
11751 let err = d.validate().unwrap_err();
11752 assert!(
11753 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11754 "got {err:?}",
11755 );
11756 }
11757
11758 #[test]
11759 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11760 // Diagnostic-shape pin (peer with
11761 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11762 // on the closest single-byte peer arm): the error's Display
11763 // surfaces the offending `:nome` and the offending `:caminho`
11764 // verbatim, and names the shell-command-substitution footgun
11765 // explicitly so a `feira lint` run can render the diagnostic
11766 // without re-parsing.
11767 let d = dep_with_fonte(DepSource::Path {
11768 caminho: "../caixa-teia/`whoami`".into(),
11769 });
11770 let rendered = d.validate().unwrap_err().to_string();
11771 assert!(
11772 rendered.contains("caixa-teia"),
11773 "diagnostic must name the offending dep: {rendered}",
11774 );
11775 assert!(
11776 rendered.contains("../caixa-teia/`whoami`"),
11777 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11778 );
11779 assert!(
11780 rendered.contains('`'),
11781 "diagnostic must reference the backtick footgun: {rendered:?}",
11782 );
11783 assert!(
11784 rendered.contains("command-substitution"),
11785 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11786 );
11787 }
11788
11789 #[test]
11790 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11791 // The fail-before-pass-after pin for the canonical pathname-
11792 // expansion paste footgun: an author copies an `ls
11793 // ../caixa-teia/*` shell-listing tail into the `:caminho`
11794 // slot and silently passes every prior arm
11795 // (`Path::is_absolute` false on `..`, no control bytes, no
11796 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11797 // doesn't end in `/`). The lacre embedded the value
11798 // verbatim, the resolver folded it through `Path::join`
11799 // looking for a literal `./../caixa-teia/*` subdirectory,
11800 // and the failure surfaced at resolve time with a non-self-
11801 // locating `No such file or directory` error. The new arm
11802 // moves the rejection to validate time and names the
11803 // offending dep + caminho + byte verbatim.
11804 let d = dep_with_fonte(DepSource::Path {
11805 caminho: "../caixa-teia/*".into(),
11806 });
11807 let err = d.validate().unwrap_err();
11808 let DepError::FonteCaminhoShellGlob {
11809 nome,
11810 caminho,
11811 byte,
11812 } = err
11813 else {
11814 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11815 };
11816 assert_eq!(nome, "caixa-teia");
11817 assert_eq!(caminho, "../caixa-teia/*");
11818 assert_eq!(byte, b'*');
11819 }
11820
11821 #[test]
11822 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11823 // The symmetric single-char-wildcard paste shape
11824 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11825 // out of shell history" idiom). Pinned separately from the
11826 // `*` shape so the gate's contract is "any `*` or `?`
11827 // anywhere", not single-byte coverage.
11828 let d = dep_with_fonte(DepSource::Path {
11829 caminho: "../foo?".into(),
11830 });
11831 let err = d.validate().unwrap_err();
11832 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11833 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11834 };
11835 assert_eq!(byte, b'?');
11836 }
11837
11838 #[test]
11839 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11840 // Leading-position `*` shape (`"*/caixa-teia"` — the
11841 // degenerate "I selected only the wildcard prefix out of a
11842 // shell-glob expression" idiom). Pinned separately from the
11843 // embedded-byte shapes so the gate covers every position,
11844 // not only mid-path.
11845 let d = dep_with_fonte(DepSource::Path {
11846 caminho: "*/caixa-teia".into(),
11847 });
11848 let err = d.validate().unwrap_err();
11849 assert!(
11850 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11851 "got {err:?}",
11852 );
11853 }
11854
11855 #[test]
11856 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11857 // The bash/zsh `globstar` recursive-glob shape
11858 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11859 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11860 // The arm fires on the first `*` encountered; pinned so a
11861 // future arm that tries to distinguish single `*` from
11862 // double `**` doesn't break the broader contract.
11863 let d = dep_with_fonte(DepSource::Path {
11864 caminho: "../caixa-teia/**/foo".into(),
11865 });
11866 let err = d.validate().unwrap_err();
11867 assert!(
11868 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11869 "got {err:?}",
11870 );
11871 }
11872
11873 #[test]
11874 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11875 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11876 // — the "I selected `*.lisp` to mean every Lisp source file
11877 // in the dep root" footgun the prior arms structurally
11878 // cannot catch since `.` is a POSIX-valid path-component
11879 // byte). Pinned so the gate's contract covers the most
11880 // idiomatic glob-paste shape every author meets first.
11881 let d = dep_with_fonte(DepSource::Path {
11882 caminho: "../caixa-teia/*.lisp".into(),
11883 });
11884 let err = d.validate().unwrap_err();
11885 assert!(
11886 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11887 "got {err:?}",
11888 );
11889 }
11890
11891 #[test]
11892 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11893 // The positive-control pin: the gate targets only `*` /
11894 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11895 // The canonical relative POSIX path (`"../caixa-teia"`) and
11896 // a nested deeply-pathed variant with adjacent printable
11897 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11898 // to validate cleanly so the gate doesn't widen to a "no
11899 // printable punctuation anywhere" sweep that would defeat
11900 // the entire path-fonte author surface.
11901 let d = dep_with_fonte(DepSource::Path {
11902 caminho: "../caixa-teia/sub-dir.v2".into(),
11903 });
11904 d.validate().unwrap();
11905 }
11906
11907 #[test]
11908 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11909 // Cascade pin on the immediate-predecessor arm: a value
11910 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11911 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11912 // command-substitution + glob chain") routes through
11913 // `FonteCaminhoShellCommandSubstitution` not
11914 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11915 // injection vector is the load-bearing root-cause edit on
11916 // every probe-as-both value — same cascade discipline every
11917 // prior `:caminho` arm establishes.
11918 let d = dep_with_fonte(DepSource::Path {
11919 caminho: "../`whoami`/*".into(),
11920 });
11921 let err = d.validate().unwrap_err();
11922 assert!(
11923 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11924 "got {err:?}",
11925 );
11926 }
11927
11928 #[test]
11929 fn fonte_caminho_shell_background_fires_before_shell_glob() {
11930 // Cascade pin on the upstream shell-background arm: a value
11931 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11932 // canonical "I pasted a `cmd & ls /*` background + glob
11933 // chain" footgun) routes through `FonteCaminhoShellBackground`
11934 // not `FonteCaminhoShellGlob`. The background-launch tail is
11935 // the load-bearing root-cause edit on every probe-as-both
11936 // value.
11937 let d = dep_with_fonte(DepSource::Path {
11938 caminho: "../caixa-teia & ls /*".into(),
11939 });
11940 let err = d.validate().unwrap_err();
11941 assert!(
11942 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11943 "got {err:?}",
11944 );
11945 }
11946
11947 #[test]
11948 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11949 // Cascade pin on the upstream shell-semicolon arm: a value
11950 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11951 // canonical sequential-cleanup + glob paste idiom) routes
11952 // through `FonteCaminhoShellSemicolon` not
11953 // `FonteCaminhoShellGlob`. The sequential-command-separator
11954 // paste is the load-bearing root-cause edit on every
11955 // probe-as-both value.
11956 let d = dep_with_fonte(DepSource::Path {
11957 caminho: "../caixa-teia; rm *".into(),
11958 });
11959 let err = d.validate().unwrap_err();
11960 assert!(
11961 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11962 "got {err:?}",
11963 );
11964 }
11965
11966 #[test]
11967 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11968 // Cascade pin on the upstream shell-pipe arm: a value
11969 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11970 // canonical pipeline-to-glob paste idiom) routes through
11971 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11972 // pipeline-tail paste is the load-bearing root-cause edit
11973 // on every probe-as-both value.
11974 let d = dep_with_fonte(DepSource::Path {
11975 caminho: "../caixa-teia | ls *".into(),
11976 });
11977 let err = d.validate().unwrap_err();
11978 assert!(
11979 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11980 "got {err:?}",
11981 );
11982 }
11983
11984 #[test]
11985 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11986 // Cascade pin on the upstream shell-redirection arm: a value
11987 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11988 // canonical "I pasted a `cmd > log *` redirect-plus-glob
11989 // chain" footgun) routes through
11990 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11991 // The input/output redirection metachar carries the more
11992 // self-locating `byte` payload (it names which of `<` or `>`
11993 // triggered), so the prior arm wins on every probe-as-both
11994 // value.
11995 let d = dep_with_fonte(DepSource::Path {
11996 caminho: "../caixa-teia>log *".into(),
11997 });
11998 let err = d.validate().unwrap_err();
11999 assert!(
12000 matches!(
12001 err,
12002 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12003 ),
12004 "got {err:?}",
12005 );
12006 }
12007
12008 #[test]
12009 fn fonte_caminho_backslash_fires_before_shell_glob() {
12010 // Cascade pin on the upstream backslash arm: a value
12011 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12012 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12013 // expression" footgun) routes through
12014 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12015 // cross-host-OS-separator divergence is the load-bearing
12016 // axis on every probe-as-both value (an author who removes
12017 // the `\` is the root-cause edit; the `*` falls away in the
12018 // same edit since it's downstream of the Windows-shell
12019 // convention).
12020 let d = dep_with_fonte(DepSource::Path {
12021 caminho: "..\\caixa-teia\\*".into(),
12022 });
12023 let err = d.validate().unwrap_err();
12024 assert!(
12025 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12026 "got {err:?}",
12027 );
12028 }
12029
12030 #[test]
12031 fn fonte_caminho_control_char_fires_before_shell_glob() {
12032 // Cascade pin on the embedded-control-byte arm: a value
12033 // carrying both a control byte and `*` (`"../foo\n*"` — the
12034 // canonical paste-from-multiline-doc footgun where a
12035 // newline landed mid-caminho between two paste fragments)
12036 // routes through `FonteCaminhoControlChar` not
12037 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12038 // NUL-`CString::new`-fail diagnostic is the load-bearing
12039 // axis on every value that probes positive for both —
12040 // mirrors the cascade discipline on every prior arm.
12041 let d = dep_with_fonte(DepSource::Path {
12042 caminho: "../foo\n*".into(),
12043 });
12044 let err = d.validate().unwrap_err();
12045 assert!(
12046 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12047 "got {err:?}",
12048 );
12049 }
12050
12051 #[test]
12052 fn fonte_caminho_absolute_fires_before_shell_glob() {
12053 // Cascade pin on the load-bearing leading-byte arm: a
12054 // leading `/` value with embedded `*` (`"/etc/*"`) routes
12055 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12056 // — the host-layout-leak diagnostic is the load-bearing
12057 // axis, the glob byte is the secondary observation. Same
12058 // precedence logic as every prior leading-byte arm.
12059 let d = dep_with_fonte(DepSource::Path {
12060 caminho: "/etc/*".into(),
12061 });
12062 let err = d.validate().unwrap_err();
12063 assert!(
12064 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12065 "got {err:?}",
12066 );
12067 }
12068
12069 #[test]
12070 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12071 // Cascade pin on the immediate-successor arm: a value
12072 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12073 // canonical "I tab-completed a path that already had a
12074 // glob-expansion tail" footgun) routes through
12075 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12076 // The embedded shell-metachar is the more semantic-locating
12077 // axis (an author who removes the `*` typically also drops
12078 // the trailing separator since both are paste-from-shell
12079 // artifacts).
12080 let d = dep_with_fonte(DepSource::Path {
12081 caminho: "../foo*/".into(),
12082 });
12083 let err = d.validate().unwrap_err();
12084 assert!(
12085 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12086 "got {err:?}",
12087 );
12088 }
12089
12090 #[test]
12091 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12092 // Diagnostic-shape pin (peer with
12093 // `fonte_caminho_shell_redirection_diagnostic_*` on the
12094 // closest two-byte peer arm): the error's Display surfaces
12095 // the offending `:nome`, the offending `:caminho` verbatim,
12096 // the offending byte's hex / character form, and names the
12097 // shell-glob / pathname-expansion footgun explicitly so a
12098 // `feira lint` run can render the diagnostic without
12099 // re-parsing.
12100 let d = dep_with_fonte(DepSource::Path {
12101 caminho: "../caixa-teia/*.lisp".into(),
12102 });
12103 let rendered = d.validate().unwrap_err().to_string();
12104 assert!(
12105 rendered.contains("caixa-teia"),
12106 "diagnostic must name the offending dep: {rendered}",
12107 );
12108 assert!(
12109 rendered.contains("../caixa-teia/*.lisp"),
12110 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12111 );
12112 assert!(
12113 rendered.contains("0x2a"),
12114 "diagnostic must surface the offending byte hex: {rendered:?}",
12115 );
12116 assert!(
12117 rendered.contains("glob"),
12118 "diagnostic must name the shell-glob footgun: {rendered:?}",
12119 );
12120 assert!(
12121 rendered.contains("pathname-expansion"),
12122 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12123 );
12124 }
12125
12126 #[test]
12127 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12128 // The fail-before-pass-after pin for the canonical modern-Bourne
12129 // command-substitution paste footgun: an author copies a
12130 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12131 // `$(<cmd>)` expansion would land the current date as a
12132 // subdirectory name and silently passed every prior arm
12133 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12134 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12135 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12136 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12137 // sits mid-path). The lacre embedded the value verbatim, the
12138 // resolver folded it through `Path::join` looking for a literal
12139 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12140 // surfaced at resolve time with a non-self-locating `No such
12141 // file or directory` error. The new arm moves the rejection to
12142 // validate time and names the offending dep + caminho + byte
12143 // verbatim. The arm fires on the first `(` encountered (the
12144 // opening byte of `$(date)`).
12145 let d = dep_with_fonte(DepSource::Path {
12146 caminho: "../caixa-teia/$(date)/build".into(),
12147 });
12148 let err = d.validate().unwrap_err();
12149 let DepError::FonteCaminhoShellSubshellGrouping {
12150 nome,
12151 caminho,
12152 byte,
12153 } = err
12154 else {
12155 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12156 };
12157 assert_eq!(nome, "caixa-teia");
12158 assert_eq!(caminho, "../caixa-teia/$(date)/build");
12159 assert_eq!(byte, b'(');
12160 }
12161
12162 #[test]
12163 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12164 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12165 // the degenerate "I selected an unbalanced closing paren out of
12166 // a shell-history block" idiom that probes for the cascade's
12167 // last-byte handling on a value carrying only the closing byte).
12168 // Pinned separately from the open-paren shape so the gate's
12169 // contract is "any `(` or `)` anywhere", not single-byte
12170 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12171 // caminho_carrying_question_glob` shape on the immediate-
12172 // predecessor `FonteCaminhoShellGlob` arm.
12173 let d = dep_with_fonte(DepSource::Path {
12174 caminho: "../caixa-teia)".into(),
12175 });
12176 let err = d.validate().unwrap_err();
12177 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12178 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12179 };
12180 assert_eq!(byte, b')');
12181 }
12182
12183 #[test]
12184 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12185 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12186 // canonical "I selected a `(cd foo)` subshell-grouping prefix
12187 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12188 // Pinned separately from the embedded-byte shape so the gate
12189 // covers every position, not only mid-path.
12190 let d = dep_with_fonte(DepSource::Path {
12191 caminho: "(cd foo)/caixa-teia".into(),
12192 });
12193 let err = d.validate().unwrap_err();
12194 assert!(
12195 matches!(
12196 err,
12197 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12198 ),
12199 "got {err:?}",
12200 );
12201 }
12202
12203 #[test]
12204 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12205 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12206 // — the canonical "I copied a `(pwd)` working-directory-probe
12207 // subshell-grouping idiom every shell-history block carries"
12208 // footgun). The value carries no other cascade-preceding
12209 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12210 // `*` / `?`) so the arm fires on the first `(` encountered;
12211 // pinned so a future arm that tries to distinguish the
12212 // opening from the closing byte doesn't break the broader
12213 // contract. Mirrors the peer
12214 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12215 // backtick_pair` shape on the upstream `FonteCaminhoShell\
12216 // CommandSubstitution` arm.
12217 let d = dep_with_fonte(DepSource::Path {
12218 caminho: "../(pwd)/caixa-teia".into(),
12219 });
12220 let err = d.validate().unwrap_err();
12221 assert!(
12222 matches!(
12223 err,
12224 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12225 ),
12226 "got {err:?}",
12227 );
12228 }
12229
12230 #[test]
12231 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12232 // The positive-control pin: the gate targets only `(` / `)`,
12233 // never adjacent printable ASCII or POSIX-valid bytes. The
12234 // canonical relative POSIX path (`"../caixa-teia"`) and a
12235 // nested deeply-pathed variant with adjacent printable
12236 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12237 // validate cleanly so the gate doesn't widen to a "no printable
12238 // punctuation anywhere" sweep that would defeat the entire
12239 // path-fonte author surface.
12240 let d = dep_with_fonte(DepSource::Path {
12241 caminho: "../caixa-teia/sub-dir.v2".into(),
12242 });
12243 d.validate().unwrap();
12244 }
12245
12246 #[test]
12247 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12248 // Cascade pin on the immediate-predecessor arm: a value
12249 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12250 // canonical "I pasted a glob expansion followed by a
12251 // subshell-grouping tail" footgun) routes through
12252 // `FonteCaminhoShellGlob` not
12253 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12254 // shape is the more common shell-history paste idiom on every
12255 // probe-as-both value — same cascade discipline every prior
12256 // `:caminho` arm establishes.
12257 let d = dep_with_fonte(DepSource::Path {
12258 caminho: "../caixa-teia/*(date)".into(),
12259 });
12260 let err = d.validate().unwrap_err();
12261 assert!(
12262 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12263 "got {err:?}",
12264 );
12265 }
12266
12267 #[test]
12268 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12269 // Cascade pin on the upstream shell-command-substitution arm: a
12270 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12271 // — the canonical "I pasted a legacy-backtick + modern-paren
12272 // command-substitution chain" footgun) routes through
12273 // `FonteCaminhoShellCommandSubstitution` not
12274 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12275 // command-injection vector is the load-bearing root-cause edit
12276 // on every probe-as-both value.
12277 let d = dep_with_fonte(DepSource::Path {
12278 caminho: "../`whoami`/$(date)".into(),
12279 });
12280 let err = d.validate().unwrap_err();
12281 assert!(
12282 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12283 "got {err:?}",
12284 );
12285 }
12286
12287 #[test]
12288 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12289 // Cascade pin on the upstream shell-background arm: a value
12290 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12291 // the canonical "I pasted a `cmd & (cd foo)` background-launch
12292 // + subshell-grouping chain" footgun) routes through
12293 // `FonteCaminhoShellBackground` not
12294 // `FonteCaminhoShellSubshellGrouping`. The background-launch
12295 // tail is the load-bearing root-cause edit on every probe-as-
12296 // both value.
12297 let d = dep_with_fonte(DepSource::Path {
12298 caminho: "../caixa-teia & (cd foo)".into(),
12299 });
12300 let err = d.validate().unwrap_err();
12301 assert!(
12302 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12303 "got {err:?}",
12304 );
12305 }
12306
12307 #[test]
12308 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12309 // Cascade pin on the upstream shell-semicolon arm: a value
12310 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12311 // the canonical sequential-cleanup + subshell-grouping paste
12312 // idiom) routes through `FonteCaminhoShellSemicolon` not
12313 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12314 // separator paste is the load-bearing root-cause edit on
12315 // every probe-as-both value.
12316 let d = dep_with_fonte(DepSource::Path {
12317 caminho: "../caixa-teia; (cd foo)".into(),
12318 });
12319 let err = d.validate().unwrap_err();
12320 assert!(
12321 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12322 "got {err:?}",
12323 );
12324 }
12325
12326 #[test]
12327 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12328 // Cascade pin on the upstream shell-pipe arm: a value carrying
12329 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12330 // canonical pipeline-to-subshell-grouping paste idiom) routes
12331 // through `FonteCaminhoShellPipe` not
12332 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12333 // is the load-bearing root-cause edit on every probe-as-both
12334 // value.
12335 let d = dep_with_fonte(DepSource::Path {
12336 caminho: "../caixa-teia | (tee log)".into(),
12337 });
12338 let err = d.validate().unwrap_err();
12339 assert!(
12340 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12341 "got {err:?}",
12342 );
12343 }
12344
12345 #[test]
12346 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12347 // Cascade pin on the upstream shell-redirection arm: a value
12348 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12349 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12350 // plus-subshell-grouping chain" footgun) routes through
12351 // `FonteCaminhoShellRedirection` not
12352 // `FonteCaminhoShellSubshellGrouping`. The input/output
12353 // redirection metachar carries the more self-locating `byte`
12354 // payload (it names which of `<` or `>` triggered), so the
12355 // prior arm wins on every probe-as-both value.
12356 let d = dep_with_fonte(DepSource::Path {
12357 caminho: "../caixa-teia>log (cd foo)".into(),
12358 });
12359 let err = d.validate().unwrap_err();
12360 assert!(
12361 matches!(
12362 err,
12363 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12364 ),
12365 "got {err:?}",
12366 );
12367 }
12368
12369 #[test]
12370 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12371 // Cascade pin on the upstream backslash arm: a value carrying
12372 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12373 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12374 // through `FonteCaminhoBackslash` not
12375 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12376 // separator divergence is the load-bearing axis on every
12377 // probe-as-both value (an author who removes the `\` is the
12378 // root-cause edit; the `(` falls away in the same edit since
12379 // it's downstream of the Windows-shell convention).
12380 let d = dep_with_fonte(DepSource::Path {
12381 caminho: "..\\caixa-teia\\(cd foo)".into(),
12382 });
12383 let err = d.validate().unwrap_err();
12384 assert!(
12385 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12386 "got {err:?}",
12387 );
12388 }
12389
12390 #[test]
12391 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12392 // Cascade pin on the embedded-control-byte arm: a value
12393 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12394 // the canonical paste-from-multiline-doc footgun where a
12395 // newline landed mid-caminho between two paste fragments)
12396 // routes through `FonteCaminhoControlChar` not
12397 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12398 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12399 // load-bearing axis on every value that probes positive for
12400 // both — mirrors the cascade discipline on every prior arm.
12401 let d = dep_with_fonte(DepSource::Path {
12402 caminho: "../foo\n(cd bar)".into(),
12403 });
12404 let err = d.validate().unwrap_err();
12405 assert!(
12406 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12407 "got {err:?}",
12408 );
12409 }
12410
12411 #[test]
12412 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12413 // Cascade pin on the load-bearing leading-byte arm: a leading
12414 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12415 // through `FonteCaminhoAbsolute` not
12416 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12417 // diagnostic is the load-bearing axis, the subshell-grouping
12418 // byte is the secondary observation. Same precedence logic as
12419 // every prior leading-byte arm.
12420 let d = dep_with_fonte(DepSource::Path {
12421 caminho: "/etc/(cd foo)".into(),
12422 });
12423 let err = d.validate().unwrap_err();
12424 assert!(
12425 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12426 "got {err:?}",
12427 );
12428 }
12429
12430 #[test]
12431 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12432 // Cascade pin on the upstream leading-`$` var-expansion arm: a
12433 // value carrying both a leading `$` and a `(` (`"$(date)/\
12434 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12435 // command-substitution at the head of a sibling-workspace
12436 // path" footgun) routes through `FonteCaminhoVarExpansion` not
12437 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12438 // shell-variable-expansion is the more self-locating diagnostic
12439 // on values that probe as both — same load-bearing-leading-
12440 // byte cascade discipline every prior `:caminho` arm
12441 // establishes. Closing both halves of `$(<cmd>)` structurally
12442 // (leading `$` here, trailing `)` on the new arm) excludes the
12443 // entire modern Bourne command-substitution surface from the
12444 // typed `:caminho` accepted set; the cascade preserves the
12445 // narrower leading-byte diagnostic on values that probe both
12446 // halves at the canonical leading position.
12447 let d = dep_with_fonte(DepSource::Path {
12448 caminho: "$(date)/caixa-teia".into(),
12449 });
12450 let err = d.validate().unwrap_err();
12451 assert!(
12452 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12453 "got {err:?}",
12454 );
12455 }
12456
12457 #[test]
12458 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12459 // Cascade pin on the immediate-successor arm: a value carrying
12460 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12461 // "I tab-completed a path that already had a subshell-grouping
12462 // expansion tail" footgun) routes through
12463 // `FonteCaminhoShellSubshellGrouping` not
12464 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12465 // the more semantic-locating axis (an author who removes the
12466 // `(` typically also drops the trailing separator since both
12467 // are paste-from-shell artifacts).
12468 let d = dep_with_fonte(DepSource::Path {
12469 caminho: "../(cd foo)/".into(),
12470 });
12471 let err = d.validate().unwrap_err();
12472 assert!(
12473 matches!(
12474 err,
12475 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12476 ),
12477 "got {err:?}",
12478 );
12479 }
12480
12481 #[test]
12482 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12483 // Diagnostic-shape pin (peer with
12484 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12485 // on the closest two-byte peer arm): the error's Display
12486 // surfaces the offending `:nome`, the offending `:caminho`
12487 // verbatim, the offending byte's hex / character form, and
12488 // names the shell-subshell-grouping footgun explicitly so a
12489 // `feira lint` run can render the diagnostic without re-
12490 // parsing.
12491 let d = dep_with_fonte(DepSource::Path {
12492 caminho: "../caixa-teia/$(date)/build".into(),
12493 });
12494 let rendered = d.validate().unwrap_err().to_string();
12495 assert!(
12496 rendered.contains("caixa-teia"),
12497 "diagnostic must name the offending dep: {rendered}",
12498 );
12499 assert!(
12500 rendered.contains("../caixa-teia/$(date)/build"),
12501 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12502 );
12503 assert!(
12504 rendered.contains("0x28"),
12505 "diagnostic must surface the offending byte hex: {rendered:?}",
12506 );
12507 assert!(
12508 rendered.contains("subshell-grouping"),
12509 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12510 );
12511 assert!(
12512 rendered.contains("command-substitution"),
12513 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12514 {rendered:?}",
12515 );
12516 }
12517
12518 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12519 //
12520 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12521 // `)`) byte-pair arm: the same per-byte cascade with the same
12522 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12523 // `}` brace-expansion / URI-Template placeholder axis. The peer
12524 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12525 // byte pair on the sibling `:fonte :repo` axis under the same
12526 // banner.
12527
12528 #[test]
12529 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12530 // The fail-before-pass-after pin for the canonical paste-from-
12531 // shell-history brace-expansion footgun: an author copies a
12532 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12533 // liner whose `{a,b}` brace expansion fans across two siblings
12534 // and silently passed every prior arm (`Path::is_absolute`
12535 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12536 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12537 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12538 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12539 // value starts with `..` not `$`). The lacre embedded the
12540 // value verbatim, the resolver folded it through `Path::join`
12541 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12542 // subdirectory, and the failure surfaced at resolve time with
12543 // a non-self-locating `No such file or directory` error. The
12544 // new arm moves the rejection to validate time and names the
12545 // offending dep + caminho + byte verbatim. The arm fires on
12546 // the first `{` encountered.
12547 let d = dep_with_fonte(DepSource::Path {
12548 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12549 });
12550 let err = d.validate().unwrap_err();
12551 let DepError::FonteCaminhoShellBraceExpansion {
12552 nome,
12553 caminho,
12554 byte,
12555 } = err
12556 else {
12557 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12558 };
12559 assert_eq!(nome, "caixa-teia");
12560 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12561 assert_eq!(byte, b'{');
12562 }
12563
12564 #[test]
12565 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12566 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12567 // the degenerate "I selected an unbalanced closing brace out
12568 // of a shell-history block" idiom that probes for the
12569 // cascade's last-byte handling on a value carrying only the
12570 // closing byte). Pinned separately from the open-brace shape
12571 // so the gate's contract is "any `{` or `}` anywhere", not
12572 // single-byte coverage. Mirrors the peer
12573 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12574 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12575 // arm.
12576 let d = dep_with_fonte(DepSource::Path {
12577 caminho: "../caixa-teia}".into(),
12578 });
12579 let err = d.validate().unwrap_err();
12580 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12581 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12582 };
12583 assert_eq!(byte, b'}');
12584 }
12585
12586 #[test]
12587 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12588 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12589 // — the canonical "I selected a `{a,b}` brace-expansion prefix
12590 // out of a shell-history one-liner" idiom). Pinned separately
12591 // from the embedded-byte shape so the gate covers every
12592 // position, not only mid-path.
12593 let d = dep_with_fonte(DepSource::Path {
12594 caminho: "{caixa-teia,caixa-helm}/build".into(),
12595 });
12596 let err = d.validate().unwrap_err();
12597 assert!(
12598 matches!(
12599 err,
12600 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12601 ),
12602 "got {err:?}",
12603 );
12604 }
12605
12606 #[test]
12607 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12608 // The canonical URI-Template / Mustache / Helm doubled-brace
12609 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12610 // "I copied a `https://github.com/{{org}}/caixa-teia` README
12611 // quick-start / OpenAPI spec / Helm chart `home:` template
12612 // and forgot to substitute the placeholder" footgun). The arm
12613 // fires on the first `{` encountered; pinned so the gate's
12614 // coverage extends from the bare-brace shell-history shape to
12615 // the doubled-brace URI-Template / templating-engine shape.
12616 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12617 // sibling `:fonte :repo` axis.
12618 let d = dep_with_fonte(DepSource::Path {
12619 caminho: "../{{org}}/caixa-teia".into(),
12620 });
12621 let err = d.validate().unwrap_err();
12622 assert!(
12623 matches!(
12624 err,
12625 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12626 ),
12627 "got {err:?}",
12628 );
12629 }
12630
12631 #[test]
12632 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12633 // The canonical bash brace-range-expansion shape (`"../caixa-
12634 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12635 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12636 // sequence-range form to the `{a,b,c}` comma-separated form).
12637 // The arm fires on the first `{` encountered; pinned so the
12638 // gate's coverage extends from the comma-separated form to
12639 // the integer-range form.
12640 let d = dep_with_fonte(DepSource::Path {
12641 caminho: "../caixa-v{1..10}".into(),
12642 });
12643 let err = d.validate().unwrap_err();
12644 assert!(
12645 matches!(
12646 err,
12647 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12648 ),
12649 "got {err:?}",
12650 );
12651 }
12652
12653 #[test]
12654 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12655 // The positive-control pin: the gate targets only `{` / `}`,
12656 // never adjacent printable ASCII or POSIX-valid bytes. The
12657 // canonical relative POSIX path (`"../caixa-teia"`) and a
12658 // nested deeply-pathed variant with adjacent printable
12659 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12660 // validate cleanly so the gate doesn't widen to a "no
12661 // printable punctuation anywhere" sweep that would defeat
12662 // the entire path-fonte author surface. Peer with
12663 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12664 // on the immediate-predecessor arm.
12665 let d = dep_with_fonte(DepSource::Path {
12666 caminho: "../caixa-teia/sub-dir.v2".into(),
12667 });
12668 d.validate().unwrap();
12669 }
12670
12671 #[test]
12672 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12673 // Cascade pin on the immediate-predecessor arm: a value
12674 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12675 // canonical "I pasted a subshell-grouping followed by a
12676 // brace-expansion tail" footgun) routes through
12677 // `FonteCaminhoShellSubshellGrouping` not
12678 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12679 // shape is the more semantic-locating axis on every probe-
12680 // as-both value because it closes both halves of the modern
12681 // Bourne `$(<cmd>)` command-substitution surface — same
12682 // cascade discipline every prior `:caminho` arm establishes.
12683 let d = dep_with_fonte(DepSource::Path {
12684 caminho: "../(cd foo)/{a,b}".into(),
12685 });
12686 let err = d.validate().unwrap_err();
12687 assert!(
12688 matches!(
12689 err,
12690 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12691 ),
12692 "got {err:?}",
12693 );
12694 }
12695
12696 #[test]
12697 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12698 // Cascade pin on the upstream shell-glob arm: a value carrying
12699 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12700 // "I pasted a glob expansion followed by a brace-expansion
12701 // tail" footgun) routes through `FonteCaminhoShellGlob` not
12702 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12703 // shape is the load-bearing root-cause edit on every
12704 // probe-as-both value.
12705 let d = dep_with_fonte(DepSource::Path {
12706 caminho: "../caixa-teia/*{a,b}".into(),
12707 });
12708 let err = d.validate().unwrap_err();
12709 assert!(
12710 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12711 "got {err:?}",
12712 );
12713 }
12714
12715 #[test]
12716 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12717 // Cascade pin on the upstream shell-command-substitution arm:
12718 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12719 // — the canonical "I pasted a legacy-backtick command-
12720 // substitution followed by a brace-expansion fan-out" footgun)
12721 // routes through `FonteCaminhoShellCommandSubstitution` not
12722 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12723 // command-injection vector is the load-bearing root-cause
12724 // edit on every probe-as-both value.
12725 let d = dep_with_fonte(DepSource::Path {
12726 caminho: "../`whoami`/{a,b}".into(),
12727 });
12728 let err = d.validate().unwrap_err();
12729 assert!(
12730 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12731 "got {err:?}",
12732 );
12733 }
12734
12735 #[test]
12736 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12737 // Cascade pin on the upstream shell-background arm: a value
12738 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12739 // canonical "I pasted a `cmd & {fork-fan}` background-launch
12740 // + brace-expansion chain" footgun) routes through
12741 // `FonteCaminhoShellBackground` not
12742 // `FonteCaminhoShellBraceExpansion`. The background-launch
12743 // tail is the load-bearing root-cause edit on every
12744 // probe-as-both value.
12745 let d = dep_with_fonte(DepSource::Path {
12746 caminho: "../caixa-teia & {a,b}".into(),
12747 });
12748 let err = d.validate().unwrap_err();
12749 assert!(
12750 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12751 "got {err:?}",
12752 );
12753 }
12754
12755 #[test]
12756 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12757 // Cascade pin on the upstream shell-semicolon arm: a value
12758 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12759 // canonical sequential-cleanup + brace-expansion paste
12760 // idiom) routes through `FonteCaminhoShellSemicolon` not
12761 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12762 // separator paste is the load-bearing root-cause edit on
12763 // every probe-as-both value.
12764 let d = dep_with_fonte(DepSource::Path {
12765 caminho: "../caixa-teia; {a,b}".into(),
12766 });
12767 let err = d.validate().unwrap_err();
12768 assert!(
12769 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12770 "got {err:?}",
12771 );
12772 }
12773
12774 #[test]
12775 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12776 // Cascade pin on the upstream shell-pipe arm: a value
12777 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12778 // — the canonical pipeline-to-brace-expansion paste idiom)
12779 // routes through `FonteCaminhoShellPipe` not
12780 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12781 // is the load-bearing root-cause edit on every probe-as-
12782 // both value.
12783 let d = dep_with_fonte(DepSource::Path {
12784 caminho: "../caixa-teia | {tee,cat}".into(),
12785 });
12786 let err = d.validate().unwrap_err();
12787 assert!(
12788 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12789 "got {err:?}",
12790 );
12791 }
12792
12793 #[test]
12794 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12795 // Cascade pin on the upstream shell-redirection arm: a value
12796 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12797 // the canonical "I pasted a `cmd > log {a,b}` redirect-
12798 // plus-brace-expansion chain" footgun) routes through
12799 // `FonteCaminhoShellRedirection` not
12800 // `FonteCaminhoShellBraceExpansion`. The input/output
12801 // redirection metachar carries the more self-locating
12802 // `byte` payload, so the prior arm wins on every probe-
12803 // as-both value.
12804 let d = dep_with_fonte(DepSource::Path {
12805 caminho: "../caixa-teia>log {a,b}".into(),
12806 });
12807 let err = d.validate().unwrap_err();
12808 assert!(
12809 matches!(
12810 err,
12811 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12812 ),
12813 "got {err:?}",
12814 );
12815 }
12816
12817 #[test]
12818 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12819 // Cascade pin on the upstream backslash arm: a value
12820 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12821 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12822 // chain") routes through `FonteCaminhoBackslash` not
12823 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12824 // separator divergence is the load-bearing axis on every
12825 // probe-as-both value.
12826 let d = dep_with_fonte(DepSource::Path {
12827 caminho: "..\\caixa-teia\\{a,b}".into(),
12828 });
12829 let err = d.validate().unwrap_err();
12830 assert!(
12831 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12832 "got {err:?}",
12833 );
12834 }
12835
12836 #[test]
12837 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12838 // Cascade pin on the embedded-control-byte arm: a value
12839 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12840 // the canonical paste-from-multiline-doc footgun where a
12841 // newline landed mid-caminho between two paste fragments)
12842 // routes through `FonteCaminhoControlChar` not
12843 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12844 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12845 // load-bearing axis on every value that probes positive for
12846 // both — mirrors the cascade discipline on every prior arm.
12847 let d = dep_with_fonte(DepSource::Path {
12848 caminho: "../foo\n{a,b}".into(),
12849 });
12850 let err = d.validate().unwrap_err();
12851 assert!(
12852 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12853 "got {err:?}",
12854 );
12855 }
12856
12857 #[test]
12858 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12859 // Cascade pin on the load-bearing leading-byte arm: a
12860 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12861 // routes through `FonteCaminhoAbsolute` not
12862 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12863 // diagnostic is the load-bearing axis, the brace-expansion
12864 // byte is the secondary observation. Same precedence logic
12865 // as every prior leading-byte arm.
12866 let d = dep_with_fonte(DepSource::Path {
12867 caminho: "/etc/{a,b}".into(),
12868 });
12869 let err = d.validate().unwrap_err();
12870 assert!(
12871 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12872 "got {err:?}",
12873 );
12874 }
12875
12876 #[test]
12877 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12878 // Cascade pin on the upstream leading-`$` var-expansion
12879 // arm: a value carrying both a leading `$` and a `{`
12880 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12881 // `${ORG}` shell-variable + curly-brace expansion at the
12882 // head of a sibling-workspace path" footgun) routes through
12883 // `FonteCaminhoVarExpansion` not
12884 // `FonteCaminhoShellBraceExpansion`. The leading-byte
12885 // shell-variable-expansion is the more self-locating
12886 // diagnostic on values that probe as both — same
12887 // load-bearing-leading-byte cascade discipline every prior
12888 // `:caminho` arm establishes.
12889 let d = dep_with_fonte(DepSource::Path {
12890 caminho: "${ORG}/caixa-teia".into(),
12891 });
12892 let err = d.validate().unwrap_err();
12893 assert!(
12894 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12895 "got {err:?}",
12896 );
12897 }
12898
12899 #[test]
12900 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12901 // Cascade pin on the immediate-successor arm: a value
12902 // carrying both `{` and a trailing `/`
12903 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12904 // tab-completed a path that already had a brace-expansion
12905 // expansion tail" footgun) routes through
12906 // `FonteCaminhoShellBraceExpansion` not
12907 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12908 // is the more semantic-locating axis (an author who removes
12909 // the `{` typically also drops the trailing separator since
12910 // both are paste-from-shell artifacts).
12911 let d = dep_with_fonte(DepSource::Path {
12912 caminho: "../{caixa-teia,caixa-helm}/".into(),
12913 });
12914 let err = d.validate().unwrap_err();
12915 assert!(
12916 matches!(
12917 err,
12918 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12919 ),
12920 "got {err:?}",
12921 );
12922 }
12923
12924 #[test]
12925 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12926 // Diagnostic-shape pin (peer with
12927 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12928 // on the closest two-byte peer arm): the error's Display
12929 // surfaces the offending `:nome`, the offending `:caminho`
12930 // verbatim, the offending byte's hex / character form, and
12931 // names the shell-brace-expansion / URI-Template footgun
12932 // explicitly so a `feira lint` run can render the diagnostic
12933 // without re-parsing.
12934 let d = dep_with_fonte(DepSource::Path {
12935 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12936 });
12937 let rendered = d.validate().unwrap_err().to_string();
12938 assert!(
12939 rendered.contains("caixa-teia"),
12940 "diagnostic must name the offending dep: {rendered}",
12941 );
12942 assert!(
12943 rendered.contains("../{caixa-teia,caixa-helm}/build"),
12944 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12945 );
12946 assert!(
12947 rendered.contains("0x7b"),
12948 "diagnostic must surface the offending byte hex: {rendered:?}",
12949 );
12950 assert!(
12951 rendered.contains("brace-expansion"),
12952 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12953 );
12954 assert!(
12955 rendered.contains("URI Template"),
12956 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12957 {rendered:?}",
12958 );
12959 }
12960
12961 #[test]
12962 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12963 // The canonical paste-from-shell-history bracket-glob /
12964 // character-class footgun: an author copies a
12965 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12966 // `[a-z]` POSIX glob character-class matches every lowercase-
12967 // ASCII-suffix sibling caixa directory and silently passed
12968 // every prior arm (`Path::is_absolute` false on `..`, no
12969 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12970 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12971 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12972 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12973 // value starts with `..` not `$`). The lacre embedded the
12974 // value verbatim, the resolver folded it through
12975 // `Path::join` looking for a literal `./../caixa-[a-z]/
12976 // build` subdirectory, and the failure surfaced at resolve
12977 // time with a non-self-locating `No such file or directory`
12978 // error. The new arm moves the rejection to validate time
12979 // and names the offending dep + caminho + byte verbatim.
12980 // The arm fires on the first `[` encountered.
12981 let d = dep_with_fonte(DepSource::Path {
12982 caminho: "../caixa-[a-z]/build".into(),
12983 });
12984 let err = d.validate().unwrap_err();
12985 let DepError::FonteCaminhoShellBracketExpansion {
12986 nome,
12987 caminho,
12988 byte,
12989 } = err
12990 else {
12991 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12992 };
12993 assert_eq!(nome, "caixa-teia");
12994 assert_eq!(caminho, "../caixa-[a-z]/build");
12995 assert_eq!(byte, b'[');
12996 }
12997
12998 #[test]
12999 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13000 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13001 // — the degenerate "I selected an unbalanced closing bracket
13002 // out of a glob character-class block" idiom that probes for
13003 // the cascade's last-byte handling on a value carrying only
13004 // the closing byte). Pinned separately from the open-bracket
13005 // shape so the gate's contract is "any `[` or `]` anywhere",
13006 // not single-byte coverage. Mirrors the peer
13007 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13008 // shape on the immediate-predecessor
13009 // `FonteCaminhoShellBraceExpansion` arm.
13010 let d = dep_with_fonte(DepSource::Path {
13011 caminho: "../caixa-teia]".into(),
13012 });
13013 let err = d.validate().unwrap_err();
13014 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13015 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13016 };
13017 assert_eq!(byte, b']');
13018 }
13019
13020 #[test]
13021 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13022 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13023 // canonical "I selected a `[caixa-teia]` TOML-table-header /
13024 // glob-character-class prefix out of an aligned config /
13025 // shell-history one-liner" idiom). Pinned separately from
13026 // the embedded-byte shape so the gate covers every position,
13027 // not only mid-path.
13028 let d = dep_with_fonte(DepSource::Path {
13029 caminho: "[caixa-teia]/build".into(),
13030 });
13031 let err = d.validate().unwrap_err();
13032 assert!(
13033 matches!(
13034 err,
13035 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13036 ),
13037 "got {err:?}",
13038 );
13039 }
13040
13041 #[test]
13042 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13043 // The canonical TOML inline-array / YAML flow-sequence
13044 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13045 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13046 // inline-array out of a sibling-Cargo manifest" cross-idiom
13047 // leak; the symmetric YAML flow-sequence form `paths: [/a,
13048 // /b]` paste-from-values.yaml shape carries the same
13049 // bracket pair). The arm fires on the first `[` encountered;
13050 // pinned so the gate's coverage extends from the bare-
13051 // bracket glob-character-class shape to the TOML / YAML /
13052 // JSON array-literal shape.
13053 let d = dep_with_fonte(DepSource::Path {
13054 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13055 });
13056 let err = d.validate().unwrap_err();
13057 assert!(
13058 matches!(
13059 err,
13060 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13061 ),
13062 "got {err:?}",
13063 );
13064 }
13065
13066 #[test]
13067 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13068 // The canonical POSIX `test` / `[` builtin command paste
13069 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13070 // script conditional every paste-from-shell-script idiom
13071 // carries; bash's `[[ <expr> ]]` extended-test grammar
13072 // would surface the same byte pair). The arm fires on the
13073 // first `[` encountered; pinned so the gate's coverage
13074 // extends from the embedded-glob-character-class shape to
13075 // the leading-`test`-builtin / extended-test form.
13076 let d = dep_with_fonte(DepSource::Path {
13077 caminho: "../[ -d caixa-teia ]".into(),
13078 });
13079 let err = d.validate().unwrap_err();
13080 assert!(
13081 matches!(
13082 err,
13083 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13084 ),
13085 "got {err:?}",
13086 );
13087 }
13088
13089 #[test]
13090 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13091 // The positive-control pin: the gate targets only `[` /
13092 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13093 // The canonical relative POSIX path (`"../caixa-teia"`) and
13094 // a nested deeply-pathed variant with adjacent printable
13095 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13096 // to validate cleanly so the gate doesn't widen to a "no
13097 // printable punctuation anywhere" sweep that would defeat
13098 // the entire path-fonte author surface. Peer with
13099 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13100 // on the immediate-predecessor arm.
13101 let d = dep_with_fonte(DepSource::Path {
13102 caminho: "../caixa-teia/sub-dir.v2".into(),
13103 });
13104 d.validate().unwrap();
13105 }
13106
13107 #[test]
13108 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13109 // Cascade pin on the immediate-predecessor arm: a value
13110 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13111 // canonical "I pasted a brace-expansion fan followed by a
13112 // glob-character-class tail" footgun) routes through
13113 // `FonteCaminhoShellBraceExpansion` not
13114 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13115 // fan is the load-bearing root-cause edit on every
13116 // probe-as-both value because the bracket-class tail
13117 // typically rides on a prior brace-expansion expansion;
13118 // same cascade discipline every prior `:caminho` arm
13119 // establishes.
13120 let d = dep_with_fonte(DepSource::Path {
13121 caminho: "../{a,b}[ch]".into(),
13122 });
13123 let err = d.validate().unwrap_err();
13124 assert!(
13125 matches!(
13126 err,
13127 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13128 ),
13129 "got {err:?}",
13130 );
13131 }
13132
13133 #[test]
13134 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13135 // Cascade pin on the upstream shell-subshell-grouping arm:
13136 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13137 // the canonical "I pasted a subshell-grouping followed by
13138 // a glob-character-class tail" footgun) routes through
13139 // `FonteCaminhoShellSubshellGrouping` not
13140 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13141 // `$(<cmd>)` command-substitution boundary is the load-
13142 // bearing axis on every probe-as-both value.
13143 let d = dep_with_fonte(DepSource::Path {
13144 caminho: "../(cd foo)/[ch]".into(),
13145 });
13146 let err = d.validate().unwrap_err();
13147 assert!(
13148 matches!(
13149 err,
13150 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13151 ),
13152 "got {err:?}",
13153 );
13154 }
13155
13156 #[test]
13157 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13158 // Cascade pin on the upstream shell-glob arm: a value
13159 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13160 // canonical "I pasted a `*.[ch]` C-source-file glob whose
13161 // unbounded `*` precedes the bracket character-class"
13162 // footgun) routes through `FonteCaminhoShellGlob` not
13163 // `FonteCaminhoShellBracketExpansion`. The unbounded
13164 // pathname-expansion sentinel is the load-bearing root-
13165 // cause edit on every probe-as-both value — the unbounded
13166 // `*` carries the more aggressive expansion vector than
13167 // the bounded `[ch]` class, so the prior arm wins.
13168 let d = dep_with_fonte(DepSource::Path {
13169 caminho: "../caixa-teia/*[ch]".into(),
13170 });
13171 let err = d.validate().unwrap_err();
13172 assert!(
13173 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13174 "got {err:?}",
13175 );
13176 }
13177
13178 #[test]
13179 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13180 // Cascade pin on the upstream shell-command-substitution
13181 // arm: a value carrying both a backtick and `[`
13182 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13183 // legacy-backtick command-substitution followed by a
13184 // glob-character-class tail" footgun) routes through
13185 // `FonteCaminhoShellCommandSubstitution` not
13186 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13187 // command-injection vector is the load-bearing root-cause
13188 // edit on every probe-as-both value.
13189 let d = dep_with_fonte(DepSource::Path {
13190 caminho: "../`whoami`/[ch]".into(),
13191 });
13192 let err = d.validate().unwrap_err();
13193 assert!(
13194 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13195 "got {err:?}",
13196 );
13197 }
13198
13199 #[test]
13200 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13201 // Cascade pin on the upstream shell-background arm: a
13202 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13203 // — the canonical "I pasted a `cmd & [glob]` background-
13204 // launch + bracket-class chain" footgun) routes through
13205 // `FonteCaminhoShellBackground` not
13206 // `FonteCaminhoShellBracketExpansion`. The background-
13207 // launch tail is the load-bearing root-cause edit on
13208 // every probe-as-both value.
13209 let d = dep_with_fonte(DepSource::Path {
13210 caminho: "../caixa-teia & [ch]".into(),
13211 });
13212 let err = d.validate().unwrap_err();
13213 assert!(
13214 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13215 "got {err:?}",
13216 );
13217 }
13218
13219 #[test]
13220 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13221 // Cascade pin on the upstream shell-semicolon arm: a value
13222 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13223 // canonical sequential-cleanup + bracket-class paste
13224 // idiom) routes through `FonteCaminhoShellSemicolon` not
13225 // `FonteCaminhoShellBracketExpansion`. The sequential-
13226 // command-separator paste is the load-bearing root-cause
13227 // edit on every probe-as-both value.
13228 let d = dep_with_fonte(DepSource::Path {
13229 caminho: "../caixa-teia; [ch]".into(),
13230 });
13231 let err = d.validate().unwrap_err();
13232 assert!(
13233 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13234 "got {err:?}",
13235 );
13236 }
13237
13238 #[test]
13239 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13240 // Cascade pin on the upstream shell-pipe arm: a value
13241 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13242 // the canonical pipeline-to-bracket-class paste idiom)
13243 // routes through `FonteCaminhoShellPipe` not
13244 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13245 // paste is the load-bearing root-cause edit on every
13246 // probe-as-both value.
13247 let d = dep_with_fonte(DepSource::Path {
13248 caminho: "../caixa-teia | [tee]".into(),
13249 });
13250 let err = d.validate().unwrap_err();
13251 assert!(
13252 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13253 "got {err:?}",
13254 );
13255 }
13256
13257 #[test]
13258 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13259 // Cascade pin on the upstream shell-redirection arm: a
13260 // value carrying both `>` and `[` (`"../caixa-teia>log
13261 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13262 // redirect-plus-bracket chain" footgun) routes through
13263 // `FonteCaminhoShellRedirection` not
13264 // `FonteCaminhoShellBracketExpansion`. The input/output
13265 // redirection metachar carries the more self-locating
13266 // `byte` payload, so the prior arm wins on every
13267 // probe-as-both value.
13268 let d = dep_with_fonte(DepSource::Path {
13269 caminho: "../caixa-teia>log [ch]".into(),
13270 });
13271 let err = d.validate().unwrap_err();
13272 assert!(
13273 matches!(
13274 err,
13275 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13276 ),
13277 "got {err:?}",
13278 );
13279 }
13280
13281 #[test]
13282 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13283 // Cascade pin on the upstream backslash arm: a value
13284 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13285 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13286 // chain") routes through `FonteCaminhoBackslash` not
13287 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13288 // separator divergence is the load-bearing axis on every
13289 // probe-as-both value.
13290 let d = dep_with_fonte(DepSource::Path {
13291 caminho: "..\\caixa-teia\\[ch]".into(),
13292 });
13293 let err = d.validate().unwrap_err();
13294 assert!(
13295 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13296 "got {err:?}",
13297 );
13298 }
13299
13300 #[test]
13301 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13302 // Cascade pin on the embedded-control-byte arm: a value
13303 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13304 // the canonical paste-from-multiline-doc footgun where a
13305 // newline landed mid-caminho between two paste fragments)
13306 // routes through `FonteCaminhoControlChar` not
13307 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13308 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13309 // the load-bearing axis on every value that probes
13310 // positive for both — mirrors the cascade discipline on
13311 // every prior arm.
13312 let d = dep_with_fonte(DepSource::Path {
13313 caminho: "../foo\n[ch]".into(),
13314 });
13315 let err = d.validate().unwrap_err();
13316 assert!(
13317 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13318 "got {err:?}",
13319 );
13320 }
13321
13322 #[test]
13323 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13324 // Cascade pin on the load-bearing leading-byte arm: a
13325 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13326 // routes through `FonteCaminhoAbsolute` not
13327 // `FonteCaminhoShellBracketExpansion` — the host-layout-
13328 // leak diagnostic is the load-bearing axis, the bracket-
13329 // expansion byte is the secondary observation. Same
13330 // precedence logic as every prior leading-byte arm.
13331 let d = dep_with_fonte(DepSource::Path {
13332 caminho: "/etc/[ch]".into(),
13333 });
13334 let err = d.validate().unwrap_err();
13335 assert!(
13336 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13337 "got {err:?}",
13338 );
13339 }
13340
13341 #[test]
13342 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13343 // Cascade pin on the upstream leading-`$` var-expansion
13344 // arm: a value carrying both a leading `$` and a `[`
13345 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13346 // variable + bracket-class at the head of a sibling-
13347 // workspace path" footgun) routes through
13348 // `FonteCaminhoVarExpansion` not
13349 // `FonteCaminhoShellBracketExpansion`. The leading-byte
13350 // shell-variable-expansion is the more self-locating
13351 // diagnostic on values that probe as both — same
13352 // load-bearing-leading-byte cascade discipline every
13353 // prior `:caminho` arm establishes.
13354 let d = dep_with_fonte(DepSource::Path {
13355 caminho: "$DIR/[ch]".into(),
13356 });
13357 let err = d.validate().unwrap_err();
13358 assert!(
13359 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13360 "got {err:?}",
13361 );
13362 }
13363
13364 #[test]
13365 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13366 // Cascade pin on the immediate-successor arm: a value
13367 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13368 // the canonical "I tab-completed a path that already had
13369 // a bracket-glob-character-class expansion tail" footgun)
13370 // routes through `FonteCaminhoShellBracketExpansion` not
13371 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13372 // is the more semantic-locating axis (an author who
13373 // removes the `[` typically also drops the trailing
13374 // separator since both are paste-from-shell artifacts).
13375 let d = dep_with_fonte(DepSource::Path {
13376 caminho: "../[a-z]/".into(),
13377 });
13378 let err = d.validate().unwrap_err();
13379 assert!(
13380 matches!(
13381 err,
13382 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13383 ),
13384 "got {err:?}",
13385 );
13386 }
13387
13388 #[test]
13389 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13390 // Diagnostic-shape pin (peer with
13391 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13392 // on the closest two-byte peer arm): the error's Display
13393 // surfaces the offending `:nome`, the offending `:caminho`
13394 // verbatim, the offending byte's hex / character form, and
13395 // names the shell-bracket-expansion / glob-character-class
13396 // footgun explicitly so a `feira lint` run can render the
13397 // diagnostic without re-parsing.
13398 let d = dep_with_fonte(DepSource::Path {
13399 caminho: "../caixa-[a-z]/build".into(),
13400 });
13401 let rendered = d.validate().unwrap_err().to_string();
13402 assert!(
13403 rendered.contains("caixa-teia"),
13404 "diagnostic must name the offending dep: {rendered}",
13405 );
13406 assert!(
13407 rendered.contains("../caixa-[a-z]/build"),
13408 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13409 );
13410 assert!(
13411 rendered.contains("0x5b"),
13412 "diagnostic must surface the offending byte hex: {rendered:?}",
13413 );
13414 assert!(
13415 rendered.contains("bracket-expansion"),
13416 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13417 );
13418 assert!(
13419 rendered.contains("glob-character-class"),
13420 "diagnostic must reference the POSIX glob-character-class vocabulary: \
13421 {rendered:?}",
13422 );
13423 }
13424
13425 #[test]
13426 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13427 // The canonical paste-from-shell-history strong-quoted
13428 // sibling-workspace-path footgun: an author copies a
13429 // `cd '../caixa-teia'` shell-history one-liner whose strong-
13430 // quoting preserved the path across a whitespace paste
13431 // boundary and silently passed every prior arm
13432 // (`Path::is_absolute` false on `'..`, no control bytes, no
13433 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13434 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13435 // doesn't end in `/`; the leading-`$` f4efe9c
13436 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13437 // value starts with `'` not `$`). The lacre embedded the
13438 // value verbatim, the resolver folded it through
13439 // `Path::join` looking for a literal `./'../caixa-teia'`
13440 // subdirectory, and the failure surfaced at resolve time
13441 // with a non-self-locating `No such file or directory`
13442 // error. The new arm moves the rejection to validate time
13443 // and names the offending dep + caminho + byte verbatim.
13444 // The arm fires on the first `'` encountered.
13445 let d = dep_with_fonte(DepSource::Path {
13446 caminho: "'../caixa-teia'".into(),
13447 });
13448 let err = d.validate().unwrap_err();
13449 let DepError::FonteCaminhoShellQuoteGrouping {
13450 nome,
13451 caminho,
13452 byte,
13453 } = err
13454 else {
13455 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13456 };
13457 assert_eq!(nome, "caixa-teia");
13458 assert_eq!(caminho, "'../caixa-teia'");
13459 assert_eq!(byte, b'\'');
13460 }
13461
13462 #[test]
13463 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13464 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13465 // — the canonical paste-from-JSON-config / paste-from-YAML-
13466 // flow-scalar / paste-from-TOML-basic-string / paste-from-
13467 // tatara-lisp-string-literal cross-idiom leak). Pinned
13468 // separately from the single-quote shape so the gate's
13469 // contract is "any `'` or `\"` anywhere", not single-byte
13470 // coverage. Mirrors the peer
13471 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13472 // shape on the immediate-predecessor
13473 // `FonteCaminhoShellBracketExpansion` arm.
13474 let d = dep_with_fonte(DepSource::Path {
13475 caminho: "\"../caixa-teia\"".into(),
13476 });
13477 let err = d.validate().unwrap_err();
13478 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13479 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13480 };
13481 assert_eq!(byte, b'"');
13482 }
13483
13484 #[test]
13485 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13486 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13487 // canonical "I pasted a JSON key-value pair fragment into
13488 // the middle of the path" idiom). Pinned separately from
13489 // the leading-byte shape so the gate covers every position,
13490 // not only leading.
13491 let d = dep_with_fonte(DepSource::Path {
13492 caminho: "../\"caixa-teia\"".into(),
13493 });
13494 let err = d.validate().unwrap_err();
13495 assert!(
13496 matches!(
13497 err,
13498 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13499 ),
13500 "got {err:?}",
13501 );
13502 }
13503
13504 #[test]
13505 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13506 // The canonical YAML double-quoted flow-scalar cross-idiom
13507 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13508 // `path: \"...\"` YAML flow-scalar entry out of an aligned
13509 // values.yaml / K8s manifest and dropped it verbatim into
13510 // the `:caminho` slot including the `path: ` key prefix"
13511 // paste-idiom). The arm fires on the first `"` encountered;
13512 // pinned so the gate's coverage extends from the bare-quote
13513 // paste shape to the aligned-YAML-manifest cross-idiom-leak
13514 // shape.
13515 let d = dep_with_fonte(DepSource::Path {
13516 caminho: "path: \"../caixa-teia\"".into(),
13517 });
13518 let err = d.validate().unwrap_err();
13519 assert!(
13520 matches!(
13521 err,
13522 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13523 ),
13524 "got {err:?}",
13525 );
13526 }
13527
13528 #[test]
13529 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13530 // The positive-control pin: the gate targets only `'` /
13531 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13532 // The canonical relative POSIX path (`"../caixa-teia"`) and
13533 // a nested deeply-pathed variant with adjacent printable
13534 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13535 // to validate cleanly so the gate doesn't widen to a "no
13536 // printable punctuation anywhere" sweep that would defeat
13537 // the entire path-fonte author surface. Peer with
13538 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13539 // on the immediate-predecessor arm.
13540 let d = dep_with_fonte(DepSource::Path {
13541 caminho: "../caixa-teia/sub-dir.v2".into(),
13542 });
13543 d.validate().unwrap();
13544 }
13545
13546 #[test]
13547 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13548 // Cascade pin on the immediate-predecessor arm: a value
13549 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13550 // "I pasted a glob-character-class followed by a strong-
13551 // quoted literal tail" footgun) routes through
13552 // `FonteCaminhoShellBracketExpansion` not
13553 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13554 // expansion is the load-bearing root-cause edit on every
13555 // probe-as-both value; same cascade discipline every prior
13556 // `:caminho` arm establishes.
13557 let d = dep_with_fonte(DepSource::Path {
13558 caminho: "../[a-z]'x'".into(),
13559 });
13560 let err = d.validate().unwrap_err();
13561 assert!(
13562 matches!(
13563 err,
13564 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13565 ),
13566 "got {err:?}",
13567 );
13568 }
13569
13570 #[test]
13571 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13572 // Cascade pin on the upstream shell-brace-expansion arm: a
13573 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13574 // canonical "I pasted a brace-expansion fan followed by a
13575 // strong-quoted literal tail" footgun) routes through
13576 // `FonteCaminhoShellBraceExpansion` not
13577 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13578 // is the load-bearing root-cause edit on every probe-as-
13579 // both value.
13580 let d = dep_with_fonte(DepSource::Path {
13581 caminho: "../{a,b}'x'".into(),
13582 });
13583 let err = d.validate().unwrap_err();
13584 assert!(
13585 matches!(
13586 err,
13587 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13588 ),
13589 "got {err:?}",
13590 );
13591 }
13592
13593 #[test]
13594 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13595 // Cascade pin on the upstream shell-subshell-grouping arm:
13596 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13597 // the canonical "I pasted a subshell-grouping followed by
13598 // a strong-quoted literal tail" footgun) routes through
13599 // `FonteCaminhoShellSubshellGrouping` not
13600 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13601 // `$(<cmd>)` command-substitution boundary is the load-
13602 // bearing axis on every probe-as-both value.
13603 let d = dep_with_fonte(DepSource::Path {
13604 caminho: "../(cd foo)/'x'".into(),
13605 });
13606 let err = d.validate().unwrap_err();
13607 assert!(
13608 matches!(
13609 err,
13610 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13611 ),
13612 "got {err:?}",
13613 );
13614 }
13615
13616 #[test]
13617 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13618 // Cascade pin on the upstream shell-glob arm: a value
13619 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13620 // canonical "I pasted a `*` unbounded pathname-expansion
13621 // followed by a strong-quoted literal tail" footgun) routes
13622 // through `FonteCaminhoShellGlob` not
13623 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13624 // expansion sentinel is the load-bearing root-cause edit
13625 // on every probe-as-both value.
13626 let d = dep_with_fonte(DepSource::Path {
13627 caminho: "../caixa-teia/*'x'".into(),
13628 });
13629 let err = d.validate().unwrap_err();
13630 assert!(
13631 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13632 "got {err:?}",
13633 );
13634 }
13635
13636 #[test]
13637 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13638 // Cascade pin on the upstream shell-command-substitution
13639 // arm: a value carrying both a backtick and `'`
13640 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13641 // legacy-backtick command-substitution followed by a
13642 // strong-quoted literal tail" footgun) routes through
13643 // `FonteCaminhoShellCommandSubstitution` not
13644 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13645 // command-injection vector is the load-bearing root-cause
13646 // edit on every probe-as-both value.
13647 let d = dep_with_fonte(DepSource::Path {
13648 caminho: "../`whoami`/'x'".into(),
13649 });
13650 let err = d.validate().unwrap_err();
13651 assert!(
13652 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13653 "got {err:?}",
13654 );
13655 }
13656
13657 #[test]
13658 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13659 // Cascade pin on the upstream shell-background arm: a value
13660 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13661 // canonical "I pasted a `cmd & 'literal'` background-launch
13662 // + quote chain" footgun) routes through
13663 // `FonteCaminhoShellBackground` not
13664 // `FonteCaminhoShellQuoteGrouping`. The background-launch
13665 // tail is the load-bearing root-cause edit on every
13666 // probe-as-both value.
13667 let d = dep_with_fonte(DepSource::Path {
13668 caminho: "../caixa-teia & 'x'".into(),
13669 });
13670 let err = d.validate().unwrap_err();
13671 assert!(
13672 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13673 "got {err:?}",
13674 );
13675 }
13676
13677 #[test]
13678 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13679 // Cascade pin on the upstream shell-semicolon arm: a value
13680 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13681 // canonical sequential-cleanup + quote paste idiom) routes
13682 // through `FonteCaminhoShellSemicolon` not
13683 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13684 // separator paste is the load-bearing root-cause edit on
13685 // every probe-as-both value.
13686 let d = dep_with_fonte(DepSource::Path {
13687 caminho: "../caixa-teia; 'x'".into(),
13688 });
13689 let err = d.validate().unwrap_err();
13690 assert!(
13691 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13692 "got {err:?}",
13693 );
13694 }
13695
13696 #[test]
13697 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13698 // Cascade pin on the upstream shell-pipe arm: a value
13699 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13700 // canonical pipeline-to-quoted-literal paste idiom) routes
13701 // through `FonteCaminhoShellPipe` not
13702 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13703 // is the load-bearing root-cause edit on every probe-as-
13704 // both value.
13705 let d = dep_with_fonte(DepSource::Path {
13706 caminho: "../caixa-teia | 'x'".into(),
13707 });
13708 let err = d.validate().unwrap_err();
13709 assert!(
13710 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13711 "got {err:?}",
13712 );
13713 }
13714
13715 #[test]
13716 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13717 // Cascade pin on the upstream shell-redirection arm: a
13718 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13719 // — the canonical "I pasted a `cmd > log 'literal'`
13720 // redirect-plus-quote chain" footgun) routes through
13721 // `FonteCaminhoShellRedirection` not
13722 // `FonteCaminhoShellQuoteGrouping`. The input/output
13723 // redirection metachar carries the more self-locating
13724 // `byte` payload, so the prior arm wins on every probe-as-
13725 // both value.
13726 let d = dep_with_fonte(DepSource::Path {
13727 caminho: "../caixa-teia>log 'x'".into(),
13728 });
13729 let err = d.validate().unwrap_err();
13730 assert!(
13731 matches!(
13732 err,
13733 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13734 ),
13735 "got {err:?}",
13736 );
13737 }
13738
13739 #[test]
13740 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13741 // Cascade pin on the upstream backslash arm: a value
13742 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13743 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13744 // chain" footgun) routes through `FonteCaminhoBackslash`
13745 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13746 // separator divergence is the load-bearing axis on every
13747 // probe-as-both value.
13748 let d = dep_with_fonte(DepSource::Path {
13749 caminho: "..\\caixa-teia\\'x'".into(),
13750 });
13751 let err = d.validate().unwrap_err();
13752 assert!(
13753 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13754 "got {err:?}",
13755 );
13756 }
13757
13758 #[test]
13759 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13760 // Cascade pin on the embedded-control-byte arm: a value
13761 // carrying both a control byte and `'` (`"../foo\n'x'"` —
13762 // the canonical paste-from-multiline-doc footgun where a
13763 // newline landed mid-caminho between two paste fragments)
13764 // routes through `FonteCaminhoControlChar` not
13765 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13766 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13767 // the load-bearing axis on every value that probes
13768 // positive for both — mirrors the cascade discipline on
13769 // every prior arm.
13770 let d = dep_with_fonte(DepSource::Path {
13771 caminho: "../foo\n'x'".into(),
13772 });
13773 let err = d.validate().unwrap_err();
13774 assert!(
13775 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13776 "got {err:?}",
13777 );
13778 }
13779
13780 #[test]
13781 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13782 // Cascade pin on the load-bearing leading-byte arm: a
13783 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13784 // through `FonteCaminhoAbsolute` not
13785 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13786 // diagnostic is the load-bearing axis, the quote byte is
13787 // the secondary observation. Same precedence logic as every
13788 // prior leading-byte arm.
13789 let d = dep_with_fonte(DepSource::Path {
13790 caminho: "/etc/'x'".into(),
13791 });
13792 let err = d.validate().unwrap_err();
13793 assert!(
13794 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13795 "got {err:?}",
13796 );
13797 }
13798
13799 #[test]
13800 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13801 // Cascade pin on the upstream leading-`$` var-expansion
13802 // arm: a value carrying both a leading `$` and a `'`
13803 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13804 // variable + quoted literal at the head of a sibling-
13805 // workspace path" footgun) routes through
13806 // `FonteCaminhoVarExpansion` not
13807 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13808 // shell-variable-expansion is the more self-locating
13809 // diagnostic on values that probe as both — same
13810 // load-bearing-leading-byte cascade discipline every
13811 // prior `:caminho` arm establishes.
13812 let d = dep_with_fonte(DepSource::Path {
13813 caminho: "$DIR/'x'".into(),
13814 });
13815 let err = d.validate().unwrap_err();
13816 assert!(
13817 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13818 "got {err:?}",
13819 );
13820 }
13821
13822 #[test]
13823 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13824 // Cascade pin on the immediate-successor arm: a value
13825 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13826 // — the canonical "I tab-completed a path whose strong-
13827 // quoted body already carried the quoting from a shell-
13828 // history paste" footgun) routes through
13829 // `FonteCaminhoShellQuoteGrouping` not
13830 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13831 // is the more semantic-locating axis (an author who removes
13832 // the `'` typically also drops the trailing separator since
13833 // both are paste-from-shell artifacts).
13834 let d = dep_with_fonte(DepSource::Path {
13835 caminho: "../'caixa-teia'/".into(),
13836 });
13837 let err = d.validate().unwrap_err();
13838 assert!(
13839 matches!(
13840 err,
13841 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13842 ),
13843 "got {err:?}",
13844 );
13845 }
13846
13847 #[test]
13848 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13849 // Diagnostic-shape pin (peer with
13850 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13851 // on the closest two-byte peer arm): the error's Display
13852 // surfaces the offending `:nome`, the offending `:caminho`
13853 // verbatim, the offending byte's hex / character form, and
13854 // names the shell-quote-grouping / cross-config-DSL-string-
13855 // literal-delimiter footgun explicitly so a `feira lint`
13856 // run can render the diagnostic without re-parsing.
13857 let d = dep_with_fonte(DepSource::Path {
13858 caminho: "'../caixa-teia'".into(),
13859 });
13860 let rendered = d.validate().unwrap_err().to_string();
13861 assert!(
13862 rendered.contains("caixa-teia"),
13863 "diagnostic must name the offending dep: {rendered}",
13864 );
13865 assert!(
13866 rendered.contains("'../caixa-teia'"),
13867 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13868 );
13869 assert!(
13870 rendered.contains("0x27"),
13871 "diagnostic must surface the offending byte hex: {rendered:?}",
13872 );
13873 assert!(
13874 rendered.contains("quote-grouping"),
13875 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13876 );
13877 assert!(
13878 rendered.contains("string-literal"),
13879 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13880 vocabulary: {rendered:?}",
13881 );
13882 }
13883
13884 #[test]
13885 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13886 // The canonical paste-from-shell-history-with-trailing-
13887 // annotation footgun: an author pastes a `cd ../caixa-teia
13888 // # legacy sibling` shell-history one-liner whose unquoted `#`
13889 // comment-lead separates the path from an inline annotation.
13890 // The POSIX shell trims the annotation to `../caixa-teia`
13891 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13892 // `Path::is_absolute` returns false on `..`, `#` is neither
13893 // a leading-byte sentinel nor a control byte nor `\` nor
13894 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13895 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13896 // `"`, and the value's last byte isn't `/` — so the value
13897 // silently passed every prior arm. The resolver folded the
13898 // value through `Path::join` looking for a literal
13899 // `./../caixa-teia # legacy sibling` subdirectory and the
13900 // failure surfaced at resolve time with a non-self-locating
13901 // `No such file or directory` error. The new arm moves the
13902 // rejection to validate time and names the offending dep +
13903 // caminho + byte verbatim.
13904 let d = dep_with_fonte(DepSource::Path {
13905 caminho: "../caixa-teia # legacy sibling".into(),
13906 });
13907 let err = d.validate().unwrap_err();
13908 let DepError::FonteCaminhoShellComment {
13909 nome,
13910 caminho,
13911 byte,
13912 } = err
13913 else {
13914 panic!("expected FonteCaminhoShellComment, got {err:?}");
13915 };
13916 assert_eq!(nome, "caixa-teia");
13917 assert_eq!(caminho, "../caixa-teia # legacy sibling");
13918 assert_eq!(byte, b'#');
13919 }
13920
13921 #[test]
13922 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13923 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13924 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
13925 // canonical "I copied a `path: ../caixa-teia # pin` YAML
13926 // scalar-plus-comment entry out of an aligned values.yaml and
13927 // dropped it verbatim into the `:caminho` slot" paste-idiom).
13928 // Pinned separately from the shell-history shape so the
13929 // gate's coverage extends from the single-space `#` shape to
13930 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
13931 // requires the `#` to be preceded by whitespace to lex as a
13932 // comment (bare `foo#bar` is a single scalar); the double-
13933 // space paste from an aligned manifest is the canonical
13934 // shape.
13935 let d = dep_with_fonte(DepSource::Path {
13936 caminho: "../caixa-teia # pin".into(),
13937 });
13938 let err = d.validate().unwrap_err();
13939 assert!(
13940 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13941 "got {err:?}",
13942 );
13943 }
13944
13945 #[test]
13946 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13947 // The URL-fragment-identifier paste shape
13948 // (`"../caixa-teia#readme"` — the canonical
13949 // paste-from-browser-address-bar permalink shape where the
13950 // browser preserved the `#anchor` tail on the copy). Pinned
13951 // separately from the whitespace-separated shell / YAML
13952 // comment shapes so the gate covers the unpadded RFC 3986
13953 // §3.5 fragment-delimiter position too, not only positions
13954 // preceded by unquoted whitespace. Peer with the immediate-
13955 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13956 // (a68f818) which closes the same byte under the same URL-
13957 // fragment-identifier banner.
13958 let d = dep_with_fonte(DepSource::Path {
13959 caminho: "../caixa-teia#readme".into(),
13960 });
13961 let err = d.validate().unwrap_err();
13962 assert!(
13963 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13964 "got {err:?}",
13965 );
13966 }
13967
13968 #[test]
13969 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13970 // Leading-position `#` shape (`"#../caixa-teia"` — the
13971 // "I copied a shell-comment-out entry from a commented-out
13972 // dep row" footgun). Pinned separately from the embedded
13973 // shapes so the gate covers every position, not only
13974 // whitespace-preceded / mid-value.
13975 let d = dep_with_fonte(DepSource::Path {
13976 caminho: "#../caixa-teia".into(),
13977 });
13978 let err = d.validate().unwrap_err();
13979 assert!(
13980 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13981 "got {err:?}",
13982 );
13983 }
13984
13985 #[test]
13986 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13987 // The positive-control pin: the gate targets only `#`,
13988 // never adjacent printable ASCII or POSIX-valid bytes. The
13989 // canonical relative POSIX path (`"../caixa-teia"`) and a
13990 // nested deeply-pathed variant with adjacent printable
13991 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13992 // to validate cleanly so the gate doesn't widen to a "no
13993 // printable punctuation anywhere" sweep that would defeat
13994 // the entire path-fonte author surface. Peer with
13995 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13996 // on the immediate-predecessor arm.
13997 let d = dep_with_fonte(DepSource::Path {
13998 caminho: "../caixa-teia/sub-dir.v2".into(),
13999 });
14000 d.validate().unwrap();
14001 }
14002
14003 #[test]
14004 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14005 // Cascade pin on the immediate-predecessor arm: a value
14006 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14007 // "I pasted a strong-quoted literal followed by a URL-
14008 // fragment permalink tail" footgun) routes through
14009 // `FonteCaminhoShellQuoteGrouping` not
14010 // `FonteCaminhoShellComment`. The shell-string-literal-
14011 // delimiter is the load-bearing root-cause edit on every
14012 // probe-as-both value; same cascade discipline every prior
14013 // `:caminho` arm establishes.
14014 let d = dep_with_fonte(DepSource::Path {
14015 caminho: "../'x'#pin".into(),
14016 });
14017 let err = d.validate().unwrap_err();
14018 assert!(
14019 matches!(
14020 err,
14021 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14022 ),
14023 "got {err:?}",
14024 );
14025 }
14026
14027 #[test]
14028 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14029 // Cascade pin on the upstream shell-bracket-expansion arm:
14030 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14031 // canonical "I pasted a glob-character-class followed by a
14032 // URL-fragment tail" footgun) routes through
14033 // `FonteCaminhoShellBracketExpansion` not
14034 // `FonteCaminhoShellComment`. The glob-character-class
14035 // expansion is the load-bearing root-cause edit on every
14036 // probe-as-both value.
14037 let d = dep_with_fonte(DepSource::Path {
14038 caminho: "../[a-z]#pin".into(),
14039 });
14040 let err = d.validate().unwrap_err();
14041 assert!(
14042 matches!(
14043 err,
14044 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14045 ),
14046 "got {err:?}",
14047 );
14048 }
14049
14050 #[test]
14051 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14052 // Cascade pin on the upstream shell-brace-expansion arm: a
14053 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14054 // canonical "I pasted a brace-expansion fan followed by a
14055 // URL-fragment tail" footgun) routes through
14056 // `FonteCaminhoShellBraceExpansion` not
14057 // `FonteCaminhoShellComment`. The brace-expansion fan is the
14058 // load-bearing root-cause edit on every probe-as-both value.
14059 let d = dep_with_fonte(DepSource::Path {
14060 caminho: "../{a,b}#pin".into(),
14061 });
14062 let err = d.validate().unwrap_err();
14063 assert!(
14064 matches!(
14065 err,
14066 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14067 ),
14068 "got {err:?}",
14069 );
14070 }
14071
14072 #[test]
14073 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14074 // Cascade pin on the upstream shell-subshell-grouping arm:
14075 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14076 // the canonical "I pasted a subshell-grouping followed by a
14077 // URL-fragment tail" footgun) routes through
14078 // `FonteCaminhoShellSubshellGrouping` not
14079 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14080 // command-substitution boundary is the load-bearing axis on
14081 // every probe-as-both value.
14082 let d = dep_with_fonte(DepSource::Path {
14083 caminho: "../(cd foo)#pin".into(),
14084 });
14085 let err = d.validate().unwrap_err();
14086 assert!(
14087 matches!(
14088 err,
14089 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14090 ),
14091 "got {err:?}",
14092 );
14093 }
14094
14095 #[test]
14096 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14097 // Cascade pin on the upstream shell-glob arm: a value
14098 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14099 // canonical "I pasted a `*` unbounded pathname-expansion
14100 // followed by a URL-fragment tail" footgun) routes through
14101 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14102 // The unbounded pathname-expansion sentinel is the load-
14103 // bearing root-cause edit on every probe-as-both value.
14104 let d = dep_with_fonte(DepSource::Path {
14105 caminho: "../caixa-teia/*#pin".into(),
14106 });
14107 let err = d.validate().unwrap_err();
14108 assert!(
14109 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14110 "got {err:?}",
14111 );
14112 }
14113
14114 #[test]
14115 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14116 // Cascade pin on the upstream shell-command-substitution
14117 // arm: a value carrying both a backtick and `#`
14118 // (``"../`whoami`#pin"`` — the canonical "I pasted a
14119 // legacy-backtick command-substitution followed by a URL-
14120 // fragment tail" footgun) routes through
14121 // `FonteCaminhoShellCommandSubstitution` not
14122 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14123 // injection vector is the load-bearing root-cause edit on
14124 // every probe-as-both value.
14125 let d = dep_with_fonte(DepSource::Path {
14126 caminho: "../`whoami`#pin".into(),
14127 });
14128 let err = d.validate().unwrap_err();
14129 assert!(
14130 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14131 "got {err:?}",
14132 );
14133 }
14134
14135 #[test]
14136 fn fonte_caminho_shell_background_fires_before_shell_comment() {
14137 // Cascade pin on the upstream shell-background arm: a value
14138 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14139 // the canonical "I pasted a `cmd &` background-launch
14140 // followed by a URL-fragment tail" footgun) routes through
14141 // `FonteCaminhoShellBackground` not
14142 // `FonteCaminhoShellComment`. The background-launch tail is
14143 // the load-bearing root-cause edit on every probe-as-both
14144 // value.
14145 let d = dep_with_fonte(DepSource::Path {
14146 caminho: "../caixa-teia&pin#tail".into(),
14147 });
14148 let err = d.validate().unwrap_err();
14149 assert!(
14150 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14151 "got {err:?}",
14152 );
14153 }
14154
14155 #[test]
14156 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14157 // Cascade pin on the upstream shell-semicolon arm: a value
14158 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14159 // the canonical sequential-cleanup + URL-fragment paste
14160 // idiom) routes through `FonteCaminhoShellSemicolon` not
14161 // `FonteCaminhoShellComment`. The sequential-command-
14162 // separator paste is the load-bearing root-cause edit on
14163 // every probe-as-both value.
14164 let d = dep_with_fonte(DepSource::Path {
14165 caminho: "../caixa-teia;pin#tail".into(),
14166 });
14167 let err = d.validate().unwrap_err();
14168 assert!(
14169 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14170 "got {err:?}",
14171 );
14172 }
14173
14174 #[test]
14175 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14176 // Cascade pin on the upstream shell-pipe arm: a value
14177 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14178 // the canonical pipeline-to-URL-fragment paste idiom) routes
14179 // through `FonteCaminhoShellPipe` not
14180 // `FonteCaminhoShellComment`. The pipeline-tail paste is
14181 // the load-bearing root-cause edit on every probe-as-both
14182 // value.
14183 let d = dep_with_fonte(DepSource::Path {
14184 caminho: "../caixa-teia|pin#tail".into(),
14185 });
14186 let err = d.validate().unwrap_err();
14187 assert!(
14188 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14189 "got {err:?}",
14190 );
14191 }
14192
14193 #[test]
14194 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14195 // Cascade pin on the upstream shell-redirection arm: a
14196 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14197 // — the canonical "I pasted a `cmd > log` redirect followed
14198 // by a URL-fragment tail" footgun) routes through
14199 // `FonteCaminhoShellRedirection` not
14200 // `FonteCaminhoShellComment`. The input/output redirection
14201 // metachar carries the more self-locating `byte` payload,
14202 // so the prior arm wins on every probe-as-both value.
14203 let d = dep_with_fonte(DepSource::Path {
14204 caminho: "../caixa-teia>log#pin".into(),
14205 });
14206 let err = d.validate().unwrap_err();
14207 assert!(
14208 matches!(
14209 err,
14210 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14211 ),
14212 "got {err:?}",
14213 );
14214 }
14215
14216 #[test]
14217 fn fonte_caminho_backslash_fires_before_shell_comment() {
14218 // Cascade pin on the upstream backslash arm: a value
14219 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14220 // canonical "I pasted a Windows-shell path followed by a
14221 // URL-fragment tail" footgun) routes through
14222 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14223 // The cross-host-OS-separator divergence is the load-
14224 // bearing axis on every probe-as-both value.
14225 let d = dep_with_fonte(DepSource::Path {
14226 caminho: "..\\caixa-teia#pin".into(),
14227 });
14228 let err = d.validate().unwrap_err();
14229 assert!(
14230 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14231 "got {err:?}",
14232 );
14233 }
14234
14235 #[test]
14236 fn fonte_caminho_control_char_fires_before_shell_comment() {
14237 // Cascade pin on the embedded-control-byte arm: a value
14238 // carrying both a control byte and `#` (`"../foo\n#pin"` —
14239 // the canonical paste-from-multiline-doc footgun where a
14240 // newline landed mid-caminho between the path and an
14241 // annotation) routes through `FonteCaminhoControlChar` not
14242 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14243 // byte diagnostic is the load-bearing axis on every value
14244 // that probes positive for both — mirrors the cascade
14245 // discipline on every prior arm.
14246 let d = dep_with_fonte(DepSource::Path {
14247 caminho: "../foo\n#pin".into(),
14248 });
14249 let err = d.validate().unwrap_err();
14250 assert!(
14251 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14252 "got {err:?}",
14253 );
14254 }
14255
14256 #[test]
14257 fn fonte_caminho_absolute_fires_before_shell_comment() {
14258 // Cascade pin on the load-bearing leading-byte arm: a
14259 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14260 // routes through `FonteCaminhoAbsolute` not
14261 // `FonteCaminhoShellComment` — the host-layout-leak
14262 // diagnostic is the load-bearing axis, the fragment byte is
14263 // the secondary observation. Same precedence logic as every
14264 // prior leading-byte arm.
14265 let d = dep_with_fonte(DepSource::Path {
14266 caminho: "/etc/foo#pin".into(),
14267 });
14268 let err = d.validate().unwrap_err();
14269 assert!(
14270 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14271 "got {err:?}",
14272 );
14273 }
14274
14275 #[test]
14276 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14277 // Cascade pin on the upstream leading-`$` var-expansion
14278 // arm: a value carrying both a leading `$` and a `#`
14279 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14280 // shell-variable at the head of a sibling-workspace path
14281 // followed by a URL-fragment tail" footgun) routes through
14282 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14283 // The leading-byte shell-variable-expansion is the more
14284 // self-locating diagnostic on values that probe as both.
14285 let d = dep_with_fonte(DepSource::Path {
14286 caminho: "$DIR/foo#pin".into(),
14287 });
14288 let err = d.validate().unwrap_err();
14289 assert!(
14290 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14291 "got {err:?}",
14292 );
14293 }
14294
14295 #[test]
14296 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14297 // Cascade pin on the immediate-successor arm: a value
14298 // carrying both `#` and a trailing `/`
14299 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14300 // a URL-fragment-carrying path" footgun) routes through
14301 // `FonteCaminhoShellComment` not
14302 // `FonteCaminhoTrailingSlash`. The embedded fragment /
14303 // comment-lead byte is the more semantic-locating axis (an
14304 // author who removes the `#pin` fragment typically also
14305 // drops the trailing separator since both are paste-from-
14306 // URL / paste-from-shell-tab-completion artifacts).
14307 let d = dep_with_fonte(DepSource::Path {
14308 caminho: "../caixa-teia#pin/".into(),
14309 });
14310 let err = d.validate().unwrap_err();
14311 assert!(
14312 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14313 "got {err:?}",
14314 );
14315 }
14316
14317 #[test]
14318 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14319 // Diagnostic-shape pin (peer with
14320 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14321 // on the immediate-predecessor arm): the error's Display
14322 // surfaces the offending `:nome`, the offending `:caminho`
14323 // verbatim, the offending byte's hex / character form, and
14324 // names the shell-comment / URL-fragment-identifier /
14325 // YAML-comment cross-config-DSL footgun explicitly so a
14326 // `feira lint` run can render the diagnostic without
14327 // re-parsing.
14328 let d = dep_with_fonte(DepSource::Path {
14329 caminho: "../caixa-teia#readme".into(),
14330 });
14331 let rendered = d.validate().unwrap_err().to_string();
14332 assert!(
14333 rendered.contains("caixa-teia"),
14334 "diagnostic must name the offending dep: {rendered}",
14335 );
14336 assert!(
14337 rendered.contains("../caixa-teia#readme"),
14338 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14339 );
14340 assert!(
14341 rendered.contains("0x23"),
14342 "diagnostic must surface the offending byte hex: {rendered:?}",
14343 );
14344 assert!(
14345 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14346 "diagnostic must name the shell-comment footgun: {rendered:?}",
14347 );
14348 assert!(
14349 rendered.contains("fragment") || rendered.contains("URL-fragment"),
14350 "diagnostic must reference the URL-fragment-identifier vocabulary: \
14351 {rendered:?}",
14352 );
14353 }
14354
14355 #[test]
14356 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14357 // The canonical paste-from-browser-address-bar percent-
14358 // encoded-space footgun: an author copies `../caixa%20teia`
14359 // out of a URL-encoded README hyperlink / browser address
14360 // bar / percent-encoded permalink expecting `%20` to decode
14361 // to a literal space at the filesystem layer. POSIX
14362 // `std::path::Path` treats `%` as a literal path-component
14363 // byte, so `Path::join` looks for a literal
14364 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14365 // returns false on `..`, `%` is neither a leading-byte
14366 // sentinel nor a control byte nor `\` nor `<` / `>` nor
14367 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14368 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14369 // and the value's last byte isn't `/` — so the value
14370 // silently passed every prior arm. The new arm moves the
14371 // rejection to validate time and names the offending dep +
14372 // caminho + byte verbatim.
14373 let d = dep_with_fonte(DepSource::Path {
14374 caminho: "../caixa%20teia".into(),
14375 });
14376 let err = d.validate().unwrap_err();
14377 let DepError::FonteCaminhoUrlPercentEncoding {
14378 nome,
14379 caminho,
14380 byte,
14381 } = err
14382 else {
14383 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14384 };
14385 assert_eq!(nome, "caixa-teia");
14386 assert_eq!(caminho, "../caixa%20teia");
14387 assert_eq!(byte, b'%');
14388 }
14389
14390 #[test]
14391 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14392 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14393 // intending the `%2F` as the URL encoding of `/`) locks a
14394 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14395 // the byte-identical `path:../caixa/teia` form. Pinned
14396 // separately from the space-encoded shape so the gate's
14397 // coverage extends past the single canonical `%20` example
14398 // to any two-hex-digit percent-encoded sequence.
14399 let d = dep_with_fonte(DepSource::Path {
14400 caminho: "../caixa%2Fteia".into(),
14401 });
14402 let err = d.validate().unwrap_err();
14403 assert!(
14404 matches!(
14405 err,
14406 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14407 ),
14408 "got {err:?}",
14409 );
14410 }
14411
14412 #[test]
14413 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14414 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14415 // where `%` isn't followed by two hex digits) — every
14416 // WHATWG-conformant URL parser rejects the value at parse
14417 // time per RFC 3986 §2.1, but the byte would silently ride
14418 // into the lacre before the resolver subprocess crosses the
14419 // URL-parser boundary. Pinned separately from the well-
14420 // formed `%HH` shapes so the gate covers every percent-
14421 // occurrence, not only strictly-conformant escapes.
14422 let d = dep_with_fonte(DepSource::Path {
14423 caminho: "../caixa-teia%foo".into(),
14424 });
14425 let err = d.validate().unwrap_err();
14426 assert!(
14427 matches!(
14428 err,
14429 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14430 ),
14431 "got {err:?}",
14432 );
14433 }
14434
14435 #[test]
14436 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14437 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14438 // — the canonical paste-from-top-of-doc YAML directive
14439 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14440 // separately from embedded shapes so the gate covers the
14441 // leading-position `%` too, not only mid-value occurrences.
14442 let d = dep_with_fonte(DepSource::Path {
14443 caminho: "%YAML/../caixa-teia".into(),
14444 });
14445 let err = d.validate().unwrap_err();
14446 assert!(
14447 matches!(
14448 err,
14449 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14450 ),
14451 "got {err:?}",
14452 );
14453 }
14454
14455 #[test]
14456 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14457 // The printf-format-specifier paste shape
14458 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14459 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14460 // 134 format-string-injection vector). Pinned separately
14461 // from the URL-encoding shapes so the gate's rationale
14462 // extends past the RFC 3986 axis to the C / POSIX printf
14463 // format-directive-lead axis.
14464 let d = dep_with_fonte(DepSource::Path {
14465 caminho: "../caixa-%s-teia".into(),
14466 });
14467 let err = d.validate().unwrap_err();
14468 assert!(
14469 matches!(
14470 err,
14471 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14472 ),
14473 "got {err:?}",
14474 );
14475 }
14476
14477 #[test]
14478 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14479 // The positive-control pin: the gate targets only `%`,
14480 // never adjacent printable ASCII or POSIX-valid bytes. The
14481 // canonical relative POSIX path (`"../caixa-teia"`) and a
14482 // nested deeply-pathed variant with adjacent printable
14483 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14484 // to validate cleanly so the gate doesn't widen to a "no
14485 // printable punctuation anywhere" sweep that would defeat
14486 // the entire path-fonte author surface. Peer with
14487 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14488 // on the immediate-predecessor arm.
14489 let d = dep_with_fonte(DepSource::Path {
14490 caminho: "../caixa-teia/sub-dir.v2".into(),
14491 });
14492 d.validate().unwrap();
14493 }
14494
14495 #[test]
14496 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14497 // Cascade pin on the immediate-predecessor arm: a value
14498 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14499 // canonical "I pasted a URL-fragment permalink followed by a
14500 // percent-encoded space tail" footgun) routes through
14501 // `FonteCaminhoShellComment` not
14502 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14503 // identifier is the load-bearing downstream-truncation edit
14504 // on every probe-as-both value; same cascade discipline
14505 // every prior `:caminho` arm establishes.
14506 let d = dep_with_fonte(DepSource::Path {
14507 caminho: "../caixa-teia#pin%20".into(),
14508 });
14509 let err = d.validate().unwrap_err();
14510 assert!(
14511 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14512 "got {err:?}",
14513 );
14514 }
14515
14516 #[test]
14517 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14518 // Cascade pin on the upstream shell-quote-grouping arm: a
14519 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14520 // canonical "I pasted a strong-quoted literal followed by
14521 // a percent-encoded space" footgun) routes through
14522 // `FonteCaminhoShellQuoteGrouping` not
14523 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14524 // literal-delimiter is the load-bearing root-cause edit on
14525 // every probe-as-both value.
14526 let d = dep_with_fonte(DepSource::Path {
14527 caminho: "../'x'%20teia".into(),
14528 });
14529 let err = d.validate().unwrap_err();
14530 assert!(
14531 matches!(
14532 err,
14533 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14534 ),
14535 "got {err:?}",
14536 );
14537 }
14538
14539 #[test]
14540 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14541 // Cascade pin on the upstream backslash arm: a value
14542 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14543 // canonical "I pasted a Windows-shell path followed by a
14544 // percent-encoded space" footgun) routes through
14545 // `FonteCaminhoBackslash` not
14546 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14547 // separator divergence is the load-bearing root-cause edit
14548 // on every probe-as-both value.
14549 let d = dep_with_fonte(DepSource::Path {
14550 caminho: "..\\caixa%20teia".into(),
14551 });
14552 let err = d.validate().unwrap_err();
14553 assert!(
14554 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14555 "got {err:?}",
14556 );
14557 }
14558
14559 #[test]
14560 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14561 // Cascade pin on the upstream control-char arm: a value
14562 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14563 // the canonical "I pasted a paste-from-binary-blob path
14564 // followed by a percent-encoded space" footgun) routes
14565 // through `FonteCaminhoControlChar` not
14566 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14567 // rejected byte is the load-bearing root-cause edit on
14568 // every probe-as-both value.
14569 let d = dep_with_fonte(DepSource::Path {
14570 caminho: "../caixa\0%20teia".into(),
14571 });
14572 let err = d.validate().unwrap_err();
14573 assert!(
14574 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14575 "got {err:?}",
14576 );
14577 }
14578
14579 #[test]
14580 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14581 // Cascade pin on the upstream absolute-path arm: a value
14582 // that's both absolute and carries `%` (`"/etc/passwd%20"`
14583 // — the canonical "I pasted an absolute path with a
14584 // percent-encoded space tail" footgun) routes through
14585 // `FonteCaminhoAbsolute` not
14586 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14587 // the load-bearing root-cause edit on every probe-as-both
14588 // value.
14589 let d = dep_with_fonte(DepSource::Path {
14590 caminho: "/etc/passwd%20".into(),
14591 });
14592 let err = d.validate().unwrap_err();
14593 assert!(
14594 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14595 "got {err:?}",
14596 );
14597 }
14598
14599 #[test]
14600 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14601 // Cascade pin on the upstream var-expansion arm: a value
14602 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14603 // — the canonical "I pasted a `$HOME`-rooted path with a
14604 // percent-encoded space" footgun) routes through
14605 // `FonteCaminhoVarExpansion` not
14606 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14607 // expansion is the load-bearing root-cause edit on every
14608 // probe-as-both value.
14609 let d = dep_with_fonte(DepSource::Path {
14610 caminho: "$HOME/caixa%20teia".into(),
14611 });
14612 let err = d.validate().unwrap_err();
14613 assert!(
14614 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14615 "got {err:?}",
14616 );
14617 }
14618
14619 #[test]
14620 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14621 // Cascade pin on the immediate-successor arm: a value
14622 // carrying both `%` and a trailing `/`
14623 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14624 // percent-encoded-space-carrying path" footgun) routes
14625 // through `FonteCaminhoUrlPercentEncoding` not
14626 // `FonteCaminhoTrailingSlash`. The embedded percent-
14627 // encoding-escape byte is the more semantic-locating axis
14628 // (an author who decodes the `%20` to a literal space is
14629 // likely to also tab-strip the trailing separator since
14630 // both are paste-from-URL / paste-from-shell-tab-completion
14631 // artifacts).
14632 let d = dep_with_fonte(DepSource::Path {
14633 caminho: "../caixa%20teia/".into(),
14634 });
14635 let err = d.validate().unwrap_err();
14636 assert!(
14637 matches!(
14638 err,
14639 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14640 ),
14641 "got {err:?}",
14642 );
14643 }
14644
14645 #[test]
14646 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14647 // Diagnostic-shape pin (peer with
14648 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14649 // on the immediate-predecessor arm): the error's Display
14650 // surfaces the offending `:nome`, the offending `:caminho`
14651 // verbatim, the offending byte's hex / character form, and
14652 // names the URL-percent-encoding-escape / printf-format-
14653 // specifier footgun explicitly so a `feira lint` run can
14654 // render the diagnostic without re-parsing.
14655 let d = dep_with_fonte(DepSource::Path {
14656 caminho: "../caixa%20teia".into(),
14657 });
14658 let rendered = d.validate().unwrap_err().to_string();
14659 assert!(
14660 rendered.contains("caixa-teia"),
14661 "diagnostic must name the offending dep: {rendered}",
14662 );
14663 assert!(
14664 rendered.contains("../caixa%20teia"),
14665 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14666 );
14667 assert!(
14668 rendered.contains("0x25"),
14669 "diagnostic must surface the offending byte hex: {rendered:?}",
14670 );
14671 assert!(
14672 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14673 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14674 );
14675 assert!(
14676 rendered.contains("printf") || rendered.contains("format-specifier"),
14677 "diagnostic must reference the printf-format-specifier vocabulary: \
14678 {rendered:?}",
14679 );
14680 }
14681
14682 #[test]
14683 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14684 // The canonical embedded-`$` shell-variable-expansion paste
14685 // shape (`"../foo$HOME/bar"` — an author copies a partially-
14686 // substituted shell one-liner where the leading segment is a
14687 // literal `../foo` while the mid segment carries the un-
14688 // substituted `$HOME` template). The leading-`$` position is
14689 // already gated by the f4efe9c leading-byte arm which routes
14690 // through `FonteCaminhoVarExpansion`; this arm closes the
14691 // last positional gap on `$` — every position on the axis is
14692 // structurally rejected.
14693 let d = dep_with_fonte(DepSource::Path {
14694 caminho: "../foo$HOME/bar".into(),
14695 });
14696 let err = d.validate().unwrap_err();
14697 let DepError::FonteCaminhoShellVariableExpansion {
14698 nome,
14699 caminho,
14700 byte,
14701 } = err
14702 else {
14703 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14704 };
14705 assert_eq!(nome, "caixa-teia");
14706 assert_eq!(caminho, "../foo$HOME/bar");
14707 assert_eq!(byte, b'$');
14708 }
14709
14710 #[test]
14711 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14712 // The symmetric braced-CI-manifest paste shape
14713 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14714 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14715 // footgun). Pinned separately from the bare-`$VAR` shape so
14716 // the gate covers both POSIX shell §2.6 Parameter Expansion
14717 // syntactic forms, not only the unbraced variant. The
14718 // embedded `{` byte in `${...}` is also caught by the 598b770
14719 // shell-brace-expansion arm but that arm fires earlier in
14720 // the cascade — the `$` arm's coverage extends to `${...}`
14721 // structurally, so the diagnostic asserted here is the
14722 // brace-expansion one (which is a valid outcome; the point
14723 // of the pin is that the value never survives validation).
14724 let d = dep_with_fonte(DepSource::Path {
14725 caminho: "../foo${WORKSPACE}/bar".into(),
14726 });
14727 let err = d.validate().unwrap_err();
14728 assert!(
14729 matches!(
14730 err,
14731 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14732 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14733 ),
14734 "got {err:?}",
14735 );
14736 }
14737
14738 #[test]
14739 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14740 // The paste-from-shell-prompt command-substitution idiom
14741 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14742 // `$VAR` shape so the gate's rationale extends to POSIX shell
14743 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14744 // legacy `` `<cmd>` `` form is already closed by the c370458
14745 // backtick arm). The embedded `(` byte in `$(...)` is also
14746 // caught structurally by the 0633c91 shell-subshell-grouping
14747 // arm which fires earlier in the cascade — the diagnostic
14748 // asserted here is either outcome, since both structurally
14749 // reject the value; the point of the pin is that the value
14750 // never survives validation.
14751 let d = dep_with_fonte(DepSource::Path {
14752 caminho: "../foo$(whoami)/bar".into(),
14753 });
14754 let err = d.validate().unwrap_err();
14755 assert!(
14756 matches!(
14757 err,
14758 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14759 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14760 ),
14761 "got {err:?}",
14762 );
14763 }
14764
14765 #[test]
14766 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14767 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14768 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14769 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14770 // idiom copied into a caminho template). None of the prior
14771 // shell-metachar arms cover this shape (`1` is a bare digit;
14772 // no `(` / `{` / letter follows the `$`), so the arm is the
14773 // sole gate on the shape.
14774 let d = dep_with_fonte(DepSource::Path {
14775 caminho: "../foo$1/bar".into(),
14776 });
14777 let err = d.validate().unwrap_err();
14778 assert!(
14779 matches!(
14780 err,
14781 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14782 ),
14783 "got {err:?}",
14784 );
14785 }
14786
14787 #[test]
14788 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14789 // The positive-control pin (peer with
14790 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14791 // on the immediate-predecessor arm): the gate targets only
14792 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14793 // A relative POSIX path carrying dashes / dots / slashes /
14794 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14795 // validate cleanly so the gate doesn't widen to a "no
14796 // printable punctuation anywhere" sweep that would defeat
14797 // the entire path-fonte author surface.
14798 let d = dep_with_fonte(DepSource::Path {
14799 caminho: "../caixa-teia/sub-dir.v2".into(),
14800 });
14801 d.validate().unwrap();
14802 }
14803
14804 #[test]
14805 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14806 // Cascade pin on the leading-`$` sibling arm at line 540: a
14807 // value starting with `$` and carrying an embedded `$` too
14808 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14809 // fully-templated CI path with two un-substituted variables")
14810 // routes through `FonteCaminhoVarExpansion` not
14811 // `FonteCaminhoShellVariableExpansion`. The leading-byte
14812 // host-layout-leak is the load-bearing self-locating axis
14813 // (the leading position dominates the semantic-locating
14814 // rationale on every probe-as-both value); the embedded
14815 // arm's positional-agnostic sweep catches only values whose
14816 // leading byte doesn't route through the earlier leading-
14817 // byte arms.
14818 let d = dep_with_fonte(DepSource::Path {
14819 caminho: "$HOME/foo$WORKSPACE/bar".into(),
14820 });
14821 let err = d.validate().unwrap_err();
14822 assert!(
14823 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14824 "got {err:?}",
14825 );
14826 }
14827
14828 #[test]
14829 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14830 // Cascade pin on the immediate-predecessor arm: a value
14831 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14832 // — the canonical "I pasted a percent-encoded space adjacent
14833 // to a `$HOME` template") routes through
14834 // `FonteCaminhoUrlPercentEncoding` not
14835 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14836 // encoding-escape byte is the more semantic-locating axis
14837 // (the paste-from-browser-address-bar shape is the load-
14838 // bearing self-locating edit); same cascade discipline every
14839 // prior `:caminho` arm establishes.
14840 let d = dep_with_fonte(DepSource::Path {
14841 caminho: "../foo%20$HOME/bar".into(),
14842 });
14843 let err = d.validate().unwrap_err();
14844 assert!(
14845 matches!(
14846 err,
14847 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14848 ),
14849 "got {err:?}",
14850 );
14851 }
14852
14853 #[test]
14854 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14855 // Cascade pin on the immediate-successor arm: a value
14856 // carrying both embedded `$` and a trailing `/`
14857 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14858 // `$HOME`-template-carrying path") routes through
14859 // `FonteCaminhoShellVariableExpansion` not
14860 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14861 // expansion byte is the more semantic-locating axis on
14862 // probe-as-both values (an author who substitutes the
14863 // `$HOME` template with a literal value is likely to also
14864 // tab-strip the trailing separator).
14865 let d = dep_with_fonte(DepSource::Path {
14866 caminho: "../foo$HOME/bar/".into(),
14867 });
14868 let err = d.validate().unwrap_err();
14869 assert!(
14870 matches!(
14871 err,
14872 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14873 ),
14874 "got {err:?}",
14875 );
14876 }
14877
14878 #[test]
14879 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14880 // Diagnostic-shape pin (peer with
14881 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14882 // on the immediate-predecessor arm): the error's Display
14883 // surfaces the offending `:nome`, the offending `:caminho`
14884 // verbatim, the offending byte's hex / character form, and
14885 // names the shell-variable-expansion / command-substitution
14886 // footgun explicitly so a `feira lint` run can render the
14887 // diagnostic without re-parsing.
14888 let d = dep_with_fonte(DepSource::Path {
14889 caminho: "../foo$HOME/bar".into(),
14890 });
14891 let rendered = d.validate().unwrap_err().to_string();
14892 assert!(
14893 rendered.contains("caixa-teia"),
14894 "diagnostic must name the offending dep: {rendered}",
14895 );
14896 assert!(
14897 rendered.contains("../foo$HOME/bar"),
14898 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14899 );
14900 assert!(
14901 rendered.contains("0x24"),
14902 "diagnostic must surface the offending byte hex: {rendered:?}",
14903 );
14904 assert!(
14905 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14906 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14907 );
14908 assert!(
14909 rendered.contains("command-substitution") || rendered.contains("command substitution"),
14910 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14911 );
14912 }
14913
14914 #[test]
14915 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14916 // The fail-before-pass-after pin for the canonical paste-from-
14917 // shell-history footgun on `:caminho`. An author copies a `cd
14918 // ../caixa-teia && !sudo make install` one-liner from a quick-
14919 // start README, intending the trailing `!sudo` as a shell-
14920 // history-expansion reference but the typed slot is itself a
14921 // byte-level string parser, not a shell context, so the byte
14922 // rides into the value verbatim. Until this arm landed the `!`
14923 // byte silently passed every prior `:caminho` cascade arm
14924 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14925 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14926 // `#` / `%` / `$`); bash with the default `histexpand` mode
14927 // rewrites `!command` to the most recent history entry
14928 // beginning with `command`, the canonical RCE-class injection
14929 // vector when the byte rides into a shell argument executed
14930 // under `bash -i` (the operator-notebook interactive shell).
14931 let d = dep_with_fonte(DepSource::Path {
14932 caminho: "../caixa-teia!sudo".into(),
14933 });
14934 let err = d.validate().unwrap_err();
14935 let DepError::FonteCaminhoShellHistoryExpansion {
14936 nome,
14937 caminho,
14938 byte,
14939 } = err
14940 else {
14941 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14942 };
14943 assert_eq!(nome, "caixa-teia");
14944 assert_eq!(caminho, "../caixa-teia!sudo");
14945 assert_eq!(byte, b'!');
14946 }
14947
14948 #[test]
14949 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14950 // The symmetric `!!` repeat-prior-command paste idiom (peer with
14951 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14952 // on `is_git_repo_url`). Pinned separately from the wrapped
14953 // `!command` shape so a future diagnostic-surface change that
14954 // only checked the leading or paired-bang position surfaces
14955 // here — the per-byte arm fires anywhere `!` appears in the
14956 // value, including at consecutive positions in the middle.
14957 let d = dep_with_fonte(DepSource::Path {
14958 caminho: "../foo!!/bar".into(),
14959 });
14960 let err = d.validate().unwrap_err();
14961 assert!(
14962 matches!(
14963 err,
14964 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14965 ),
14966 "got {err:?}",
14967 );
14968 }
14969
14970 #[test]
14971 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14972 // The English-typography enthusiasm-form paste-from-prose
14973 // idiom: an author writes `:caminho "../caixa-teia!"`
14974 // expecting the substrate to coerce it to a kebab-case slug.
14975 // Pinned separately from the `!<word>` shell-history shape so
14976 // the gate's rationale extends to the paste-from-prose surface
14977 // (the same rationale the peer `is_git_repo_url` bang arm at
14978 // 7d53c68 covers). None of the prior shell-metachar arms cover
14979 // this shape (no `!<word>` reference and no `!!` repeat), so
14980 // the arm is the sole gate on the shape.
14981 let d = dep_with_fonte(DepSource::Path {
14982 caminho: "../caixa-teia!".into(),
14983 });
14984 let err = d.validate().unwrap_err();
14985 assert!(
14986 matches!(
14987 err,
14988 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14989 ),
14990 "got {err:?}",
14991 );
14992 }
14993
14994 #[test]
14995 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14996 // The positive-control pin (peer with
14997 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14998 // on the immediate-predecessor arm): the gate targets only
14999 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15000 // A relative POSIX path carrying dashes / dots / slashes /
15001 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15002 // validate cleanly so the gate doesn't widen to a "no
15003 // printable punctuation anywhere" sweep that would defeat
15004 // the entire path-fonte author surface.
15005 let d = dep_with_fonte(DepSource::Path {
15006 caminho: "../caixa-teia/sub-dir.v2".into(),
15007 });
15008 d.validate().unwrap();
15009 }
15010
15011 #[test]
15012 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15013 // Cascade pin on the immediate-predecessor arm: a value
15014 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15015 // — the canonical "I pasted a `$HOME`-templated path adjacent
15016 // to a trailing `!sudo` history-expansion") routes through
15017 // `FonteCaminhoShellVariableExpansion` not
15018 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15019 // expansion byte is the more semantic-locating axis on
15020 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15021 // template shape is the load-bearing self-locating edit);
15022 // same cascade discipline every prior `:caminho` arm
15023 // establishes.
15024 let d = dep_with_fonte(DepSource::Path {
15025 caminho: "../foo$HOME/bar!sudo".into(),
15026 });
15027 let err = d.validate().unwrap_err();
15028 assert!(
15029 matches!(
15030 err,
15031 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15032 ),
15033 "got {err:?}",
15034 );
15035 }
15036
15037 #[test]
15038 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15039 // Cascade pin on the immediate-successor arm: a value carrying
15040 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15041 // — the canonical "I tab-completed a `!sudo`-carrying path")
15042 // routes through `FonteCaminhoShellHistoryExpansion` not
15043 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15044 // expansion byte is the more semantic-locating axis on probe-
15045 // as-both values (an author who removes the `!sudo` history
15046 // reference is likely to also tab-strip the trailing separator).
15047 let d = dep_with_fonte(DepSource::Path {
15048 caminho: "../caixa-teia!sudo/".into(),
15049 });
15050 let err = d.validate().unwrap_err();
15051 assert!(
15052 matches!(
15053 err,
15054 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15055 ),
15056 "got {err:?}",
15057 );
15058 }
15059
15060 #[test]
15061 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15062 // Diagnostic-shape pin (peer with
15063 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15064 // on the immediate-predecessor arm): the error's Display
15065 // surfaces the offending `:nome`, the offending `:caminho`
15066 // verbatim, the offending byte's hex / character form, and
15067 // names the shell-history-expansion / bang-operator footgun
15068 // explicitly so a `feira lint` run can render the diagnostic
15069 // without re-parsing.
15070 let d = dep_with_fonte(DepSource::Path {
15071 caminho: "../caixa-teia!sudo".into(),
15072 });
15073 let rendered = d.validate().unwrap_err().to_string();
15074 assert!(
15075 rendered.contains("caixa-teia"),
15076 "diagnostic must name the offending dep: {rendered}",
15077 );
15078 assert!(
15079 rendered.contains("../caixa-teia!sudo"),
15080 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15081 );
15082 assert!(
15083 rendered.contains("0x21"),
15084 "diagnostic must surface the offending byte hex: {rendered:?}",
15085 );
15086 assert!(
15087 rendered.contains("history-expansion") || rendered.contains("history expansion"),
15088 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15089 );
15090 assert!(
15091 rendered.contains("bang"),
15092 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15093 );
15094 }
15095
15096 #[test]
15097 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15098 // The fail-before-pass-after pin for the canonical paste-from-
15099 // shell-history-quick-substitution footgun on `:caminho`. An
15100 // author copies a `git clone <bad-url>` line from their terminal,
15101 // corrects it via bash's `^bad^good` quick-substitution history
15102 // operator (bash reference §9.3, `set -o histexpand` mode's
15103 // default for interactive sessions), and pastes the trailing
15104 // `^bad^good` substitution fragment into a `:caminho` value
15105 // without trimming the leading `git clone` prefix — the byte
15106 // rides into the manifest verbatim. Until this arm landed the
15107 // `^` byte silently passed every prior `:caminho` cascade arm
15108 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15109 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15110 // `%` / `$` / `!`); bash with the default `histexpand` mode
15111 // rewrites the prior command's `bad` string to `good` and re-
15112 // executes it, the paired-operator half of the `set -o
15113 // histexpand` feature the peer `!` arm already closes the prefix
15114 // half of. The peer `is_git_repo_url` axis rejects the byte at
15115 // 49e142f under the same shell-history-substitution / RFC-3986-
15116 // unwise banner.
15117 let d = dep_with_fonte(DepSource::Path {
15118 caminho: "../foo^bad^good".into(),
15119 });
15120 let err = d.validate().unwrap_err();
15121 let DepError::FonteCaminhoShellHistorySubstitution {
15122 nome,
15123 caminho,
15124 byte,
15125 } = err
15126 else {
15127 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15128 };
15129 assert_eq!(nome, "caixa-teia");
15130 assert_eq!(caminho, "../foo^bad^good");
15131 assert_eq!(byte, b'^');
15132 }
15133
15134 #[test]
15135 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15136 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15137 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15138 // on `is_git_repo_url`). An author copies a `grep '^archived'`
15139 // regex-anchor / negation idiom from a doc snippet and the byte
15140 // rides in verbatim. Pinned separately from the `^old^new^`
15141 // quick-substitution shape so a future diagnostic-surface change
15142 // that only checked the paired-caret history-substitution
15143 // position surfaces here — the per-byte arm fires anywhere `^`
15144 // appears in the value, including at a solitary leading-of-
15145 // segment position.
15146 let d = dep_with_fonte(DepSource::Path {
15147 caminho: "../foo/^archived".into(),
15148 });
15149 let err = d.validate().unwrap_err();
15150 assert!(
15151 matches!(
15152 err,
15153 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15154 ),
15155 "got {err:?}",
15156 );
15157 }
15158
15159 #[test]
15160 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15161 // The trailing-`^` history-substitution-open shape — an author
15162 // starts typing a `^bad^good` quick-substitution but pastes only
15163 // the leading `^` sentinel before context-switching (a bash-
15164 // reference §9.3 valid histexpand prefix on its own — even a
15165 // solitary `^` on the prior command's whole re-execution shape).
15166 // Pinned separately from the `^old^new^` full-form and the leading-
15167 // of-segment `^archived` regex-anchor shape so the gate's
15168 // rationale extends to the paste-from-shell-history-with-only-
15169 // the-first-byte-selected surface. None of the prior shell-
15170 // metachar arms cover this shape.
15171 let d = dep_with_fonte(DepSource::Path {
15172 caminho: "../caixa-teia^".into(),
15173 });
15174 let err = d.validate().unwrap_err();
15175 assert!(
15176 matches!(
15177 err,
15178 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15179 ),
15180 "got {err:?}",
15181 );
15182 }
15183
15184 #[test]
15185 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15186 // The positive-control pin (peer with
15187 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15188 // on the immediate-predecessor arm): the gate targets only
15189 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15190 // A relative POSIX path carrying dashes / dots / slashes /
15191 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15192 // continue to validate cleanly so the gate doesn't widen to
15193 // a "no printable punctuation anywhere" sweep that would
15194 // defeat the entire path-fonte author surface.
15195 let d = dep_with_fonte(DepSource::Path {
15196 caminho: "../caixa-teia/sub_v2.rc".into(),
15197 });
15198 d.validate().unwrap();
15199 }
15200
15201 #[test]
15202 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15203 // Cascade pin on the immediate-predecessor arm: a value carrying
15204 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15205 // canonical "I pasted a `!sudo` history-reference next to a
15206 // `^bad^good` quick-substitution") routes through
15207 // `FonteCaminhoShellHistoryExpansion` not
15208 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15209 // the more semantic-locating axis on probe-as-both values (an
15210 // author who removes the `!sudo` reference is likely to also
15211 // strip the paired `^` substitution fragment); same cascade
15212 // discipline every prior `:caminho` arm establishes.
15213 let d = dep_with_fonte(DepSource::Path {
15214 caminho: "../foo!sudo^bad^good".into(),
15215 });
15216 let err = d.validate().unwrap_err();
15217 assert!(
15218 matches!(
15219 err,
15220 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15221 ),
15222 "got {err:?}",
15223 );
15224 }
15225
15226 #[test]
15227 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15228 // Cascade pin on the immediate-successor arm: a value carrying
15229 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15230 // the canonical "I tab-completed a `^bad^good`-carrying path")
15231 // routes through `FonteCaminhoShellHistorySubstitution` not
15232 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15233 // substitution byte is the more semantic-locating axis on probe-
15234 // as-both values (an author who removes the `^bad^good`
15235 // substitution fragment is likely to also tab-strip the trailing
15236 // separator).
15237 let d = dep_with_fonte(DepSource::Path {
15238 caminho: "../foo^bad^good/".into(),
15239 });
15240 let err = d.validate().unwrap_err();
15241 assert!(
15242 matches!(
15243 err,
15244 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15245 ),
15246 "got {err:?}",
15247 );
15248 }
15249
15250 #[test]
15251 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15252 {
15253 // Diagnostic-shape pin (peer with
15254 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15255 // on the immediate-predecessor arm): the error's Display
15256 // surfaces the offending `:nome`, the offending `:caminho`
15257 // verbatim, the offending byte's hex form, and names the
15258 // shell-history-substitution / RFC-3986-'unwise' / regex-
15259 // negation footgun explicitly so a `feira lint` run can render
15260 // the diagnostic without re-parsing.
15261 let d = dep_with_fonte(DepSource::Path {
15262 caminho: "../foo^bad^good".into(),
15263 });
15264 let rendered = d.validate().unwrap_err().to_string();
15265 assert!(
15266 rendered.contains("caixa-teia"),
15267 "diagnostic must name the offending dep: {rendered}",
15268 );
15269 assert!(
15270 rendered.contains("../foo^bad^good"),
15271 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15272 );
15273 assert!(
15274 rendered.contains("0x5e") || rendered.contains("0x5E"),
15275 "diagnostic must surface the offending byte hex: {rendered:?}",
15276 );
15277 assert!(
15278 rendered.contains("history-substitution") || rendered.contains("history substitution"),
15279 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15280 );
15281 assert!(
15282 rendered.contains("unwise"),
15283 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15284 );
15285 }
15286
15287 #[test]
15288 fn fonte_repo_empty_fires_before_pin_missing() {
15289 // Order pin: empty `:repo` is the more self-locating diagnostic
15290 // (every git source needs a repo; the pin discussion is
15291 // secondary), so it fires before the pin-missing arm even when
15292 // both are violated. Mirrors the
15293 // `nome_empty_takes_precedence_over_versao_invalid` ordering
15294 // discipline on the per-entry layer.
15295 let d = dep_with_fonte(DepSource::Git {
15296 repo: String::new(),
15297 tag: None,
15298 rev: None,
15299 branch: None,
15300 });
15301 let err = d.validate().unwrap_err();
15302 assert!(
15303 matches!(err, DepError::FonteRepoEmpty { .. }),
15304 "got {err:?}"
15305 );
15306 }
15307
15308 #[test]
15309 fn fonte_pin_missing_fires_before_pin_empty() {
15310 // Order pin: a fully-None pin set is structurally distinct from
15311 // a Some(empty) pin — the first surfaces as FontePinMissing
15312 // (no axis chosen), the second as FontePinEmpty (axis chosen
15313 // but value blank). Pin the disjoint relationship so a future
15314 // unification collapses to one variant only as a structural
15315 // decision.
15316 let d = dep_with_fonte(DepSource::Git {
15317 repo: "github:pleme-io/caixa-teia".into(),
15318 tag: None,
15319 rev: None,
15320 branch: None,
15321 });
15322 assert!(matches!(
15323 d.validate().unwrap_err(),
15324 DepError::FontePinMissing { .. }
15325 ));
15326 }
15327
15328 #[test]
15329 fn nome_empty_takes_precedence_over_fonte_invalid() {
15330 // Order pin: a per-entry diagnostic without a non-empty :nome
15331 // can't be self-locating, so :nome "" fires first even when
15332 // :fonte is also malformed. Mirrors
15333 // `nome_empty_takes_precedence_over_versao_invalid` on the
15334 // adjacent axis.
15335 let mut d = dep_with_fonte(DepSource::Git {
15336 repo: String::new(),
15337 tag: None,
15338 rev: None,
15339 branch: None,
15340 });
15341 d.nome = String::new();
15342 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15343 }
15344
15345 #[test]
15346 fn versao_invalid_takes_precedence_over_fonte_invalid() {
15347 // Order pin: the :versao parse-side diagnostic is narrower than
15348 // the :fonte shape diagnostic — a malformed :versao always names
15349 // the parser's reason, which is more actionable than the
15350 // :fonte gate's "the pins are wrong" wording. Pin the ordering
15351 // so a re-ordering surfaces here.
15352 let mut d = dep_with_fonte(DepSource::Git {
15353 repo: String::new(),
15354 tag: None,
15355 rev: None,
15356 branch: None,
15357 });
15358 d.versao = "v0.1".into();
15359 let err = d.validate().unwrap_err();
15360 assert!(
15361 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15362 "got {err:?}"
15363 );
15364 }
15365
15366 #[test]
15367 fn fonte_invalid_diagnostic_carries_offending_nome() {
15368 // The diagnostic-shape pin: every :fonte error variant names
15369 // the offending dep's :nome verbatim, so the author can grep
15370 // caixa.lisp for the `:nome "<n>"` block and fix it in one
15371 // edit. Cover all seven variants so a future variant addition
15372 // forces a parallel diagnostic-shape decision.
15373 for (case, fonte) in [
15374 (
15375 "repo-empty",
15376 DepSource::Git {
15377 repo: String::new(),
15378 tag: Some("v1".into()),
15379 rev: None,
15380 branch: None,
15381 },
15382 ),
15383 (
15384 "repo-shape",
15385 DepSource::Git {
15386 repo: "github:p/x ".into(),
15387 tag: Some("v1".into()),
15388 rev: None,
15389 branch: None,
15390 },
15391 ),
15392 (
15393 "pin-missing",
15394 DepSource::Git {
15395 repo: "github:p/x".into(),
15396 tag: None,
15397 rev: None,
15398 branch: None,
15399 },
15400 ),
15401 (
15402 "pin-ambiguous",
15403 DepSource::Git {
15404 repo: "github:p/x".into(),
15405 tag: Some("v1".into()),
15406 rev: None,
15407 branch: Some("main".into()),
15408 },
15409 ),
15410 (
15411 "pin-empty",
15412 DepSource::Git {
15413 repo: "github:p/x".into(),
15414 tag: Some(String::new()),
15415 rev: None,
15416 branch: None,
15417 },
15418 ),
15419 (
15420 "caminho-empty",
15421 DepSource::Path {
15422 caminho: String::new(),
15423 },
15424 ),
15425 (
15426 "caminho-absolute",
15427 DepSource::Path {
15428 caminho: "/home/me/work/caixa-teia".into(),
15429 },
15430 ),
15431 ] {
15432 let d = dep_with_fonte(fonte);
15433 let msg = d
15434 .validate()
15435 .expect_err(&format!("{case}: expected fonte error"))
15436 .to_string();
15437 assert!(
15438 msg.contains("\"caixa-teia\""),
15439 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15440 );
15441 }
15442 }
15443
15444 // -- :tag / :branch value-shape gate ----------------------------------
15445
15446 #[test]
15447 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15448 // The canonical paste-from-doc footgun on `:tag` — author
15449 // copies `"v0.1.0 "` (trailing space) out of a release-notes
15450 // paragraph. Until this gate landed the empty-pin arm passed
15451 // (the string isn't empty), the resolver issued
15452 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15453 // surfaced at clone time with a quoting-confused git error
15454 // far from the source caixa.lisp. The new gate moves the
15455 // check to caixa-build time and names the offending dep +
15456 // pin + value verbatim.
15457 let d = dep_with_fonte(DepSource::Git {
15458 repo: "github:pleme-io/caixa-teia".into(),
15459 tag: Some("v0.1.0 ".into()),
15460 rev: None,
15461 branch: None,
15462 });
15463 let err = d.validate().unwrap_err();
15464 let DepError::FontePinShape {
15465 nome,
15466 pin,
15467 value,
15468 reason,
15469 } = err
15470 else {
15471 panic!("expected FontePinShape, got other variant");
15472 };
15473 assert_eq!(nome, "caixa-teia");
15474 assert_eq!(pin, ":tag");
15475 assert_eq!(value, "v0.1.0 ");
15476 assert!(
15477 reason.contains("whitespace"),
15478 "reason must surface the whitespace arm, got {reason:?}"
15479 );
15480 }
15481
15482 #[test]
15483 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15484 // The `.lock` suffix is git's atomic-rename guard for
15485 // in-flight ref updates — a refname ending in `.lock` is
15486 // unwritable on disk. Pinned separately from the whitespace
15487 // arm so a future relaxation that admits one but not the
15488 // other surfaces here.
15489 let d = dep_with_fonte(DepSource::Git {
15490 repo: "github:pleme-io/caixa-teia".into(),
15491 tag: Some("v0.1.0.lock".into()),
15492 rev: None,
15493 branch: None,
15494 });
15495 let err = d.validate().unwrap_err();
15496 let DepError::FontePinShape {
15497 pin, value, reason, ..
15498 } = err
15499 else {
15500 panic!("expected FontePinShape, got other variant");
15501 };
15502 assert_eq!(pin, ":tag");
15503 assert_eq!(value, "v0.1.0.lock");
15504 assert!(
15505 reason.contains(".lock"),
15506 "reason must surface the .lock arm, got {reason:?}"
15507 );
15508 }
15509
15510 #[test]
15511 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15512 // The canonical "branch name with spaces" footgun (`feature
15513 // foo`, `release branch`) — git's refname parser rejects raw
15514 // whitespace, and the failure surfaces at `git checkout
15515 // 'feature foo'` time with a quoting-confused error far from
15516 // the source caixa.lisp. Pinned on the `:branch` axis so the
15517 // gate-applies-to-both-:tag-and-:branch contract is a build-
15518 // error to relax.
15519 let d = dep_with_fonte(DepSource::Git {
15520 repo: "github:pleme-io/caixa-teia".into(),
15521 tag: None,
15522 rev: None,
15523 branch: Some("feature/foo bar".into()),
15524 });
15525 let err = d.validate().unwrap_err();
15526 let DepError::FontePinShape {
15527 pin, value, reason, ..
15528 } = err
15529 else {
15530 panic!("expected FontePinShape, got other variant");
15531 };
15532 assert_eq!(pin, ":branch");
15533 assert_eq!(value, "feature/foo bar");
15534 assert!(
15535 reason.contains("whitespace"),
15536 "reason must surface the whitespace arm, got {reason:?}"
15537 );
15538 }
15539
15540 #[test]
15541 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15542 // The `refs/heads/main` shape — the canonical "I copied the
15543 // fully-qualified ref out of `git show-ref` instead of the
15544 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15545 // at clone time, so this resolves to a literal ref named
15546 // `refs/heads/refs/heads/main` on disk; the silent double-
15547 // prefix is the load-bearing reason to gate at validate.
15548 // The diagnostic must enumerate the leaf the author probably
15549 // meant (`"main"`) so the fix is one edit.
15550 let d = dep_with_fonte(DepSource::Git {
15551 repo: "github:pleme-io/caixa-teia".into(),
15552 tag: None,
15553 rev: None,
15554 branch: Some("refs/heads/main".into()),
15555 });
15556 let err = d.validate().unwrap_err();
15557 let DepError::FontePinShape {
15558 pin, value, reason, ..
15559 } = err
15560 else {
15561 panic!("expected FontePinShape, got other variant");
15562 };
15563 assert_eq!(pin, ":branch");
15564 assert_eq!(value, "refs/heads/main");
15565 assert!(
15566 reason.contains("fully-qualified"),
15567 "reason must surface the qualified-prefix arm, got {reason:?}"
15568 );
15569 assert!(
15570 reason.contains("\"main\""),
15571 "reason must quote the leaf the author probably meant, got {reason:?}"
15572 );
15573 }
15574
15575 #[test]
15576 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15577 // Sibling arm of the qualified-prefix gate on the `:tag`
15578 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15579 // footgun). Pinned separately so a future relaxation that
15580 // only catches the `:branch` arm surfaces here.
15581 let d = dep_with_fonte(DepSource::Git {
15582 repo: "github:pleme-io/caixa-teia".into(),
15583 tag: Some("refs/tags/v0.1.0".into()),
15584 rev: None,
15585 branch: None,
15586 });
15587 let err = d.validate().unwrap_err();
15588 let DepError::FontePinShape {
15589 pin, value, reason, ..
15590 } = err
15591 else {
15592 panic!("expected FontePinShape, got other variant");
15593 };
15594 assert_eq!(pin, ":tag");
15595 assert_eq!(value, "refs/tags/v0.1.0");
15596 assert!(
15597 reason.contains("fully-qualified"),
15598 "reason must surface the qualified-prefix arm, got {reason:?}"
15599 );
15600 assert!(
15601 reason.contains("\"v0.1.0\""),
15602 "reason must quote the leaf the author probably meant, got {reason:?}"
15603 );
15604 }
15605
15606 #[test]
15607 fn validate_rejects_git_fonte_with_branch_named_at() {
15608 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15609 // unsourceable. Pinned so a future relaxation that admits
15610 // any single-character refname surfaces here.
15611 let d = dep_with_fonte(DepSource::Git {
15612 repo: "github:pleme-io/caixa-teia".into(),
15613 tag: None,
15614 rev: None,
15615 branch: Some("@".into()),
15616 });
15617 let err = d.validate().unwrap_err();
15618 let DepError::FontePinShape { pin, value, .. } = err else {
15619 panic!("expected FontePinShape, got other variant");
15620 };
15621 assert_eq!(pin, ":branch");
15622 assert_eq!(value, "@");
15623 }
15624
15625 #[test]
15626 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15627 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15628 // a `:tag "../escape"` (path-traversal-shaped slug) silently
15629 // passes parse and surfaces as a refname-parse error or, on
15630 // older git, a literal `../escape` checkout that escapes the
15631 // refs/ directory tree. Pinned separately from the
15632 // qualified-prefix arm so a future relaxation that catches
15633 // one but not the other surfaces here.
15634 let d = dep_with_fonte(DepSource::Git {
15635 repo: "github:pleme-io/caixa-teia".into(),
15636 tag: Some("../escape".into()),
15637 rev: None,
15638 branch: None,
15639 });
15640 let err = d.validate().unwrap_err();
15641 let DepError::FontePinShape { pin, value, .. } = err else {
15642 panic!("expected FontePinShape, got other variant");
15643 };
15644 assert_eq!(pin, ":tag");
15645 assert_eq!(value, "../escape");
15646 }
15647
15648 #[test]
15649 fn validate_accepts_git_fonte_with_hierarchical_branch() {
15650 // The positive-control pin: hierarchical refnames with one or
15651 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15652 // canonical idiom) round-trip through the gate. Pinned
15653 // separately from the leaf-`"main"` positive control so a
15654 // future tightening that rejects all multi-component refnames
15655 // surfaces here.
15656 let d = dep_with_fonte(DepSource::Git {
15657 repo: "github:pleme-io/caixa-teia".into(),
15658 tag: None,
15659 rev: None,
15660 branch: Some("feature/checkout-rewrite".into()),
15661 });
15662 d.validate().unwrap();
15663 }
15664
15665 #[test]
15666 fn validate_accepts_git_fonte_with_prerelease_tag() {
15667 // The positive-control pin: semver pre-release shape
15668 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15669 // (only consecutive `..` and trailing `.` are rejected), the
15670 // mid-component hyphen is allowed. Pinned separately from
15671 // the bare-`"v0.1.0"` positive control so a future tightening
15672 // that rejects pre-release tags surfaces here.
15673 let d = dep_with_fonte(DepSource::Git {
15674 repo: "github:pleme-io/caixa-teia".into(),
15675 tag: Some("v0.1.0-alpha.1".into()),
15676 rev: None,
15677 branch: None,
15678 });
15679 d.validate().unwrap();
15680 }
15681
15682 #[test]
15683 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15684 // The `:rev` axis is routed through `crate::render::is_git_oid`
15685 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15686 // value with refname-shape punctuation (here, a `:` mid-string
15687 // — would be a refname violation under `is_git_ref_name` too)
15688 // is rejected at the OID-shape gate. The two predicates
15689 // partition the `:fonte` pin axes structurally: an `:rev` value
15690 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15691 // *still* rejected here because every refname character outside
15692 // `[0-9a-f]` fails the OID gate. Same shape as
15693 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15694 // on the refname-shaped axes — the diagnostic names the
15695 // offending dep + pin + value verbatim. The flip-from-accept
15696 // case the prior `:tag`/`:branch` gate left as a "future axis"
15697 // (e70d213) — now landed.
15698 let d = dep_with_fonte(DepSource::Git {
15699 repo: "github:pleme-io/caixa-teia".into(),
15700 tag: None,
15701 rev: Some("c0ffee:notarefname".into()),
15702 branch: None,
15703 });
15704 let err = d.validate().unwrap_err();
15705 let DepError::FontePinShape {
15706 nome,
15707 pin,
15708 value,
15709 reason,
15710 } = err
15711 else {
15712 panic!("expected FontePinShape, got other variant");
15713 };
15714 assert_eq!(nome, "caixa-teia");
15715 assert_eq!(pin, ":rev");
15716 assert_eq!(value, "c0ffee:notarefname");
15717 assert!(
15718 !reason.is_empty(),
15719 "FontePinShape `reason` must carry the predicate's wording verbatim"
15720 );
15721 }
15722
15723 #[test]
15724 fn validate_accepts_git_fonte_with_rev_full_sha1() {
15725 // The positive-control pin on the SHA-1 OID width: exactly 40
15726 // lowercase hex characters — the canonical `git rev-parse HEAD`
15727 // emission on a SHA-1-hashed repository (the default on every
15728 // pre-2.42 git and the canonical pleme-io substrate hash).
15729 // Pinned separately from the SHA-256 positive control so a
15730 // future tightening that only admits one width surfaces here.
15731 let d = dep_with_fonte(DepSource::Git {
15732 repo: "github:pleme-io/caixa-teia".into(),
15733 tag: None,
15734 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15735 branch: None,
15736 });
15737 d.validate().unwrap();
15738 }
15739
15740 #[test]
15741 fn validate_accepts_git_fonte_with_rev_full_sha256() {
15742 // The positive-control pin on the SHA-256 OID width: exactly
15743 // 64 lowercase hex characters — `git`'s
15744 // `extensions.objectFormat = sha256` emission (GA since Git
15745 // 2.42 / Oct 2023). The substrate admits either canonical
15746 // width so an `:rev` authored against a SHA-256-hashed
15747 // upstream round-trips through the gate without per-repo
15748 // configuration. Pinned separately from the SHA-1 positive
15749 // control so a future tightening that drops one width surfaces
15750 // here as a structural decision.
15751 let d = dep_with_fonte(DepSource::Git {
15752 repo: "github:pleme-io/caixa-teia".into(),
15753 tag: None,
15754 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15755 branch: None,
15756 });
15757 d.validate().unwrap();
15758 }
15759
15760 #[test]
15761 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15762 // The canonical `git log --short` / `git rev-parse --short HEAD`
15763 // paste-from-release-notes footgun: a 7-char prefix (git's
15764 // default `core.abbrev`) silently passes string emptiness
15765 // checks and resolves to one commit today, but becomes ambiguous
15766 // tomorrow as the repo grows. Until this gate landed the empty-
15767 // pin arm passed (the string isn't empty) and the resolver
15768 // accepted the prefix through git's separate prefix-lookup pass
15769 // — defeating the reproducibility contract `:rev` carries vs.
15770 // `:tag` / `:branch`. The new gate moves the check to caixa-
15771 // build time and names the offending dep + pin + value verbatim.
15772 let d = dep_with_fonte(DepSource::Git {
15773 repo: "github:pleme-io/caixa-teia".into(),
15774 tag: None,
15775 rev: Some("c0ffee0".into()),
15776 branch: None,
15777 });
15778 let err = d.validate().unwrap_err();
15779 let DepError::FontePinShape {
15780 pin, value, reason, ..
15781 } = err
15782 else {
15783 panic!("expected FontePinShape, got other variant");
15784 };
15785 assert_eq!(pin, ":rev");
15786 assert_eq!(value, "c0ffee0");
15787 assert!(
15788 reason.contains("abbreviated") || reason.contains("ambiguous"),
15789 "reason must surface the abbreviation arm, got {reason:?}"
15790 );
15791 }
15792
15793 #[test]
15794 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15795 // The canonical "I pasted the SHA in uppercase" footgun: `git
15796 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15797 // bearing `:rev` round-trips inconsistently across the
15798 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15799 // equality-check pipeline and fails the lacre's content-
15800 // addressing probe with a confusing case-only diff. Pinned
15801 // separately from the non-hex arm so a future relaxation that
15802 // admits one but not the other surfaces here.
15803 let d = dep_with_fonte(DepSource::Git {
15804 repo: "github:pleme-io/caixa-teia".into(),
15805 tag: None,
15806 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15807 branch: None,
15808 });
15809 let err = d.validate().unwrap_err();
15810 let DepError::FontePinShape {
15811 pin, value, reason, ..
15812 } = err
15813 else {
15814 panic!("expected FontePinShape, got other variant");
15815 };
15816 assert_eq!(pin, ":rev");
15817 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15818 assert!(
15819 reason.contains("uppercase"),
15820 "reason must surface the uppercase arm, got {reason:?}"
15821 );
15822 }
15823
15824 #[test]
15825 fn validate_rejects_git_fonte_with_rev_refname_value() {
15826 // The cross-axis mis-slot footgun: `:rev "main"` — the author
15827 // conflated `:rev` (hex commit ID, immutable) and `:branch`
15828 // (mutable ref pointing at whatever HEAD is today). Until this
15829 // gate landed the resolver silently dispatched on the value
15830 // shape ("`main` doesn't look like a SHA, fall back to
15831 // refname"), defeating the `:rev` reproducibility contract.
15832 // The new gate rejects every non-hex value on the `:rev` axis,
15833 // so the `:rev`/`:branch` boundary is structurally enforced —
15834 // a refname in the `:rev` slot is a build error, not a
15835 // resolver-time silent reinterpretation.
15836 let d = dep_with_fonte(DepSource::Git {
15837 repo: "github:pleme-io/caixa-teia".into(),
15838 tag: None,
15839 rev: Some("main".into()),
15840 branch: None,
15841 });
15842 let err = d.validate().unwrap_err();
15843 let DepError::FontePinShape {
15844 pin, value, reason, ..
15845 } = err
15846 else {
15847 panic!("expected FontePinShape, got other variant");
15848 };
15849 assert_eq!(pin, ":rev");
15850 assert_eq!(value, "main");
15851 // 4 chars `main` fails the length arm before the character arm,
15852 // so the diagnostic surfaces the abbreviation wording (same
15853 // path the `c0ffee0` 7-char fixture lands on); the structural
15854 // assertion is just that the `:rev "main"` value is rejected.
15855 assert!(
15856 !reason.is_empty(),
15857 "FontePinShape reason must be non-empty for refname-shaped :rev"
15858 );
15859 }
15860
15861 #[test]
15862 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15863 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15864 // conflated `:rev` and `:tag`. Pinned separately from the
15865 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15866 // that catches one but not the other surfaces here. The
15867 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15868 // assertion is just that the cross-axis mis-slot is a build
15869 // error, regardless of which sub-arm surfaces the diagnostic
15870 // (`is_git_oid` rejects at the first violation; longer
15871 // tag-shape values would hit the non-hex arm instead).
15872 let d = dep_with_fonte(DepSource::Git {
15873 repo: "github:pleme-io/caixa-teia".into(),
15874 tag: None,
15875 rev: Some("v0.1.0".into()),
15876 branch: None,
15877 });
15878 let err = d.validate().unwrap_err();
15879 let DepError::FontePinShape {
15880 pin, value, reason, ..
15881 } = err
15882 else {
15883 panic!("expected FontePinShape, got other variant");
15884 };
15885 assert_eq!(pin, ":rev");
15886 assert_eq!(value, "v0.1.0");
15887 assert!(
15888 !reason.is_empty(),
15889 "FontePinShape reason must be non-empty for tag-shaped :rev"
15890 );
15891 }
15892
15893 #[test]
15894 fn validate_rejects_git_fonte_with_rev_too_long() {
15895 // Boundary case on the upper end: 41 hex chars — one past the
15896 // SHA-1 width, well below the SHA-256 width. Pin so a future
15897 // relaxation that admits "long enough to be a SHA" without
15898 // matching either canonical width surfaces here. The diagnostic
15899 // names the offending length verbatim so the author's grep
15900 // target is unambiguous (either trim one char or paste the
15901 // full SHA-256).
15902 let too_long: String = "0".repeat(41);
15903 let d = dep_with_fonte(DepSource::Git {
15904 repo: "github:pleme-io/caixa-teia".into(),
15905 tag: None,
15906 rev: Some(too_long.clone()),
15907 branch: None,
15908 });
15909 let err = d.validate().unwrap_err();
15910 let DepError::FontePinShape {
15911 pin, value, reason, ..
15912 } = err
15913 else {
15914 panic!("expected FontePinShape, got other variant");
15915 };
15916 assert_eq!(pin, ":rev");
15917 assert_eq!(value, too_long);
15918 assert!(
15919 reason.contains("41"),
15920 "reason must surface the offending length verbatim, got {reason:?}"
15921 );
15922 }
15923
15924 #[test]
15925 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15926 // The canonical paste-from-doc footgun on `:rev` — author
15927 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15928 // commit-message paragraph. Until this gate landed the empty-
15929 // pin arm passed (the string isn't empty), the resolver issued
15930 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15931 // clone time with a quoting-confused git error far from the
15932 // source caixa.lisp. The new gate moves the check to caixa-
15933 // build time. Length is 41 (40 hex + space) so the length arm
15934 // fires first — pinned separately from the pure-length arm to
15935 // ensure the diagnostic surfaces *some* parser wording, not
15936 // silently pass through.
15937 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15938 let d = dep_with_fonte(DepSource::Git {
15939 repo: "github:pleme-io/caixa-teia".into(),
15940 tag: None,
15941 rev: Some(with_space.clone()),
15942 branch: None,
15943 });
15944 let err = d.validate().unwrap_err();
15945 let DepError::FontePinShape {
15946 pin, value, reason, ..
15947 } = err
15948 else {
15949 panic!("expected FontePinShape, got other variant");
15950 };
15951 assert_eq!(pin, ":rev");
15952 assert_eq!(value, with_space);
15953 assert!(
15954 !reason.is_empty(),
15955 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15956 );
15957 }
15958
15959 #[test]
15960 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15961 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15962 // variant on this axis names the offending dep's `:nome` + the
15963 // `:rev` axis + the offending value verbatim, so the author's
15964 // grep target is the literal `:rev "<value>"` block in
15965 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15966 // carries_offending_nome_pin_value` test on the refname-shaped
15967 // (`:tag` / `:branch`) axes.
15968 let d = dep_with_fonte(DepSource::Git {
15969 repo: "github:p/x".into(),
15970 tag: None,
15971 rev: Some("not-a-sha".into()),
15972 branch: None,
15973 });
15974 let msg = d
15975 .validate()
15976 .expect_err(":rev: expected FontePinShape")
15977 .to_string();
15978 assert!(
15979 msg.contains("\"caixa-teia\""),
15980 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15981 );
15982 assert!(
15983 msg.contains(":rev"),
15984 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15985 );
15986 assert!(
15987 msg.contains("not-a-sha"),
15988 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15989 );
15990 }
15991
15992 #[test]
15993 fn fonte_pin_empty_fires_before_pin_shape() {
15994 // Order pin: a `Some("")` `:tag` is the more self-locating
15995 // diagnostic (the author chose an axis but left it blank;
15996 // grep is unambiguous), so it fires before the shape gate
15997 // even when both arms would match. Pinned so a future
15998 // reordering surfaces here. Mirrors the
15999 // `fonte_repo_empty_fires_before_pin_missing` ordering
16000 // discipline on the peer per-axis arms.
16001 let d = dep_with_fonte(DepSource::Git {
16002 repo: "github:pleme-io/caixa-teia".into(),
16003 tag: Some(String::new()),
16004 rev: None,
16005 branch: None,
16006 });
16007 assert!(matches!(
16008 d.validate().unwrap_err(),
16009 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16010 ));
16011 }
16012
16013 #[test]
16014 fn fonte_pin_shape_fires_after_repo_empty() {
16015 // Order pin: `:repo ""` is the more self-locating axis
16016 // (every git source needs a repo; the per-pin shape gate is
16017 // secondary), so the repo-empty arm fires before the
16018 // per-pin shape arm even when both are violated. Pinned so
16019 // a future reordering surfaces here. Mirrors
16020 // `fonte_repo_empty_fires_before_pin_missing` on the
16021 // adjacent axis pair.
16022 let d = dep_with_fonte(DepSource::Git {
16023 repo: String::new(),
16024 tag: Some("v0.1.0 ".into()),
16025 rev: None,
16026 branch: None,
16027 });
16028 assert!(matches!(
16029 d.validate().unwrap_err(),
16030 DepError::FonteRepoEmpty { .. }
16031 ));
16032 }
16033
16034 #[test]
16035 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16036 // Diagnostic-shape pin across both refname-shaped axes
16037 // (`:tag` + `:branch`): every `FontePinShape` variant names
16038 // the offending dep's `:nome` + the offending pin axis + the
16039 // offending value verbatim, so the author's grep target is
16040 // unambiguous (the literal `:tag "<value>"` / `:branch
16041 // "<value>"` lands in caixa.lisp with quotes). Cover both
16042 // pin axes so a future variant addition forces a parallel
16043 // diagnostic-shape decision.
16044 for (pin_label, fonte) in [
16045 (
16046 ":tag",
16047 DepSource::Git {
16048 repo: "github:p/x".into(),
16049 tag: Some("v0.1.0~1".into()),
16050 rev: None,
16051 branch: None,
16052 },
16053 ),
16054 (
16055 ":branch",
16056 DepSource::Git {
16057 repo: "github:p/x".into(),
16058 tag: None,
16059 rev: None,
16060 branch: Some("feature/foo*".into()),
16061 },
16062 ),
16063 ] {
16064 let d = dep_with_fonte(fonte);
16065 let msg = d
16066 .validate()
16067 .expect_err(&format!("{pin_label}: expected FontePinShape"))
16068 .to_string();
16069 assert!(
16070 msg.contains("\"caixa-teia\""),
16071 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16072 );
16073 assert!(
16074 msg.contains(pin_label),
16075 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16076 );
16077 }
16078 }
16079
16080 #[test]
16081 fn git_source_json_round_trip() {
16082 let src = DepSource::Git {
16083 repo: "github:pleme-io/caixa-teia".into(),
16084 tag: Some("v0.1.0".into()),
16085 rev: None,
16086 branch: None,
16087 };
16088 let s = serde_json::to_string(&src).unwrap();
16089 assert!(s.contains(&format!(
16090 r#""{tipo}":"{git}""#,
16091 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16092 git = crate::render::DEP_SOURCE_TIPO_GIT,
16093 )));
16094 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16095 assert!(s.contains(r#""tag":"v0.1.0""#));
16096 assert!(!s.contains("rev"));
16097 assert!(!s.contains("branch"));
16098 let round: DepSource = serde_json::from_str(&s).unwrap();
16099 assert_eq!(round, src);
16100 }
16101
16102 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16103 //
16104 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16105 // attribute on [`DepSource`] pins three load-bearing byte-sequences
16106 // that flow into every serialized `Dep.fonte` block: the outer
16107 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16108 // the two admitted variant-tag values `"git"` / `"path"` the
16109 // `rename_all = "lowercase"` attribute pins as the discriminator's
16110 // closed-set arms. The three pin tests below round-trip a
16111 // fully-populated variant of each arm through
16112 // [`serde_json::to_value`] and assert each canonical byte-sequence
16113 // appears at its axis — pins a hypothetical future
16114 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16115 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16116 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16117 // at build time rather than at fetch time when the resolver's
16118 // `Dep.fonte` dispatch silently fails to match on the drifted
16119 // discriminator. Same "serialize-and-check" discipline the peer
16120 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16121 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16122 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16123 // family in caixa-core lacking a lifted peer.
16124
16125 #[test]
16126 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16127 // Fail-before-pass-after: a future `tag = "type"` at the derive
16128 // attribute would serialize under `"type":"git"`, and this test
16129 // would trip because `"tipo"` no longer appears at the emitted
16130 // discriminator key. A future `rename_all = "kebab-case"` /
16131 // `"snake_case"` (both no-ops on `Git` since it lacks internal
16132 // word boundaries) is caught by the sibling
16133 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16134 // pin below (Path has no internal boundary either but the pair
16135 // catches any per-arm inconsistency). A future variant rename
16136 // `Git` → `Repository` would emit `"tipo":"repository"` and
16137 // trip this pin.
16138 let src = DepSource::Git {
16139 repo: "github:pleme-io/caixa-teia".into(),
16140 tag: Some("v0.1.0".into()),
16141 rev: None,
16142 branch: None,
16143 };
16144 let json = serde_json::to_value(&src).unwrap();
16145 let obj = json.as_object().expect("Git serializes as a JSON object");
16146 assert_eq!(
16147 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16148 .and_then(serde_json::Value::as_str),
16149 Some(crate::render::DEP_SOURCE_TIPO_GIT),
16150 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16151 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16152 detected in {json}"
16153 );
16154 }
16155
16156 #[test]
16157 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16158 // Fail-before-pass-after: a future variant rename `Path` →
16159 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16160 // this pin. A per-consumer disambiguation as the `defcaixa`
16161 // macro stabilizes ("caminho" → "path" for English-uniformity)
16162 // is scoped to the inner field key, not the discriminator; this
16163 // pin is orthogonal to that and catches only the outer
16164 // discriminator drift.
16165 let src = DepSource::Path {
16166 caminho: "../caixa-teia".into(),
16167 };
16168 let json = serde_json::to_value(&src).unwrap();
16169 let obj = json.as_object().expect("Path serializes as a JSON object");
16170 assert_eq!(
16171 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16172 .and_then(serde_json::Value::as_str),
16173 Some(crate::render::DEP_SOURCE_TIPO_PATH),
16174 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16175 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16176 detected in {json}"
16177 );
16178 }
16179
16180 #[test]
16181 fn dep_source_key_consts_are_pairwise_distinct() {
16182 // Cross-axis collapse detector: a hypothetical future edit that
16183 // accidentally set two of the three consts to the same byte
16184 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16185 // pass every per-arm serialize pin above but silently collapse
16186 // the discriminator's closed-set arms onto one another; this pin
16187 // catches the collapse at build time.
16188 assert_ne!(
16189 crate::render::DEP_SOURCE_KEY_TIPO,
16190 crate::render::DEP_SOURCE_TIPO_GIT,
16191 );
16192 assert_ne!(
16193 crate::render::DEP_SOURCE_KEY_TIPO,
16194 crate::render::DEP_SOURCE_TIPO_PATH,
16195 );
16196 assert_ne!(
16197 crate::render::DEP_SOURCE_TIPO_GIT,
16198 crate::render::DEP_SOURCE_TIPO_PATH,
16199 );
16200 }
16201
16202 #[test]
16203 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16204 // Shape pin against `rename_all` drift: the two variant-tag
16205 // consts must be ASCII-lowercase-only to match the
16206 // `rename_all = "lowercase"` attribute the derive uses; a future
16207 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16208 // would emit `"GIT"` / `"Git"` instead and trip this pin.
16209 for (label, s) in [
16210 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16211 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16212 ] {
16213 assert!(!s.is_empty(), "{label} must not be empty");
16214 assert!(
16215 s.bytes().all(|b| b.is_ascii_lowercase()),
16216 "{label} must be ASCII-lowercase-only (matching \
16217 rename_all = \"lowercase\"), got {s:?}",
16218 );
16219 }
16220 }
16221
16222 // ── per-entry :caracteristicas set-not-multiset gate ────────────
16223 //
16224 // Every Vec-keyed-by-name authoring surface on the typed Caixa
16225 // surface that identifies its entries by a name field now uniformly
16226 // closes the set-not-multiset discipline at build time (cite
16227 // `validate_caracteristicas`'s peer-axis enumeration). The
16228 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16229 // set-shaped (a feature is either enabled or not — there is no
16230 // `feature × 2` semantic), so two entries naming the same feature
16231 // are a redundant declaration the caixa-resolver's lacre pipeline
16232 // would silently dedup at resolve time. The empty-feature arm
16233 // closes the parallel "operationally-meaningless value" axis on
16234 // the same slot. Same linear-walk + `HashSet` + first-collision
16235 // shape every peer set gate uses; same empty-first cascade every
16236 // peer per-entry shape + duplicate gate uses (the empty-feature
16237 // axis is the more-actionable defect since two `""` entries would
16238 // both report `caracteristica: ""` under a duplicate-first
16239 // ordering, with no way to distinguish the offending site).
16240
16241 fn dep_with_features(features: &[&str]) -> Dep {
16242 Dep {
16243 nome: "caixa-teia".into(),
16244 versao: "^0.1".into(),
16245 fonte: None,
16246 opcional: false,
16247 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16248 }
16249 }
16250
16251 #[test]
16252 fn validate_rejects_empty_caracteristica() {
16253 // Fail-before-pass-after pin: every pre-gate codebase accepted
16254 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16255 // imposed no per-entry shape contract), the dep validated, and
16256 // the empty feature would have reached the future caixa-resolver
16257 // lacre pipeline as a no-op feature enable — silently dropping
16258 // the author's intent far from the source `caixa.lisp`. The new
16259 // gate surfaces the structural defect at the typed-validate
16260 // surface with a self-locating diagnostic naming the offending
16261 // dep's `:nome`.
16262 let d = dep_with_features(&[""]);
16263 assert!(
16264 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16265 "expected CaracteristicaEmpty, got {:?}",
16266 d.validate(),
16267 );
16268 }
16269
16270 #[test]
16271 fn validate_rejects_duplicate_caracteristica() {
16272 // Fail-before-pass-after pin on the set-not-multiset arm: the
16273 // feature-toggle slot is set-shaped, so `(:caracteristicas
16274 // ("http" "http"))` is a redundant declaration the lacre
16275 // pipeline dedupes silently at resolve time. The diagnostic
16276 // names the offending dep + the colliding feature verbatim so
16277 // the author can grep their caixa.lisp for `:caracteristicas`
16278 // and fix it in one edit. First-collision determinism is
16279 // pinned separately below.
16280 let d = dep_with_features(&["http", "http"]);
16281 assert!(
16282 matches!(
16283 d.validate().unwrap_err(),
16284 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16285 if nome == "caixa-teia" && caracteristica == "http"
16286 ),
16287 "expected CaracteristicaDuplicate, got {:?}",
16288 d.validate(),
16289 );
16290 }
16291
16292 #[test]
16293 fn validate_accepts_distinct_caracteristicas() {
16294 // The canonical authoring shape — every feature distinct — must
16295 // remain a clean pass (positive control sweep). Covers the
16296 // canonical kebab-case feature names a target caixa typically
16297 // declares.
16298 dep_with_features(&["http", "json", "tls"])
16299 .validate()
16300 .unwrap();
16301 }
16302
16303 #[test]
16304 fn validate_accepts_single_caracteristica() {
16305 // Single-element list is the minimum non-empty shape; passes
16306 // the gate as the identity of the duplicate check (no second
16307 // entry to collide with).
16308 dep_with_features(&["http"]).validate().unwrap();
16309 }
16310
16311 #[test]
16312 fn validate_accepts_empty_caracteristicas_list() {
16313 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16314 // produces `caracteristicas: Vec::new()`; the empty list is
16315 // the gate's empty-set identity and passes vacuously. Pin
16316 // this so a future tightening that requires ≥1 feature
16317 // surfaces here as a test failure rather than a silent
16318 // contract narrowing.
16319 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16320 assert!(dep_with_features(&[]).validate().is_ok());
16321 }
16322
16323 #[test]
16324 fn validate_caracteristica_empty_fires_before_duplicate() {
16325 // Empty-first cascade: an entry with an empty feature *and*
16326 // duplicate entries surfaces the empty diagnostic first. The
16327 // empty-feature axis is the more-actionable defect since
16328 // `caracteristica: ""` is unambiguous; under duplicate-first
16329 // ordering the diagnostic could report the empty string from
16330 // either of two empty entries with no way to distinguish.
16331 // Mirrors the peer empty-before-duplicate ordering
16332 // discipline every per-entry shape + duplicate gate establishes
16333 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16334 // `DuplicateChildCaixa`, `validate_membros`'s
16335 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16336 let d = dep_with_features(&["", "http", "http"]);
16337 assert!(matches!(
16338 d.validate().unwrap_err(),
16339 DepError::CaracteristicaEmpty { .. }
16340 ));
16341 }
16342
16343 #[test]
16344 fn validate_caracteristica_duplicate_first_collision_determinism() {
16345 // Three matching entries: the second occurrence surfaces the
16346 // diagnostic (the second is the first *collision* — the first
16347 // entry is the establishing one, not a duplicate). Mirrors
16348 // every peer first-collision posture
16349 // (`SupervisorError::DuplicateChildCaixa` reports the second
16350 // collision, `AplicacaoError::MembroDuplicate` reports the
16351 // second, `DepError::DuplicateNome` reports the second).
16352 // Pinning this so a future shortcut that flips to last-
16353 // collision (or non-deterministic) surfaces here.
16354 let d = dep_with_features(&["http", "http", "http"]);
16355 assert!(matches!(
16356 d.validate().unwrap_err(),
16357 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16358 ));
16359 }
16360
16361 #[test]
16362 fn validate_per_entry_shape_fires_before_caracteristicas() {
16363 // Per-entry shape precedence: a dep with a malformed `:nome`
16364 // (uppercase) AND duplicate `:caracteristicas` surfaces the
16365 // narrower `NomeInvalid` diagnostic first, not the set-gate
16366 // diagnostic. The `:nome` is the self-locating axis (every
16367 // diagnostic from the caracteristicas gate quotes the
16368 // offending dep's `:nome` to anchor the grep target —
16369 // surfacing the malformed name first keeps that anchor
16370 // valid). Same precedence shape every peer per-entry-shape
16371 // arm establishes against its peer set-gate
16372 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16373 // on the cross-entry `:nome` axis).
16374 let d = Dep {
16375 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16376 versao: "^0.1".into(),
16377 fonte: None,
16378 opcional: false,
16379 caracteristicas: vec!["http".into(), "http".into()],
16380 };
16381 assert!(matches!(
16382 d.validate().unwrap_err(),
16383 DepError::NomeInvalid { .. }
16384 ));
16385 }
16386
16387 // ── per-entry :caracteristicas value-shape gate ──────────────────
16388 //
16389 // Until this gate landed `:caracteristicas` only refused the empty
16390 // string and cross-entry duplicates: a non-empty distinct but
16391 // structurally invalid feature name silently passed validate and the
16392 // failure surfaced at `cargo metadata` time as Cargo's
16393 // `restricted_names::validate_feature_name` parser rejection, far from
16394 // the source `caixa.lisp` with no field naming which `:deps` entry's
16395 // `:caracteristicas` carried the typo. The lifted predicate makes the
16396 // Cargo-feature-name-grammar intersection-floor a substrate-level
16397 // invariant at validate time. Same trajectory as the eight peer
16398 // value-shape predicates each typed surface downstream of a structured
16399 // grammar already follows.
16400
16401 #[test]
16402 fn validate_rejects_caracteristica_with_leading_plus() {
16403 // Fail-before-pass-after pin on the canonical Cargo
16404 // `+<feature>` activation-form-in-feature-name-slot footgun.
16405 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16406 // `+optional-feature` as an enablement of a previously-disabled
16407 // feature; pasting that activation form into `:caracteristicas`
16408 // (which names the feature itself) silently passed pre-gate and
16409 // failed at `cargo metadata` parse time.
16410 let d = dep_with_features(&["+http"]);
16411 let err = d.validate().unwrap_err();
16412 assert!(
16413 matches!(
16414 err,
16415 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16416 if nome == "caixa-teia" && caracteristica == "+http"
16417 ),
16418 "expected CaracteristicaInvalid, got {err:?}"
16419 );
16420 }
16421
16422 #[test]
16423 fn validate_rejects_caracteristica_with_leading_hyphen() {
16424 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16425 // is a legitimate continuation character (kebab-case feature
16426 // names like `runtime-tokio` pass) but Cargo rejects it at the
16427 // start; the structural defect — and its CLI-argument-injection
16428 // adjacency at any downstream Cargo subprocess invocation — is
16429 // closed at validate time, not at `cargo metadata` time.
16430 let d = dep_with_features(&["-json"]);
16431 let err = d.validate().unwrap_err();
16432 assert!(
16433 matches!(
16434 err,
16435 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16436 ),
16437 "expected CaracteristicaInvalid, got {err:?}"
16438 );
16439 }
16440
16441 #[test]
16442 fn validate_rejects_caracteristica_with_leading_dot() {
16443 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16444 // a legitimate continuation character (version-suffix shapes
16445 // like `feat.v2` pass) but the leading-dot form is the
16446 // canonical dotted-version-suffix-as-feature-name confusion.
16447 let d = dep_with_features(&[".feat"]);
16448 let err = d.validate().unwrap_err();
16449 assert!(matches!(
16450 err,
16451 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16452 ));
16453 }
16454
16455 #[test]
16456 fn validate_rejects_caracteristica_with_whitespace() {
16457 // Fail-before-pass-after pin on the embedded-whitespace footgun:
16458 // a feature name with a space inside is structurally a multi-
16459 // token blob (the canonical paste-from-doc footgun, or an
16460 // accidental `"http server"` where the author meant
16461 // `"http-server"`).
16462 let d = dep_with_features(&["http feature"]);
16463 let err = d.validate().unwrap_err();
16464 assert!(matches!(
16465 err,
16466 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16467 ));
16468 }
16469
16470 #[test]
16471 fn validate_rejects_caracteristica_with_comma() {
16472 // Fail-before-pass-after pin on the embedded-comma footgun:
16473 // the list-separator-belongs-to-the-list-grammar
16474 // miscomprehension where the author writes
16475 // `:caracteristicas ("http,json")` intending two features but
16476 // the `Vec<String>` field consumes the bare token as one entry.
16477 let d = dep_with_features(&["http,json"]);
16478 let err = d.validate().unwrap_err();
16479 assert!(matches!(
16480 err,
16481 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16482 ));
16483 }
16484
16485 #[test]
16486 fn validate_rejects_caracteristica_with_slash() {
16487 // Fail-before-pass-after pin on the embedded-slash footgun:
16488 // Cargo's `dep/feat` namespaced-dep syntax applies inside
16489 // `[dependencies.<dep>.features]` list entries that already
16490 // name the parent dep (so the syntax says "enable feature
16491 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16492 // per-dep already (a sibling slot on the `Dep` itself), so the
16493 // segment separator within an entry must be `-`, `_`, `+`,
16494 // or `.`. The diagnostic remediation points at the canonical
16495 // Cargo namespaced-dep discipline.
16496 let d = dep_with_features(&["http/json"]);
16497 let err = d.validate().unwrap_err();
16498 assert!(matches!(
16499 err,
16500 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16501 ));
16502 }
16503
16504 #[test]
16505 fn validate_rejects_caracteristica_with_non_ascii() {
16506 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16507 // byte footgun: NFC-vs-NFD normalization across filesystems
16508 // silently rewrites the feature-key, breaking the lacre's
16509 // content-addressing invariant. Pinned at a canonical
16510 // smart-quote-paste shape (`café`) where the raw `é` byte is the
16511 // documented APFS round-trip break.
16512 let d = dep_with_features(&["caf\u{e9}"]);
16513 let err = d.validate().unwrap_err();
16514 assert!(matches!(
16515 err,
16516 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16517 ));
16518 }
16519
16520 #[test]
16521 fn validate_rejects_caracteristica_with_control_character() {
16522 // Fail-before-pass-after pin on the embedded-control-character
16523 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16524 // feature name is the canonical paste-from-multiline-doc
16525 // footgun the predicate's reason wording specifically calls out.
16526 let d = dep_with_features(&["http\njson"]);
16527 let err = d.validate().unwrap_err();
16528 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16529 }
16530
16531 #[test]
16532 fn validate_accepts_canonical_caracteristicas_shapes() {
16533 // Positive control sweep: every canonical Cargo feature name
16534 // shape the pleme-io ecosystem uses must still pass. Mirrors
16535 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16536 // sweep — drift between either landing site and the predicate's
16537 // accepted set is a build error visible at this pair of tests,
16538 // not a per-renderer "this passed validate but failed at
16539 // cargo metadata time" surprise on the next acceptance.
16540 for s in [
16541 "http",
16542 "json",
16543 "derive",
16544 "serde_json",
16545 "runtime-tokio",
16546 "tokio.full",
16547 "v0.1",
16548 "http+json",
16549 "_internal",
16550 "__private",
16551 "default",
16552 "rt-multi-thread",
16553 "feat.v2",
16554 ] {
16555 let d = dep_with_features(&[s]);
16556 d.validate().unwrap_or_else(|e| {
16557 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16558 });
16559 }
16560 }
16561
16562 #[test]
16563 fn validate_caracteristica_empty_fires_before_invalid() {
16564 // Cascade precedence pin: an entry list with both an empty
16565 // feature AND an invalid-shape feature surfaces the
16566 // `CaracteristicaEmpty` arm first (the empty value carries no
16567 // self-locating data — `caracteristica: ""` is the diagnostic
16568 // with no way to anchor a grep target — so closing the empty
16569 // axis first preserves the per-entry-shape diagnostic's
16570 // self-locating discipline). Same empty-first cascade every
16571 // peer per-entry shape gate establishes
16572 // (`SupervisorSpec::validate`'s `EmptyChildName` before
16573 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16574 // before `MembroCaixaInvalid`).
16575 let d = dep_with_features(&["", "+http"]);
16576 assert!(matches!(
16577 d.validate().unwrap_err(),
16578 DepError::CaracteristicaEmpty { .. }
16579 ));
16580 }
16581
16582 #[test]
16583 fn validate_caracteristica_invalid_fires_before_duplicate() {
16584 // Per-entry-shape precedence pin: an entry list with the same
16585 // invalid feature shape declared twice surfaces the
16586 // `CaracteristicaInvalid` diagnostic on the first entry, not
16587 // the `CaracteristicaDuplicate` on the second collision. The
16588 // per-entry shape gate fires before the cross-entry set gate
16589 // — same precedence shape every peer two-arm-plus-set gate
16590 // establishes (`SupervisorSpec::validate`'s
16591 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16592 // `validate_membros`'s `MembroCaixaInvalid` before
16593 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16594 // cross-list `DuplicateNome`).
16595 let d = dep_with_features(&["+http", "+http"]);
16596 assert!(matches!(
16597 d.validate().unwrap_err(),
16598 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16599 ));
16600 }
16601
16602 #[test]
16603 fn validate_rejects_caracteristica_at_65_byte_boundary() {
16604 // Boundary pin on the 64-byte cap — both the boundary-accepting
16605 // case and the boundary-exceeding case in one place, so a
16606 // future cap shift surfaces both arms simultaneously, mirroring
16607 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16608 // predicate-level pin at the dep-axis landing site.
16609 let max_ok = "a".repeat(64);
16610 dep_with_features(&[&max_ok])
16611 .validate()
16612 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16613 let too_long = "a".repeat(65);
16614 let d = dep_with_features(&[&too_long]);
16615 assert!(matches!(
16616 d.validate().unwrap_err(),
16617 DepError::CaracteristicaInvalid { .. }
16618 ));
16619 }
16620
16621 // ── self-dep cross-slot gate ─────────────────────────────────────
16622
16623 #[test]
16624 fn validate_no_self_dep_rejects_self_in_deps() {
16625 // A caixa whose `:deps` lists its own `:nome` is a one-node
16626 // cycle in the lacre closure's dep-graph traversal — rejected,
16627 // naming the parent and the offending list tag.
16628 let deps = vec![
16629 Dep::simple("caixa-teia", "^0.1"),
16630 Dep::simple("orquestra", "^0.1"),
16631 ];
16632 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16633 assert!(
16634 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16635 "got {err:?}"
16636 );
16637 }
16638
16639 #[test]
16640 fn validate_no_self_dep_rejects_self_in_deps_dev() {
16641 // Same gate on the `:deps-dev` axis — neither dep list is a
16642 // second-class citizen on the self-edge invariant.
16643 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16644 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16645 assert!(
16646 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16647 "got {err:?}"
16648 );
16649 }
16650
16651 #[test]
16652 fn validate_no_self_dep_deps_fires_before_deps_dev() {
16653 // Walk order pin: a caixa that self-references on both lists
16654 // surfaces the `:deps` arm first — the load-bearing axis the
16655 // lacre closure resolves at every build. Mirrors the canonical
16656 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16657 let deps = vec![Dep::simple("orquestra", "^0.1")];
16658 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16659 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16660 assert!(
16661 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16662 "got {err:?}"
16663 );
16664 }
16665
16666 #[test]
16667 fn validate_no_self_dep_accepts_distinct_names() {
16668 // Positive control: every dep names a distinct caixa. The
16669 // canonical author surface — peer of
16670 // [`validate_no_self_supervision_accepts_distinct_children`].
16671 let deps = vec![
16672 Dep::simple("caixa-teia", "^0.1"),
16673 Dep::simple("caixa-arch", "^0.1"),
16674 ];
16675 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16676 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16677 }
16678
16679 #[test]
16680 fn validate_no_self_dep_empty_lists_pass() {
16681 // A caixa with no declared deps has nothing to self-reference —
16682 // the gate is vacuously satisfied. Peer of
16683 // [`validate_no_self_supervision_empty_children_is_ok`].
16684 validate_no_self_dep(&[], &[], "orquestra").unwrap();
16685 }
16686
16687 #[test]
16688 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16689 // Diagnostic-shape pin (peer with
16690 // [`validate_no_self_supervision`]'s diagnostic): the error's
16691 // Display surfaces both the offending list tag and the
16692 // parent's `:nome` verbatim, so the author can grep their
16693 // caixa.lisp for the offending block in one edit. Names
16694 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16695 // surface — every legitimate "I want to use code from this
16696 // caixa" intent routes through one of those three slots.
16697 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16698 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16699 .unwrap_err()
16700 .to_string();
16701 assert!(
16702 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16703 "diagnostic must name the offending list tag: {rendered}",
16704 );
16705 assert!(
16706 rendered.contains("orquestra"),
16707 "diagnostic must quote the parent caixa name: {rendered}",
16708 );
16709 assert!(
16710 rendered.contains(":bibliotecas"),
16711 "diagnostic must point at the corrective code-surface slot: {rendered}",
16712 );
16713 }
16714
16715 #[test]
16716 fn validate_no_self_dep_accepts_coincidental_substring_match() {
16717 // Identity is exact-string equality, not substring — a dep
16718 // named `"orquestra-helper"` is a distinct caixa even when the
16719 // parent is `"orquestra"`. Pin the exact-match discipline so a
16720 // future relaxation that uses `contains` surfaces here, peer
16721 // with the supervision-tree and Aplicacao-membership gates
16722 // which all use exact-string equality on the typed identity.
16723 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16724 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16725 }
16726
16727 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16728
16729 #[test]
16730 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16731 // Scalar-value pin: the two author-facing kebab-case labels the
16732 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16733 // the two-list dep-graph slot axis, one arm per typed slot.
16734 // Mirrors the peer scalar-value pin the sibling
16735 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16736 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16737 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16738 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16739 // (882f498) M3 top-level author-labels, and
16740 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16741 // Supervisor top-level author-labels carry, so every kind-scoped
16742 // typed-slot-family axis routes through one canonical per-arm
16743 // declaration.
16744 //
16745 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16746 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16747 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16748 // for symmetry) lands as an edit to exactly one const, and
16749 // every consumer that reaches for the label picks it up at
16750 // build time rather than at runtime as a downstream mismatch on
16751 // a `DepError::DuplicateNome { list: … }` diagnostic far from
16752 // the rename's commit.
16753 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16754 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16755 }
16756
16757 #[test]
16758 fn dep_author_key_consts_are_pairwise_distinct() {
16759 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16760 // must not collapse onto one byte-string. A future copy-paste
16761 // slip that renamed both consts to the same value (or a rebrand
16762 // that dropped the `-dev` suffix from one but not the other)
16763 // would leave every `DepError::DuplicateNome { list: … }`
16764 // diagnostic naming an unattributable list — the linter would
16765 // route the author to the wrong caixa.lisp block, or the
16766 // cross-list precedence gate
16767 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16768 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16769 // duplicate. Peer of the sibling
16770 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16771 // other top-level kind-scoped slot-family axes carry
16772 // (implicitly held by their different byte-values today).
16773 assert_ne!(
16774 crate::render::DEP_AUTHOR_KEY_DEPS,
16775 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16776 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16777 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16778 self-locates the offending block in the author's caixa.lisp",
16779 );
16780 }
16781
16782 #[test]
16783 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16784 // Production-through-const pin: the two per-arm list tags
16785 // [`validate_no_self_dep`] threads onto the `list:` field of a
16786 // returned [`DepError::DepIsSelf`] route through the lifted
16787 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16788 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16789 // the walker (a rename that reaches one arm but not the const,
16790 // or vice versa) surfaces here at build time rather than at
16791 // runtime as a `feira lint` diagnostic naming the wrong list
16792 // tag. Mirror of the peer
16793 // [`crate::Caixa::declared_servico_slots`] production tagger
16794 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16795 // onto the two-list dep-graph gate.
16796 let deps = vec![Dep::simple("orquestra", "^0.1")];
16797 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16798 let DepError::DepIsSelf { list, .. } = err else {
16799 panic!("expected DepIsSelf from :deps walk");
16800 };
16801 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16802
16803 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16804 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16805 let DepError::DepIsSelf { list, .. } = err else {
16806 panic!("expected DepIsSelf from :deps-dev walk");
16807 };
16808 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16809 }
16810
16811 // ── Dep::nome accessor pins ───────────────────────────────────────
16812 //
16813 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16814 // projection over the plain-shorthand / explicit-git / explicit-path
16815 // fixture triad the [`Dep`] docstring lists (so the accessor's
16816 // accept-set is exercised across every author-surface `:fonte`
16817 // shape); by-borrow pointer identity so the projection stays
16818 // zero-copy at every consumer site; and validate-composition through
16819 // the [`validate_no_self_dep`] cross-slot gate reading its
16820 // parent-name equality check through the lifted accessor rather than
16821 // the raw field.
16822
16823 #[test]
16824 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16825 // Plain-shorthand form (`:fonte None`).
16826 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16827 // Explicit git-source form with a tag pin — same accessor path.
16828 assert_eq!(
16829 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16830 "caixa-teia",
16831 );
16832 // Explicit path-source form.
16833 assert_eq!(
16834 Dep {
16835 nome: "caixa-teia".to_string(),
16836 versao: "0.1.0".to_string(),
16837 fonte: Some(DepSource::Path {
16838 caminho: "../caixa-teia".to_string(),
16839 }),
16840 opcional: false,
16841 caracteristicas: Vec::new(),
16842 }
16843 .nome(),
16844 "caixa-teia",
16845 );
16846 // The empty-string `:nome` sentinel (which [`Dep::validate`]
16847 // refuses through the [`DepError::NomeEmpty`] arm) still round-
16848 // trips as an empty `&str` through the accessor — the accessor is
16849 // a projection, not a gate; the gate is [`Dep::validate`].
16850 assert_eq!(Dep::simple("", "^0.1").nome(), "");
16851 }
16852
16853 #[test]
16854 fn dep_nome_is_by_borrow_pointer_identity() {
16855 // Zero-copy pin: the accessor must borrow into the field's own
16856 // storage, not clone. If a future rewrite regresses to
16857 // `self.nome.clone().leak()` or an owned-buffer shape, the two
16858 // pointers diverge and this pin fails at build time.
16859 let d = Dep::simple("caixa-teia", "^0.1");
16860 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16861 }
16862
16863 // ── Dep::versao_requirement accessor pins ─────────────────────────
16864 //
16865 // Three coherence pins on the lifted `Dep::versao_requirement`
16866 // accessor: byte-equal projection over the plain-shorthand /
16867 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16868 // lists plus the empty-sentinel that round-trips as `""` (the accessor
16869 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16870 // borrow pointer identity so the projection stays zero-copy at every
16871 // consumer site; and validate-composition through the
16872 // [`crate::render::require_valid_versao_requirement`] cascade reading
16873 // its requirement-shape check through the lifted accessor rather than
16874 // the raw field.
16875 #[test]
16876 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16877 // Plain-shorthand form (`:fonte None`).
16878 assert_eq!(
16879 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16880 "^0.1",
16881 );
16882 // Explicit git-source form with a tag pin — same accessor path.
16883 assert_eq!(
16884 Dep::git(
16885 "caixa-teia",
16886 "~0.1.2",
16887 "github:pleme-io/caixa-teia",
16888 "v0.1.0"
16889 )
16890 .versao_requirement(),
16891 "~0.1.2",
16892 );
16893 // Explicit path-source form.
16894 assert_eq!(
16895 Dep {
16896 nome: "caixa-teia".to_string(),
16897 versao: "0.1.0".to_string(),
16898 fonte: Some(DepSource::Path {
16899 caminho: "../caixa-teia".to_string(),
16900 }),
16901 opcional: false,
16902 caracteristicas: Vec::new(),
16903 }
16904 .versao_requirement(),
16905 "0.1.0",
16906 );
16907 // The wildcard requirement (`"*"`) — the shorthand
16908 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16909 // verbatim through the accessor as `"*"`, same byte-shape the
16910 // author wrote.
16911 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16912 // The empty-string `:versao` sentinel (which [`Dep::validate`]
16913 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16914 // trips as an empty `&str` through the accessor — the accessor is
16915 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16916 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16917 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16918 }
16919
16920 #[test]
16921 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16922 // Zero-copy pin: the accessor must borrow into the field's own
16923 // storage, not clone. If a future rewrite regresses to
16924 // `self.versao.clone().leak()` or an owned-buffer shape, the two
16925 // pointers diverge and this pin fails at build time. Peer of the
16926 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16927 // discipline extended onto the requirement-carrying axis.
16928 let d = Dep::simple("caixa-teia", "^0.1");
16929 assert!(std::ptr::eq(
16930 d.versao_requirement().as_ptr(),
16931 d.versao.as_ptr(),
16932 ));
16933 }
16934
16935 #[test]
16936 fn dep_validate_reads_requirement_through_accessor() {
16937 // Composition pin: the [`Dep::validate`]
16938 // [`crate::render::require_valid_versao_requirement`] cascade
16939 // consumes the requirement string through the lifted accessor —
16940 // both the requirement-gate input and the
16941 // [`DepError::VersaoInvalid`] error-body carrier route through
16942 // `self.versao_requirement()`. A valid requirement passes
16943 // (positive control); a malformed-but-non-empty requirement fails
16944 // and the diagnostic quotes the offending byte-string verbatim
16945 // (same shape the accessor projects), so a future regression that
16946 // detoured the requirement carrier through a different byte-
16947 // string (say the parsed `VersionReq`'s `Display`, or a
16948 // normalized rewrite) would surface here at build time. The
16949 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16950 // ahead of the parse arm, pinning the empty-first cascade the
16951 // accessor's `""` sentinel round-trip acknowledges.
16952 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16953 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16954 assert!(
16955 matches!(
16956 &err,
16957 DepError::VersaoInvalid {
16958 nome,
16959 versao,
16960 ..
16961 } if nome == "caixa-teia" && versao == "v0.1",
16962 ),
16963 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16964 );
16965 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16966 assert!(
16967 matches!(
16968 &err,
16969 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16970 ),
16971 "expected VersaoEmpty from the empty-first arm, got {err:?}",
16972 );
16973 }
16974
16975 // ── Dep::fonte accessor pins ──────────────────────────────────────
16976 //
16977 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16978 // equal projection over the plain-shorthand (`:fonte None`) /
16979 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16980 // docstring lists (so the accessor's accept-set is exercised across
16981 // every author-surface `:fonte` shape and both `DepSource` variants);
16982 // pointer identity so the borrowed reference points into the field's
16983 // own `Option<DepSource>` storage (not a cloned side-buffer); and
16984 // validate-composition through the [`Dep::validate`] gate reading
16985 // its per-`:fonte` [`DepSource::validate`] delegation through the
16986 // lifted accessor rather than the raw `if let Some(ref fonte) =
16987 // self.fonte` bracket.
16988
16989 #[test]
16990 fn dep_fonte_returns_declared_source_across_shapes() {
16991 // Plain-shorthand form — `:fonte` omitted, accessor projects
16992 // the `None` partition the resolver-side default-fill treats
16993 // as "resolve through `github:<default-org>/<nome>`".
16994 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16995 // Explicit git-source form with a tag pin — same accessor path.
16996 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16997 match git.fonte() {
16998 Some(DepSource::Git {
16999 repo,
17000 tag,
17001 rev,
17002 branch,
17003 }) => {
17004 assert_eq!(repo, "github:pleme-io/caixa-teia");
17005 assert_eq!(tag.as_deref(), Some("v0.1.0"));
17006 assert!(rev.is_none());
17007 assert!(branch.is_none());
17008 }
17009 other => panic!("expected explicit git :fonte, got {other:?}"),
17010 }
17011 // Explicit path-source form — the dev-only local-filesystem
17012 // arm the [`Dep`] docstring's third fixture carries.
17013 let path = Dep {
17014 nome: "caixa-teia".to_string(),
17015 versao: "0.1.0".to_string(),
17016 fonte: Some(DepSource::Path {
17017 caminho: "../caixa-teia".to_string(),
17018 }),
17019 opcional: false,
17020 caracteristicas: Vec::new(),
17021 };
17022 match path.fonte() {
17023 Some(DepSource::Path { caminho }) => {
17024 assert_eq!(caminho, "../caixa-teia");
17025 }
17026 other => panic!("expected explicit path :fonte, got {other:?}"),
17027 }
17028 }
17029
17030 #[test]
17031 fn dep_fonte_is_by_borrow_pointer_identity() {
17032 // Zero-copy pin: the accessor must borrow into the field's own
17033 // `Option<DepSource>` storage, not clone into a side buffer. If
17034 // a future rewrite regresses to `self.fonte.clone()` or an
17035 // owned-buffer shape, the two pointers diverge and this pin
17036 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17037 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17038 // identity pins — same by-borrow discipline extended onto the
17039 // outer-`Dep` `Option<&Composite>` composite-reference axis.
17040 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17041 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17042 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17043 assert!(std::ptr::eq(accessed, raw));
17044 }
17045
17046 #[test]
17047 fn dep_validate_reads_fonte_through_accessor() {
17048 // Composition pin: [`Dep::validate`]'s per-`:fonte`
17049 // [`DepSource::validate`] delegation consumes the typed slot
17050 // through the lifted accessor — an author-omitted `:fonte`
17051 // still passes the outer gate (positive control), an explicit
17052 // well-formed git source with exactly one pin passes, and a
17053 // malformed git source (empty `:repo`) surfaces the
17054 // [`DepError::FonteRepoEmpty`] variant quoting the offending
17055 // dep's `:nome` verbatim so a future regression that detoured
17056 // the `:fonte` delegation through a different path (say a
17057 // per-scope override projector) would surface here at build
17058 // time. Peer of the sibling
17059 // `dep_validate_reads_requirement_through_accessor` composition
17060 // pin on the `:versao` axis.
17061 // Positive control 1: no `:fonte` at all.
17062 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17063 // Positive control 2: well-formed git source.
17064 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17065 .validate()
17066 .unwrap();
17067 // Negative control: empty `:repo` — the accessor still returns
17068 // `Some(&DepSource::Git { repo: "", … })` and the delegated
17069 // `DepSource::validate` gate raises the typed carrier.
17070 let bad = Dep {
17071 nome: "caixa-teia".to_string(),
17072 versao: "^0.1".to_string(),
17073 fonte: Some(DepSource::Git {
17074 repo: String::new(),
17075 tag: Some("v0.1.0".to_string()),
17076 rev: None,
17077 branch: None,
17078 }),
17079 opcional: false,
17080 caracteristicas: Vec::new(),
17081 };
17082 let err = bad.validate().unwrap_err();
17083 assert!(
17084 matches!(
17085 &err,
17086 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17087 ),
17088 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17089 );
17090 }
17091
17092 #[test]
17093 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17094 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17095 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17096 // own `:nome` through the lifted accessor rather than the raw
17097 // field. Fails-before-passes-after: with the accessor lifted the
17098 // gate reads its equality check through `dep.nome() ==
17099 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17100 // the diagnostic still names the offending list tag as expected.
17101 let deps = vec![Dep::simple("orquestra", "^0.1")];
17102 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17103 assert!(matches!(
17104 err,
17105 DepError::DepIsSelf {
17106 ref nome,
17107 list,
17108 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17109 ));
17110 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17111 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17112 assert!(matches!(
17113 err,
17114 DepError::DepIsSelf {
17115 ref nome,
17116 list,
17117 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17118 ));
17119 // A non-matching `:nome` passes through the accessor gate.
17120 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17121 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17122 }
17123
17124 // ── Dep::caracteristicas accessor pins ────────────────────────────
17125 //
17126 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17127 // byte-equal projection over the default-empty / single-entry /
17128 // multi-entry fixture triad (so the accessor's accept-set is
17129 // exercised across every author-surface `:caracteristicas` shape,
17130 // matching the peer sibling family's fixture-triad discipline); by-
17131 // borrow pointer identity so the projection stays zero-copy at every
17132 // consumer site; and validate-composition through the
17133 // [`Dep::validate_caracteristicas`] gate reading its per-entry
17134 // linear walk through the lifted accessor rather than the raw
17135 // `for c in &self.caracteristicas` bracket.
17136
17137 #[test]
17138 fn dep_caracteristicas_returns_declared_features_across_shapes() {
17139 // Default-empty form — the [`Dep::simple`] constructor's
17140 // `Vec::new()` fill; the accessor projects the empty slice
17141 // verbatim (no `None` collapse).
17142 assert!(
17143 Dep::simple("caixa-teia", "^0.1")
17144 .caracteristicas()
17145 .is_empty(),
17146 );
17147 // Single-entry form — the canonical Cargo-shaped one-feature
17148 // enable ([`crate::render::is_cargo_feature_name`] accepts the
17149 // `"http"` byte-string as a valid feature name).
17150 let one = Dep {
17151 nome: "caixa-teia".to_string(),
17152 versao: "^0.1".to_string(),
17153 fonte: None,
17154 opcional: false,
17155 caracteristicas: vec!["http".to_string()],
17156 };
17157 assert_eq!(one.caracteristicas(), &["http".to_string()]);
17158 // Multi-entry form — the substrate's set-shaped multi-feature
17159 // enable, exercising the accessor over a length-two slice with
17160 // no duplicate collapse.
17161 let two = Dep {
17162 nome: "caixa-teia".to_string(),
17163 versao: "^0.1".to_string(),
17164 fonte: None,
17165 opcional: false,
17166 caracteristicas: vec!["http".to_string(), "json".to_string()],
17167 };
17168 assert_eq!(
17169 two.caracteristicas(),
17170 &["http".to_string(), "json".to_string()],
17171 );
17172 }
17173
17174 #[test]
17175 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17176 // Zero-copy pin: the accessor must borrow into the field's own
17177 // `Vec<String>` storage, not clone into a side buffer. If a
17178 // future rewrite regresses to `self.caracteristicas.clone()` or
17179 // an owned-buffer shape, the two pointers diverge and this pin
17180 // fails at build time. Peer of the sibling per-`Dep`
17181 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17182 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17183 // borrow discipline extended onto the outer-`Dep` `&[String]`
17184 // slice-projection axis.
17185 let d = Dep {
17186 nome: "caixa-teia".to_string(),
17187 versao: "^0.1".to_string(),
17188 fonte: None,
17189 opcional: false,
17190 caracteristicas: vec!["http".to_string(), "json".to_string()],
17191 };
17192 assert!(std::ptr::eq(
17193 d.caracteristicas().as_ptr(),
17194 d.caracteristicas.as_ptr(),
17195 ));
17196 }
17197
17198 #[test]
17199 fn dep_validate_reads_caracteristicas_through_accessor() {
17200 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17201 // linear walk consumes the feature-toggle list through the
17202 // lifted accessor — a well-formed `:caracteristicas` set passes
17203 // (positive control), an empty-string entry surfaces the
17204 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17205 // `Dep::nome`, and a within-list duplicate surfaces the
17206 // [`DepError::CaracteristicaDuplicate`] variant so a future
17207 // regression that detoured the walk through a different byte-
17208 // string list (say a per-scope override projector) would surface
17209 // here at build time. Peer of the sibling
17210 // `dep_validate_reads_fonte_through_accessor` /
17211 // `dep_validate_reads_requirement_through_accessor` composition
17212 // pins on the `:fonte` / `:versao` axes.
17213 // Positive control: two distinct well-formed feature names pass.
17214 Dep {
17215 nome: "caixa-teia".to_string(),
17216 versao: "^0.1".to_string(),
17217 fonte: None,
17218 opcional: false,
17219 caracteristicas: vec!["http".to_string(), "json".to_string()],
17220 }
17221 .validate()
17222 .unwrap();
17223 // Negative control 1: empty-string feature-name entry — the
17224 // accessor still returns `&[""]` and the walk raises the typed
17225 // empty-first carrier.
17226 let err = Dep {
17227 nome: "caixa-teia".to_string(),
17228 versao: "^0.1".to_string(),
17229 fonte: None,
17230 opcional: false,
17231 caracteristicas: vec![String::new()],
17232 }
17233 .validate()
17234 .unwrap_err();
17235 assert!(
17236 matches!(
17237 &err,
17238 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17239 ),
17240 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17241 );
17242 // Negative control 2: within-list duplicate — the accessor's
17243 // slice view carries both entries, and the walk's dedup arm
17244 // raises the typed duplicate carrier quoting the offending
17245 // feature name verbatim.
17246 let err = Dep {
17247 nome: "caixa-teia".to_string(),
17248 versao: "^0.1".to_string(),
17249 fonte: None,
17250 opcional: false,
17251 caracteristicas: vec!["http".to_string(), "http".to_string()],
17252 }
17253 .validate()
17254 .unwrap_err();
17255 assert!(
17256 matches!(
17257 &err,
17258 DepError::CaracteristicaDuplicate {
17259 nome,
17260 caracteristica,
17261 } if nome == "caixa-teia" && caracteristica == "http",
17262 ),
17263 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17264 );
17265 }
17266
17267 // ── Dep::opcional accessor pins ───────────────────────────────────
17268 //
17269 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17270 // equal projection over the default-`false` / explicit-`true`
17271 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17272 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17273 // exercising the accessor's accept-set over every author-surface
17274 // `:fonte` shape × every author-surface `:opcional` shape; and by-
17275 // `Copy` idempotency so the projection stays value-return (no
17276 // silent detour to a fresh `&bool` borrow that would introduce a
17277 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17278 // shape elides). No composition pin — `:opcional` does not
17279 // participate in [`Dep::validate`] (an opcional dep with any bool
17280 // value is validate-accepted; the missing-source arm is a resolver-
17281 // side runtime dispatch, not a build-time refusal), so the axis
17282 // reduces to the value-shape + `Copy` pin pair the peer
17283 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17284 // outer-`Option<Copy>` accessor pins already carry.
17285
17286 #[test]
17287 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17288 // Default-`false` form via the [`Dep::simple`] constructor —
17289 // the accessor projects the `false` bit the default-fill sets.
17290 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17291 // Default-`false` form via the [`Dep::git`] constructor — same
17292 // default fill; the accessor projects `false` regardless of the
17293 // `:fonte` arm.
17294 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17295 // Explicit-`true` form × plain-shorthand `:fonte` — the
17296 // canonical author-surface "this dep may be missing" shape.
17297 let plain_true = Dep {
17298 nome: "caixa-teia".to_string(),
17299 versao: "^0.1".to_string(),
17300 fonte: None,
17301 opcional: true,
17302 caracteristicas: Vec::new(),
17303 };
17304 assert!(plain_true.opcional());
17305 // Explicit-`true` form × explicit git-source — the accessor
17306 // projects the bit verbatim regardless of the `:fonte` arm.
17307 let git_true = Dep {
17308 nome: "caixa-teia".to_string(),
17309 versao: "^0.1".to_string(),
17310 fonte: Some(DepSource::Git {
17311 repo: "github:pleme-io/caixa-teia".to_string(),
17312 tag: Some("v0.1.0".to_string()),
17313 rev: None,
17314 branch: None,
17315 }),
17316 opcional: true,
17317 caracteristicas: Vec::new(),
17318 };
17319 assert!(git_true.opcional());
17320 // Explicit-`true` form × explicit path-source — the dev-only
17321 // local-filesystem arm the [`Dep`] docstring's third fixture
17322 // carries.
17323 let path_true = Dep {
17324 nome: "caixa-teia".to_string(),
17325 versao: "0.1.0".to_string(),
17326 fonte: Some(DepSource::Path {
17327 caminho: "../caixa-teia".to_string(),
17328 }),
17329 opcional: true,
17330 caracteristicas: Vec::new(),
17331 };
17332 assert!(path_true.opcional());
17333 }
17334
17335 #[test]
17336 fn dep_opcional_projects_bool_by_copy() {
17337 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17338 // (`bool: Copy`) — the accessor does not borrow `&self` past
17339 // the call (no lifetime on the return type), and calling the
17340 // accessor twice on the same [`Dep`] must yield discriminant-
17341 // equal values (idempotent, no side effects on `&self`). Peer
17342 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17343 // `max_restarts_projects_option_by_copy` (eba5211) /
17344 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17345 // outer-`Caixa` altitude — extended here to the outer-`Dep`
17346 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17347 // replaces the pointer-equality claim the sibling per-`Dep`
17348 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17349 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17350 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17351 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17352 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17353 // the same discriminant, so the axis reduces to discriminant
17354 // equality).
17355 //
17356 // Pins against a future silent detour that returned a fresh
17357 // `&bool` reference (which would type-check but silently
17358 // introduce a borrow of `&self` past the call, collapsing the
17359 // load-bearing "no lifetime on the return type" `Copy`
17360 // projection the plain-`Copy`-scalar axis's `bool` shape
17361 // carries) or a stale-read side effect that flipped the outer
17362 // discriminant on successive calls.
17363 for opcional in [false, true] {
17364 let d = Dep {
17365 nome: "caixa-teia".to_string(),
17366 versao: "^0.1".to_string(),
17367 fonte: None,
17368 opcional,
17369 caracteristicas: Vec::new(),
17370 };
17371 let first = d.opcional();
17372 let second = d.opcional();
17373 assert_eq!(
17374 first, second,
17375 "Dep::opcional must be idempotent — two successive calls \
17376 on the same &self must return the same bool",
17377 );
17378 assert_eq!(
17379 first, opcional,
17380 "Dep::opcional must return :opcional verbatim by Copy — \
17381 got {first}, expected {opcional}",
17382 );
17383 assert_eq!(
17384 d.opcional(),
17385 d.opcional,
17386 "Dep::opcional accessor and self.opcional field access \
17387 must byte-equal — a bit-flip drift would silently split \
17388 the paired resolver-side drop-vs-error dispatch from \
17389 the storage-side default-fill the [`Dep::simple`] / \
17390 [`Dep::git`] constructor pair carries",
17391 );
17392 }
17393 }
17394
17395 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17396
17397 #[test]
17398 fn sole_pin_returns_none_for_path_source() {
17399 // A path source carries no git-ref, so `sole_pin()` returns
17400 // `None` structurally — the sibling arm every git-fetching
17401 // consumer partitions off before reaching for a git-ref. Pins
17402 // the Path-arm branch of the accessor against a future silent
17403 // detour that treats a `Self::Path` as an unpinned-git source
17404 // and returns the wrong "no pin" signal (e.g. the empty string,
17405 // or a hard-coded `Some("HEAD")` matching the caixa-crd
17406 // path-arm `git_ref` fill).
17407 let s = DepSource::Path {
17408 caminho: "../local-caixa".to_string(),
17409 };
17410 assert_eq!(s.sole_pin(), None);
17411 }
17412
17413 #[test]
17414 fn sole_pin_returns_none_for_unpinned_git_source() {
17415 // The [`DepSource::default_github`] shorthand shape carries no
17416 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17417 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17418 // materializes when the author omits `:fonte` entirely, then
17419 // hands to `fetch_git` which raises `ResolveError::MissingPin`
17420 // on the `None` arm — the accessor's return matches the arm
17421 // the resolver's diagnostic keys off.
17422 let s = DepSource::default_github("pleme-io", "caixa-teia");
17423 assert_eq!(s.sole_pin(), None);
17424 }
17425
17426 #[test]
17427 fn sole_pin_returns_rev_when_only_rev_is_set() {
17428 let s = DepSource::Git {
17429 repo: "github:o/x".into(),
17430 tag: None,
17431 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17432 branch: None,
17433 };
17434 assert_eq!(
17435 s.sole_pin(),
17436 Some("deadbeefcafebabe1234567890abcdef12345678")
17437 );
17438 }
17439
17440 #[test]
17441 fn sole_pin_returns_tag_when_only_tag_is_set() {
17442 let s = DepSource::Git {
17443 repo: "github:o/x".into(),
17444 tag: Some("v0.1.0".into()),
17445 rev: None,
17446 branch: None,
17447 };
17448 assert_eq!(s.sole_pin(), Some("v0.1.0"));
17449 }
17450
17451 #[test]
17452 fn sole_pin_returns_branch_when_only_branch_is_set() {
17453 let s = DepSource::Git {
17454 repo: "github:o/x".into(),
17455 tag: None,
17456 rev: None,
17457 branch: Some("main".into()),
17458 };
17459 assert_eq!(s.sole_pin(), Some("main"));
17460 }
17461
17462 #[test]
17463 fn sole_pin_precedence_rev_beats_tag_and_branch() {
17464 // Precedence: rev > tag > branch. Validate() rejects
17465 // multiple-pin shapes, but the accessor's precedence is defined
17466 // for pre-validate consumers (the resolver's `MissingPin`
17467 // diagnostic path, the caixa-crd round-trip's default `"main"`
17468 // fallback) and as defense-in-depth if the gate is ever
17469 // bypassed. Pins the same precedence caixa-resolver's
17470 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17471 // inline.
17472 let s = DepSource::Git {
17473 repo: "github:o/x".into(),
17474 tag: Some("v1".into()),
17475 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17476 branch: Some("main".into()),
17477 };
17478 assert_eq!(
17479 s.sole_pin(),
17480 Some("deadbeefcafebabe1234567890abcdef12345678")
17481 );
17482 }
17483
17484 #[test]
17485 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17486 let s = DepSource::Git {
17487 repo: "github:o/x".into(),
17488 tag: Some("v1".into()),
17489 rev: None,
17490 branch: Some("main".into()),
17491 };
17492 assert_eq!(s.sole_pin(), Some("v1"));
17493 }
17494
17495 #[test]
17496 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17497 // Fail-before-pass-after byte-parity pin: the substrate accessor
17498 // must return byte-identical to the inline
17499 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17500 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17501 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17502 // time if the accessor's precedence silently drifts from the
17503 // consumer-side cascade — the exact drift this lift converges
17504 // to one substrate primitive to close structurally.
17505 //
17506 // Iterates through the 2^3 = 8 combinations of (tag, rev,
17507 // branch) each-either-`None`-or-`Some`, so every arm of the
17508 // precedence cascade lands under the pin. `validate()` refuses
17509 // the 4 multi-pin combinations, but the accessor's return is
17510 // defined on all 8.
17511 let vals = [Some("R".to_string()), None];
17512 for tag in &vals {
17513 for rev in &vals {
17514 for branch in &vals {
17515 let s = DepSource::Git {
17516 repo: "github:o/x".into(),
17517 tag: tag.clone(),
17518 rev: rev.clone(),
17519 branch: branch.clone(),
17520 };
17521 // The exact inline cascade the two pre-lift
17522 // consumer sites hand-rolled, byte-for-byte.
17523 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17524 assert_eq!(
17525 s.sole_pin(),
17526 expected,
17527 "sole_pin() must byte-equal \
17528 rev.or(tag).or(branch) for \
17529 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17530 a drift would silently split caixa-resolver's \
17531 fetch_git checkout target from caixa-crd's \
17532 dep_into_ref git_ref fill",
17533 );
17534 }
17535 }
17536 }
17537 }
17538
17539 // Fail-before-pass-after pins on the eleven
17540 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17541 // constructors folded from the [`DepSource::validate_caminho`]
17542 // wire-up sites. Each pins the generated ctor's output to the
17543 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17544 // any wrapper-side lowercase / trim / re-order / silent-field-swap
17545 // regression on the two-field `{ nome: nome.to_string(), caminho:
17546 // caminho.to_string() }` construction surfaces here rather than at
17547 // a downstream diagnostic-shape mismatch. Peer of the sibling
17548 // `empty_child_version_ctor_matches_struct_literal_wrap` /
17549 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17550 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17551 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17552 // pins on the peer `SupervisorError` / `AplicacaoError` /
17553 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17554
17555 #[test]
17556 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17557 assert_eq!(
17558 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17559 DepError::FonteCaminhoAbsolute {
17560 nome: "caixa-teia".to_string(),
17561 caminho: "/home/me/work/caixa-teia".to_string(),
17562 },
17563 "generated fonte_caminho_absolute ctor must produce byte-equal \
17564 DepError to the open-coded struct-literal wrap on the same \
17565 (&str, &str) fixture",
17566 );
17567 }
17568
17569 #[test]
17570 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17571 assert_eq!(
17572 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17573 DepError::FonteCaminhoTildeExpansion {
17574 nome: "caixa-teia".to_string(),
17575 caminho: "~/work/caixa-teia".to_string(),
17576 },
17577 );
17578 }
17579
17580 #[test]
17581 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17582 assert_eq!(
17583 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17584 DepError::FonteCaminhoVarExpansion {
17585 nome: "caixa-teia".to_string(),
17586 caminho: "$HOME/work/caixa-teia".to_string(),
17587 },
17588 );
17589 }
17590
17591 #[test]
17592 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17593 assert_eq!(
17594 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17595 DepError::FonteCaminhoLeadingWhitespace {
17596 nome: "caixa-teia".to_string(),
17597 caminho: " ../caixa-teia".to_string(),
17598 },
17599 );
17600 }
17601
17602 #[test]
17603 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17604 assert_eq!(
17605 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17606 DepError::FonteCaminhoLeadingHyphen {
17607 nome: "caixa-teia".to_string(),
17608 caminho: "-rf".to_string(),
17609 },
17610 );
17611 }
17612
17613 #[test]
17614 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17615 assert_eq!(
17616 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17617 DepError::FonteCaminhoBackslash {
17618 nome: "caixa-teia".to_string(),
17619 caminho: "..\\caixa-teia".to_string(),
17620 },
17621 );
17622 }
17623
17624 #[test]
17625 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17626 assert_eq!(
17627 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17628 DepError::FonteCaminhoShellPipe {
17629 nome: "caixa-teia".to_string(),
17630 caminho: "../caixa-teia|evil".to_string(),
17631 },
17632 );
17633 }
17634
17635 #[test]
17636 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17637 assert_eq!(
17638 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17639 DepError::FonteCaminhoShellSemicolon {
17640 nome: "caixa-teia".to_string(),
17641 caminho: "../caixa-teia;evil".to_string(),
17642 },
17643 );
17644 }
17645
17646 #[test]
17647 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17648 assert_eq!(
17649 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17650 DepError::FonteCaminhoShellBackground {
17651 nome: "caixa-teia".to_string(),
17652 caminho: "../caixa-teia&".to_string(),
17653 },
17654 );
17655 }
17656
17657 #[test]
17658 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17659 assert_eq!(
17660 DepError::fonte_caminho_shell_command_substitution(
17661 "caixa-teia",
17662 "../caixa-teia`whoami`",
17663 ),
17664 DepError::FonteCaminhoShellCommandSubstitution {
17665 nome: "caixa-teia".to_string(),
17666 caminho: "../caixa-teia`whoami`".to_string(),
17667 },
17668 );
17669 }
17670
17671 #[test]
17672 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17673 assert_eq!(
17674 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17675 DepError::FonteCaminhoTrailingSlash {
17676 nome: "caixa-teia".to_string(),
17677 caminho: "../caixa-teia/".to_string(),
17678 },
17679 );
17680 }
17681
17682 #[test]
17683 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17684 // Cross-axis pin: sweep the two constructor input axes
17685 // (`nome: &str`, `caminho: &str`) through a non-default fixture
17686 // pair against every generated arm in the
17687 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17688 // / trim / truncate / re-order on the two-field
17689 // `{ nome, caminho }` construction — or a silent field swap
17690 // between the two axes at codegen time — surfaces here rather
17691 // than at a downstream diagnostic-shape mismatch. Peer of the
17692 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17693 // to_string` cross-axis routing pin on the peer
17694 // `SupervisorError` envelope, extended here onto the
17695 // `DepError` `{ nome: String, caminho: String }` envelope so
17696 // every substrate-primitive ctor family in caixa-core
17697 // guarantees each `&str`-field construction routes the
17698 // caller's `&str` verbatim through `.to_string()`.
17699 let nome = "sibling-teia";
17700 let caminho = "../workspace/sibling";
17701 let cases: [(DepError, DepError); 11] = [
17702 (
17703 DepError::fonte_caminho_absolute(nome, caminho),
17704 DepError::FonteCaminhoAbsolute {
17705 nome: nome.to_string(),
17706 caminho: caminho.to_string(),
17707 },
17708 ),
17709 (
17710 DepError::fonte_caminho_tilde_expansion(nome, caminho),
17711 DepError::FonteCaminhoTildeExpansion {
17712 nome: nome.to_string(),
17713 caminho: caminho.to_string(),
17714 },
17715 ),
17716 (
17717 DepError::fonte_caminho_var_expansion(nome, caminho),
17718 DepError::FonteCaminhoVarExpansion {
17719 nome: nome.to_string(),
17720 caminho: caminho.to_string(),
17721 },
17722 ),
17723 (
17724 DepError::fonte_caminho_leading_whitespace(nome, caminho),
17725 DepError::FonteCaminhoLeadingWhitespace {
17726 nome: nome.to_string(),
17727 caminho: caminho.to_string(),
17728 },
17729 ),
17730 (
17731 DepError::fonte_caminho_leading_hyphen(nome, caminho),
17732 DepError::FonteCaminhoLeadingHyphen {
17733 nome: nome.to_string(),
17734 caminho: caminho.to_string(),
17735 },
17736 ),
17737 (
17738 DepError::fonte_caminho_backslash(nome, caminho),
17739 DepError::FonteCaminhoBackslash {
17740 nome: nome.to_string(),
17741 caminho: caminho.to_string(),
17742 },
17743 ),
17744 (
17745 DepError::fonte_caminho_shell_pipe(nome, caminho),
17746 DepError::FonteCaminhoShellPipe {
17747 nome: nome.to_string(),
17748 caminho: caminho.to_string(),
17749 },
17750 ),
17751 (
17752 DepError::fonte_caminho_shell_semicolon(nome, caminho),
17753 DepError::FonteCaminhoShellSemicolon {
17754 nome: nome.to_string(),
17755 caminho: caminho.to_string(),
17756 },
17757 ),
17758 (
17759 DepError::fonte_caminho_shell_background(nome, caminho),
17760 DepError::FonteCaminhoShellBackground {
17761 nome: nome.to_string(),
17762 caminho: caminho.to_string(),
17763 },
17764 ),
17765 (
17766 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17767 DepError::FonteCaminhoShellCommandSubstitution {
17768 nome: nome.to_string(),
17769 caminho: caminho.to_string(),
17770 },
17771 ),
17772 (
17773 DepError::fonte_caminho_trailing_slash(nome, caminho),
17774 DepError::FonteCaminhoTrailingSlash {
17775 nome: nome.to_string(),
17776 caminho: caminho.to_string(),
17777 },
17778 ),
17779 ];
17780 for (via_ctor, via_struct_literal) in cases {
17781 assert_eq!(
17782 via_ctor, via_struct_literal,
17783 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17784 through `.to_string()` in declared field order — a field-swap or \
17785 silent-conversion regression surfaces here rather than at a \
17786 downstream diagnostic-shape mismatch",
17787 );
17788 }
17789 }
17790
17791 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17792 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17793 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17794 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17795 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17796
17797 #[test]
17798 fn versao_empty_ctor_matches_struct_literal_wrap() {
17799 assert_eq!(
17800 DepError::versao_empty("caixa-teia"),
17801 DepError::VersaoEmpty {
17802 nome: "caixa-teia".to_string(),
17803 },
17804 );
17805 }
17806
17807 #[test]
17808 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17809 assert_eq!(
17810 DepError::fonte_repo_empty("caixa-teia"),
17811 DepError::FonteRepoEmpty {
17812 nome: "caixa-teia".to_string(),
17813 },
17814 );
17815 }
17816
17817 #[test]
17818 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17819 assert_eq!(
17820 DepError::fonte_pin_missing("caixa-teia"),
17821 DepError::FontePinMissing {
17822 nome: "caixa-teia".to_string(),
17823 },
17824 );
17825 }
17826
17827 #[test]
17828 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17829 assert_eq!(
17830 DepError::fonte_caminho_empty("caixa-teia"),
17831 DepError::FonteCaminhoEmpty {
17832 nome: "caixa-teia".to_string(),
17833 },
17834 );
17835 }
17836
17837 #[test]
17838 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17839 assert_eq!(
17840 DepError::caracteristica_empty("caixa-teia"),
17841 DepError::CaracteristicaEmpty {
17842 nome: "caixa-teia".to_string(),
17843 },
17844 );
17845 }
17846
17847 #[test]
17848 fn dep_nome_only_ctors_route_nome_through_to_string() {
17849 // Cross-axis routing pin: sweep the single constructor input
17850 // axis (`nome: &str`) through a non-default fixture against
17851 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17852 // any wrapper-side lowercase / trim / truncate at codegen time
17853 // — or a silent field re-name away from the canonical `nome`
17854 // axis on any one variant — surfaces here rather than at a
17855 // downstream diagnostic-shape mismatch. Peer of the sibling
17856 // `fonte_caminho_ctors_route_nome_and_caminho_through_
17857 // to_string` cross-axis routing pin on the same envelope's
17858 // two-slot family (f85f145) and of the peer
17859 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17860 // pin on the `SupervisorError` single-slot family (db09650).
17861 let nome = "sibling-teia";
17862 let cases: [(DepError, DepError); 5] = [
17863 (
17864 DepError::versao_empty(nome),
17865 DepError::VersaoEmpty {
17866 nome: nome.to_string(),
17867 },
17868 ),
17869 (
17870 DepError::fonte_repo_empty(nome),
17871 DepError::FonteRepoEmpty {
17872 nome: nome.to_string(),
17873 },
17874 ),
17875 (
17876 DepError::fonte_pin_missing(nome),
17877 DepError::FontePinMissing {
17878 nome: nome.to_string(),
17879 },
17880 ),
17881 (
17882 DepError::fonte_caminho_empty(nome),
17883 DepError::FonteCaminhoEmpty {
17884 nome: nome.to_string(),
17885 },
17886 ),
17887 (
17888 DepError::caracteristica_empty(nome),
17889 DepError::CaracteristicaEmpty {
17890 nome: nome.to_string(),
17891 },
17892 ),
17893 ];
17894 for (via_ctor, via_struct_literal) in cases {
17895 assert_eq!(
17896 via_ctor, via_struct_literal,
17897 "dep_nome_only_ctors!-generated ctor must route `nome` \
17898 through `.to_string()` onto the canonical `nome` field \
17899 — a field-rename or silent-conversion regression surfaces \
17900 here rather than at a downstream diagnostic-shape mismatch",
17901 );
17902 }
17903 }
17904
17905 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17906 // &'static str }` two-slot envelope on `DepError`, strict
17907 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17908 // same envelope's `{ nome: String }` one-slot shape and of the
17909 // peer `supervisor_caixa_only_ctors!` (db09650) on the
17910 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17911
17912 #[test]
17913 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17914 assert_eq!(
17915 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17916 DepError::DuplicateNome {
17917 nome: "caixa-teia".to_string(),
17918 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17919 },
17920 "generated duplicate_nome ctor must produce byte-equal \
17921 `DepError::DuplicateNome` to the pre-lift struct-literal \
17922 wrap on the same scalar fixtures",
17923 );
17924 }
17925
17926 #[test]
17927 fn dep_is_self_ctor_matches_struct_literal_wrap() {
17928 assert_eq!(
17929 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17930 DepError::DepIsSelf {
17931 nome: "orquestra".to_string(),
17932 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17933 },
17934 "generated dep_is_self ctor must produce byte-equal \
17935 `DepError::DepIsSelf` to the pre-lift struct-literal \
17936 wrap on the same scalar fixtures",
17937 );
17938 }
17939
17940 #[test]
17941 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17942 // Cross-axis routing pin: sweep the two constructor input axes
17943 // (`nome: &str`, `list: &'static str`) through non-default
17944 // fixtures against every generated arm in the
17945 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17946 // lowercase / trim / truncate at codegen time — or a silent
17947 // field re-name away from the canonical `nome` / `list` axes
17948 // on any one variant, or a `list` axis silently rerouted
17949 // through `.to_string()` instead of passed as `&'static str`
17950 // verbatim — surfaces here rather than at a downstream
17951 // diagnostic-shape mismatch. Peer of the sibling
17952 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17953 // (792aa92) on the same envelope's one-slot family, and of the
17954 // peer
17955 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17956 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17957 // two-slot `{ caixa: String, reason: String }` shape.
17958 let nome = "sibling-teia";
17959 let cases: [(DepError, DepError); 4] = [
17960 (
17961 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17962 DepError::DuplicateNome {
17963 nome: nome.to_string(),
17964 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17965 },
17966 ),
17967 (
17968 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17969 DepError::DuplicateNome {
17970 nome: nome.to_string(),
17971 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17972 },
17973 ),
17974 (
17975 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17976 DepError::DepIsSelf {
17977 nome: nome.to_string(),
17978 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17979 },
17980 ),
17981 (
17982 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17983 DepError::DepIsSelf {
17984 nome: nome.to_string(),
17985 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17986 },
17987 ),
17988 ];
17989 for (via_ctor, via_struct_literal) in cases {
17990 assert_eq!(
17991 via_ctor, via_struct_literal,
17992 "dep_nome_list_ctors!-generated ctor must route `nome` \
17993 through `.to_string()` onto the canonical `nome` field \
17994 and pass `list` verbatim onto the canonical `&'static str` \
17995 `list` field — a field-rename, silent-conversion, or \
17996 axis-swap regression surfaces here rather than at a \
17997 downstream diagnostic-shape mismatch",
17998 );
17999 }
18000 }
18001
18002 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18003 // value: String, reason: String }` four-slot envelope on
18004 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18005 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18006 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18007 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
18008 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
18009 // envelope. Single-variant lift closing the last open-coded ctor
18010 // site on the `:fonte (:tipo git …)` value-shape trajectory.
18011
18012 #[test]
18013 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18014 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18015 // ctor: sweep both wire-up-shape arms (the refname-pin arm
18016 // routing `":tag"` / `":branch"` value through
18017 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18018 // routing `":rev"` through [`crate::render::is_git_oid`]) and
18019 // assert byte-equal `PartialEq` against the pre-lift
18020 // struct-literal, so any wrapper-side field-rename /
18021 // silent-conversion regression surfaces here rather than at a
18022 // downstream diagnostic-shape mismatch. Peer of the sibling
18023 // per-envelope byte-equal ctor pins
18024 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18025 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18026 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18027 assert_eq!(
18028 DepError::fonte_pin_shape(
18029 "caixa-teia",
18030 ":tag",
18031 "v0.1.0 ",
18032 "trailing whitespace".to_string(),
18033 ),
18034 DepError::FontePinShape {
18035 nome: "caixa-teia".to_string(),
18036 pin: ":tag".to_string(),
18037 value: "v0.1.0 ".to_string(),
18038 reason: "trailing whitespace".to_string(),
18039 },
18040 "fonte_pin_shape ctor must produce byte-equal \
18041 `DepError::FontePinShape` to the pre-lift struct-literal \
18042 wrap on a refname-pin (`:tag` / `:branch`) fixture",
18043 );
18044 assert_eq!(
18045 DepError::fonte_pin_shape(
18046 "caixa-teia",
18047 ":rev",
18048 "DEADBEEF",
18049 "abbreviated OID rejected".to_string(),
18050 ),
18051 DepError::FontePinShape {
18052 nome: "caixa-teia".to_string(),
18053 pin: ":rev".to_string(),
18054 value: "DEADBEEF".to_string(),
18055 reason: "abbreviated OID rejected".to_string(),
18056 },
18057 "fonte_pin_shape ctor must produce byte-equal \
18058 `DepError::FontePinShape` to the pre-lift struct-literal \
18059 wrap on a hex-OID-pin (`:rev`) fixture",
18060 );
18061 }
18062
18063 #[test]
18064 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18065 // Cross-axis routing pin: sweep every one of the four
18066 // constructor input axes (`nome: &str`, `pin: &str`,
18067 // `value: &str`, `reason: String`) through non-default
18068 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18069 // any wrapper-side lowercase / trim / truncate at codegen time
18070 // — or a silent field re-name / axis-swap on any one of the
18071 // four fields, or a `reason` axis silently routed through
18072 // `.to_string()` instead of forwarded owned — surfaces here
18073 // rather than at a downstream diagnostic-shape mismatch. Peer
18074 // of the sibling
18075 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18076 // (792aa92) and
18077 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18078 // pin (6f5e0cd) on the same envelope's one- and two-slot
18079 // families. Distinct-per-axis fixtures rule out any two-axis
18080 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18081 // etc.) that would still pass a same-fixture-per-axis pin.
18082 let nome = "sibling-teia";
18083 let pin = ":branch";
18084 let value = "feature/bar";
18085 let reason = "embedded space".to_string();
18086 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18087 let via_struct_literal = DepError::FontePinShape {
18088 nome: nome.to_string(),
18089 pin: pin.to_string(),
18090 value: value.to_string(),
18091 reason: reason.clone(),
18092 };
18093 assert_eq!(
18094 via_ctor, via_struct_literal,
18095 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18096 through `.to_string()` onto their canonical fields and \
18097 forward `reason` owned onto the canonical `reason` field \
18098 — a field-rename, silent-conversion, or axis-swap \
18099 regression surfaces here rather than at a downstream \
18100 diagnostic-shape mismatch",
18101 );
18102 let DepError::FontePinShape {
18103 nome: n,
18104 pin: p,
18105 value: v,
18106 reason: r,
18107 } = via_ctor
18108 else {
18109 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18110 };
18111 assert_eq!(n, nome);
18112 assert_eq!(p, pin);
18113 assert_eq!(v, value);
18114 assert_eq!(r, reason);
18115 }
18116
18117 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18118 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18119 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18120 // the same envelope's `{ nome: String, caminho: String }` two-slot
18121 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18122 // same envelope's `{ nome: String }` one-slot shape.
18123
18124 #[test]
18125 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18126 assert_eq!(
18127 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18128 DepError::FonteCaminhoControlChar {
18129 nome: "caixa-teia".to_string(),
18130 caminho: "../caixa-teia\x00foo".to_string(),
18131 byte: 0x00,
18132 },
18133 );
18134 }
18135
18136 #[test]
18137 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18138 assert_eq!(
18139 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18140 DepError::FonteCaminhoShellRedirection {
18141 nome: "caixa-teia".to_string(),
18142 caminho: "../caixa-teia>log".to_string(),
18143 byte: b'>',
18144 },
18145 );
18146 }
18147
18148 #[test]
18149 #[allow(
18150 clippy::too_many_lines,
18151 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18152 byte-classification arm on the {nome,caminho,byte} envelope; \
18153 the linear per-variant repetition is exactly what the sweep \
18154 is pinning — a helper macro would hide the shape the fold is \
18155 keying on"
18156 )]
18157 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18158 // Cross-axis routing pin: sweep the three constructor input axes
18159 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18160 // non-default fixture triple against every generated arm in the
18161 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18162 // lowercase / trim / truncate on the two `&str` axes — a silent
18163 // field swap between `nome` and `caminho`, or a silent
18164 // re-classification of the offending byte — surfaces here rather
18165 // than at a downstream diagnostic-shape mismatch. Peer of the
18166 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18167 // to_string` cross-axis routing pin on the same envelope's
18168 // two-slot family (f85f145) and of the sibling
18169 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18170 // same envelope's one-slot family (792aa92), extended here onto
18171 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18172 // envelope so every substrate-primitive ctor family in
18173 // caixa-core's `DepError` envelope guarantees each field routes
18174 // the caller's value verbatim through `.to_string()` (or byte-
18175 // identity for `byte: u8`) in declared field order.
18176 let nome = "sibling-teia";
18177 let caminho = "../workspace/sibling";
18178 let byte = 0x2A_u8;
18179 let cases: [(DepError, DepError); 12] = [
18180 (
18181 DepError::fonte_caminho_control_char(nome, caminho, byte),
18182 DepError::FonteCaminhoControlChar {
18183 nome: nome.to_string(),
18184 caminho: caminho.to_string(),
18185 byte,
18186 },
18187 ),
18188 (
18189 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18190 DepError::FonteCaminhoShellRedirection {
18191 nome: nome.to_string(),
18192 caminho: caminho.to_string(),
18193 byte,
18194 },
18195 ),
18196 (
18197 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18198 DepError::FonteCaminhoShellGlob {
18199 nome: nome.to_string(),
18200 caminho: caminho.to_string(),
18201 byte,
18202 },
18203 ),
18204 (
18205 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18206 DepError::FonteCaminhoShellSubshellGrouping {
18207 nome: nome.to_string(),
18208 caminho: caminho.to_string(),
18209 byte,
18210 },
18211 ),
18212 (
18213 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18214 DepError::FonteCaminhoShellBraceExpansion {
18215 nome: nome.to_string(),
18216 caminho: caminho.to_string(),
18217 byte,
18218 },
18219 ),
18220 (
18221 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18222 DepError::FonteCaminhoShellBracketExpansion {
18223 nome: nome.to_string(),
18224 caminho: caminho.to_string(),
18225 byte,
18226 },
18227 ),
18228 (
18229 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18230 DepError::FonteCaminhoShellQuoteGrouping {
18231 nome: nome.to_string(),
18232 caminho: caminho.to_string(),
18233 byte,
18234 },
18235 ),
18236 (
18237 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18238 DepError::FonteCaminhoShellComment {
18239 nome: nome.to_string(),
18240 caminho: caminho.to_string(),
18241 byte,
18242 },
18243 ),
18244 (
18245 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18246 DepError::FonteCaminhoUrlPercentEncoding {
18247 nome: nome.to_string(),
18248 caminho: caminho.to_string(),
18249 byte,
18250 },
18251 ),
18252 (
18253 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18254 DepError::FonteCaminhoShellVariableExpansion {
18255 nome: nome.to_string(),
18256 caminho: caminho.to_string(),
18257 byte,
18258 },
18259 ),
18260 (
18261 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18262 DepError::FonteCaminhoShellHistoryExpansion {
18263 nome: nome.to_string(),
18264 caminho: caminho.to_string(),
18265 byte,
18266 },
18267 ),
18268 (
18269 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18270 DepError::FonteCaminhoShellHistorySubstitution {
18271 nome: nome.to_string(),
18272 caminho: caminho.to_string(),
18273 byte,
18274 },
18275 ),
18276 ];
18277 for (via_ctor, via_struct_literal) in cases {
18278 assert_eq!(
18279 via_ctor, via_struct_literal,
18280 "fonte_caminho_byte_ctors!-generated ctor must route \
18281 (nome, caminho, byte) through `.to_string()` / byte-\
18282 identity in declared field order — a field-swap or \
18283 silent-conversion regression surfaces here rather than \
18284 at a downstream diagnostic-shape mismatch",
18285 );
18286 }
18287 }
18288
18289 #[test]
18290 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18291 // Fail-before-pass-after byte-parity pin on the lifted
18292 // `impl AsRef<str> for DepList` — asserts the standard-
18293 // library trait impl and the substrate-primitive
18294 // [`super::DepList::as_str`] `pub const fn` accessor resolve
18295 // to the same `&str` per instance across the two-arm closed
18296 // set, so any future silent detour that routes the impl
18297 // through a divergent projection (a per-arm inline
18298 // `match self { DepList::Prod => ":deps", … }` re-inlining
18299 // that opens a compile-time link to the un-lifted arm-literal,
18300 // a swap onto a second projection axis) trips at caixa-core
18301 // test time under `PartialEq` rather than at a downstream
18302 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18303 // every one of the two arms [`super::DepList::ALL`] carries
18304 // so no arm's projection is covered only by the sibling
18305 // `Display` path. Peer of the sibling
18306 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18307 // (1723611) on the top-level dialect-classification closed-
18308 // set typed enum, and the peer
18309 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18310 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18311 // typed enum — the pins together close the substrate
18312 // primitive's `AsRef<str>` projection axis onto the seventh
18313 // (and last unlifted) closed-set typed enum on the caixa
18314 // surface.
18315 for &list in super::DepList::ALL {
18316 assert_eq!(
18317 <super::DepList as AsRef<str>>::as_ref(&list),
18318 list.as_str(),
18319 "AsRef<str> impl on DepList::{list:?} must byte-equal \
18320 DepList::as_str on the same instance — divergence \
18321 signals a silent detour off the substrate-primitive \
18322 accessor"
18323 );
18324 }
18325 }
18326
18327 #[test]
18328 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18329 // Fail-before-pass-after byte-parity pin on the three-path
18330 // convergence discipline the [`super::DepList`] two-list
18331 // dep-graph closed-set typed enum now carries on the `&str`-
18332 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18333 // newly lifted impl), `format!("{v}")` (the pre-existing
18334 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18335 // primitive `pub const fn` accessor both trait impls delegate
18336 // through) must resolve to the same byte-string on every
18337 // instance across the two-arm closed set. Refuses any future
18338 // divergence between the two trait impls (a stray
18339 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18340 // rather than delegating through the shared accessor; a
18341 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18342 // literal cascade) that would silently split the two
18343 // projection paths of the same closed-set typed enum. Mirrors
18344 // the sibling three-path-convergence discipline the peer
18345 // [`crate::CaixaDialeto`] typed enum carries
18346 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18347 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18348 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18349 // d8136db), the peer [`crate::CaixaKind`] triple
18350 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18351 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18352 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18353 // 16d5c7e).
18354 for &list in super::DepList::ALL {
18355 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18356 let via_display: String = format!("{list}");
18357 let via_accessor: &str = list.as_str();
18358 assert_eq!(via_as_ref, via_accessor);
18359 assert_eq!(via_display, via_accessor);
18360 assert_eq!(via_as_ref, via_display.as_str());
18361 }
18362 }
18363
18364 #[test]
18365 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18366 // Fail-before-pass-after byte-parity pin on the newly lifted
18367 // `impl TryFrom<&str> for DepList` — asserts the standard-
18368 // library trait impl and the substrate-primitive
18369 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18370 // to the same two-arm accept-set across every arm the
18371 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18372 // the sibling
18373 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18374 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18375 // and the 12 other substrate-wide trait-idiomatic reverse-
18376 // projection routes-through pins — closes the campaign's
18377 // completeness gap on the two-list dep-graph closed-set enum.
18378 for &list in super::DepList::ALL {
18379 let wire = list.as_str();
18380 assert_eq!(
18381 <super::DepList as TryFrom<&str>>::try_from(wire),
18382 Ok(list),
18383 "TryFrom<&str> impl on DepList must round-trip \
18384 DepList::{list:?}.as_str() = {wire:?} back to \
18385 Ok(DepList::{list:?}) — divergence from \
18386 DepList::from_wire signals a silent detour off the \
18387 substrate-primitive accessor"
18388 );
18389 assert_eq!(
18390 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18391 super::DepList::from_wire(wire),
18392 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18393 DepList::from_wire on the same input"
18394 );
18395 }
18396 }
18397
18398 #[test]
18399 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18400 // Rejection witness on the `impl TryFrom<&str> for DepList` —
18401 // sweeps candidate byte-strings outside the two-arm accept-set
18402 // the sibling [`super::DepList::as_str`] emits (`:deps` /
18403 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18404 // future accidental widening of the trait impl's accept-set (a
18405 // stray case-fold path, a silent inclusion of a rebrand alias
18406 // like `":packages"`, an English rebrand `":dev-deps"` in
18407 // reverse arm-order that would silently swap the two arms) trips
18408 // at caixa-core test time. Peer of the sibling
18409 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18410 // (5b828ed) rejection witness.
18411 let rejected: &[&str] = &[
18412 "",
18413 " ",
18414 "\t",
18415 "\n",
18416 ":deps ",
18417 " :deps",
18418 ":DEPS",
18419 ":Deps",
18420 ":Deps-Dev",
18421 ":deps_dev",
18422 ":deps-development",
18423 ":dev-deps",
18424 ":packages",
18425 ":packages-dev",
18426 "deps",
18427 "deps-dev",
18428 "Prod",
18429 "Dev",
18430 "prod",
18431 "dev",
18432 "\":deps\"",
18433 "\":deps-dev\"",
18434 ":deps\n",
18435 ":deps-dev\n",
18436 ];
18437 for &input in rejected {
18438 assert_eq!(
18439 <super::DepList as TryFrom<&str>>::try_from(input),
18440 Err(()),
18441 "TryFrom<&str> impl on DepList must reject unknown \
18442 byte-string {input:?} — divergence from \
18443 DepList::from_wire on the same input signals a silent \
18444 accept-set widening past the two lifted \
18445 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18446 );
18447 assert_eq!(
18448 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18449 super::DepList::from_wire(input),
18450 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18451 DepList::from_wire on the same input — divergence signals \
18452 the two reverse-projection paths have drifted onto \
18453 different accept-sets"
18454 );
18455 }
18456 }
18457
18458 #[test]
18459 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18460 // Fail-before-pass-after byte-parity pin on the newly lifted
18461 // `impl From<DepList> for &'static str` — asserts the standard-
18462 // library trait impl and the substrate-primitive
18463 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18464 // the same two-arm emit-set across every arm the exhaustive
18465 // [`super::DepList::ALL`] slice enumerates. Materializes the
18466 // `<&'static str as From<DepList>>::from` output in a
18467 // `const`-shape binding to make the `'static` lifetime promise
18468 // a build-time invariant — a future accidental downgrade of
18469 // either arm to a non-`&'static str` (a `String::leak()`-
18470 // produced return, a `Box::leak`-cast) trips at caixa-core
18471 // build time rather than at a downstream `'static`-bound
18472 // consumer. Peer of the sibling
18473 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18474 // (523157d) and the 13 other substrate-wide forward-projection
18475 // routes-through pins.
18476 const PROD: &str = super::DepList::Prod.as_str();
18477 const DEV: &str = super::DepList::Dev.as_str();
18478 for &list in super::DepList::ALL {
18479 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18480 let via_method: &'static str = list.as_str();
18481 assert_eq!(
18482 via_trait, via_method,
18483 "From<DepList> for &'static str impl must round-trip \
18484 DepList::{list:?} to the same lifted \
18485 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18486 DepList::as_str returns — divergence signals a silent \
18487 detour off the substrate-primitive accessor"
18488 );
18489 let via_into: &'static str = list.into();
18490 assert_eq!(
18491 via_into, via_method,
18492 "Into<&'static str>::into on DepList::{list:?} must \
18493 byte-equal DepList::as_str on the same input — the \
18494 blanket-derived Into shape must resolve to the same \
18495 as_str dispatch as the explicit From impl"
18496 );
18497 }
18498 assert_eq!(
18499 [PROD, DEV],
18500 [
18501 crate::render::DEP_AUTHOR_KEY_DEPS,
18502 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18503 ],
18504 "const-context DepList::as_str must resolve to the two lifted \
18505 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18506 of either arm to a non-const or non-static byte-string breaks \
18507 the `&'static str`-lifetime promise the paired \
18508 From<DepList> for &'static str impl carries by construction"
18509 );
18510 }
18511
18512 #[test]
18513 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18514 // Cross-axis partition pin: the paired trait-idiomatic
18515 // `From<DepList> for &'static str` forward projection and the
18516 // method-named [`super::DepList::as_str`] forward projection
18517 // must resolve identically on every arm, locking the two paths
18518 // together so any future detour trips at caixa-core test time.
18519 // Then a round-trip witness: every arm's forward `From` output
18520 // re-parses through the paired trait-idiomatic reverse
18521 // `TryFrom<&str>` back to the original variant, closing the
18522 // two-way `DepList ↔ &'static str` round-trip on the trait-
18523 // idiomatic axis pair, mirroring the pre-existing method-named
18524 // `as_str` + `from_wire` round-trip. Peer of the sibling
18525 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18526 // (523157d).
18527 for &list in super::DepList::ALL {
18528 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18529 let via_method: &'static str = list.as_str();
18530 assert_eq!(
18531 via_trait, via_method,
18532 "From<DepList> for &'static str and DepList::as_str must \
18533 resolve identically on DepList::{list:?} — divergence \
18534 signals the two forward-projection paths have drifted \
18535 onto different emit-sets"
18536 );
18537 }
18538 for &list in super::DepList::ALL {
18539 let emitted: &'static str = list.into();
18540 let re_parsed: Result<super::DepList, ()> =
18541 <super::DepList as TryFrom<&str>>::try_from(emitted);
18542 assert_eq!(
18543 re_parsed,
18544 Ok(list),
18545 "trait-idiomatic axis pair must round-trip \
18546 DepList::{list:?} through `.into::<&'static str>()` and \
18547 back through `TryFrom<&str>` — a break signals the \
18548 forward-emit and reverse-parse axes have drifted onto \
18549 different vocabularies"
18550 );
18551 }
18552 }
18553
18554 #[test]
18555 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18556 // Fail-before-pass-after byte-parity pin on the newly lifted
18557 // `impl From<&DepList> for &'static str` — asserts the borrowed-
18558 // input standard-library trait impl and the substrate-primitive
18559 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18560 // the same two-arm emit-set across every arm the exhaustive
18561 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18562 // does not auto-derive the borrowed-input sibling from a paired
18563 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18564 // U: From<T>` blanket in `core`), so the borrowed-input axis is
18565 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18566 // shape over [`super::DepList::ALL`] (whose iterator yields
18567 // `&DepList`, not `DepList`) reaches through this impl and no
18568 // other — the paired owned-input [`From<DepList>`] impl requires
18569 // an explicit `.copied()` / dereference before the trait fires.
18570 // Materializes the `<&'static str as From<&DepList>>::from`
18571 // output in a `const`-shape binding to make the `'static`
18572 // lifetime promise a build-time invariant.
18573 const PROD: &str = super::DepList::Prod.as_str();
18574 const DEV: &str = super::DepList::Dev.as_str();
18575 for list in super::DepList::ALL {
18576 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18577 let via_method: &'static str = list.as_str();
18578 assert_eq!(
18579 via_trait, via_method,
18580 "From<&DepList> for &'static str impl must round-trip \
18581 &DepList::{list:?} to the same lifted \
18582 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18583 DepList::as_str returns — divergence signals a silent \
18584 detour off the substrate-primitive accessor"
18585 );
18586 let via_into: &'static str = list.into();
18587 assert_eq!(
18588 via_into, via_method,
18589 "Into<&'static str>::into on &DepList::{list:?} must \
18590 byte-equal DepList::as_str on the same input — the \
18591 blanket-derived Into shape must resolve to the same \
18592 as_str dispatch as the explicit From impl"
18593 );
18594 }
18595 assert_eq!(
18596 [PROD, DEV],
18597 [
18598 crate::render::DEP_AUTHOR_KEY_DEPS,
18599 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18600 ],
18601 "const-context DepList::as_str must resolve to the two lifted \
18602 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18603 From<&DepList> for &'static str impl inherits its `'static` \
18604 lifetime promise from the same accessor the owned-input \
18605 sibling routes through"
18606 );
18607 }
18608
18609 #[test]
18610 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18611 // Cross-axis partition pin: the paired trait-idiomatic
18612 // owned-input `From<DepList> for &'static str` (523157d
18613 // campaign-shape) and borrowed-input `From<&DepList> for
18614 // &'static str` (this lift) forward projections must resolve
18615 // identically on every arm, locking the two input-shape paths
18616 // together so any future detour trips at caixa-core test time.
18617 // Then a witness that a `.iter().map(Into::into)` pipe over
18618 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18619 // materializes the two-arm accept-set through the borrowed-
18620 // input axis alone — the exact shape a future M4 admission-
18621 // webhook rejection body composer, a future substrate-wide
18622 // per-arm diagnostic column, or a
18623 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18624 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18625 // through — closing the two-way owned/borrowed input-shape
18626 // symmetry on the forward-projection trait-idiomatic axis.
18627 for &list in super::DepList::ALL {
18628 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18629 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18630 assert_eq!(
18631 owned, borrowed,
18632 "From<DepList> and From<&DepList> for &'static str must \
18633 resolve identically on DepList::{list:?} — divergence \
18634 signals the owned-input and borrowed-input forward-\
18635 projection paths have drifted onto different emit-sets"
18636 );
18637 }
18638 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18639 let via_method: Vec<&'static str> =
18640 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18641 assert_eq!(
18642 via_iter, via_method,
18643 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18644 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18645 input `From<&DepList> for &'static str` axis is what makes \
18646 the `.iter().map(Into::into)` shape route through the \
18647 substrate-primitive `DepList::as_str` accessor rather than \
18648 through a per-call-site `.copied()` / dereference detour"
18649 );
18650 }
18651
18652 #[test]
18653 fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18654 // Fail-before-pass-after byte-parity pin on the newly lifted
18655 // `impl From<DepList> for String` — asserts the owned-`String`
18656 // -returning standard-library trait impl and the substrate-
18657 // primitive [`super::DepList::as_str`] `pub const fn` accessor
18658 // resolve to the same two-arm emit-set across every arm the
18659 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18660 // standard library does not carry a blanket
18661 // `impl<T: AsRef<str>> From<T> for String` (nor an
18662 // `impl<T: fmt::Display> From<T> for String`), so the
18663 // owned-`String` forward-projection axis is a distinct trait-
18664 // idiomatic surface that a `let key: String = list.into();`-
18665 // shaped call site reaches through this impl and no other — the
18666 // paired sibling `From<DepList> for &'static str` impl forces
18667 // every owned-`String` call site through an explicit
18668 // `.to_owned()` / `String::from` restatement. Peer of the
18669 // first-mover
18670 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18671 // (7baa18a), the second-peer
18672 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18673 // (7851725), the third-peer
18674 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18675 // (231a18c), and the fourth-peer
18676 // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18677 // (88942cd) — extends the trait-idiomatic owned-`String`
18678 // forward-projection axis onto the fifth closed-set fieldless
18679 // typed enum on the caixa surface (the two-list dep-graph axis).
18680 for &variant in super::DepList::ALL {
18681 let via_trait: String = <String as From<super::DepList>>::from(variant);
18682 let via_method: &'static str = variant.as_str();
18683 assert_eq!(
18684 via_trait.as_str(),
18685 via_method,
18686 "From<DepList> for String impl must round-trip \
18687 DepList::{variant:?} to the same lifted \
18688 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18689 DepList::as_str returns — divergence signals a silent \
18690 detour off the substrate-primitive accessor"
18691 );
18692 let via_into: String = variant.into();
18693 assert_eq!(
18694 via_into.as_str(),
18695 via_method,
18696 "Into<String>::into on DepList::{variant:?} must \
18697 byte-equal DepList::as_str on the same input — the \
18698 blanket-derived Into shape must resolve to the same \
18699 as_str dispatch as the explicit From impl"
18700 );
18701 }
18702 }
18703
18704 #[test]
18705 fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18706 // Cross-axis partition pin: the paired trait-idiomatic
18707 // owned-`String` `From<DepList> for String` (this lift) and
18708 // owned-`&'static str` `From<DepList> for &'static str`
18709 // (523157d campaign-shape) forward projections must resolve
18710 // identically on every arm, locking the two return-type-shape
18711 // paths together so any future detour trips at caixa-core test
18712 // time. Also byte-parity witness against the sibling
18713 // [`ToString::to_string`] surface routed through
18714 // [`std::fmt::Display`] — the three owned-heap-string paths
18715 // (`.into::<String>()`, `String::from`, `.to_string()`) must
18716 // resolve identically on every arm so a future consumer that
18717 // picks any of the three lands on the same two-arm lifted
18718 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18719 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18720 // Then a `.iter().copied().map(String::from)` pipe witness
18721 // over [`super::DepList::ALL`] that materializes the two-arm
18722 // accept-set through the owned-`String` axis alone — the exact
18723 // shape a future M4 admission-webhook rejection body composer
18724 // or a
18725 // `HashMap::<String, DepList>::from_iter(
18726 // DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18727 // style owned-key per-list lookup reaches through — closing the
18728 // owned-`String` forward-projection axis's iterator-pipe shape.
18729 // Then a direct round-trip witness through the paired
18730 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18731 // owned-`String`'s [`String::as_str`] borrow that closes the
18732 // two-way `Self → String → Self` round-trip on the trait-
18733 // idiomatic owned-`String` forward + reverse axis pair.
18734 //
18735 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18736 // `From` emit lands on the lowercase Portuguese `as_str`
18737 // diagnostic vocabulary while the reverse `TryFrom<&str>`
18738 // parses the `PascalCase` `wire_name` author-surface vocabulary,
18739 // forcing the round-trip through an intermediate
18740 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18741 // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18742 // parse resolve through the same lifted
18743 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18744 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18745 // construction (there is no wire/diagnostic axis split on this
18746 // enum), so the owned-`String` forward axis and the reverse
18747 // axis compose directly — matching the peer
18748 // [`crate::supervisor::RestartStrategy`] /
18749 // [`crate::supervisor::RestartPolicy`] /
18750 // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18751 for &list in super::DepList::ALL {
18752 let owned_string: String = <String as From<super::DepList>>::from(list);
18753 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18754 assert_eq!(
18755 owned_string.as_str(),
18756 owned_static,
18757 "From<DepList> for String and From<DepList> for \
18758 &'static str must resolve identically on \
18759 DepList::{list:?} — divergence signals the owned-\
18760 `String` and owned-`&'static str` forward-projection \
18761 return-type-shape paths have drifted onto different \
18762 emit-sets"
18763 );
18764 let via_to_string: String = list.to_string();
18765 assert_eq!(
18766 owned_string, via_to_string,
18767 "From<DepList> for String must byte-equal \
18768 DepList::to_string on DepList::{list:?} — divergence \
18769 signals the trait-idiomatic owned-`String` forward-\
18770 projection axis and the ToString-through-Display axis \
18771 have drifted onto different emit-sets"
18772 );
18773 }
18774 let via_iter: Vec<String> = super::DepList::ALL
18775 .iter()
18776 .copied()
18777 .map(String::from)
18778 .collect();
18779 let via_method: Vec<String> = super::DepList::ALL
18780 .iter()
18781 .map(|l| l.as_str().to_owned())
18782 .collect();
18783 assert_eq!(
18784 via_iter, via_method,
18785 "`.iter().copied().map(String::from)` over DepList::ALL must \
18786 byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18787 every arm — the owned-`String` `From<DepList> for String` \
18788 axis is what makes the `String::from` composition route \
18789 through the substrate-primitive `DepList::as_str` accessor \
18790 rather than through a per-call-site `.to_owned()` / \
18791 `String::from(list.as_str())` detour"
18792 );
18793 for &variant in super::DepList::ALL {
18794 let emitted: String = variant.into();
18795 let re_parsed: Result<super::DepList, ()> =
18796 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18797 assert_eq!(
18798 re_parsed,
18799 Ok(variant),
18800 "trait-idiomatic owned-`String` forward-projection + \
18801 reverse-projection axis pair must round-trip \
18802 DepList::{variant:?} through `.into::<String>()` and \
18803 back through `TryFrom<&str>` on the owned-`String`'s \
18804 String::as_str borrow — a break signals the owned-\
18805 `String` forward-emit and reverse-parse axes have \
18806 drifted onto different vocabularies (unlike the peer \
18807 CaixaKind axis pair, DepList's forward emit and \
18808 reverse parse share the same lifted \
18809 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18810 round-trip composes directly)"
18811 );
18812 }
18813 }
18814
18815 #[test]
18816 fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
18817 // Fail-before-pass-after byte-parity pin on the newly lifted
18818 // `impl From<&DepList> for String` — asserts the borrowed-input
18819 // owned-`String`-returning standard-library trait impl and the
18820 // substrate-primitive [`super::DepList::as_str`] `pub const fn`
18821 // accessor resolve to the same two-arm emit-set across every
18822 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
18823 // Rust's standard library does not carry a blanket
18824 // `impl<T: AsRef<str>> From<&T> for String` (nor an
18825 // `impl<T: fmt::Display> From<&T> for String`), so the
18826 // borrowed-input owned-`String` forward-projection axis is a
18827 // distinct trait-idiomatic surface that a
18828 // `let key: String = (&list).into();`-shaped call site reaches
18829 // through this impl and no other — the paired sibling
18830 // `From<DepList> for String` impl forces every borrowed-input
18831 // call site through an explicit `Copy` deref
18832 // (`String::from(*list)`) or an `.as_str().to_owned()` /
18833 // `.to_string()` detour. Peer of the first-mover
18834 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18835 // (579385f) and the second-peer
18836 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18837 // (8465740) — extends the trait-idiomatic borrowed-input owned-
18838 // `String` forward-projection axis off the M2 OTP-shape sibling
18839 // axis pair onto the first non-M2 closed-set fieldless typed
18840 // enum peer (the two-list dep-graph axis).
18841 for &variant in super::DepList::ALL {
18842 let via_trait: String = <String as From<&super::DepList>>::from(&variant);
18843 let via_method: &'static str = variant.as_str();
18844 assert_eq!(
18845 via_trait.as_str(),
18846 via_method,
18847 "From<&DepList> for String impl must round-trip \
18848 &DepList::{variant:?} to the same lifted \
18849 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18850 DepList::as_str returns — divergence signals a silent \
18851 detour off the substrate-primitive accessor"
18852 );
18853 let via_into: String = (&variant).into();
18854 assert_eq!(
18855 via_into.as_str(),
18856 via_method,
18857 "Into<String>::into on &DepList::{variant:?} must \
18858 byte-equal DepList::as_str on the same input — the \
18859 blanket-derived Into shape must resolve to the same \
18860 as_str dispatch as the explicit From impl"
18861 );
18862 }
18863 }
18864
18865 #[test]
18866 fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
18867 // Cross-axis partition pin: the newly lifted trait-idiomatic
18868 // borrowed-input owned-`String` `From<&DepList> for String`
18869 // (this lift), the paired owned-input owned-`String`
18870 // `From<DepList> for String` (32b0ee8), the paired borrowed-
18871 // input owned-`&'static str` `From<&DepList> for &'static str`
18872 // (64aa742), and the paired owned-input owned-`&'static str`
18873 // `From<DepList> for &'static str` (3455cbf) — every corner of
18874 // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
18875 // idiomatic projection family — must resolve identically on
18876 // every arm, locking the four return-shape × input-shape paths
18877 // together so any future detour trips at caixa-core test time.
18878 // Also byte-parity witness against the sibling
18879 // [`ToString::to_string`] surface routed through
18880 // [`std::fmt::Display`] and a direct round-trip witness through
18881 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
18882 // the owned-`String`'s [`String::as_str`] borrow that closes
18883 // the two-way `&Self → String → Self` round-trip on the trait-
18884 // idiomatic borrowed-input owned-`String` forward + reverse
18885 // axis pair. Peer of the first-mover
18886 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18887 // (579385f) and the second-peer
18888 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18889 // (8465740) — closes the whole `{Self, &Self} × {&'static str,
18890 // String}` 2×2 projection corner on the third substrate-wide
18891 // closed-set fieldless typed enum peer (the two-list dep-graph
18892 // axis, first outside the M2 OTP-shape sibling pair).
18893 //
18894 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18895 // `From` emit lands on the lowercase Portuguese `as_str`
18896 // diagnostic vocabulary while the reverse `TryFrom<&str>`
18897 // parses the `PascalCase` `wire_name` author-surface vocabulary,
18898 // forcing the round-trip through an intermediate
18899 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18900 // [`super::DepList::as_str`] emit and
18901 // [`super::DepList::from_wire`] parse resolve through the same
18902 // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18903 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18904 // construction (there is no wire/diagnostic axis split on this
18905 // enum), so the borrowed-input owned-`String` forward axis and
18906 // the reverse axis compose directly — matching the peer
18907 // [`crate::supervisor::RestartStrategy`] /
18908 // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
18909 // `String` axis pairs.
18910 for &list in super::DepList::ALL {
18911 let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
18912 let owned_string: String = <String as From<super::DepList>>::from(list);
18913 let borrowed_static: &'static str =
18914 <&'static str as From<&super::DepList>>::from(&list);
18915 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18916 assert_eq!(
18917 borrowed_string, owned_string,
18918 "From<&DepList> for String and From<DepList> for String \
18919 must resolve identically on DepList::{list:?} — \
18920 divergence signals the borrowed-input and owned-input \
18921 owned-`String` forward-projection input-shape paths \
18922 have drifted onto different emit-sets"
18923 );
18924 assert_eq!(
18925 borrowed_string.as_str(),
18926 borrowed_static,
18927 "From<&DepList> for String and From<&DepList> for \
18928 &'static str must resolve identically on \
18929 DepList::{list:?} — divergence signals the borrowed-\
18930 input `&'static str` and owned-`String` return-shape \
18931 paths have drifted onto different emit-sets"
18932 );
18933 assert_eq!(
18934 borrowed_string.as_str(),
18935 owned_static,
18936 "From<&DepList> for String and From<DepList> for \
18937 &'static str must resolve identically on \
18938 DepList::{list:?} — divergence signals a break in the \
18939 diagonal corner of the {{Self, &Self}} × {{&'static \
18940 str, String}} 2×2 trait-idiomatic projection family"
18941 );
18942 let via_to_string: String = list.to_string();
18943 assert_eq!(
18944 borrowed_string, via_to_string,
18945 "From<&DepList> for String must byte-equal \
18946 DepList::to_string on DepList::{list:?} — divergence \
18947 signals the trait-idiomatic borrowed-input owned-\
18948 `String` forward-projection axis and the ToString-\
18949 through-Display axis have drifted onto different \
18950 emit-sets"
18951 );
18952 }
18953 let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
18954 let via_method: Vec<String> = super::DepList::ALL
18955 .iter()
18956 .map(|l| l.as_str().to_owned())
18957 .collect();
18958 assert_eq!(
18959 via_iter, via_method,
18960 "`.iter().map(String::from)` over DepList::ALL — a call \
18961 site whose iteration axis holds `&DepList` by construction \
18962 — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
18963 on every arm — the borrowed-input owned-`String` \
18964 `From<&DepList> for String` axis is what makes the \
18965 `String::from` composition route through the substrate-\
18966 primitive `DepList::as_str` accessor without a spurious \
18967 `Copy` deref (which would only be reachable through the \
18968 owned-input `From<DepList> for String` axis by first \
18969 calling `.copied()` on the iterator)"
18970 );
18971 for &variant in super::DepList::ALL {
18972 let emitted: String = (&variant).into();
18973 let re_parsed: Result<super::DepList, ()> =
18974 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18975 assert_eq!(
18976 re_parsed,
18977 Ok(variant),
18978 "trait-idiomatic borrowed-input owned-`String` \
18979 forward-projection + reverse-projection axis pair must \
18980 round-trip &DepList::{variant:?} through \
18981 `.into::<String>()` on the borrowed-input surface and \
18982 back through `TryFrom<&str>` on the owned-`String`'s \
18983 String::as_str borrow — a break signals the \
18984 borrowed-input owned-`String` forward-emit and \
18985 reverse-parse axes have drifted onto different \
18986 vocabularies (unlike the peer CaixaKind axis pair, \
18987 DepList's forward emit and reverse parse share the \
18988 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
18989 construction, so the round-trip composes directly)"
18990 );
18991 }
18992 }
18993
18994 #[test]
18995 fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
18996 // Fail-before-pass-after byte-parity pin on the newly lifted
18997 // `impl From<DepList> for std::borrow::Cow<'static, str>` —
18998 // asserts the standard-library trait impl and the substrate-
18999 // primitive [`super::DepList::as_str`] `pub const fn`
19000 // accessor resolve to the same two-arm emit-set across every
19001 // arm the exhaustive [`super::DepList::ALL`] slice
19002 // enumerates. Rust's standard library does not carry a
19003 // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19004 // (nor an `impl<T: fmt::Display> From<T> for
19005 // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19006 // projection axis is a distinct trait-idiomatic surface that
19007 // a `let key: Cow<'static, str> = list.into();`-shaped call
19008 // site reaches through this impl and no other — the paired
19009 // sibling `From<DepList> for &'static str` and
19010 // `From<DepList> for String` impls force every
19011 // `Cow<'static, str>`-parameterized call site through a
19012 // `Cow::Borrowed(list.as_str())` /
19013 // `Cow::Owned(list.to_string())` composition whose type
19014 // bounds have no compile-time link back to the substrate
19015 // primitive.
19016 //
19017 // Also asserts the projection lands on the zero-alloc
19018 // [`std::borrow::Cow::Borrowed`] arm (not the
19019 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19020 // [`super::DepList::as_str`] accessor's `&'static str`
19021 // return lifetime by construction (each match arm resolves
19022 // to one of the two lifted
19023 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19024 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19025 // &str` values) makes the borrowed arm the type-correct
19026 // projection with no runtime allocation. Any future silent
19027 // detour that routes the impl through the owned arm trips
19028 // at caixa-core test time under the
19029 // [`std::borrow::Cow::Borrowed`] discriminator witness
19030 // rather than at a downstream `Cow<'static, str>`-bound
19031 // consumer's silent allocation.
19032 //
19033 // First-mover on the outside-M3 substrate-wide tier of the
19034 // substrate-wide trait-idiomatic
19035 // [`std::borrow::Cow<'static, str>`] forward-projection
19036 // campaign — extends the axis off the paired
19037 // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19038 // the paired M2 OTP-shape
19039 // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19040 // and [`crate::supervisor::RestartPolicy`] (0612398 +
19041 // ee577fd), and the paired M3-mesh-shape
19042 // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19043 // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19044 // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19045 // peers onto the first outside-M3 caixa-core peer (the two-
19046 // list dep-graph axis), opening the outside-M3 caixa-core
19047 // tier of the substrate-wide Cow<'static, str> forward-
19048 // projection campaign's owned-input corner.
19049 for &variant in super::DepList::ALL {
19050 let via_trait: std::borrow::Cow<'static, str> =
19051 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19052 let via_method: &'static str = variant.as_str();
19053 assert_eq!(
19054 via_trait.as_ref(),
19055 via_method,
19056 "From<DepList> for Cow<'static, str> impl must \
19057 round-trip DepList::{variant:?} to the same lifted \
19058 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19059 DepList::as_str returns — divergence signals a \
19060 silent detour off the substrate-primitive accessor"
19061 );
19062 assert!(
19063 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19064 "From<DepList> for Cow<'static, str> impl must land \
19065 on the zero-alloc Cow::Borrowed arm on \
19066 DepList::{variant:?} — a Cow::Owned outcome signals \
19067 the projection has silently allocated where the \
19068 substrate-primitive DepList::as_str `&'static str` \
19069 return makes the borrowed arm the type-correct \
19070 projection"
19071 );
19072 let via_into: std::borrow::Cow<'static, str> = variant.into();
19073 assert_eq!(
19074 via_into.as_ref(),
19075 via_method,
19076 "Into<Cow<'static, str>>::into on DepList::\
19077 {variant:?} must byte-equal DepList::as_str on the \
19078 same input — the blanket-derived Into shape must \
19079 resolve to the same as_str dispatch as the explicit \
19080 From impl"
19081 );
19082 assert!(
19083 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19084 "Into<Cow<'static, str>>::into on DepList::\
19085 {variant:?} must land on the zero-alloc \
19086 Cow::Borrowed arm — the blanket-derived Into shape \
19087 must resolve to the same Cow::Borrowed dispatch as \
19088 the explicit From impl"
19089 );
19090 }
19091 }
19092
19093 #[test]
19094 fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19095 // Cross-axis partition pin: the newly lifted trait-idiomatic
19096 // `From<DepList> for std::borrow::Cow<'static, str>` (this
19097 // lift), the paired owned-input `From<DepList> for
19098 // &'static str` (3455cbf), and the paired owned-input
19099 // `From<DepList> for String` (32b0ee8) forward projections
19100 // must resolve identically on every arm, locking the three
19101 // return-shape paths together by construction so any future
19102 // detour trips at caixa-core test time. Also byte-parity
19103 // witness against the sibling [`ToString::to_string`]
19104 // surface routed through [`std::fmt::Display`] — every
19105 // owned-heap-string path (the `Cow::Owned` promotion of
19106 // this axis's `.into_owned()`, `From<DepList> for String`,
19107 // and `.to_string()`) resolves to the same two-arm lifted
19108 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19109 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19110 // arm.
19111 //
19112 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19113 // witness over [`super::DepList::ALL`] that materializes the
19114 // two-arm accept-set through the
19115 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19116 // shape a future M4 admission-webhook rejection body's
19117 // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19118 // future substrate-wide per-arm diagnostic surface whose
19119 // typing rules out the sibling [`AsRef<str>`] borrowed
19120 // return, or a future per-arm dep-list emitter that binds
19121 // through a [`std::borrow::Cow<'static, str>`] boundary
19122 // reaches through — opening the composable-projection axis
19123 // on the first outside-M3 caixa-core closed-set fieldless
19124 // typed enum peer on the caixa surface. The pipe witness
19125 // also pins the zero-alloc discipline: every element in the
19126 // collected vector satisfies the
19127 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19128 // accidental silent-allocation regression on the pipe's
19129 // iteration axis is a caixa-core-test-time failure.
19130 for &variant in super::DepList::ALL {
19131 let via_cow: std::borrow::Cow<'static, str> =
19132 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19133 let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19134 let via_string: String = <String as From<super::DepList>>::from(variant);
19135 assert_eq!(
19136 via_cow.as_ref(),
19137 via_static,
19138 "From<DepList> for Cow<'static, str> and \
19139 From<DepList> for &'static str must resolve \
19140 identically on DepList::{variant:?} — divergence \
19141 signals the Cow<'static, str> and &'static str \
19142 return-shape paths have drifted onto different \
19143 emit-sets"
19144 );
19145 assert_eq!(
19146 via_cow.as_ref(),
19147 via_string.as_str(),
19148 "From<DepList> for Cow<'static, str> and \
19149 From<DepList> for String must resolve identically \
19150 on DepList::{variant:?} — divergence signals the \
19151 Cow<'static, str> and String return-shape paths \
19152 have drifted onto different emit-sets"
19153 );
19154 let via_to_string: String = variant.to_string();
19155 assert_eq!(
19156 via_cow.as_ref(),
19157 via_to_string.as_str(),
19158 "From<DepList> for Cow<'static, str> must byte-equal \
19159 DepList::to_string on DepList::{variant:?} — \
19160 divergence signals the trait-idiomatic \
19161 Cow<'static, str> forward-projection axis and the \
19162 ToString-through-Display axis have drifted onto \
19163 different emit-sets"
19164 );
19165 }
19166 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19167 .iter()
19168 .copied()
19169 .map(std::borrow::Cow::from)
19170 .collect();
19171 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19172 .iter()
19173 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19174 .collect();
19175 assert_eq!(
19176 via_iter, via_method,
19177 "`.iter().copied().map(Cow::from)` over DepList::ALL \
19178 must byte-equal `.iter().map(|l| \
19179 Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19180 idiomatic `From<DepList> for Cow<'static, str>` axis is \
19181 what makes the `Cow::from` composition route through \
19182 the substrate-primitive `DepList::as_str` accessor with \
19183 the zero-alloc Cow::Borrowed arm by construction, \
19184 rather than a per-call-site `Cow::Owned(list.to_string())` \
19185 allocation"
19186 );
19187 for cow in &via_iter {
19188 assert!(
19189 matches!(cow, std::borrow::Cow::Borrowed(_)),
19190 "every element of the .iter().copied().map(Cow::from) \
19191 pipe over DepList::ALL must land on the zero-alloc \
19192 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19193 signals the pipe's iteration axis has silently \
19194 allocated where the substrate-primitive \
19195 DepList::as_str `&'static str` return makes the \
19196 borrowed arm the type-correct projection"
19197 );
19198 }
19199 }
19200
19201 #[test]
19202 fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19203 // Fail-before-pass-after byte-parity pin on the newly lifted
19204 // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19205 // asserts the borrowed-input standard-library trait impl and
19206 // the substrate-primitive [`super::DepList::as_str`] `pub const
19207 // fn` accessor resolve to the same two-arm emit-set across
19208 // every arm the exhaustive [`super::DepList::ALL`] slice
19209 // enumerates. Rust's standard library does not carry a blanket
19210 // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19211 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19212 // the borrowed-input `Cow<'static, str>` forward-projection
19213 // axis is a distinct trait-idiomatic surface that a
19214 // `let key: Cow<'static, str> = (&list).into();`-shaped call
19215 // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19216 // reaches through this impl and no other — the paired owned-
19217 // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19218 // forces every borrowed-input call site through an explicit
19219 // `Copy` deref (`Cow::from(*list)`) or a
19220 // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19221 // have no compile-time link back to the substrate primitive.
19222 //
19223 // Also asserts the projection lands on the zero-alloc
19224 // [`std::borrow::Cow::Borrowed`] arm (not the
19225 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19226 // [`super::DepList::as_str`] accessor's `&'static str` return
19227 // lifetime by construction (each match arm resolves to one of
19228 // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19229 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19230 // values) makes the borrowed arm the type-correct projection
19231 // with no runtime allocation on the borrowed-input surface
19232 // just as on the paired owned-input surface.
19233 //
19234 // Closes the `{Self, &Self}` input-shape corner on the outside-
19235 // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19236 // on the first outside-M3 caixa-core closed-set fieldless typed
19237 // enum peer on the caixa surface, exactly as afdf0f4 closed it
19238 // on the second M3-mesh-primitive peer
19239 // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19240 // the owning half (eee504d) landed, as 25690ef closed it on
19241 // the first M3-mesh-primitive peer
19242 // ([`crate::aplicacao::WitShape`]) one commit after the owning
19243 // half (8634dec) landed, as d45c409 closed it on the top-level
19244 // [`crate::CaixaKind`] one commit after the owning half
19245 // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19246 // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19247 // [`crate::supervisor::RestartPolicy`] sibling peers one
19248 // commit after (7dd28b3 / 0612398) landed.
19249 for &variant in super::DepList::ALL {
19250 let via_trait: std::borrow::Cow<'static, str> =
19251 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19252 let via_method: &'static str = variant.as_str();
19253 assert_eq!(
19254 via_trait.as_ref(),
19255 via_method,
19256 "From<&DepList> for Cow<'static, str> impl must \
19257 round-trip &DepList::{variant:?} to the same lifted \
19258 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19259 DepList::as_str returns — divergence signals a silent \
19260 detour off the substrate-primitive accessor"
19261 );
19262 assert!(
19263 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19264 "From<&DepList> for Cow<'static, str> impl must land \
19265 on the zero-alloc Cow::Borrowed arm on \
19266 &DepList::{variant:?} — a Cow::Owned outcome signals \
19267 the projection has silently allocated where the \
19268 substrate-primitive DepList::as_str `&'static str` \
19269 return makes the borrowed arm the type-correct \
19270 projection"
19271 );
19272 let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19273 assert_eq!(
19274 via_into.as_ref(),
19275 via_method,
19276 "Into<Cow<'static, str>>::into on &DepList::\
19277 {variant:?} must byte-equal DepList::as_str on the \
19278 same input — the blanket-derived Into shape must \
19279 resolve to the same as_str dispatch as the explicit \
19280 From impl"
19281 );
19282 assert!(
19283 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19284 "Into<Cow<'static, str>>::into on &DepList::\
19285 {variant:?} must land on the zero-alloc \
19286 Cow::Borrowed arm — the blanket-derived Into shape \
19287 must resolve to the same Cow::Borrowed dispatch as \
19288 the explicit From impl"
19289 );
19290 }
19291 }
19292
19293 #[test]
19294 fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19295 // Cross-axis partition pin: the newly lifted trait-idiomatic
19296 // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19297 // str>` (this lift), the paired owned-input `From<DepList> for
19298 // std::borrow::Cow<'static, str>` (6858bac), the paired
19299 // borrowed-input owned-`&'static str` `From<&DepList> for
19300 // &'static str` (3455cbf), and the paired borrowed-input
19301 // owned-`String` `From<&DepList> for String` must resolve
19302 // identically on every arm, locking the four return-shape ×
19303 // input-shape paths together by construction so any future
19304 // detour trips at caixa-core test time. Also byte-parity
19305 // witness against the sibling [`ToString::to_string`] surface
19306 // routed through [`std::fmt::Display`] — every owned-heap-
19307 // string path (this axis's `.into_owned()` promotion, the
19308 // paired [`From<&DepList> for String`], and `.to_string()`)
19309 // resolves to the same two-arm lifted
19310 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19311 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19312 // arm.
19313 //
19314 // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19315 // over [`super::DepList::ALL`] — whose iterator yields
19316 // `&DepList` by construction, so the borrowed-input
19317 // [`Cow<'static, str>`] axis is what routes the pipe through
19318 // the substrate-primitive [`super::DepList::as_str`] accessor
19319 // without a spurious [`Copy`] deref (which would only be
19320 // reachable through the owned-input [`From<DepList> for
19321 // Cow<'static, str>`] axis by first calling `.copied()` on the
19322 // iterator). The pipe witness also pins the zero-alloc
19323 // discipline: every element in the collected vector satisfies
19324 // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19325 // future accidental silent-allocation regression on the pipe's
19326 // iteration axis is a caixa-core-test-time failure. Peer of
19327 // the sibling
19328 // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19329 // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19330 // axis — extends the whole borrowed-input `Cow<'static, str>`
19331 // + paired `{&'static str, String}` cross-axis-parity corner
19332 // onto the first outside-M3 caixa-core closed-set fieldless
19333 // typed enum peer on the caixa surface.
19334 for &variant in super::DepList::ALL {
19335 let borrowed_cow: std::borrow::Cow<'static, str> =
19336 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19337 let owned_cow: std::borrow::Cow<'static, str> =
19338 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19339 let borrowed_static: &'static str =
19340 <&'static str as From<&super::DepList>>::from(&variant);
19341 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19342 assert_eq!(
19343 borrowed_cow, owned_cow,
19344 "From<&DepList> for Cow<'static, str> and \
19345 From<DepList> for Cow<'static, str> must resolve \
19346 identically on DepList::{variant:?} — divergence \
19347 signals the borrowed-input and owned-input \
19348 Cow<'static, str> forward-projection input-shape \
19349 paths have drifted onto different emit-sets"
19350 );
19351 assert_eq!(
19352 borrowed_cow.as_ref(),
19353 borrowed_static,
19354 "From<&DepList> for Cow<'static, str> and \
19355 From<&DepList> for &'static str must resolve \
19356 identically on DepList::{variant:?} — divergence \
19357 signals the borrowed-input Cow<'static, str> and \
19358 &'static str return-shape paths have drifted onto \
19359 different emit-sets"
19360 );
19361 assert_eq!(
19362 borrowed_cow.as_ref(),
19363 borrowed_string.as_str(),
19364 "From<&DepList> for Cow<'static, str> and \
19365 From<&DepList> for String must resolve identically \
19366 on DepList::{variant:?} — divergence signals the \
19367 borrowed-input Cow<'static, str> and owned-`String` \
19368 return-shape paths have drifted onto different \
19369 emit-sets"
19370 );
19371 let via_to_string: String = variant.to_string();
19372 assert_eq!(
19373 borrowed_cow.as_ref(),
19374 via_to_string.as_str(),
19375 "From<&DepList> for Cow<'static, str> must byte-equal \
19376 DepList::to_string on DepList::{variant:?} — \
19377 divergence signals the trait-idiomatic borrowed-input \
19378 Cow<'static, str> forward-projection axis and the \
19379 ToString-through-Display axis have drifted onto \
19380 different emit-sets"
19381 );
19382 }
19383 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19384 .iter()
19385 .map(std::borrow::Cow::from)
19386 .collect();
19387 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19388 .iter()
19389 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19390 .collect();
19391 assert_eq!(
19392 via_iter, via_method,
19393 "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19394 whose iteration axis holds &DepList by construction — \
19395 must byte-equal `.iter().map(|l| \
19396 Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19397 input Cow<'static, str> `From<&DepList> for Cow<'static, \
19398 str>` axis is what makes the `Cow::from` composition \
19399 route through the substrate-primitive `DepList::as_str` \
19400 accessor with the zero-alloc Cow::Borrowed arm by \
19401 construction and without a spurious `Copy` deref (which \
19402 would only be reachable through the owned-input \
19403 `From<DepList> for Cow<'static, str>` axis by first \
19404 calling `.copied()` on the iterator)"
19405 );
19406 for cow in &via_iter {
19407 assert!(
19408 matches!(cow, std::borrow::Cow::Borrowed(_)),
19409 "every element of the .iter().map(Cow::from) pipe \
19410 over DepList::ALL must land on the zero-alloc \
19411 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19412 signals the pipe's iteration axis has silently \
19413 allocated where the substrate-primitive \
19414 DepList::as_str `&'static str` return makes the \
19415 borrowed arm the type-correct projection"
19416 );
19417 }
19418 }
19419
19420 #[test]
19421 fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19422 // Fail-before-pass-after byte-parity pin on the newly lifted
19423 // `impl From<DepList> for Box<str>` — asserts the owned-input
19424 // standard-library trait impl and the substrate-primitive
19425 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19426 // the same two-arm emit-set (the paired
19427 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19428 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19429 // byte-strings) across every arm the exhaustive
19430 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19431 // core-internal tier of the substrate-wide [`Box<str>`] forward-
19432 // projection campaign onto the second caixa-core-internal peer,
19433 // after the render-side path-shape-diagnostic
19434 // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19435 // both corners in one axis) opened the tier. Rust's standard
19436 // library carries `impl From<&str> for Box<str>` and
19437 // `impl From<String> for Box<str>` but no blanket
19438 // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19439 // distinct trait-idiomatic surface that a
19440 // `let key: Box<str> = list.into();`-shaped call site reaches
19441 // through this impl and no other — a paired
19442 // `Box::from(list.as_str())` open-code has no compile-time link
19443 // back to the substrate primitive.
19444 for &variant in super::DepList::ALL {
19445 let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19446 let via_method: &'static str = variant.as_str();
19447 assert_eq!(
19448 via_trait.as_ref(),
19449 via_method,
19450 "From<DepList> for Box<str> impl must round-trip \
19451 DepList::{variant:?} to the same lifted \
19452 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19453 DepList::as_str returns — divergence signals a silent \
19454 detour off the substrate-primitive accessor"
19455 );
19456 let via_into: Box<str> = variant.into();
19457 assert_eq!(
19458 via_into.as_ref(),
19459 via_method,
19460 "Into<Box<str>>::into on DepList::{variant:?} must \
19461 byte-equal DepList::as_str on the same input — the \
19462 blanket-derived Into shape must resolve to the same \
19463 as_str dispatch as the explicit From impl"
19464 );
19465 }
19466 }
19467
19468 #[test]
19469 fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
19470 // Fail-before-pass-after byte-parity pin on the newly lifted
19471 // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
19472 // standard-library trait impl and the substrate-primitive
19473 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19474 // the same two-arm emit-set (the paired
19475 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19476 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19477 // byte-strings) across every arm the exhaustive
19478 // [`super::DepList::ALL`] slice enumerates. Rust's standard
19479 // library carries `impl From<&str> for Box<str>` and
19480 // `impl From<String> for Box<str>` but no blanket
19481 // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
19482 // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
19483 // input [`Box<str>`] forward-projection axis is a distinct
19484 // trait-idiomatic surface that a
19485 // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
19486 // iterator over `&'static [DepList]` yields `&DepList` by
19487 // construction) or a `let key: Box<str> = (&list).into();`-shaped
19488 // call site reaches through this impl and no other — the paired
19489 // owned-input `From<DepList> for Box<str>` impl alone would force
19490 // every borrowed-input call site through an explicit `Copy` deref
19491 // (`Box::<str>::from(*list)`) or a
19492 // `Box::<str>::from(list.as_str())` open-code whose type bounds
19493 // have no compile-time link back to the substrate primitive.
19494 //
19495 // Closes the `{Self, &Self}` input-shape corner on the second
19496 // caixa-core-internal closed-set fieldless typed enum peer of
19497 // the substrate-wide [`Box<str>`] forward-projection campaign —
19498 // one commit after the paired render-side path-shape-diagnostic
19499 // [`super::super::render::PathShapeViolation`] pair (0d87a72)
19500 // opened the caixa-core-internal tier — matching the trajectory
19501 // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
19502 // in one axis), the caixa-provedor `FerriteRuntime` pair
19503 // (14886a8, both corners in one axis), and the render-side
19504 // `PathShapeViolation` pair (0d87a72, both corners in one axis)
19505 // walked before it.
19506 for &variant in super::DepList::ALL {
19507 let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19508 let via_method: &'static str = variant.as_str();
19509 assert_eq!(
19510 via_trait.as_ref(),
19511 via_method,
19512 "From<&DepList> for Box<str> impl must round-trip \
19513 &DepList::{variant:?} to the same lifted \
19514 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19515 DepList::as_str returns — divergence signals a silent \
19516 detour off the substrate-primitive accessor"
19517 );
19518 let via_into: Box<str> = (&variant).into();
19519 assert_eq!(
19520 via_into.as_ref(),
19521 via_method,
19522 "Into<Box<str>>::into on &DepList::{variant:?} must \
19523 byte-equal DepList::as_str on the same input — the \
19524 blanket-derived Into shape on the borrowed-input \
19525 surface must resolve to the same as_str dispatch as \
19526 the explicit From impl"
19527 );
19528 }
19529
19530 // Pipe witness — the distinguishing shape that forces the
19531 // borrowed-input axis to be independent of the owned-input
19532 // peer. `DepList::ALL.iter()` yields `&DepList` by
19533 // construction, so `.map(Box::<str>::from)` resolves through
19534 // the borrowed-input `From<&DepList> for Box<str>` impl and
19535 // no other — without this axis, the same pipe would force an
19536 // explicit `.copied()` restatement whose type bounds bypass
19537 // the substrate primitive.
19538 let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
19539 let via_accessor: Vec<&'static str> =
19540 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19541 assert_eq!(
19542 via_pipe.len(),
19543 via_accessor.len(),
19544 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19545 preserve arity against the paired DepList::as_str \
19546 accessor — a length divergence signals the borrowed-input \
19547 axis has silently rejected an arm"
19548 );
19549 for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
19550 assert_eq!(
19551 pipe_arm.as_ref(),
19552 *accessor_arm,
19553 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19554 byte-equal the paired \
19555 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
19556 arm — divergence signals the borrowed-input \
19557 `From<&DepList> for Box<str>` axis has silently \
19558 detoured off the substrate-primitive accessor"
19559 );
19560 }
19561 }
19562
19563 #[test]
19564 fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
19565 // Fail-before-pass-after byte-parity pin on the newly lifted
19566 // `impl From<DepList> for std::sync::Arc<str>` — asserts the
19567 // owned-input standard-library trait impl and the substrate-
19568 // primitive [`super::DepList::as_str`] `pub const fn` accessor
19569 // resolve to the same two-arm emit-set (the paired
19570 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19571 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19572 // byte-strings) across every arm the exhaustive
19573 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19574 // core-internal tier of the substrate-wide
19575 // [`std::sync::Arc<str>`] forward-projection campaign onto the
19576 // second caixa-core-internal peer, after the top-level
19577 // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
19578 // opened the tier. Rust's standard library carries
19579 // `impl From<&str> for std::sync::Arc<str>` and
19580 // `impl From<String> for std::sync::Arc<str>` but no blanket
19581 // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
19582 // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
19583 // this axis is a distinct trait-idiomatic surface that a
19584 // `let key: std::sync::Arc<str> = list.into();`-shaped call site
19585 // reaches through this impl and no other — a paired
19586 // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
19587 // compile-time link back to the substrate primitive, and a two-
19588 // step `std::sync::Arc::<str>::from(String::from(list))`
19589 // composition through the owned-`String` axis allocates twice
19590 // (once into the intermediate `String`, once into the
19591 // [`std::sync::Arc<str>`] on the `From<String>` conversion)
19592 // where the single-step trait impl allocates once.
19593 //
19594 // Cross-axis byte-parity witness against the sibling owned-input
19595 // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
19596 // shape axes — locking the five return-shape paths on the owned-
19597 // input surface together by construction so any future detour
19598 // off the substrate-primitive [`super::DepList::as_str`] accessor
19599 // trips at caixa-core test time.
19600 for &variant in super::DepList::ALL {
19601 let via_trait: std::sync::Arc<str> =
19602 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19603 let via_method: &'static str = variant.as_str();
19604 assert_eq!(
19605 via_trait.as_ref(),
19606 via_method,
19607 "From<DepList> for std::sync::Arc<str> impl must round-\
19608 trip DepList::{variant:?} to the same lifted \
19609 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19610 DepList::as_str returns — divergence signals a silent \
19611 detour off the substrate-primitive accessor"
19612 );
19613 let via_into: std::sync::Arc<str> = variant.into();
19614 assert_eq!(
19615 via_into.as_ref(),
19616 via_method,
19617 "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
19618 must byte-equal DepList::as_str on the same input — \
19619 the blanket-derived Into shape must resolve to the same \
19620 as_str dispatch as the explicit From impl"
19621 );
19622 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19623 assert_eq!(
19624 via_trait.as_ref(),
19625 owned_static,
19626 "From<DepList> for std::sync::Arc<str> and \
19627 From<DepList> for &'static str must resolve identically \
19628 on DepList::{variant:?} — divergence signals the owned-\
19629 input std::sync::Arc<str> and &'static str return-shape \
19630 paths have drifted onto different emit-sets"
19631 );
19632 let owned_string: String = <String as From<super::DepList>>::from(variant);
19633 assert_eq!(
19634 via_trait.as_ref(),
19635 owned_string.as_str(),
19636 "From<DepList> for std::sync::Arc<str> and \
19637 From<DepList> for String must resolve identically on \
19638 DepList::{variant:?} — divergence signals the owned-\
19639 input std::sync::Arc<str> and owned-`String` return-shape \
19640 paths have drifted onto different emit-sets"
19641 );
19642 let owned_cow: std::borrow::Cow<'static, str> =
19643 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19644 assert_eq!(
19645 via_trait.as_ref(),
19646 owned_cow.as_ref(),
19647 "From<DepList> for std::sync::Arc<str> and \
19648 From<DepList> for Cow<'static, str> must resolve \
19649 identically on DepList::{variant:?} — divergence signals \
19650 the owned-input std::sync::Arc<str> and \
19651 Cow<'static, str> return-shape paths have drifted onto \
19652 different emit-sets"
19653 );
19654 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19655 assert_eq!(
19656 via_trait.as_ref(),
19657 owned_box.as_ref(),
19658 "From<DepList> for std::sync::Arc<str> and \
19659 From<DepList> for Box<str> must resolve identically on \
19660 DepList::{variant:?} — divergence signals the owned-\
19661 input std::sync::Arc<str> and Box<str> return-shape \
19662 paths have drifted onto different emit-sets"
19663 );
19664 }
19665 }
19666
19667 #[test]
19668 #[allow(
19669 clippy::too_many_lines,
19670 reason = "cross-axis partition pin folds four borrowed-input \
19671 return-shape paths (&'static str, String, Cow<'static, \
19672 str>, Box<str>) plus the paired owned-input Arc<str> \
19673 witness and the .iter().map(std::sync::Arc::<str>::from) \
19674 pipe witness into one exhaustive round-trip over \
19675 DepList::ALL — the accepted line-count cost of keying \
19676 the whole borrowed-input Arc<str> corner to the \
19677 substrate-primitive as_str accessor at the same test-site"
19678 )]
19679 fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
19680 // Fail-before-pass-after byte-parity pin on the newly lifted
19681 // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
19682 // borrowed-input standard-library trait impl and the substrate-
19683 // primitive [`super::DepList::as_str`] `pub const fn` accessor
19684 // resolve to the same two-arm emit-set across every arm the
19685 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19686 // standard library does not carry a blanket
19687 // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
19688 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19689 // the borrowed-input `std::sync::Arc<str>` forward-projection
19690 // axis is a distinct trait-idiomatic surface that a
19691 // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
19692 // site or a
19693 // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
19694 // pipe reaches through this impl and no other — the paired
19695 // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
19696 // forces every borrowed-input call site through a spurious
19697 // `Copy` deref
19698 // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
19699 // `.copied()` restatement whose type bounds have no compile-time
19700 // link back to the substrate primitive.
19701 //
19702 // Closes the `{Self, &Self}` input-shape corner on the second
19703 // caixa-core-internal closed-set fieldless typed enum peer of
19704 // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
19705 // forward-projection campaign — one commit after the paired
19706 // top-level [`crate::CaixaKind`] pair (c17be64) opened the
19707 // caixa-core-internal tier — matching the
19708 // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
19709 // Box<str>}` 2×4 forward-projection matrix the peer projection
19710 // surfaces already close on this same enum.
19711 //
19712 // Cross-axis partition pin against the paired owned-input
19713 // [`From<DepList> for std::sync::Arc<str>`] and the sibling
19714 // borrowed-input `{&'static str, String, Cow<'static, str>,
19715 // Box<str>}` return-shape axes — locking the five return-shape
19716 // × input-shape paths on the borrowed-input surface together by
19717 // construction so any future detour off the substrate-primitive
19718 // accessor trips at caixa-core test time. Then a
19719 // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
19720 // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
19721 // construction, so the borrowed-input
19722 // [`std::sync::Arc<str>`] axis is what routes the pipe through
19723 // the substrate-primitive [`super::DepList::as_str`] accessor
19724 // without a spurious [`Copy`] deref (which would only be
19725 // reachable through the owned-input
19726 // [`From<DepList> for std::sync::Arc<str>`] axis by first
19727 // calling `.copied()` on the iterator).
19728 for &variant in super::DepList::ALL {
19729 let via_trait: std::sync::Arc<str> =
19730 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
19731 let via_method: &'static str = variant.as_str();
19732 assert_eq!(
19733 via_trait.as_ref(),
19734 via_method,
19735 "From<&DepList> for std::sync::Arc<str> impl must round-\
19736 trip &DepList::{variant:?} to the same lifted \
19737 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19738 DepList::as_str returns — divergence signals a silent \
19739 detour off the substrate-primitive accessor"
19740 );
19741 let via_into: std::sync::Arc<str> = (&variant).into();
19742 assert_eq!(
19743 via_into.as_ref(),
19744 via_method,
19745 "Into<std::sync::Arc<str>>::into on &DepList::\
19746 {variant:?} must byte-equal DepList::as_str on the \
19747 same input — the blanket-derived Into shape on the \
19748 borrowed-input surface must resolve to the same as_str \
19749 dispatch as the explicit From impl"
19750 );
19751 let owned_arc: std::sync::Arc<str> =
19752 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19753 assert_eq!(
19754 via_trait, owned_arc,
19755 "From<&DepList> for std::sync::Arc<str> and \
19756 From<DepList> for std::sync::Arc<str> must resolve \
19757 identically on DepList::{variant:?} — divergence \
19758 signals the borrowed-input and owned-input \
19759 std::sync::Arc<str> forward-projection input-shape \
19760 paths have drifted onto different emit-sets"
19761 );
19762 let borrowed_static: &'static str =
19763 <&'static str as From<&super::DepList>>::from(&variant);
19764 assert_eq!(
19765 via_trait.as_ref(),
19766 borrowed_static,
19767 "From<&DepList> for std::sync::Arc<str> and \
19768 From<&DepList> for &'static str must resolve \
19769 identically on DepList::{variant:?} — divergence \
19770 signals the borrowed-input std::sync::Arc<str> and \
19771 &'static str return-shape paths have drifted onto \
19772 different emit-sets"
19773 );
19774 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19775 assert_eq!(
19776 via_trait.as_ref(),
19777 borrowed_string.as_str(),
19778 "From<&DepList> for std::sync::Arc<str> and \
19779 From<&DepList> for String must resolve identically on \
19780 DepList::{variant:?} — divergence signals the \
19781 borrowed-input std::sync::Arc<str> and owned-`String` \
19782 return-shape paths have drifted onto different emit-\
19783 sets"
19784 );
19785 let borrowed_cow: std::borrow::Cow<'static, str> =
19786 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19787 assert_eq!(
19788 via_trait.as_ref(),
19789 borrowed_cow.as_ref(),
19790 "From<&DepList> for std::sync::Arc<str> and \
19791 From<&DepList> for Cow<'static, str> must resolve \
19792 identically on DepList::{variant:?} — divergence \
19793 signals the borrowed-input std::sync::Arc<str> and \
19794 Cow<'static, str> return-shape paths have drifted onto \
19795 different emit-sets"
19796 );
19797 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19798 assert_eq!(
19799 via_trait.as_ref(),
19800 borrowed_box.as_ref(),
19801 "From<&DepList> for std::sync::Arc<str> and \
19802 From<&DepList> for Box<str> must resolve identically \
19803 on DepList::{variant:?} — divergence signals the \
19804 borrowed-input std::sync::Arc<str> and Box<str> \
19805 return-shape paths have drifted onto different emit-sets"
19806 );
19807 }
19808 let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
19809 .iter()
19810 .map(std::sync::Arc::<str>::from)
19811 .collect();
19812 let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
19813 .iter()
19814 .map(|l| std::sync::Arc::<str>::from(l.as_str()))
19815 .collect();
19816 assert_eq!(
19817 via_iter, via_method,
19818 "`.iter().map(std::sync::Arc::<str>::from)` over \
19819 DepList::ALL — a call site whose iteration axis holds \
19820 `&DepList` by construction — must byte-equal \
19821 `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
19822 on every arm — the borrowed-input std::sync::Arc<str> \
19823 `From<&DepList> for std::sync::Arc<str>` axis is what \
19824 makes the `std::sync::Arc::<str>::from` composition route \
19825 through the substrate-primitive `DepList::as_str` \
19826 accessor without a spurious `Copy` deref (which would \
19827 only be reachable through the owned-input \
19828 `From<DepList> for std::sync::Arc<str>` axis by first \
19829 calling `.copied()` on the iterator)"
19830 );
19831 }
19832
19833 #[test]
19834 fn dep_list_author_keys_covers_every_arm() {
19835 // Load-bearing pin on the substrate-canonical
19836 // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
19837 // on the `:`-prefixed kebab-case tatara-lisp author-surface
19838 // key axis: every variant of the sibling
19839 // [`super::DepList::ALL`] exhaustive-iteration surface must
19840 // project through [`super::DepList::as_str`] onto an entry the
19841 // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
19842 // roster's length must byte-equal `super::DepList::ALL.len()`
19843 // so a silent skew between the [`super::DepList::as_str`]
19844 // match's arm-set and the roster's arm-set trips here at
19845 // caixa-core test time rather than at a downstream M4
19846 // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
19847 // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
19848 // a `feira dep --list …` "did you mean" hint drift / a
19849 // downstream [`super::DepError`] widening's typed `list:
19850 // DepList` carry that fans on the enum through a stale
19851 // accepted-set. A future arm addition (a `:build-dep` or
19852 // `:tool-dep` third list once the substrate grows Cargo-style
19853 // split-graphs — both trajectory items the sibling
19854 // [`super::DepList::from_wire`] doc block already names)
19855 // extends [`super::DepList::ALL`] as a single edit and this
19856 // pin sweeps the new arm by iteration; the paired
19857 // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
19858 // or this assertion trips. Every entry is further pinned to
19859 // open with the ASCII `:` byte (the tatara-lisp author-surface
19860 // keyword marker) so a silent collapse of the author-key axis
19861 // with any hypothetical peer un-prefixed wire-form axis (an
19862 // entry byte-identical to a sibling `deps` / `deps-dev`
19863 // bare-kebab byte-string that would let an author-key-axis
19864 // consumer accept the un-prefixed vocabulary) trips here
19865 // rather than at a downstream consumer's
19866 // vocabulary-collision miss.
19867 //
19868 // Peer of the sibling
19869 // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
19870 // (bd708bd) /
19871 // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
19872 // (427fe75) /
19873 // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
19874 // (3033f45) /
19875 // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
19876 // (ce9412b) /
19877 // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
19878 // (3e5b194) /
19879 // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
19880 // (9d9f585) /
19881 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
19882 // (b553ec9) /
19883 // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
19884 // (1898d77) /
19885 // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
19886 // (cc42c0e) pins — the same closed-set exhaustive-roster
19887 // coverage discipline extended here onto the two-list dep-graph
19888 // closed-set typed enum, the ninth substrate-side closed-set
19889 // typed enum on the roster axis and the last unlifted
19890 // `&'static str`-carrying closed-set typed enum on the top-
19891 // level manifest surface to converge onto the discipline.
19892 //
19893 // Fail-before-pass-after locally verified by mutating one arm
19894 // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
19895 // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
19896 // `":deps-dev"` to `":deps_dev"`) — the length pin still
19897 // passes but the `contains` check fires on the mutated arm;
19898 // and by shortening the roster to one entry — the length pin
19899 // fires first.
19900 assert_eq!(
19901 super::DepList::AUTHOR_KEYS.len(),
19902 super::DepList::ALL.len(),
19903 "DepList::AUTHOR_KEYS.len() must byte-equal \
19904 DepList::ALL.len() — a mismatch means the roster and \
19905 the enum's arm-set have drifted; downstream consumers \
19906 that fan through both will silently disagree on the \
19907 accepted arm-set"
19908 );
19909 for &variant in super::DepList::ALL {
19910 let key = variant.as_str();
19911 assert!(
19912 super::DepList::AUTHOR_KEYS.contains(&key),
19913 "DepList::{variant:?}.as_str() = {key:?} must be a \
19914 member of DepList::AUTHOR_KEYS — the emitter and the \
19915 roster have drifted out of lockstep"
19916 );
19917 }
19918 for tag in super::DepList::AUTHOR_KEYS {
19919 let first = tag.chars().next().unwrap_or_else(|| {
19920 panic!(
19921 "DepList::AUTHOR_KEYS entry {tag:?} must be a \
19922 non-empty `:`-prefixed kebab-case tatara-lisp \
19923 author-surface key byte-string"
19924 )
19925 });
19926 assert_eq!(
19927 first, ':',
19928 "DepList::AUTHOR_KEYS entry {tag:?} must open with \
19929 the ASCII `:` byte (tatara-lisp author-surface \
19930 keyword marker) — an un-prefixed entry would \
19931 collide the roster with any hypothetical peer bare-\
19932 kebab wire-form axis a downstream consumer might \
19933 disambiguate against"
19934 );
19935 }
19936 // Pin the exact two-arm roster in declaration order so a
19937 // future arm-swap on either the roster or the paired
19938 // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
19939 // arm-key mapping that leaves both the length pin and the
19940 // membership pin passing on their own) trips at caixa-core
19941 // test time under `assert_eq!`. Order matches variant
19942 // declaration order verbatim (`Prod` → `Dev`) so the roster
19943 // is the canonical ordering every listing / rendering
19944 // consumer defers to. Same declaration-order pin the sibling
19945 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
19946 // (b553ec9) closes on the M3 `:politicas :rate-limit`
19947 // canonical-suffix axis.
19948 assert_eq!(
19949 super::DepList::AUTHOR_KEYS,
19950 &[
19951 crate::render::DEP_AUTHOR_KEY_DEPS,
19952 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19953 ],
19954 "DepList::AUTHOR_KEYS must enumerate every arm's \
19955 author-surface key exactly once, in variant declaration \
19956 order (Prod → Dev)"
19957 );
19958 }
19959}
19960
19961#[cfg(test)]
19962mod dep_source_is_variant_tests {
19963 use super::*;
19964
19965 fn all_variants() -> Vec<(DepSource, &'static str)> {
19966 vec![
19967 (
19968 DepSource::Git {
19969 repo: "github:pleme-io/caixa-teia".into(),
19970 tag: Some("v0.1.0".into()),
19971 rev: None,
19972 branch: None,
19973 },
19974 "Git",
19975 ),
19976 (
19977 DepSource::Path {
19978 caminho: "../caixa-teia".into(),
19979 },
19980 "Path",
19981 ),
19982 ]
19983 }
19984
19985 fn predicate_row(s: &DepSource) -> [bool; 2] {
19986 [s.is_git(), s.is_path()]
19987 }
19988
19989 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
19990 // derive-generated per-arm predicate partition — for every variant
19991 // in `all_variants()`, the observed 2-slot predicate row must equal
19992 // a one-hot row with the `true` at exactly the same index as the
19993 // variant's declaration order. Expected rows are generated live
19994 // from the enumeration rather than transcribed by hand, so a
19995 // copy-paste flip that reroutes one arm through the wrong predicate
19996 // lane trips at the identity-diagonal assertion the way every peer
19997 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
19998 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
19999 // / [`crate::upgrade::UpgradeInstruction`] /
20000 // [`crate::aplicacao::PlacementStrategy`] /
20001 // [`crate::aplicacao::RateLimitUnit`] /
20002 // [`crate::aplicacao::WitTarget`] /
20003 // [`crate::render::PathShapeViolation`] partition pin already does.
20004 #[test]
20005 fn dep_source_is_variant_predicates_partition_the_arm_set() {
20006 let variants = all_variants();
20007 for (idx, (variant, name)) in variants.iter().enumerate() {
20008 let observed = predicate_row(variant);
20009 let mut expected = [false; 2];
20010 expected[idx] = true;
20011 assert_eq!(
20012 observed, expected,
20013 "DepSource::{name} at declaration-order slot {idx} must \
20014 satisfy exactly one is_* predicate (its own); observed \
20015 row must equal the one-hot expected row — a drift \
20016 would silently reroute one `:fonte`-arm consumer \
20017 through the wrong predicate lane"
20018 );
20019 }
20020 }
20021
20022 // Byte-parity pin on the two field-agnostic `matches!` shapes the
20023 // per-arm arm-discriminator predicates replace at any future
20024 // consumer site (a `:fonte`-shape-only lint rule that flags path
20025 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
20026 // a future admission-webhook that rejects `:fonte` shapes outside
20027 // the `is_git()` accept-set, a caixa-lacre indexing pass that
20028 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
20029 // Refuses a future accidental split between the derived predicate
20030 // and its `matches!` shape — a hand-rolled shadow impl that
20031 // overrides one path, an accidental rebrand that leaves one
20032 // consumer on the raw `matches!` form — on the two load-bearing
20033 // `:fonte`-arm-discriminator axes every downstream substrate
20034 // consumer of the dep-source axis keys off.
20035 #[test]
20036 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
20037 for (variant, name) in all_variants() {
20038 let via_matches_git = matches!(variant, DepSource::Git { .. });
20039 let via_predicate_git = variant.is_git();
20040 assert_eq!(
20041 via_predicate_git, via_matches_git,
20042 "DepSource::{name}.is_git() must byte-equal \
20043 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
20044 future converged consumer site would silently \
20045 disagree with its pre-lift shape"
20046 );
20047 let via_matches_path = matches!(variant, DepSource::Path { .. });
20048 let via_predicate_path = variant.is_path();
20049 assert_eq!(
20050 via_predicate_path, via_matches_path,
20051 "DepSource::{name}.is_path() must byte-equal \
20052 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
20053 future converged consumer site would silently \
20054 disagree with its pre-lift shape"
20055 );
20056 }
20057 }
20058
20059 // Cross-pin against every constructor path that materializes a
20060 // [`DepSource`] shape today (the [`DepSource::default_github`]
20061 // resolver-side fallback that materializes an unpinned
20062 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
20063 // surface constructor that materializes a pinned `:tag`-carrying
20064 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
20065 // fixture family builds inline). Every constructor's return must
20066 // satisfy the arm-discriminator predicate the constructor's
20067 // variant name matches — a future constructor addition (an
20068 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
20069 // enclosing docstring already names as a trajectory item) surfaces
20070 // as a build-time failure that names the offending drift when its
20071 // return arm doesn't route through the paired predicate.
20072 #[test]
20073 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
20074 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
20075 assert!(
20076 via_default_github.is_git(),
20077 "DepSource::default_github must materialize a Git-arm shape — \
20078 a future constructor that routed through a non-Git arm \
20079 (a registry-fetch pin, a `DepSource::Feira` promotion) \
20080 would silently split the resolver's unpinned-shorthand \
20081 materializer from the sole_pin() precedence cascade"
20082 );
20083 assert!(
20084 !via_default_github.is_path(),
20085 "DepSource::default_github must NOT materialize a Path-arm \
20086 shape — the paired negation pin"
20087 );
20088
20089 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
20090 .fonte
20091 .expect("Dep::git materializes a Some(fonte)");
20092 assert!(
20093 via_dep_git.is_git(),
20094 "Dep::git's `:fonte` materialization must land on the Git \
20095 arm — the author-surface pinned-git constructor's return \
20096 must route through the paired predicate"
20097 );
20098 assert!(!via_dep_git.is_path(), "paired negation pin");
20099
20100 let via_path = DepSource::Path {
20101 caminho: "../caixa-teia".into(),
20102 };
20103 assert!(
20104 via_path.is_path(),
20105 "the dev-mode Path-arm materialization must satisfy is_path()"
20106 );
20107 assert!(!via_path.is_git(), "paired negation pin");
20108 }
20109
20110 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
20111 // String, reason: String }` three-slot envelope on `DepError`,
20112 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
20113 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
20114 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
20115 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
20116 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
20117 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
20118
20119 #[test]
20120 fn versao_invalid_ctor_matches_struct_literal_wrap() {
20121 assert_eq!(
20122 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
20123 DepError::VersaoInvalid {
20124 nome: "caixa-teia".to_string(),
20125 versao: "^0..1".to_string(),
20126 reason: "invalid comparator".to_string(),
20127 },
20128 "versao_invalid ctor must produce byte-equal \
20129 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
20130 );
20131 }
20132
20133 #[test]
20134 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
20135 assert_eq!(
20136 DepError::fonte_repo_shape(
20137 "caixa-teia",
20138 "-upload-pack=evil",
20139 "leading dash rejected".to_string(),
20140 ),
20141 DepError::FonteRepoShape {
20142 nome: "caixa-teia".to_string(),
20143 repo: "-upload-pack=evil".to_string(),
20144 reason: "leading dash rejected".to_string(),
20145 },
20146 "fonte_repo_shape ctor must produce byte-equal \
20147 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
20148 );
20149 }
20150
20151 #[test]
20152 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
20153 assert_eq!(
20154 DepError::caracteristica_invalid(
20155 "caixa-teia",
20156 "bad feature!",
20157 "embedded space rejected".to_string(),
20158 ),
20159 DepError::CaracteristicaInvalid {
20160 nome: "caixa-teia".to_string(),
20161 caracteristica: "bad feature!".to_string(),
20162 reason: "embedded space rejected".to_string(),
20163 },
20164 "caracteristica_invalid ctor must produce byte-equal \
20165 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
20166 );
20167 }
20168
20169 #[test]
20170 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
20171 // Cross-axis routing pin: sweep the three constructor input axes
20172 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
20173 // distinct-per-axis fixtures against every generated arm in the
20174 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
20175 // lowercase / trim / truncate on the two `&str` axes — a silent
20176 // field swap between `nome`, the middle `<axis>` field, and
20177 // `reason`, or a `reason` axis silently rerouted through
20178 // `.to_string()` instead of forwarded owned — surfaces here rather
20179 // than at a downstream diagnostic-shape mismatch. Peer of the
20180 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
20181 // through_to_string` (0e35793) cross-axis routing pin on the same
20182 // envelope's `{ nome, caminho, byte }` three-slot family and of
20183 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
20184 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
20185 // — extended here onto the `{ nome, <axis>: String, reason:
20186 // String }` three-slot envelope so every substrate-primitive ctor
20187 // family in caixa-core's `DepError` envelope guarantees each field
20188 // routes the caller's value verbatim through `.to_string()` (or
20189 // owned-forward for `reason: String`) in declared field order.
20190 // Distinct-per-axis fixtures rule out any two-axis swap
20191 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
20192 // same-fixture-per-axis pin.
20193 let nome = "sibling-teia";
20194 let axis = "distinct-axis-value";
20195 let reason = "distinct rejection sentence".to_string();
20196 assert_eq!(
20197 DepError::versao_invalid(nome, axis, reason.clone()),
20198 DepError::VersaoInvalid {
20199 nome: nome.to_string(),
20200 versao: axis.to_string(),
20201 reason: reason.clone(),
20202 },
20203 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
20204 `reason` → `reason` in declared field order",
20205 );
20206 assert_eq!(
20207 DepError::fonte_repo_shape(nome, axis, reason.clone()),
20208 DepError::FonteRepoShape {
20209 nome: nome.to_string(),
20210 repo: axis.to_string(),
20211 reason: reason.clone(),
20212 },
20213 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
20214 `reason` → `reason` in declared field order",
20215 );
20216 assert_eq!(
20217 DepError::caracteristica_invalid(nome, axis, reason.clone()),
20218 DepError::CaracteristicaInvalid {
20219 nome: nome.to_string(),
20220 caracteristica: axis.to_string(),
20221 reason: reason.clone(),
20222 },
20223 "caracteristica_invalid must route `nome` → `nome`, \
20224 `axis` → `caracteristica`, `reason` → `reason` in declared \
20225 field order",
20226 );
20227 }
20228
20229 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
20230 // two-slot envelope on `DepError`, missing rung between
20231 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
20232 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
20233 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
20234 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
20235 // two-slot `{ nome, list: &'static str }` envelope (same slot
20236 // count, `&'static str` axis instead of owned `String` axis).
20237
20238 #[test]
20239 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
20240 assert_eq!(
20241 DepError::fonte_pin_empty("caixa-teia", ":tag"),
20242 DepError::FontePinEmpty {
20243 nome: "caixa-teia".to_string(),
20244 pin: ":tag".to_string(),
20245 },
20246 "fonte_pin_empty ctor must produce byte-equal \
20247 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
20248 on the same `(&str, &str)` fixture",
20249 );
20250 }
20251
20252 #[test]
20253 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
20254 assert_eq!(
20255 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
20256 DepError::FontePinAmbiguous {
20257 nome: "caixa-teia".to_string(),
20258 pins: ":tag, :rev".to_string(),
20259 },
20260 "fonte_pin_ambiguous ctor must produce byte-equal \
20261 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
20262 wrap on the same `(&str, &str)` fixture",
20263 );
20264 }
20265
20266 #[test]
20267 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
20268 assert_eq!(
20269 DepError::caracteristica_duplicate("caixa-teia", "http"),
20270 DepError::CaracteristicaDuplicate {
20271 nome: "caixa-teia".to_string(),
20272 caracteristica: "http".to_string(),
20273 },
20274 "caracteristica_duplicate ctor must produce byte-equal \
20275 `DepError::CaracteristicaDuplicate` to the pre-lift \
20276 struct-literal wrap on the same `(&str, &str)` fixture",
20277 );
20278 }
20279
20280 #[test]
20281 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
20282 // Owned-`String` routing pin: thread the real
20283 // `set.join(", ")` `String` carrier through the ctor's
20284 // `&str`-parameter Deref coercion, so the ambiguity-arm
20285 // wire-up site's actual `&set.join(", ")` shape stays
20286 // byte-equal to a direct `":tag, :rev"` literal. A future
20287 // parameter-shape change silently dropping the Deref
20288 // coercion route (e.g., a switch to `impl Into<String>`)
20289 // surfaces here rather than at the wire-up's compile
20290 // error far from the ctor definition.
20291 let set: Vec<&'static str> = vec![":tag", ":rev"];
20292 let joined: String = set.join(", ");
20293 assert_eq!(
20294 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
20295 DepError::FontePinAmbiguous {
20296 nome: "caixa-teia".to_string(),
20297 pins: ":tag, :rev".to_string(),
20298 },
20299 "fonte_pin_ambiguous ctor must accept an owned-`String` \
20300 `&set.join(\", \")` carrier via Deref coercion — the exact \
20301 shape the ambiguity-arm wire-up site passes into it",
20302 );
20303 }
20304
20305 #[test]
20306 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
20307 // Cross-axis routing pin: sweep the two constructor input axes
20308 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
20309 // fixtures against every generated arm in the
20310 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
20311 // trim / truncate at codegen time — a silent field swap between
20312 // `nome` and the middle `<axis>` field, or a `<axis>` axis
20313 // silently rerouted through the wrong field on any one variant
20314 // — surfaces here rather than at a downstream diagnostic-shape
20315 // mismatch. Peer of the sibling
20316 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
20317 // (6f5e0cd) pin on the same envelope's peer two-slot family
20318 // (`{ nome, list: &'static str }`) and of the sibling
20319 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20320 // (5621f8a) pin on the same envelope's three-slot `{ nome,
20321 // <axis>: String, reason: String }` family — extended here onto
20322 // the `{ nome, <axis>: String }` two-slot envelope so the last
20323 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
20324 // ladder guarantees each field routes the caller's value
20325 // verbatim through `.to_string()` in declared field order.
20326 // Distinct-per-axis fixtures rule out any two-axis swap
20327 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
20328 // per-axis pin.
20329 let nome = "sibling-teia";
20330 let axis = "distinct-axis-value";
20331 assert_eq!(
20332 DepError::fonte_pin_empty(nome, axis),
20333 DepError::FontePinEmpty {
20334 nome: nome.to_string(),
20335 pin: axis.to_string(),
20336 },
20337 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
20338 in declared field order",
20339 );
20340 assert_eq!(
20341 DepError::fonte_pin_ambiguous(nome, axis),
20342 DepError::FontePinAmbiguous {
20343 nome: nome.to_string(),
20344 pins: axis.to_string(),
20345 },
20346 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
20347 in declared field order",
20348 );
20349 assert_eq!(
20350 DepError::caracteristica_duplicate(nome, axis),
20351 DepError::CaracteristicaDuplicate {
20352 nome: nome.to_string(),
20353 caracteristica: axis.to_string(),
20354 },
20355 "caracteristica_duplicate must route `nome` → `nome`, \
20356 `axis` → `caracteristica` in declared field order",
20357 );
20358 }
20359
20360 #[test]
20361 fn nome_invalid_ctor_matches_struct_literal_wrap() {
20362 // Equivalence pin: the ctor produces byte-equal
20363 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
20364 // literal that cloned the offending `:deps :nome` verbatim and
20365 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
20366 // owned `reason` payload at the caller site inside
20367 // [`Dep::validate`]. Guards any future field-addition /
20368 // reordering / accessor-return tweak on the variant. Sibling of
20369 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
20370 // (below) and the sibling three-slot
20371 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20372 // pin on the same envelope's three-slot `{ nome, <axis>: String,
20373 // reason: String }` family.
20374 let nome = "Caixa-Teia";
20375 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
20376 let via_ctor = DepError::nome_invalid(nome, reason.clone());
20377 let via_literal = DepError::NomeInvalid {
20378 nome: nome.to_string(),
20379 reason,
20380 };
20381 assert_eq!(
20382 via_ctor, via_literal,
20383 "nome_invalid(nome, reason) must byte-equal the open-coded \
20384 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
20385 );
20386 assert_eq!(
20387 via_ctor.to_string(),
20388 via_literal.to_string(),
20389 "Display byte-string must byte-equal the open-coded struct-literal"
20390 );
20391 }
20392
20393 #[test]
20394 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
20395 // Boundary-sweep pin on the ctor's two-slot projection: sweep
20396 // the two ctor input axes (`nome: &str`, `reason: String`)
20397 // through distinct-per-axis fixtures against a representative
20398 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
20399 // wrapper-side silent lowercase / trim / truncate at codegen
20400 // time — a silent field swap between `nome` and `reason`, an
20401 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
20402 // divergence on the `reason` axis — surfaces at caixa-core
20403 // build time rather than at a downstream diagnostic consumer
20404 // that reads `err.nome` / `err.reason` back and gets a different
20405 // value than the one it stored. Peer of the sibling
20406 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
20407 // (7f7c950) pin on the same envelope's peer two-slot family
20408 // (`{ nome, <axis>: String }`) — extended here onto the
20409 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
20410 // variant carries. Distinct-per-axis fixtures rule out any
20411 // two-axis swap (`nome` ↔ `reason`) that would still pass a
20412 // same-fixture-per-axis pin. The sweep list carries a mixed
20413 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
20414 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
20415 // over-63-byte) so a future silent per-input normalization
20416 // surfaces on the arm that diverges.
20417 for nome in [
20418 "Caixa-Teia",
20419 "caixa_teia",
20420 "caixa.teia",
20421 "-caixa-teia",
20422 "caixa-teia-",
20423 "caixa/teia",
20424 &"a".repeat(64),
20425 ] {
20426 let reason = crate::render::is_dns_1123_label(nome)
20427 .expect_err("fixture must be a DNS-1123-refused label");
20428 let via_ctor = DepError::nome_invalid(nome, reason.clone());
20429 let DepError::NomeInvalid {
20430 nome: stored_nome,
20431 reason: stored_reason,
20432 } = via_ctor
20433 else {
20434 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
20435 };
20436 assert_eq!(
20437 stored_nome, nome,
20438 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
20439 );
20440 assert_eq!(
20441 stored_reason, reason,
20442 "reason slot must forward the owned `String` verbatim for {nome:?}"
20443 );
20444 }
20445 }
20446
20447 #[test]
20448 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
20449 // End-to-end pin: the sole in-crate wire-up site
20450 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
20451 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
20452 // the ctor's output on the same DNS-1123-refused `:deps :nome`
20453 // fixture, with identical `Display` rendering. A future silent
20454 // de-lift of the wire-up back to the open-coded struct-literal
20455 // trips this test at caixa-core build time rather than at a
20456 // downstream diagnostic consumer far from the wire-up commit.
20457 // Sibling of the peer
20458 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
20459 // pin on the same wire-up — extended here from a `matches!`
20460 // shape check to a byte-identity + Display parity route through
20461 // the ctor.
20462 let d = Dep::simple("Caixa_Teia", "^0.1");
20463 let observed = d.validate().unwrap_err();
20464 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
20465 .expect_err("fixture must be DNS-1123-refused");
20466 let expected = DepError::nome_invalid("Caixa_Teia", reason);
20467 assert_eq!(
20468 observed, expected,
20469 "Dep::validate's DNS-1123 refusal arm must byte-equal \
20470 nome_invalid(nome, reason)"
20471 );
20472 assert_eq!(
20473 observed.to_string(),
20474 expected.to_string(),
20475 "Display byte-string parity"
20476 );
20477 }
20478}