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/// Trait-idiomatic *owned-input, [`std::rc::Rc<str>`] output* forward
4312/// projection on the outside-M3 caixa-core two-list dep-graph
4313/// [`DepList`] closed-set fieldless typed enum — routes byte-for-byte
4314/// through the substrate-primitive [`DepList::as_str`] `pub const fn`
4315/// accessor via [`std::rc::Rc::<str>::from`] on the returned
4316/// `&'static str`, so every consumer that binds a [`DepList`] through
4317/// the standard-library `.into()` / `From::from` surfaces onto the
4318/// non-atomic single-threaded-reference-counted `std::rc::Rc<str>` axis
4319/// reaches the same two lifted
4320/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4321/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4322/// strings the sibling `{&'static str, String, Cow<'static, str>,
4323/// Box<str>, std::sync::Arc<str>}` return-shape axes already return.
4324///
4325/// Rust's standard library carries `impl From<&str> for
4326/// std::rc::Rc<str>` and `impl From<String> for std::rc::Rc<str>` but
4327/// no blanket `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and
4328/// the [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait tables
4329/// are disjoint — so a single-threaded caixa-core dep-graph pass whose
4330/// per-list `:deps` / `:deps-dev` bucket key is cloned across intra-
4331/// pass tree nodes through the cheaper non-atomic [`std::rc::Rc<str>`]
4332/// refcount (the atomically-reference-counted [`std::sync::Arc<str>`]
4333/// axis cannot elide the CAS-fence cost within a single-threaded
4334/// caixa-core pass), a future `feira dep --list <deps|deps-dev>`-
4335/// side per-list histogram-column emitter keyed on a shared-ownership
4336/// per-arm bucket key, a future `caixa-lsp`-side dep-graph quick-fix
4337/// panel composer holding a shared per-list canonical `:`-prefixed
4338/// kebab tag across intra-file dep tree nodes without atomic contention
4339/// — reaches the substrate primitive through this impl and no other.
4340/// A paired `std::rc::Rc::<str>::from(list.as_str())` open-code has no
4341/// compile-time link back to the substrate primitive, and a two-step
4342/// `std::rc::Rc::<str>::from(String::from(list))` composition through
4343/// the owned-`String` axis allocates twice (once into the intermediate
4344/// `String`, once into the [`std::rc::Rc<str>`] on the `From<String>`
4345/// conversion) where the single-step trait impl allocates once.
4346///
4347/// Opens the caixa-core-internal tier of the [`std::rc::Rc<str>`]
4348/// forward-projection campaign onto the caixa-core two-list dep-graph
4349/// peer, following the trajectory the paired top-level
4350/// [`crate::CaixaKind`] pair (e04aff0), the second caixa-core-internal
4351/// peer [`crate::dialeto::CaixaDialeto`] pair (c5595e5), the render-
4352/// side path-shape-diagnostic peer [`crate::render::PathShapeViolation`]
4353/// pair (31fc43e), the M3-mesh-primitive-defining
4354/// [`crate::aplicacao::PlacementStrategy`] pair (91b4c92), and the
4355/// outside-`caixa-core` peers (`InvariantKind` c71818b, `ArchVerdict`
4356/// cc759ef, `Severity` d7c58b6, `FixSafety` 046cc5f) walked before it
4357/// on the same axis — closes the caixa-core-internal tier's third-peer
4358/// slot after the render-side [`crate::render::PathShapeViolation`]
4359/// second-peer pair. Leaves the outside-`caixa-core` peers
4360/// (`caixa_theme::Semantic`, `caixa_provedor::FerriteRuntime`) as the
4361/// campaign's next multi-peer targets on the [`std::rc::Rc<str>`] axis.
4362///
4363/// Pinned load-bearing by
4364/// [`tests::dep_list_from_into_rc_str_routes_through_as_str_accessor`]
4365/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4366/// [`DepList::ALL`] emit-set on the owned-input surface, plus a
4367/// blanket-derived [`Into`] shape witness and cross-axis byte-parity
4368/// pins against the sibling owned-input `{&'static str, String,
4369/// Cow<'static, str>, Box<str>, std::sync::Arc<str>}` return-shape
4370/// axes).
4371impl From<DepList> for std::rc::Rc<str> {
4372 fn from(list: DepList) -> std::rc::Rc<str> {
4373 std::rc::Rc::<str>::from(list.as_str())
4374 }
4375}
4376
4377/// Trait-idiomatic *borrowed-input, [`std::rc::Rc<str>`] output*
4378/// forward projection on the outside-M3 caixa-core two-list dep-graph
4379/// [`DepList`] closed-set fieldless typed enum — the borrowed-input
4380/// companion to the paired owned-input
4381/// [`From<DepList> for std::rc::Rc<str>`] impl immediately above,
4382/// closing the `{Self, &Self}` input-shape corner of the caixa-core-
4383/// internal tier of the [`std::rc::Rc<str>`] axis on the two-list
4384/// dep-graph peer. Routes byte-for-byte through the substrate-primitive
4385/// [`DepList::as_str`] `pub const fn` accessor via
4386/// [`std::rc::Rc::<str>::from`] on the returned `&'static str`, so a
4387/// `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped pipe
4388/// (whose iterator over `&'static [DepList]` yields `&DepList` by
4389/// construction) reaches the same two lifted
4390/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4391/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4392/// strings the paired owned-input axis and the sibling
4393/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>,
4394/// std::sync::Arc<str>}` forward-projection corner already return.
4395///
4396/// Rust's standard library carries no blanket
4397/// `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a `Copy`-
4398/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
4399/// input axis is a distinct trait-idiomatic surface that the pipe
4400/// shape [`DepList::ALL`]`.iter().map(std::rc::Rc::<str>::from)`
4401/// reaches through this impl and no other — without it, the same pipe
4402/// would force a spurious [`Copy`] deref
4403/// (`std::rc::Rc::<str>::from((*list).as_str())`) or a `.copied()`
4404/// restatement whose type bounds have no compile-time link back to
4405/// the substrate primitive, and a `let key: std::rc::Rc<str> =
4406/// (&list).into();`-shaped call site would force an explicit [`Copy`]
4407/// deref (`std::rc::Rc::<str>::from(*list)`) or a
4408/// `std::rc::Rc::<str>::from(list.as_str())` open-code with the same
4409/// defect.
4410///
4411/// Closes the `{Self, &Self}` input-shape corner on the third caixa-
4412/// core-internal closed-set fieldless typed enum peer of the
4413/// substrate-wide trait-idiomatic [`std::rc::Rc<str>`] forward-
4414/// projection campaign, matching the trajectory the paired
4415/// [`crate::CaixaKind`] (e04aff0),
4416/// [`crate::dialeto::CaixaDialeto`] (c5595e5), and
4417/// [`crate::render::PathShapeViolation`] (31fc43e) pairs walked before
4418/// it on the caixa-core-internal tier of the same axis. Leaves the
4419/// outside-`caixa-core` peers ([`caixa_theme::Semantic`],
4420/// [`caixa_provedor::FerriteRuntime`]) as the campaign's next multi-
4421/// peer targets on the [`std::rc::Rc<str>`] axis — this commit gives
4422/// them a fifth-peer `{Self, &Self}` caixa-core-internal-tier template
4423/// to converge onto.
4424///
4425/// Pinned load-bearing by
4426/// [`tests::dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor`]
4427/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4428/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4429/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
4430/// against the paired owned-input
4431/// [`From<DepList> for std::rc::Rc<str>`] and the sibling borrowed-
4432/// input `{&'static str, String, Cow<'static, str>, Box<str>,
4433/// std::sync::Arc<str>}` return-shape axes, and a
4434/// `.iter().map(std::rc::Rc::<str>::from)` pipe witness over
4435/// [`DepList::ALL`] that resolves through the borrowed-input axis
4436/// without a spurious [`Copy`] deref).
4437impl From<&DepList> for std::rc::Rc<str> {
4438 fn from(list: &DepList) -> std::rc::Rc<str> {
4439 std::rc::Rc::<str>::from(list.as_str())
4440 }
4441}
4442
4443/// Trait-idiomatic [`std::str::FromStr`] parse axis on the two-list
4444/// dep-graph [`DepList`] closed-set typed enum — routes byte-for-byte
4445/// through the paired [`TryFrom<&str> for DepList`] impl (which in
4446/// turn routes through the substrate-primitive [`DepList::from_wire`]
4447/// `Option<Self>` accessor), so `"...".parse::<DepList>()` /
4448/// `<DepList as FromStr>::from_str(…)` reaches the same two-arm
4449/// accept-set the sibling method-named [`DepList::from_wire`]
4450/// resolver and the paired [`TryFrom<&str>`] impl already resolve
4451/// against.
4452///
4453/// Opens the trait-idiomatic `str::parse`-axis campaign on the
4454/// substrate-wide closed-set fieldless typed-enum surface. The
4455/// substrate already carries three peers per enum on the projection
4456/// star: the method-named substrate-primitive pair
4457/// ([`DepList::as_str`] `pub const fn` accessor + [`DepList::from_wire`]
4458/// `Option<Self>` resolver), the emit-set trait pair
4459/// ([`std::fmt::Display`], [`AsRef<str>`], the owned-input +
4460/// borrowed-input `{&'static str, String, Cow<'static, str>, Box<str>,
4461/// std::sync::Arc<str>}` `From<{Self,&Self}>` return-shape matrix),
4462/// and the parse-set `TryFrom<&str>` reverse trait. [`FromStr`] is the
4463/// canonical Rust-idiomatic parse-set entry point every stdlib-shaped
4464/// consumer reaches for — [`str::parse::<T>()`] is a
4465/// `T: FromStr`-bounded generic, not a `T: for<'a> TryFrom<&'a str>`-
4466/// bounded one — so lifting [`FromStr`] onto the closed-set enum
4467/// unlocks the `.parse::<DepList>()` short-form on every consumer
4468/// (a future `feira dep --list <deps|deps-dev>` clap-style arg-parse
4469/// composes `arg.parse::<DepList>()`; a `serde` string-tagged
4470/// deserializer routes through the same `FromStr` bound; the future
4471/// M4 admission webhook's `Deserialize` derive reaches the enum
4472/// through its `FromStr` impl via `serde_with::DisplayFromStr`).
4473///
4474/// The impl trivially delegates to the paired [`TryFrom<&str>`] —
4475/// same `type Err = ()` deliberate-deferral shape the sibling
4476/// reverse-projection trait carries — so both trait-idiomatic
4477/// parse-axis paths (`TryFrom<&str>` and `FromStr::from_str`) resolve
4478/// to the same two-arm accept-set by construction. A future accept-set
4479/// widening (a `":packages"` rebrand, a `":dev-deps"` alias) reaches
4480/// every parse path through one edit on the substrate-primitive
4481/// [`DepList::from_wire`] accessor, not a coordinated rewrite across
4482/// the two reverse-projection trait impls.
4483///
4484/// Pinned load-bearing by
4485/// [`tests::dep_list_from_str_routes_through_try_from_str_impl`]
4486/// (byte-parity pin across the two-arm accept-set + delegated-
4487/// `.parse()`-projection witness) and
4488/// [`tests::dep_list_from_str_rejects_unknown_byte_strings`]
4489/// (rejection witness against silent accept-set widening).
4490impl std::str::FromStr for DepList {
4491 type Err = ();
4492
4493 fn from_str(s: &str) -> Result<Self, Self::Err> {
4494 <Self as TryFrom<&str>>::try_from(s)
4495 }
4496}
4497
4498/// Substrate-canonical [`AsRef<[u8]>`] byte-view projection on the
4499/// caixa-core-internal two-list dep-graph [`DepList`] closed-set
4500/// fieldless typed enum — routes byte-for-byte through the substrate-
4501/// primitive [`DepList::as_str`] `pub const fn` accessor via
4502/// [`str::as_bytes`] on the returned `&'static str`, so any future
4503/// consumer that binds a [`DepList`] through a standard-library
4504/// `<T: AsRef<[u8]>>` trait bound reaches the same lifted
4505/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4506/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` roster
4507/// the paired sibling [`AsRef<str>`] / [`std::fmt::Display`] /
4508/// [`DepList::as_str`] / `{Self, &Self} × {&'static str, String,
4509/// Cow<'static, str>, Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
4510/// str-view + reverse-projection surfaces already return — through the
4511/// byte-view axis, which the str-view axes cannot express.
4512///
4513/// The primary compounding target is the same [`crate`]-adjacent
4514/// [`caixa-lacre`](../../caixa-lacre/) BLAKE3 content-address closure
4515/// the peer [`crate::CaixaKind`] (69d8d86) and
4516/// [`crate::dialeto::CaixaDialeto`] (8151347) `AsRef<[u8]>` impls open
4517/// onto: [`blake3::hash`] and [`blake3::Hasher::update`] both bind
4518/// their input through `impl AsRef<[u8]>`, so any future per-caixa
4519/// content-address tag that folds a dep-list discriminator byte-tag
4520/// into the [`crate::Lacre`] closure (a hypothetical
4521/// `hasher.update(list);`-shape composition on the per-caixa BLAKE3
4522/// closure builder that partitions the runtime-closure `:deps` closure
4523/// from the dev-only-closure `:deps-dev` closure at content-address
4524/// time so a downstream `Lacre` consumer can key its per-list build
4525/// cache off the typed discriminator directly rather than the sibling
4526/// `&'static str` wire scalar) reaches the substrate-primitive
4527/// [`DepList::as_str`] accessor through this impl and no other —
4528/// without it, every such call site opens the two-hop composition
4529/// `list.as_str().as_bytes()` whose byte-tail has no compile-time link
4530/// back to the byte-projection axis. Peer consumer paths on the byte-
4531/// view axis: any future [`std::io::Write::write_all`]-bound
4532/// `feira dep census` per-list histogram-column emitter (whose input
4533/// binds through `impl AsRef<[u8]>`), any future byte-keyed
4534/// [`std::collections::HashMap`] `<K: AsRef<[u8]>, V>` per-list tally
4535/// lookup whose entry-key trait bound rules out the sibling
4536/// [`AsRef<str>`] str-view projection, and any future
4537/// `ring::digest::Context::update` / `sha2::Sha256::update` /
4538/// `blake3::Hasher::update` byte-input surface on any future per-list
4539/// content-address digest.
4540///
4541/// Rust's standard library carries `impl AsRef<[u8]> for str` and
4542/// `impl AsRef<[u8]> for String`, so the two-hop composition
4543/// `list.as_str().as_bytes()` (or, equivalently,
4544/// `AsRef::<str>::as_ref(&list).as_bytes()`) is reachable through the
4545/// pre-existing str-view axis alone. But that two-hop shape has no
4546/// compile-time link back to the byte-projection axis, forces every
4547/// downstream `<T: AsRef<[u8]>>`-bound consumer to open-code the two-
4548/// hop composition at every call site rather than pass a [`DepList`]
4549/// through the trait bound directly, and admits a silent split
4550/// whenever a future call site takes the sibling [`std::fmt::Display`]
4551/// or [`From<Self> for String`] axis (whose `.as_bytes()` byte-tails
4552/// byte-equal `as_str`'s by construction but carry no compile-time
4553/// byte-view surface, since `Display` returns a formatter and `String`
4554/// allocates). The lifted single-hop impl closes the byte-view axis so
4555/// every future `<T: AsRef<[u8]>>`-bound consumer reaches the
4556/// substrate primitive through one trait dispatch, and every future
4557/// arm addition (a `:build-dep` third list once the substrate grows
4558/// Cargo-style split-graphs, a `:tool-dep` for build-time-only tooling
4559/// per the peer Cargo `[build-dependencies]` /
4560/// `[target.<cfg>.dev-dependencies]` future admission surface — both
4561/// trajectory items the sibling [`DepList::from_wire`] doc block
4562/// already names) grows the byte-view axis through one edit on the
4563/// substrate-primitive `as_str` accessor, not a coordinated rewrite
4564/// across every future `<T: AsRef<[u8]>>`-bound consumer's arm-set.
4565///
4566/// Extends the trait-idiomatic *byte-view* axis onto the third
4567/// caixa-core-internal closed-set fieldless typed-enum peer on the
4568/// substrate — the two-list dep-graph enum — matching the trajectory
4569/// the sibling [`crate::CaixaKind`] first-mover [`AsRef<[u8]>`] impl
4570/// (69d8d86) and [`crate::dialeto::CaixaDialeto`] second-mover impl
4571/// (8151347) walked before it on the caixa-core tier of the byte-view
4572/// axis, and matching the discipline the paired sibling closed-set
4573/// fieldless typed enums already carry on the peer str-view
4574/// ([`AsRef<str>`]), parse ([`std::str::FromStr`]), and reverse-
4575/// projection (`{Self, &Self} × {&'static str, String,
4576/// Cow<'static, str>, Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`)
4577/// axes on this same enum. Unlike [`crate::CaixaKind`] — which carries
4578/// a two-axis split ([`crate::CaixaKind::as_str`] returning
4579/// lowercase-Portuguese diagnostic form vs
4580/// [`crate::CaixaKind::wire_name`] returning `PascalCase` tatara-lisp
4581/// author-surface bytes) — [`DepList`] carries a single canonical
4582/// axis: [`DepList::as_str`] returns the `:`-prefixed kebab-case
4583/// tatara-lisp author-surface key ([`crate::render::DEP_AUTHOR_KEY_DEPS`]
4584/// / [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`]), which is
4585/// simultaneously the wire form the paired [`DepList::from_wire`]
4586/// resolver reads back. The byte-view axis therefore lands on the
4587/// same `:`-prefixed kebab byte-string every str-view and reverse-
4588/// projection axis on this enum already returns, and no wire-axis
4589/// cross-witness applies.
4590///
4591/// Pinned load-bearing by
4592/// [`tests::dep_list_as_ref_bytes_routes_through_as_str_accessor`]
4593/// (fail-before-pass-after byte-parity pin against
4594/// [`DepList::as_str`] `.as_bytes()` across the two-arm
4595/// [`DepList::ALL`] emit-set, cross-axis witness against the paired
4596/// str-view [`AsRef<str>`] / [`std::fmt::Display`] /
4597/// [`DepList::as_str`] axes' `.as_bytes()` byte-tails, cross-axis
4598/// witness against the paired reverse-projection
4599/// `{&'static str, String, Cow<'static, str>, Box<str>,
4600/// std::sync::Arc<str>, std::rc::Rc<str>}` return-shape axes'
4601/// `.as_bytes()` byte-tails, a `<T: AsRef<[u8]>>`-bound-consumer
4602/// witness that a generic byte-input function accepts a [`DepList`]
4603/// directly through the trait bound on both owned and borrowed input
4604/// shapes, and a `blake3::Hasher::update`-shape byte-input surface
4605/// witness routed through the `<T: AsRef<[u8]>>`-bound consumer axis
4606/// to reach the caixa-lacre compounding target on both owned and
4607/// borrowed input shapes). Any future silent detour that routes the
4608/// byte-view impl off the substrate-primitive [`DepList::as_str`]
4609/// accessor (a per-arm inline `b":deps".as_slice()`-shaped re-inlining
4610/// that opens a compile-time link to the un-lifted arm-literal, a
4611/// hypothetical un-prefixed bare-kebab byte-string swap that would
4612/// silently collapse the `:`-prefixed tatara-lisp author-surface
4613/// discipline the sibling [`DepList::AUTHOR_KEYS`] doc block
4614/// explicitly pins) trips at caixa-core test time rather than at a
4615/// downstream byte-consumer's silent split.
4616impl AsRef<[u8]> for DepList {
4617 fn as_ref(&self) -> &[u8] {
4618 self.as_str().as_bytes()
4619 }
4620}
4621
4622/// Trait-idiomatic *owned-input, owned-`Vec<u8>` output* byte-owned
4623/// reverse projection on the third caixa-core-internal closed-set
4624/// fieldless typed enum peer ([`DepList`]) — the byte-mirror of the
4625/// [`From<DepList> for String`] str-owned reverse-projection axis and
4626/// the owned-`Vec<u8>` reverse-projection sibling of the paired
4627/// [`AsRef<[u8]>`] borrowed byte-view axis lifted on this same enum.
4628/// Routes byte-for-byte through the substrate-primitive
4629/// [`DepList::as_str`] `pub const fn` accessor via [`str::as_bytes`] +
4630/// [`slice::to_vec`] so every consumer that binds a [`DepList`]
4631/// through the standard-library `impl From<DepList> for Vec<u8>` axis
4632/// (equivalently `<T: Into<Vec<u8>>>`) — a future
4633/// [`std::io::Write::write_all`]-shape per-`:deps` audit-log byte-sink
4634/// whose input parameter is an owned [`Vec<u8>`] payload, a future
4635/// `bytes::Bytes::from(Vec::<u8>::from(list))` composer folding the
4636/// per-arm dep-list discriminator byte-tag into the [`bytes::Bytes`]
4637/// framing surface, a future `hasher.update(&Vec::<u8>::from(list))`-
4638/// shape BLAKE3 content-address closure that needs the owned byte-tail
4639/// buffered before folding into the [`crate::Lacre`] closure body so a
4640/// downstream `Lacre` consumer can partition the runtime-closure
4641/// `:deps` from the dev-only-closure `:deps-dev` at content-address
4642/// time, a future per-dep-list protobuf/CBOR/msgpack payload composer
4643/// whose framer takes an owned [`Vec<u8>`] rather than a borrowed
4644/// byte-slice — reaches the same two-arm lifted
4645/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4646/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const roster the paired
4647/// [`AsRef<[u8]>`] borrowed byte-view axis, the four
4648/// `{Self, &Self} × {&'static str, String}` 2×2 str-view forward-
4649/// projection corners, the [`std::borrow::Cow<'static, str>`] /
4650/// [`Box<str>`] / [`std::sync::Arc<str>`] / [`std::rc::Rc<str>`] str-
4651/// owned reverse-projection quartet, and the substrate-primitive
4652/// [`DepList::as_str`] accessor already return, rather than an open-
4653/// coded per-call-site `list.as_str().as_bytes().to_vec()` /
4654/// `<DepList as AsRef<[u8]>>::as_ref(&list).to_vec()` /
4655/// `String::from(list).into_bytes()` composition whose type bounds
4656/// have no compile-time link back to the substrate primitive.
4657///
4658/// Third peer on the substrate-wide trait-idiomatic *byte-owned
4659/// reverse-projection* family opened on the sibling top-level
4660/// [`crate::CaixaKind`] enum (b245fd6 first-mover) and extended onto
4661/// [`crate::dialeto::CaixaDialeto`] (4cceaf5 second-mover) — Rust's
4662/// standard library carries `impl From<&[u8]> for Vec<u8>` and
4663/// `impl From<String> for Vec<u8>`, so a two-hop composition
4664/// `list.as_str().as_bytes().to_vec()` (or
4665/// `String::from(list).into_bytes()`, or
4666/// `<DepList as AsRef<[u8]>>::as_ref(&list).to_vec()`) is reachable
4667/// through the pre-existing str-view axes and the paired
4668/// [`AsRef<[u8]>`] borrowed byte-view axis alone. But that two-hop
4669/// shape has no compile-time link back to the byte-owned reverse-
4670/// projection axis, forces every downstream `<T: Into<Vec<u8>>>`-bound
4671/// consumer to open-code the composition at every call site, and
4672/// admits a silent split whenever a future call site takes a sibling
4673/// projection axis whose `into_bytes()` / `to_vec()` byte-tail carries
4674/// no compile-time byte-owned surface. The lifted single-hop impl
4675/// closes the byte-owned reverse-projection axis so every future
4676/// `Vec<u8>`-parameterized consumer reaches the substrate primitive
4677/// through one trait dispatch, and every future arm addition (the
4678/// sibling [`DepList::from_wire`] doc block's `:deps-build` build-only
4679/// dep-list trajectory item and the `[target.<cfg>.dev-dependencies]`
4680/// future admission surface both name) grows the byte-owned axis
4681/// through one edit on the substrate-primitive [`DepList::as_str`]
4682/// accessor.
4683///
4684/// Unlike the sibling first-mover [`crate::CaixaKind`] enum — which
4685/// carries a two-axis split (lowercase-Portuguese diagnostic form vs
4686/// `PascalCase` tatara-lisp author-surface bytes) so its byte-owned
4687/// axis pins a wire-axis rejection witness — [`DepList`] carries a
4688/// single canonical axis: [`DepList::as_str`] returns the `:`-prefixed
4689/// kebab-case tatara-lisp author-surface key
4690/// ([`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4691/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`]), which is
4692/// simultaneously the wire form the paired [`DepList::from_wire`]
4693/// resolver reads back. The byte-owned axis therefore lands on the
4694/// same `:`-prefixed kebab byte-string every str-view / reverse-
4695/// projection / byte-view axis on this enum already returns, and no
4696/// wire-axis cross-witness applies (matching the discipline
4697/// [`crate::dialeto::CaixaDialeto`]'s `From<{Self, &Self}> for Vec<u8>`
4698/// impls established on the caixa-core-internal tier).
4699///
4700/// Extends the byte-owned reverse-projection axis onto the third
4701/// closed-set fieldless typed enum peer on the caixa-core-internal
4702/// tier — every remaining closed-set fieldless typed enum peer on the
4703/// substrate ([`crate::supervisor::RestartStrategy`],
4704/// [`crate::supervisor::RestartPolicy`],
4705/// [`crate::aplicacao::PlacementStrategy`],
4706/// [`crate::aplicacao::RateLimitUnit`], and the outside-`caixa-core`
4707/// peers `WitShape`, `PathShapeViolation`, `InvariantKind`,
4708/// `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`,
4709/// `FerriteRuntime`) is a future target of the campaign, mirroring
4710/// the discipline the paired [`AsRef<[u8]>`] borrowed byte-view axis
4711/// campaign already tracked across every closed-set fieldless typed
4712/// enum peer on the substrate.
4713///
4714/// Pinned load-bearing by
4715/// [`tests::dep_list_from_into_owned_vec_bytes_routes_through_as_str_accessor`]
4716/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4717/// emit-set binding the byte-owned reverse-projection axis against the
4718/// paired [`AsRef<[u8]>`] borrowed byte-view axis and the str-view
4719/// family's `.as_bytes().to_vec()` byte-tails, plus a
4720/// `<T: Into<Vec<u8>>>`-bound generic-consumer witness and a
4721/// `std::io::Write::write_all`-shape owned-byte-sink surface witness
4722/// on both owned and borrowed input shapes).
4723impl From<DepList> for Vec<u8> {
4724 fn from(list: DepList) -> Vec<u8> {
4725 list.as_str().as_bytes().to_vec()
4726 }
4727}
4728
4729/// Trait-idiomatic *borrowed-input, owned-`Vec<u8>` output* byte-owned
4730/// reverse projection on the third caixa-core-internal closed-set
4731/// fieldless typed enum peer ([`DepList`]) — the borrowed-input peer
4732/// of [`From<DepList> for Vec<u8>`], closing the
4733/// `{Self, &Self} → Vec<u8>` pair on the byte-owned reverse-projection
4734/// axis in one lift. Routes byte-for-byte through the substrate-
4735/// primitive [`DepList::as_str`] `pub const fn` accessor so every
4736/// consumer that holds a borrowed [`&DepList`] and needs an owned
4737/// [`Vec<u8>`] — a future `.iter().map(Vec::<u8>::from).collect()`
4738/// pipe over `&[DepList]` (whose iterator yields `&DepList`, not
4739/// `DepList`, so the owned-input axis alone forces every call site
4740/// through an explicit `.copied()` / spurious [`Copy`] deref
4741/// restatement rather than the direct trait-idiomatic projection), a
4742/// future dep-graph audit-report body composer that walks
4743/// [`DepList::ALL`] through an `Into<Vec<u8>>`-bound per-arm byte-
4744/// writer to surface the accepted dep-list set — reaches the same two-
4745/// arm lifted `crate::render::DEP_AUTHOR_KEY_DEPS*` const roster the
4746/// paired owned-input peer already returns.
4747impl From<&DepList> for Vec<u8> {
4748 fn from(list: &DepList) -> Vec<u8> {
4749 list.as_str().as_bytes().to_vec()
4750 }
4751}
4752
4753/// Errors raised by [`Dep::validate`].
4754///
4755/// Mirrors the per-axis error families the other `:versao`-carrying
4756/// typed surfaces expose
4757/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4758/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4759/// [`crate::SupervisorError::EmptyChildVersion`] /
4760/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4761/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4762#[derive(Debug, Error, PartialEq, Eq)]
4763pub enum DepError {
4764 #[error(
4765 ":deps entry has empty :nome (every dep must name a target caixa; \
4766 omit the entry instead of carrying an empty name)"
4767 )]
4768 NomeEmpty,
4769 #[error(
4770 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4771 (the value flows verbatim as the target caixa's `:nome`, the rendered \
4772 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4773 value, and the resolver's checkout-directory leaf — each apiserver-side \
4774 schema rejects non-DNS-1123 names at admission time; use a lowercase \
4775 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4776 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4777 )]
4778 NomeInvalid { nome: String, reason: String },
4779 #[error(
4780 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4781 constraint that resolves through the lacre pipeline)"
4782 )]
4783 VersaoEmpty { nome: String },
4784 #[error(
4785 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4786 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4787 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4788 and `:children :versao` carry; the lacre pipeline resolves all three \
4789 through the same parser)"
4790 )]
4791 VersaoInvalid {
4792 nome: String,
4793 versao: String,
4794 reason: String,
4795 },
4796 #[error(
4797 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4798 (every git source must name a repo — use a `github:org/repo` \
4799 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4800 entire :fonte block to fall back to the default-host resolver \
4801 convention)"
4802 )]
4803 FonteRepoEmpty { nome: String },
4804 #[error(
4805 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4806 invalid value-shape: {reason} (the value flows verbatim into the \
4807 caixa-resolver's `git clone <repo>` subprocess invocation; every \
4808 documented form carries a `:` separator and no whitespace / \
4809 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4810 an `https://host/path` / `ssh://[user@]host/path` / \
4811 `git://host/path` / `file:///path` URL, or the `git@host:path` \
4812 scp-style SSH form)"
4813 )]
4814 FonteRepoShape {
4815 nome: String,
4816 repo: String,
4817 reason: String,
4818 },
4819 #[error(
4820 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4821 (set exactly one of :tag, :rev, or :branch so the resolver \
4822 can pick a reproducible commit; omit the entire :fonte block \
4823 to fall back to the default-host resolver convention, which \
4824 resolves the latest tag matching :versao)"
4825 )]
4826 FontePinMissing { nome: String },
4827 #[error(
4828 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4829 set ({pins}); exactly one of :tag, :rev, or :branch must be \
4830 set so the resolver's checkout target is unambiguous (the \
4831 resolver's silent precedence is :rev > :tag > :branch — if \
4832 you intended one specifically, drop the others)"
4833 )]
4834 FontePinAmbiguous { nome: String, pins: String },
4835 #[error(
4836 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4837 (a set pin must name a non-empty git ref; drop the {pin} key \
4838 entirely to fall through to another pin axis)"
4839 )]
4840 FontePinEmpty { nome: String, pin: String },
4841 #[error(
4842 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4843 value-shape: {reason} (the git porcelain enforces the same shape at \
4844 `git fetch` / `git checkout` time on every pin; use a leaf refname \
4845 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4846 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4847 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4848 prepends at clone time, and avoid abbreviated SHAs which are \
4849 ambiguous across repository history)"
4850 )]
4851 FontePinShape {
4852 nome: String,
4853 pin: String,
4854 value: String,
4855 reason: String,
4856 },
4857 #[error(
4858 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4859 (every path source must name a non-empty filesystem path; \
4860 omit the entire :fonte block to fall back to the default-host \
4861 resolver convention)"
4862 )]
4863 FonteCaminhoEmpty { nome: String },
4864 #[error(
4865 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4866 absolute (the lacre pipeline embeds the value verbatim in its \
4867 per-dep content-address `path:{caminho}` at \
4868 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4869 BLAKE3 closure differ across machines — defeating the \
4870 reproducibility contract that's load-bearing for CSE; express \
4871 the path relative to the caixa.lisp location, e.g. \
4872 \"../caixa-teia\" for a sibling workspace dep)"
4873 )]
4874 FonteCaminhoAbsolute { nome: String, caminho: String },
4875 #[error(
4876 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4877 with `~` (the leading-tilde is a shell-expansion convention, not a \
4878 POSIX path component — `Path::is_absolute` returns false on it, so \
4879 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4880 pipeline embeds the value verbatim in its per-dep content-address \
4881 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4882 caixa-resolver folds it through `Path::join` without `~`-expansion, \
4883 so the build looks for a literal `./{caminho}` subdirectory and \
4884 fails at resolve time far from the source caixa.lisp; even worse, a \
4885 future caixa-resolver pass that *does* expand `~` would silently \
4886 re-open the host-layout-leak the b94fd83 absolute gate closes — \
4887 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4888 runners with different `$HOME` layouts resolve to two distinct paths \
4889 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4890 determinism contract; express the path relative to the caixa.lisp \
4891 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4892 spell out the full relative path explicitly if a workstation-rooted \
4893 dep is genuinely intended)"
4894 )]
4895 FonteCaminhoTildeExpansion { nome: String, caminho: String },
4896 #[error(
4897 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4898 with `$` (the leading-`$` is a shell-variable-expansion convention, \
4899 not a POSIX path component — `Path::is_absolute` returns false on it \
4900 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4901 embeds the value verbatim in its per-dep content-address \
4902 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4903 caixa-resolver folds it through `Path::join` without `$`-expansion, \
4904 so the build looks for a literal `./{caminho}` subdirectory and \
4905 fails at resolve time far from the source caixa.lisp; even worse, a \
4906 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4907 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4908 invites) would silently re-open the host-layout-leak the b94fd83 \
4909 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4910 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4911 layouts resolve to two distinct paths for the byte-identical caixa, \
4912 defeating the THEORY.md §V.2 render-determinism contract; express \
4913 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4914 for a sibling workspace dep, or spell out the full relative path \
4915 explicitly if a workstation-rooted dep is genuinely intended)"
4916 )]
4917 FonteCaminhoVarExpansion { nome: String, caminho: String },
4918 #[error(
4919 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4920 with a space (the leading ASCII space `0x20` is the orthogonal \
4921 paste-from-aligned-doc footgun that silently passes \
4922 `Path::is_absolute` and every prior leading-byte arm — \
4923 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4924 `./ ../caixa-teia` subdirectory the resolver fails to find at \
4925 resolve time with a non-self-locating `No such file or directory` \
4926 error far from the source caixa.lisp; the lacre pipeline embeds \
4927 the value verbatim in its per-dep content-address `path:{caminho}` \
4928 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4929 semantic-identical caixa values (` ../caixa-teia` vs \
4930 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4931 workstations whose authors differ only in paste-from-aligned- \
4932 caixa.lisp-doc whitespace habits — the most insidious failure \
4933 mode the typed slot can carry (no error surfaces; the divergence \
4934 is invisible until two machines compare lacres), defeating the \
4935 THEORY.md §V.2 render-determinism contract. The canonical \
4936 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4937 a multi-entry `:deps` block sits at the same column — an author \
4938 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4939 the rendered alignment into a fresh entry preserves the leading \
4940 whitespace verbatim); peer `:fonte :repo` axis already rejects \
4941 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4942 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4943 `is_chart_description_shape`, `:licenca` via \
4944 `is_spdx_expression_shape`. Drop the leading space; express the \
4945 path as a bare relative single-token like \"../caixa-teia\")"
4946 )]
4947 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4948 #[error(
4949 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4950 with `-` (the canonical CLI-argument-injection footgun on the \
4951 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4952 its per-dep content-address `path:{caminho}` at \
4953 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4954 through `Path::join` looking for a literal `./{caminho}` \
4955 subdirectory. Every downstream subprocess that consumes the resolved \
4956 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4957 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4958 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4959 value as a CLI flag rather than a positional path when the invocation \
4960 does not carry a `--` argument-list terminator between the flag block \
4961 and the path (the common case at every porcelain entry point). The \
4962 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4963 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4964 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4965 CLI-arg-injection vector at every git porcelain entry point that \
4966 consumes a path or URL argument, peer with is_git_repo_url's \
4967 leading-`-` arm on the sibling `:fonte :repo` axis), \
4968 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4969 POSIX `std::path::Path` treats a leading `-` as a literal filename \
4970 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4971 for a literal `./-rf` subdirectory that fails at resolve time with a \
4972 non-self-locating `No such file or directory` error far from the \
4973 source caixa.lisp — but on any downstream shell-out without `--` the \
4974 reinterpretation is silent and the failure mode is arbitrary-\
4975 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4976 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4977 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4978 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4979 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4980 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4981 `:children :caixa`, `:deps :nome`, cluster names); \
4982 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4983 the feira `init` / `add <nome>` positional gate (868c191) rejects \
4984 leading `-` on the CLI positional itself. Express the path as a bare \
4985 relative single-token like \"../caixa-teia\" — the sibling-workspace \
4986 directory name carries no leading-hyphen semantic, and `./` / `../` \
4987 prefixes structurally partition the leading-byte set to safe values.)"
4988 )]
4989 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4990 #[error(
4991 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4992 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4993 every `std::fs` syscall routes the path through `CString::new` which \
4994 fails with `NulError` at resolve time; the lacre pipeline embeds the \
4995 value verbatim in its per-dep content-address `path:{caminho}` at \
4996 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4997 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4998 determinism contract — the canonical paste-from-multiline-doc \
4999 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
5000 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
5001 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
5002 already gates against. Express the path as a relative single-line ASCII \
5003 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
5004 )]
5005 FonteCaminhoControlChar {
5006 nome: String,
5007 caminho: String,
5008 byte: u8,
5009 },
5010 #[error(
5011 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
5012 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
5013 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
5014 not the parent's sibling — and the caixa-resolver folds the value through \
5015 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
5016 resolve time with a non-self-locating `No such file or directory` error far \
5017 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
5018 primary path separator equal to `/`, so byte-identical caixa.lisp values \
5019 resolve to two distinct directories across runner OSes — the lacre pipeline \
5020 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5021 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
5022 determinism contract via the cross-host-OS-separator divergence vector. The \
5023 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
5024 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
5025 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
5026 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
5027 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
5028 \"../caixa-teia\" for a sibling workspace dep)"
5029 )]
5030 FonteCaminhoBackslash { nome: String, caminho: String },
5031 #[error(
5032 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5033 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
5034 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
5035 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
5036 paste-from-shell-pipeline footgun where an author copies a `command > log` \
5037 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
5038 as literal path-component bytes, so the resolver folds the value through \
5039 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5040 subdirectory and fails at resolve time with a non-self-locating `No such \
5041 file or directory` error far from the source caixa.lisp. The lacre pipeline \
5042 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5043 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
5044 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5045 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5046 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
5047 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
5048 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
5049 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
5050 RFC-3986-reserved set. Express the path as a bare relative single-token like \
5051 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5052 redirection semantic.",
5053 ch = *byte as char
5054 )]
5055 FonteCaminhoShellRedirection {
5056 nome: String,
5057 caminho: String,
5058 byte: u8,
5059 },
5060 #[error(
5061 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
5062 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
5063 `|` as the pipe operator that wires one command's stdout to the next command's \
5064 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
5065 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
5066 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
5067 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
5068 treats `|` as a literal path-component byte, so the resolver folds the value \
5069 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5070 subdirectory and fails at resolve time with a non-self-locating `No such file or \
5071 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
5072 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
5073 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
5074 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
5075 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
5076 subprocess-argument / shell-metachar injection surface every peer single-token-\
5077 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
5078 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5079 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5080 workspace directory name carries no shell-pipe semantic."
5081 )]
5082 FonteCaminhoShellPipe { nome: String, caminho: String },
5083 #[error(
5084 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5085 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
5086 / nushell — lexes `;` as the sequential-command terminator that fires the next \
5087 command regardless of the prior command's exit status, so `:caminho \
5088 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
5089 footgun where an author copies a `cd path; do-thing` chain without trimming \
5090 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
5091 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
5092 literal path-component byte, so the resolver folds the value through \
5093 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5094 subdirectory and fails at resolve time with a non-self-locating `No such file \
5095 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5096 the value verbatim in its per-dep content-address `path:{caminho}` at \
5097 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5098 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5099 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5100 canonical shell-metachar injection surface every peer single-token-shaped \
5101 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
5102 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5103 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5104 workspace directory name carries no shell-command-separator semantic."
5105 )]
5106 FonteCaminhoShellSemicolon { nome: String, caminho: String },
5107 #[error(
5108 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5109 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
5110 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
5111 terminator detaching the prior command and returning control immediately to \
5112 the prompt, double `&&` as the logical-AND list operator firing the next \
5113 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
5114 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
5115 sleep 1` background-launch one-liner or a `cd path && make install` build-\
5116 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
5117 05c358e closed the sequential-command-separator vector, this arm closes the \
5118 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
5119 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
5120 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5121 byte lands in the BLAKE3 closure and rides into every shell-spawned \
5122 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5123 future operator-side `nix` spawn) as the canonical shell-metachar injection \
5124 surface every peer single-token-shaped typed slot already closes. The peer \
5125 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
5126 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
5127 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
5128 shell-background / logical-AND semantic."
5129 )]
5130 FonteCaminhoShellBackground { nome: String, caminho: String },
5131 #[error(
5132 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5133 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
5134 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
5135 wrapper that runs the enclosed command and substitutes its standard-output \
5136 verbatim into the surrounding word, so a backticked `whoami` expands to the \
5137 current user's name and a backticked `cat /etc/passwd` expands to the file's \
5138 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
5139 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
5140 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
5141 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
5142 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
5143 background / logical-AND vector, this arm closes the orthogonal command-\
5144 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
5145 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
5146 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
5147 value verbatim in its per-dep content-address `path:{caminho}` at \
5148 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5149 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
5150 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5151 shell-metachar injection surface every peer single-token-shaped typed slot \
5152 already closes. The peer `:entrada :paths` axis rejects the byte via \
5153 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
5154 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5155 directory name carries no shell-command-substitution semantic."
5156 )]
5157 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
5158 #[error(
5159 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5160 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
5161 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
5162 expansion wildcards: `*` matches any sequence of characters in a path component \
5163 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
5164 canonical paste-from-shell-listing footgun where an author copies a \
5165 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
5166 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
5167 `std::path::Path` treats both bytes as literal path-component bytes, so the \
5168 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
5169 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
5170 locating `No such file or directory` error far from the source caixa.lisp. The \
5171 lacre pipeline embeds the value verbatim in its per-dep content-address \
5172 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
5173 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
5174 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
5175 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
5176 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
5177 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
5178 reserved set. Express the path as a bare relative single-token like \
5179 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
5180 / pathname-expansion semantic.",
5181 ch = *byte as char
5182 )]
5183 FonteCaminhoShellGlob {
5184 nome: String,
5185 caminho: String,
5186 byte: u8,
5187 },
5188 #[error(
5189 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5190 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
5191 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
5192 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
5193 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
5194 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
5195 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
5196 arm closes the leading byte of — together the two arms now structurally exclude the \
5197 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
5198 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5199 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
5200 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
5201 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
5202 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
5203 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
5204 self-locating `No such file or directory` error far from the source caixa.lisp. The \
5205 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
5206 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
5207 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5208 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5209 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
5210 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
5211 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
5212 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
5213 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
5214 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5215 subshell-grouping semantic.",
5216 ch = *byte as char
5217 )]
5218 FonteCaminhoShellSubshellGrouping {
5219 nome: String,
5220 caminho: String,
5221 byte: u8,
5222 },
5223 #[error(
5224 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5225 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
5226 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
5227 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
5228 comma-separated members and `{{1..10}}` expands to the integer range — the \
5229 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
5230 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
5231 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
5232 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
5233 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
5234 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
5235 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
5236 `std::path::Path` treats the byte as a literal path-component byte, so a \
5237 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
5238 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
5239 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
5240 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
5241 silently passes every prior arm and the resolver folds the value through \
5242 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5243 resolve time with a non-self-locating `No such file or directory` error far from \
5244 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
5245 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5246 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5247 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5248 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
5249 expansion / URI-Template-placeholder surface every peer single-token-shaped \
5250 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
5251 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
5252 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
5253 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5254 directory name carries no shell-brace-expansion / URI-Template-placeholder \
5255 semantic; if two siblings actually need pinning, author two separate `:deps` \
5256 entries rather than one brace-expanded `:caminho` value.",
5257 ch = *byte as char
5258 )]
5259 FonteCaminhoShellBraceExpansion {
5260 nome: String,
5261 caminho: String,
5262 byte: u8,
5263 },
5264 #[error(
5265 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5266 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
5267 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
5268 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
5269 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
5270 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
5271 glob every shell-history block carries; the bracket pair additionally carries the \
5272 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
5273 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
5274 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
5275 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
5276 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
5277 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
5278 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5279 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
5280 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
5281 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
5282 leak) silently passes every prior arm and the resolver folds the value through \
5283 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5284 resolve time with a non-self-locating `No such file or directory` error far from \
5285 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5286 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5287 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5288 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5289 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
5290 surface every peer single-token-shaped typed slot already closes. Express the path \
5291 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5292 directory name carries no shell-bracket-expansion / glob-character-class / array-\
5293 literal semantic; if a family of sibling caixas actually needs pinning, author \
5294 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
5295 ch = *byte as char
5296 )]
5297 FonteCaminhoShellBracketExpansion {
5298 nome: String,
5299 caminho: String,
5300 byte: u8,
5301 },
5302 #[error(
5303 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5304 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
5305 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5306 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
5307 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
5308 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
5309 every path-with-embedded-whitespace paste block carries and the symmetric \
5310 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
5311 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
5312 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
5313 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
5314 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
5315 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
5316 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
5317 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
5318 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
5319 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
5320 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
5321 production. POSIX `std::path::Path` treats the byte as a literal path-component \
5322 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
5323 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
5324 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
5325 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
5326 shape) silently passes every prior arm and the resolver folds the value through \
5327 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5328 resolve time with a non-self-locating `No such file or directory` error far from \
5329 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5330 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5331 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5332 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5333 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
5334 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5335 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
5336 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
5337 `is_git_repo_url`). Express the path as a bare relative single-token like \
5338 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
5339 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
5340 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
5341 quoting on the outer syntactic layer, so an inner quote pair would nest and \
5342 desugar to a broken layer).",
5343 ch = *byte as char
5344 )]
5345 FonteCaminhoShellQuoteGrouping {
5346 nome: String,
5347 caminho: String,
5348 byte: u8,
5349 },
5350 #[error(
5351 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5352 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
5353 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5354 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
5355 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
5356 discarding the byte and everything after it to the end of the physical line \
5357 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
5358 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
5359 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
5360 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
5361 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
5362 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
5363 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
5364 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
5365 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
5366 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
5367 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
5368 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
5369 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
5370 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
5371 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
5372 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
5373 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
5374 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
5375 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
5376 fails at resolve time with a non-self-locating `No such file or directory` \
5377 error far from the source caixa.lisp — while every downstream shell / YAML / \
5378 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
5379 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
5380 scalar disagree with the resolver on which directory the value names. The \
5381 lacre pipeline embeds the value verbatim in its per-dep content-address \
5382 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
5383 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5384 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
5385 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
5386 fragment-delimiter surface every peer single-token-shaped typed slot already \
5387 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
5388 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
5389 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5390 workspace directory name carries no shell-comment / URL-fragment / YAML-\
5391 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
5392 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
5393 and drop any `#fragment` tail entirely (fragment identifiers select \
5394 renderings, not directories, and `:caminho` names a directory).",
5395 ch = *byte as char
5396 )]
5397 FonteCaminhoShellComment {
5398 nome: String,
5399 caminho: String,
5400 byte: u8,
5401 },
5402 #[error(
5403 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
5404 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
5405 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
5406 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
5407 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
5408 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
5409 literally inside a URL value. The canonical paste-from-browser-address-bar \
5410 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
5411 encoded README hyperlink / browser address bar / percent-encoded permalink \
5412 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
5413 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
5414 what the author intended as the byte-identical sibling-workspace dep. POSIX \
5415 `std::path::Path` treats the byte as a literal path-component byte, so \
5416 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
5417 resolve time with a non-self-locating `No such file or directory` error far \
5418 from the source caixa.lisp — while every downstream URL parser / shell printf \
5419 builtin / YAML directive parser silently reinterprets the byte to a different \
5420 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
5421 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
5422 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
5423 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
5424 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
5425 recent job whose command started with `foo`\" — a future `kill %1` invocation \
5426 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
5427 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
5428 directive block cross-idiom leak); and the Windows-shell env-var-reference \
5429 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
5430 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
5431 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5432 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
5433 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5434 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
5435 printf-format-specifier / job-control-specifier surface every peer single-\
5436 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
5437 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
5438 `is_git_repo_url`). Express the path as a bare relative single-token like \
5439 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
5440 percent-encoding-escape / format-specifier / job-control semantic; substitute \
5441 any `%20` percent-encoded-space with a literal space then reject the whole \
5442 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5443 directory name never carries an embedded space in practice); drop any \
5444 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5445 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5446 ch = *byte as char
5447 )]
5448 FonteCaminhoUrlPercentEncoding {
5449 nome: String,
5450 caminho: String,
5451 byte: u8,
5452 },
5453 #[error(
5454 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5455 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5456 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5457 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5458 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5459 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5460 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5461 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5462 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5463 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5464 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5465 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5466 the byte is a first-class parser byte in nearly every config / templating / \
5467 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5468 `std::path::Path` treats the byte as a literal path-component byte, so the \
5469 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5470 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5471 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5472 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5473 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5474 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5475 subdirectory that fails at resolve time with a non-self-locating `No such file \
5476 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5477 the value verbatim in its per-dep content-address `path:{caminho}` at \
5478 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5479 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5480 time lock to two distinct BLAKE3 closures across two workstations whose \
5481 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5482 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5483 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5484 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5485 is the canonical CWE-78 shell-command-injection surface every peer single-\
5486 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5487 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5488 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5489 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5490 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5491 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5492 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5493 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5494 so every position — leading and embedded — is structurally rejected. Substitute \
5495 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5496 time, or express the path as a bare relative single-token like \
5497 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5498 variable-expansion / command-substitution / arithmetic-expansion semantic.",
5499 ch = *byte as char
5500 )]
5501 FonteCaminhoShellVariableExpansion {
5502 nome: String,
5503 caminho: String,
5504 byte: u8,
5505 },
5506 #[error(
5507 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5508 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5509 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5510 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5511 reference §9.3: `!command` re-runs the most recent history entry beginning with \
5512 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5513 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5514 and the substitution fires at every history-expansion-enabled shell context — \
5515 `set -o histexpand` is bash's default for interactive sessions and the layer \
5516 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5517 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5518 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5519 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5520 encodes it inside a query component via the 'special-query percent-encode set' \
5521 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5522 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5523 prefix — the paste-from-source-code idiom where an author copies \
5524 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5525 the string-literal boundary); the canonical English-typography emphasis / \
5526 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5527 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5528 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5529 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5530 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5531 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5532 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5533 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5534 repeat-prior-command paste idiom), the English-typography `:caminho \
5535 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5536 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5537 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5538 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5539 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5540 subdirectory that fails at resolve time with a non-self-locating `No such file \
5541 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5542 the value verbatim in its per-dep content-address `path:{caminho}` at \
5543 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5544 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5545 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5546 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5547 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5548 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5549 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5550 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5551 name carries no shell-history-expansion / bang-operator semantic; drop any \
5552 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5553 idiom; and drop any trailing English-typography exclamation mark that pasted \
5554 from prose.",
5555 ch = *byte as char
5556 )]
5557 FonteCaminhoShellHistoryExpansion {
5558 nome: String,
5559 caminho: String,
5560 byte: u8,
5561 },
5562 #[error(
5563 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5564 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5565 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5566 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5567 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5568 substitution' history operator that rewrites the prior command's `old` string to \
5569 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5570 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5571 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5572 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5573 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5574 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5575 literal value diverges from every downstream `feira tofu` curl-invocation / \
5576 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5577 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5578 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5579 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5580 `std::path::Path` treats `^` as a literal path-component byte, so \
5581 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5582 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5583 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5584 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5585 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5586 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5587 that fails at resolve time with a non-self-locating `No such file or directory` \
5588 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5589 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5590 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5591 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5592 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5593 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5594 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5595 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5596 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5597 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5598 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5599 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5600 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5601 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5602 drop any trailing `^` history-substitution-open fragment.",
5603 ch = *byte as char
5604 )]
5605 FonteCaminhoShellHistorySubstitution {
5606 nome: String,
5607 caminho: String,
5608 byte: u8,
5609 },
5610 #[error(
5611 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5612 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5613 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5614 value verbatim in its per-dep content-address `path:{caminho}` at \
5615 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5616 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5617 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5618 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5619 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5620 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5621 trailing `/`; every `:caminho` value names a sibling-workspace directory \
5622 already, so the trailing separator carries no information. Use \
5623 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5624 )]
5625 FonteCaminhoTrailingSlash { nome: String, caminho: String },
5626 #[error(
5627 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5628 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5629 apply the same set-not-multiset discipline; one package per table), and \
5630 two entries naming the same caixa carry two version constraints / source \
5631 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5632 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5633 silently overwrites the first at the resolver-side `concrete_versao` step, \
5634 and the dropped entry's pin / features never reach the closure — far from \
5635 the source caixa.lisp, with no field naming which `:deps` entry was the \
5636 silent loser. If two version constraints are genuinely needed (the rare \
5637 multi-version closure case the lacre pipeline doesn't yet support), the \
5638 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5639 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5640 )]
5641 DuplicateNome { nome: String, list: &'static str },
5642 #[error(
5643 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5644 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5645 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5646 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5647 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5648 with the canonical kebab-case feature name the target caixa declares."
5649 )]
5650 CaracteristicaEmpty { nome: String },
5651 #[error(
5652 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5653 feature name: {reason} (the value flows verbatim into Cargo's \
5654 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5655 parser enforces the same shape at `cargo metadata` time; use a single-token \
5656 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5657 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5658 an ASCII alphanumeric or `_`)"
5659 )]
5660 CaracteristicaInvalid {
5661 nome: String,
5662 caracteristica: String,
5663 reason: String,
5664 },
5665 #[error(
5666 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5667 every feature-flag list keys its entries by name (Cargo's \
5668 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5669 per feature per dep), and two entries naming the same feature are a redundant \
5670 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5671 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5672 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5673 feature once regardless of declaration count, so the duplicate's pin / position never \
5674 reaches the closure with no field naming the silent loser. One entry per feature per \
5675 dep; if two distinct features are intended, name each verbatim."
5676 )]
5677 CaracteristicaDuplicate {
5678 nome: String,
5679 caracteristica: String,
5680 },
5681 #[error(
5682 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5683 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5684 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5685 rejects mid-traversal far from the source caixa.lisp or recurses on until \
5686 it exhausts its stack). Every :nome is globally-unique substrate identity, \
5687 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5688 *is* the parent itself, not a coincidentally-named peer. Drop the \
5689 self-referential dep entry — to reference code from this caixa, use \
5690 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5691 referencing the caixa's own code surface) instead."
5692 )]
5693 DepIsSelf { nome: String, list: &'static str },
5694}
5695
5696// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5697// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5698// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5699// variant — the paired `{ nome: String, caminho: String }` two-slot family
5700// on [`DepError`], sibling of the peer
5701// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5702// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5703// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5704// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5705// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5706// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5707// `{ de, para, wit, expected }`), and
5708// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5709// variants on `{ de, para, <field>: String, reason: String }`) on the
5710// `AplicacaoError` envelopes, the peer
5711// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5712// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5713// (0419438, 4 variants on `{ caixa, kind, slots }`),
5714// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5715// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5716// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5717// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5718// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5719// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5720// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5721// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5722//
5723// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5724// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5725// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5726// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5727// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5728// CommandSubstitution}` on the four single-byte shell operators; and the
5729// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5730// opened the identical `DepError::FonteCaminho<Variant> { nome:
5731// nome.to_string(), caminho: caminho.to_string() }` four-line
5732// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5733// — the exact "same block re-inlined at every consumer" shape the PRIME
5734// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5735// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5736// families each closed on their sibling envelopes. The eleven variants
5737// share one `{ nome: String, caminho: String }` shape, so the fold routes
5738// each wire-up site through one dispatch per typed variant.
5739//
5740// The macro below generates one `#[must_use]` inherent constructor per
5741// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5742// wire-up site collapses onto one dispatch:
5743// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5744// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5745// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5746// once — inside the macro — rather than at every wire-up site.
5747//
5748// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5749// shapes at the per-byte-classification arms — the
5750// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5751// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5752// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5753// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5754// cluster — carry an additional `byte: u8` naming the offending byte and
5755// so would break the uniform-two-field routing this macro promises. They
5756// instead fold onto the sibling three-field envelope through
5757// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5758// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5759// two-slot family is the `byte: u8` classification the arms carry. The
5760// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5761// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5762// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5763// envelope.
5764//
5765// Every future consumer that wants to construct one of these eleven
5766// variants outside the current in-crate [`DepSource::validate_caminho`]
5767// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5768// at lacre-resolve time re-checking the same value-shape axes the resolver
5769// consumes, a future `feira validate --deps` per-caixa admission verb
5770// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5771// rejecting a `:caminho` value against a cluster-local snapshot) now
5772// reaches each variant through one call rather than re-inlining the
5773// four-line struct-literal in lockstep with the eleven in-crate wire-up
5774// sites.
5775macro_rules! fonte_caminho_ctors {
5776 ($($ctor:ident => $variant:ident),* $(,)?) => {
5777 impl DepError {
5778 $(
5779 #[doc = concat!(
5780 "Construct a [`DepError::",
5781 stringify!($variant),
5782 "`] naming the offending `:deps :nome` + `:fonte ",
5783 "(:tipo path …) :caminho` pair. Folds the uniform ",
5784 "`Self::",
5785 stringify!($variant),
5786 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5787 "two-slot struct-literal onto one substrate primitive so ",
5788 "every [`DepSource::validate_caminho`] wire-up on this ",
5789 "variant reads through one dispatch rather than the ",
5790 "pre-lift four-line open-coded block."
5791 )]
5792 #[must_use]
5793 pub fn $ctor(nome: &str, caminho: &str) -> Self {
5794 Self::$variant {
5795 nome: nome.to_string(),
5796 caminho: caminho.to_string(),
5797 }
5798 }
5799 )*
5800 }
5801 };
5802}
5803
5804fonte_caminho_ctors! {
5805 fonte_caminho_absolute => FonteCaminhoAbsolute,
5806 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5807 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5808 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5809 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5810 fonte_caminho_backslash => FonteCaminhoBackslash,
5811 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5812 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5813 fonte_caminho_shell_background => FonteCaminhoShellBackground,
5814 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5815 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5816}
5817
5818// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5819// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5820// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5821// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5822// three-slot family on [`DepError`], strict sibling of the peer
5823// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5824// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5825// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5826// axis broke its uniform-two-field routing — the exact "future compounding
5827// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5828// here. Third fold family on this `DepError` envelope, sibling of the peer
5829// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5830// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5831// same enum.
5832//
5833// Each of the twelve wire-up sites on this shape (the control-byte arm
5834// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5835// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5836// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5837// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5838// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5839// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5840// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5841// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5842// `FonteCaminhoShellHistoryExpansion` on `!`, and
5843// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5844// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5845// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5846// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5847// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5848// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5849// closed on the sibling two-field envelope of this same enum. The twelve
5850// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5851// the fold routes each wire-up site through one dispatch per typed variant.
5852//
5853// The macro below generates one `#[must_use]` inherent constructor per
5854// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5855// so every wire-up site collapses onto one dispatch:
5856// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5857// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5858// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5859// `byte`) is spelled once — inside the macro — rather than at every wire-up
5860// site.
5861//
5862// Every future consumer that wants to construct one of these twelve
5863// variants outside the current in-crate [`DepSource::validate_caminho`]
5864// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5865// at lacre-resolve time re-checking the same value-shape axes the resolver
5866// consumes, a future `feira validate --deps` per-caixa admission verb
5867// re-checking the `:fonte :caminho` axis against the shell-metachar
5868// classification bytes this cluster catches, a per-lacre overlay resolver
5869// rejecting a `:caminho` value against a cluster-local snapshot) now
5870// reaches each variant through one call rather than re-inlining the
5871// five-line struct-literal in lockstep with the twelve in-crate wire-up
5872// sites.
5873macro_rules! fonte_caminho_byte_ctors {
5874 ($($ctor:ident => $variant:ident),* $(,)?) => {
5875 impl DepError {
5876 $(
5877 #[doc = concat!(
5878 "Construct a [`DepError::",
5879 stringify!($variant),
5880 "`] naming the offending `:deps :nome` + `:fonte ",
5881 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5882 "classification. Folds the uniform `Self::",
5883 stringify!($variant),
5884 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5885 "byte }` three-slot struct-literal onto one substrate ",
5886 "primitive so every [`DepSource::validate_caminho`] wire-up ",
5887 "on this variant reads through one dispatch rather than ",
5888 "the pre-lift five-line open-coded block."
5889 )]
5890 #[must_use]
5891 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5892 Self::$variant {
5893 nome: nome.to_string(),
5894 caminho: caminho.to_string(),
5895 byte,
5896 }
5897 }
5898 )*
5899 }
5900 };
5901}
5902
5903fonte_caminho_byte_ctors! {
5904 fonte_caminho_control_char => FonteCaminhoControlChar,
5905 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5906 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5907 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5908 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5909 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5910 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5911 fonte_caminho_shell_comment => FonteCaminhoShellComment,
5912 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5913 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5914 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5915 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5916}
5917
5918// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5919// single-slot struct-variant wire-up sites scattered across
5920// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5921// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5922// substrate primitive per typed variant — the paired `{ nome: String }`
5923// single-slot family on [`DepError`], sibling of the peer
5924// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5925// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5926// the same enum, and of the peer
5927// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5928// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5929// axis. Second fold family on this `DepError` envelope, and the first on
5930// the single-`{ nome }` shape.
5931//
5932// The five wire-up sites this fold closes each opened the identical
5933// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5934// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5935// local — the exact "same block re-inlined at every consumer" shape the
5936// PRIME DIRECTIVE names as a bug. The five variants share one
5937// `{ nome: String }` shape, so the fold routes each wire-up site through
5938// one dispatch per typed variant.
5939//
5940// The macro below generates one `#[must_use]` inherent constructor per
5941// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5942// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5943// pre-lift struct-literal on the same `&str` fixture. The uniform
5944// one-field construction (`nome.to_string()`) is spelled once — inside
5945// the macro — rather than at every wire-up site. Callers that hold a
5946// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5947// and lets the macro-owned `.to_string()` produce the fresh owning copy
5948// the enum variant needs; the semantics collapse onto the same
5949// `.clone()`-equivalent one this fold replaces at every site.
5950//
5951// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5952// on the same envelope stays on its pre-lift open-coded wire-up shape —
5953// it carries no `nome` field (the offending `:nome` value *is* the empty
5954// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5955// signature this macro promises does not apply. Every future consumer
5956// that wants to construct one of these five variants outside the current
5957// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5958// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5959// re-validator at lacre-resolve time, a future `feira validate --deps`
5960// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5961// these empty-value shapes against a cluster-local snapshot) now reaches
5962// each variant through one call rather than re-inlining the three-line
5963// struct-literal in lockstep with the five in-crate wire-up sites.
5964macro_rules! dep_nome_only_ctors {
5965 ($($ctor:ident => $variant:ident),* $(,)?) => {
5966 impl DepError {
5967 $(
5968 #[doc = concat!(
5969 "Construct a [`DepError::",
5970 stringify!($variant),
5971 "`] naming the offending `:deps :nome`. Folds the ",
5972 "uniform `Self::",
5973 stringify!($variant),
5974 " { nome: nome.to_string() }` one-field ",
5975 "struct-literal onto one substrate primitive so every ",
5976 "in-crate wire-up on this variant reads through one ",
5977 "dispatch rather than the pre-lift three-line ",
5978 "open-coded block."
5979 )]
5980 #[must_use]
5981 pub fn $ctor(nome: &str) -> Self {
5982 Self::$variant { nome: nome.to_string() }
5983 }
5984 )*
5985 }
5986 };
5987}
5988
5989dep_nome_only_ctors! {
5990 versao_empty => VersaoEmpty,
5991 fonte_repo_empty => FonteRepoEmpty,
5992 fonte_pin_missing => FontePinMissing,
5993 fonte_caminho_empty => FonteCaminhoEmpty,
5994 caracteristica_empty => CaracteristicaEmpty,
5995}
5996
5997// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5998// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5999// [`crate::manifest::Caixa::validate_deps`] +
6000// [`validate_no_self_dep`] onto one substrate-primitive family per
6001// typed variant — the `DepError`-side siblings of the peer
6002// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
6003// on the `SupervisorError { caixa: String }` one-slot envelope and of
6004// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
6005// `DepError { nome: String }` one-slot envelope. The two variants
6006// carry the same `{ nome: String, list: &'static str }` two-slot
6007// shape: the `nome` field names the offending dep the diagnostic
6008// points the author back at, and the `list` field carries the
6009// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
6010// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
6011// [`validate_deps`] arms, and via the paired
6012// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
6013// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
6014// canonicals on the [`validate_no_self_dep`] arm) so the author can
6015// grep their caixa.lisp for the offending list block in one edit.
6016//
6017// Each of the four wire-up sites opened the same struct-literal
6018// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
6019// two-line block — the exact "same block re-inlined at every
6020// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
6021// altitude the peer `DepError` / `SupervisorError` /
6022// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
6023// already closed on their sibling envelopes. The two `#[must_use]`
6024// inherent constructors below fold each wire-up onto one dispatch:
6025// `DepError::duplicate_nome(<nome>, <list>)` and
6026// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
6027// pre-lift struct-literal on the same scalar fixtures. The `list:
6028// &'static str` parameter (not `impl Into<String>`) preserves the
6029// exact wire tag every consumer already passes verbatim — no
6030// downstream diagnostic reshaping at the lift, matching the peer
6031// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
6032// contract each wire-up site already keys off.
6033macro_rules! dep_nome_list_ctors {
6034 ($($ctor:ident => $variant:ident),* $(,)?) => {
6035 impl DepError {
6036 $(
6037 #[doc = concat!(
6038 "Construct a [`DepError::",
6039 stringify!($variant),
6040 "`] naming the offending `:deps :nome` and the ",
6041 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
6042 "the diagnostic points the author back at. Folds ",
6043 "the uniform `Self::",
6044 stringify!($variant),
6045 " { nome: nome.to_string(), list }` two-field ",
6046 "struct-literal onto one substrate primitive so ",
6047 "every in-crate wire-up on this variant reads ",
6048 "through one dispatch rather than the pre-lift ",
6049 "open-coded struct-literal block."
6050 )]
6051 #[must_use]
6052 pub fn $ctor(nome: &str, list: &'static str) -> Self {
6053 Self::$variant { nome: nome.to_string(), list }
6054 }
6055 )*
6056 }
6057 };
6058}
6059
6060dep_nome_list_ctors! {
6061 duplicate_nome => DuplicateNome,
6062 dep_is_self => DepIsSelf,
6063}
6064
6065// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
6066// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
6067// <value>.to_string(), reason }` struct-variant wire-up sites at
6068// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
6069// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
6070// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
6071// primitive family per typed variant — the `DepError`-side siblings of the
6072// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
6073// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
6074// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
6075// the two-slot `{ nome, caminho }` envelope, and
6076// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
6077// caminho, byte }` envelope. The three variants share the same
6078// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
6079// the `nome` field names the offending dep the diagnostic points the
6080// author back at, the middle `<axis>: String` field carries the offending
6081// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
6082// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
6083// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
6084// field carries the parser-shaped rejection sentence the paired
6085// [`crate::render::require_valid_versao_requirement`] /
6086// [`crate::render::is_git_repo_url`] /
6087// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
6088// axis-field name differs across variants (`versao` / `repo` /
6089// `caracteristica`) so the ctor family below takes the axis field name as
6090// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
6091// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
6092// -> Self` inherent constructor per typed variant that spells the uniform
6093// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
6094// `reason` forwarded owned) exactly once. Peer of the sibling
6095// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
6096// family on the `AplicacaoError` envelope's mirror-symmetric
6097// `{ <field>: String, reason: String }` two-slot shape — same
6098// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
6099// one `nome`-axis added at the per-dep-owned altitude the `DepError`
6100// envelope keys off (every `DepError` variant carries the offending
6101// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
6102// offending block in one edit).
6103//
6104// The three wire-up sites this fold closes are:
6105// - [`DepSource::validate`]'s `:repo` value-shape arm
6106// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
6107// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
6108// rejects the offending URL);
6109// - [`Dep::validate`]'s `:versao` requirement-shape arm
6110// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
6111// self.versao_requirement().to_string(), reason }` inside the
6112// [`crate::render::require_valid_versao_requirement`] callback pair);
6113// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
6114// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
6115// caracteristica: c.clone(), reason })` after
6116// [`crate::render::is_cargo_feature_name`] rejects the offending
6117// feature-name).
6118//
6119// Each opened the identical five-line struct-literal against the same
6120// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
6121// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6122// same altitude the peer four already-lifted `DepError` ctor families
6123// closed on their sibling shape-envelopes. The three variant / axis-field
6124// discriminators are the only things that vary between them; the rest of
6125// the struct-literal is a byte-for-byte re-inline.
6126//
6127// Every future consumer wanting to raise one of these three diagnostics
6128// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
6129// time re-checking each declared dep against the same requirement +
6130// git-URL + feature-name value-shape cascade, a future `feira validate
6131// --deps` per-caixa admission verb re-running the shape gates on demand,
6132// a per-lacre overlay resolver rejecting an author-supplied dep against a
6133// cluster-local snapshot) now reaches one dispatch rather than re-inlining
6134// the five-line struct-literal in lockstep with the three in-crate
6135// wire-up sites.
6136macro_rules! dep_nome_axis_reason_ctors {
6137 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6138 impl DepError {
6139 $(
6140 #[doc = concat!(
6141 "Construct a [`DepError::",
6142 stringify!($variant),
6143 "`] naming the offending `:deps :nome`, the offending ",
6144 "`:", stringify!($axis), "` axis value, and the ",
6145 "parser-shaped rejection `reason`. Folds the uniform ",
6146 "`Self::",
6147 stringify!($variant),
6148 " { nome: nome.to_string(), ",
6149 stringify!($axis),
6150 ": ",
6151 stringify!($axis),
6152 ".to_string(), reason }` three-field struct-literal ",
6153 "onto one substrate primitive so every in-crate ",
6154 "wire-up on this variant reads through one dispatch ",
6155 "rather than the pre-lift five-line open-coded block. ",
6156 "The `nome: &str` and `",
6157 stringify!($axis),
6158 ": &str` parameters accept `&str` literals and ",
6159 "`&String` (via Deref coercion) so every existing ",
6160 "wire-up threads through the ctor without a ",
6161 "pre-conversion; the `reason: String` parameter takes ",
6162 "an owned `String` (not `impl Into<String>`) matching ",
6163 "the paired `crate::render::*` predicate's ",
6164 "`Result<(), String>` return shape every wire-up ",
6165 "already holds owned at the call site."
6166 )]
6167 #[must_use]
6168 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
6169 Self::$variant {
6170 nome: nome.to_string(),
6171 $axis: $axis.to_string(),
6172 reason,
6173 }
6174 }
6175 )*
6176 }
6177 };
6178}
6179
6180dep_nome_axis_reason_ctors! {
6181 versao_invalid => VersaoInvalid { versao },
6182 fonte_repo_shape => FonteRepoShape { repo },
6183 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
6184}
6185
6186// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
6187// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
6188// <value>.to_string() }` struct-variant wire-up sites at
6189// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
6190// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
6191// per-entry set-not-multiset dedup closure onto one substrate-primitive
6192// family per typed variant — the missing two-slot rung on the
6193// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
6194// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
6195// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
6196// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
6197// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
6198// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
6199// symmetric sibling of the peer
6200// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
6201// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
6202// envelope — same `<axis>: <value>.to_string()` owned-forward payload
6203// shape, `reason` axis removed and `nome`-axis added at the per-dep-
6204// owned altitude the `DepError` envelope keys off (every `DepError`
6205// variant carries the offending `:deps :nome` verbatim so the author
6206// can grep their caixa.lisp for the offending block in one edit). The
6207// three variants share the same `{ nome: String, <axis>: String }`
6208// two-slot shape: the `nome` field names the offending dep the
6209// diagnostic points the author back at, and the middle `<axis>:
6210// String` field carries the offending per-envelope axis value verbatim
6211// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
6212// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
6213// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
6214// The middle axis-field name differs across variants (`pin` / `pins` /
6215// `caracteristica`) so the ctor family below takes the axis field name
6216// as a macro parameter (`$axis:ident`) alongside the ctor + variant
6217// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
6218// Self` inherent constructor per typed variant that spells the
6219// uniform two-field construction (`nome.to_string()` /
6220// `<axis>.to_string()`) exactly once.
6221//
6222// The three wire-up sites this fold closes are:
6223// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
6224// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
6225// pin.to_string() });` inside the `set.len() == 1` branch after the
6226// `is_some_and(String::is_empty)` iterator);
6227// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
6228// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
6229// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
6230// - [`Dep::validate_caracteristicas`]'s per-entry
6231// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
6232// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
6233// [`crate::render::insert_first_seen`]).
6234//
6235// Each opened the identical four-line struct-literal against the same
6236// `(nome, <axis>)` local pair — the exact "same block re-inlined at
6237// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6238// same altitude the peer four already-lifted `DepError` ctor families
6239// closed on their sibling shape-envelopes. The three variant / axis-
6240// field discriminators are the only things that vary between them;
6241// the rest of the struct-literal is a byte-for-byte re-inline.
6242//
6243// Every future consumer wanting to raise one of these three
6244// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
6245// at lacre-resolve time re-checking each declared dep against the
6246// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
6247// set-not-multiset cascade, a future `feira validate --deps` per-
6248// caixa admission verb re-running the shape gates on demand, a
6249// per-lacre overlay resolver rejecting an author-supplied dep against
6250// a cluster-local snapshot the M4 CR materializer projects) now
6251// reaches one dispatch rather than re-inlining the four-line struct-
6252// literal in lockstep with the three in-crate wire-up sites.
6253macro_rules! dep_nome_axis_ctors {
6254 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6255 impl DepError {
6256 $(
6257 #[doc = concat!(
6258 "Construct a [`DepError::",
6259 stringify!($variant),
6260 "`] naming the offending `:deps :nome` and the ",
6261 "offending `:", stringify!($axis), "` axis value. ",
6262 "Folds the uniform `Self::",
6263 stringify!($variant),
6264 " { nome: nome.to_string(), ",
6265 stringify!($axis),
6266 ": ",
6267 stringify!($axis),
6268 ".to_string() }` two-field struct-literal onto one ",
6269 "substrate primitive so every in-crate wire-up on ",
6270 "this variant reads through one dispatch rather than ",
6271 "the pre-lift four-line open-coded block. Both `nome: ",
6272 "&str` and `",
6273 stringify!($axis),
6274 ": &str` parameters accept `&str` literals and ",
6275 "`&String` (via Deref coercion) so every existing ",
6276 "wire-up threads through the ctor without a pre-",
6277 "conversion."
6278 )]
6279 #[must_use]
6280 pub fn $ctor(nome: &str, $axis: &str) -> Self {
6281 Self::$variant {
6282 nome: nome.to_string(),
6283 $axis: $axis.to_string(),
6284 }
6285 }
6286 )*
6287 }
6288 };
6289}
6290
6291dep_nome_axis_ctors! {
6292 fonte_pin_empty => FontePinEmpty { pin },
6293 fonte_pin_ambiguous => FontePinAmbiguous { pins },
6294 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
6295}
6296
6297// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
6298// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
6299// struct-variant wire-up sites at [`DepSource::validate`]'s
6300// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
6301// the `DepError` envelope — the last open-coded ctor site remaining on
6302// the `:fonte (:tipo git …)` value-shape trajectory this envelope
6303// carries, and the single-variant sibling of the peer four already-
6304// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
6305// on the two-slot `{ nome, caminho }` envelope,
6306// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
6307// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
6308// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
6309// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
6310// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
6311// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
6312// `{ …, value: String, reason: String }` payload shape, one axis
6313// removed at the `nome`-only-owner altitude the `DepError` envelope
6314// keys off (no `edge_pair()` de/para pair).
6315//
6316// The two wire-up sites this fold closes are the paired refname-pin
6317// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
6318// pin: pin.to_string(), value: v.clone(), reason }` inside the
6319// `[(":tag", tag), (":branch", branch)]` iterator against
6320// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
6321// (`|| DepError::FontePinShape { nome: nome.to_string(),
6322// pin: ":rev".to_string(), value: v.clone(), reason }` against
6323// [`crate::render::is_git_oid`]) — each opened the identical
6324// `DepError::FontePinShape { … }` six-line struct-literal against the
6325// same `(nome: &str, pin: &str, v: &String, reason: String)` local
6326// tuple, the exact "same block re-inlined at every consumer" shape
6327// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
6328// the only thing that varies between them (`":tag"`/`":branch"` on
6329// the refname arm, `":rev"` on the hex-OID arm); the rest of the
6330// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
6331// route through the same ctor because their `pin` field carries the
6332// author-surface tag verbatim (matching the `FontePinEmpty` /
6333// `FontePinAmbiguous` sibling variants' `pin: String` axis
6334// convention), so the offending author can grep their caixa.lisp for
6335// the offending `:tag "<value>"` / `:branch "<value>"` /
6336// `:rev "<value>"` literal in one edit.
6337//
6338// The single ctor below folds each wire-up onto one dispatch:
6339// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
6340// the pre-lift struct-literal on the same `(&str, &str, &str,
6341// String)` fixture. The uniform four-field construction
6342// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
6343// `reason` forwarded owned) is spelled once here rather than at every
6344// wire-up site. The `reason: String` field takes an owned `String`
6345// (not `impl Into<String>`) matching the two call sites' pre-existing
6346// `let Err(reason) = crate::render::is_git_ref_name(v)` /
6347// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
6348// predicates return `Result<(), String>`, so the caller always holds
6349// an owned `String` at the wire-up site and threading it through the
6350// ctor without a `.into()` shim keeps the routing shape byte-equal to
6351// the pre-lift block. The `value: &str` parameter accepts both `&str`
6352// literals (unused today) and `&String` (from the caller-held
6353// `v: &String` on each arm, via Deref coercion), so every existing
6354// wire-up threads through the ctor without a pre-conversion.
6355//
6356// Every future consumer that wants to construct this variant outside
6357// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
6358// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
6359// re-checking the same value-shape axes the resolver consumes, a
6360// future `feira validate --deps` per-caixa admission verb re-checking
6361// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
6362// resolver rejecting a git-pin value against a cluster-local
6363// snapshot) now reaches this variant through one call rather than
6364// re-inlining the six-line struct-literal in lockstep with the two
6365// in-crate wire-up sites.
6366impl DepError {
6367 /// Construct a [`DepError::FontePinShape`] naming the offending
6368 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
6369 /// axis tag, the offending value, and the parser-shaped `reason`.
6370 /// Folds the uniform
6371 /// `Self::FontePinShape { nome: nome.to_string(),
6372 /// pin: pin.to_string(), value: value.to_string(), reason }`
6373 /// four-field struct-literal onto one substrate primitive so
6374 /// every [`DepSource::validate`] wire-up on this variant reads
6375 /// through one dispatch rather than the pre-lift six-line
6376 /// open-coded block. The `nome` string threads verbatim from
6377 /// [`Dep::nome`] at the call site; the `pin` string carries the
6378 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
6379 /// `value` string carries the offending refname / hex-OID
6380 /// verbatim; and `reason` forwards the owned `String` returned
6381 /// by [`crate::render::is_git_ref_name`] /
6382 /// [`crate::render::is_git_oid`] without a `.into()` shim.
6383 #[must_use]
6384 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
6385 Self::FontePinShape {
6386 nome: nome.to_string(),
6387 pin: pin.to_string(),
6388 value: value.to_string(),
6389 reason,
6390 }
6391 }
6392
6393 /// Construct a [`DepError::NomeInvalid`] naming the offending
6394 /// `:deps :nome` byte-string and the parser-shaped rejection
6395 /// `reason` returned by [`crate::render::is_dns_1123_label`].
6396 ///
6397 /// Folds the uniform
6398 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
6399 /// struct-literal onto one substrate primitive so every wire-up on
6400 /// this variant reads through one dispatch rather than the pre-lift
6401 /// four-line open-coded `DepError::NomeInvalid { nome:
6402 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
6403 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
6404 /// ctor-family ladder (`{ nome }` one-slot →
6405 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
6406 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
6407 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
6408 /// `{ nome, <axis>: String, reason: String }` three-slot →
6409 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
6410 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
6411 /// — the sole variant on the envelope carrying the
6412 /// `{ nome: String, reason: String }` two-slot shape without a
6413 /// middle axis, matching the peer
6414 /// [`crate::manifest::ManifestError::NomeInvalid`] +
6415 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
6416 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
6417 /// four-axis DNS-1123 caixa-identifier diagnostic family the
6418 /// existing `nome_invalid_diagnostic_carries_offending_name` test
6419 /// pins on this envelope.
6420 ///
6421 /// The `nome: &str` parameter accepts `&str` literals and `&String`
6422 /// (via Deref coercion) so the sole in-crate wire-up threads through
6423 /// the ctor without a pre-conversion; the `reason: String`
6424 /// parameter takes an owned `String` (not `impl Into<String>`)
6425 /// matching the [`crate::render::is_dns_1123_label`] predicate's
6426 /// `Result<(), String>` return shape the sole wire-up site already
6427 /// holds owned at the call site, keeping the routing byte-equal to
6428 /// the pre-lift block. Same owned-`String`-forward `reason` payload
6429 /// discipline as the sibling three-slot family
6430 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
6431 /// and the four-slot [`DepError::fonte_pin_shape`] on
6432 /// `{ nome, pin, value, reason }`.
6433 ///
6434 /// Every future consumer that raises the same diagnostic outside
6435 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
6436 /// re-validator at lacre-resolve time re-checking each declared
6437 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
6438 /// side schema uses (the `:nome` value flows verbatim as the target
6439 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
6440 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
6441 /// checkout-directory leaf), a future `feira validate --deps`
6442 /// per-caixa admission verb re-running the shape gate on demand, a
6443 /// per-lacre overlay resolver rejecting an author-supplied dep's
6444 /// `:nome` against a cluster-local snapshot the M4 CR materializer
6445 /// projects, a future authoring-surface widening the field into a
6446 /// `(String, Vec<Suggestion>)` pair carrying a
6447 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6448 /// variant through one call rather than re-inlining the four-line
6449 /// struct-literal in lockstep with the one in-crate wire-up site.
6450 #[must_use]
6451 pub fn nome_invalid(nome: &str, reason: String) -> Self {
6452 Self::NomeInvalid {
6453 nome: nome.to_string(),
6454 reason,
6455 }
6456 }
6457}
6458
6459#[allow(clippy::trivially_copy_pass_by_ref)]
6460fn is_false(b: &bool) -> bool {
6461 !*b
6462}
6463
6464#[cfg(test)]
6465mod tests {
6466 use super::*;
6467
6468 #[test]
6469 fn registry_dep_is_minimal() {
6470 let d = Dep::simple("caixa-teia", "^0.1");
6471 assert_eq!(d.nome, "caixa-teia");
6472 assert_eq!(d.versao, "^0.1");
6473 assert!(d.fonte.is_none());
6474 assert!(!d.opcional());
6475 assert!(d.caracteristicas().is_empty());
6476 }
6477
6478 #[test]
6479 fn dep_string_scalar_accessor_pair_is_const_fn() {
6480 // Fail-before-pass-after pin on [`Dep::nome`] +
6481 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6482 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6483 // entry's [`String`] storage through the `pub const fn`
6484 // [`String::as_str`] (const-stable since Rust 1.87, well
6485 // within the workspace MSRV) — any future accidental
6486 // downgrade to non-`const` fails the corresponding
6487 // `<name>_via_const_fn` wrapper at caixa-core build time with
6488 // E0015 (`cannot call non-const method`), strictly stronger
6489 // than a runtime `assert!`. Sibling of the peer
6490 // per-M2/M3/universal-axis `String → &str` scalar-accessor
6491 // family pins on the sibling `const`-eval-surface passes
6492 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6493 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6494 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6495 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6496 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6497 // [`crate::aplicacao::Entrada::destination`] at the M3
6498 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6499 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6500 // M2 supervisor-tree axis,
6501 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6502 // M2 upgrade axis, and the per-`:contratos`
6503 // [`crate::aplicacao::WitContract::source`] /
6504 // [`crate::aplicacao::WitContract::destination`] /
6505 // [`crate::aplicacao::WitContract::world_ref`] trio the
6506 // sibling pin at 279823b already anchors).
6507 const fn nome_via_const_fn(d: &Dep) -> &str {
6508 d.nome()
6509 }
6510 const fn versao_via_const_fn(d: &Dep) -> &str {
6511 d.versao_requirement()
6512 }
6513 for (nome, versao) in [
6514 ("caixa-teia", "^0.1"),
6515 ("caixa-mesh", "~0.2.3"),
6516 ("caixa-helm", "*"),
6517 ] {
6518 let d = Dep::simple(nome, versao);
6519 assert_eq!(nome_via_const_fn(&d), d.nome());
6520 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6521 assert_eq!(d.nome(), nome);
6522 assert_eq!(d.versao_requirement(), versao);
6523 }
6524 }
6525
6526 #[test]
6527 fn dep_outer_accessor_family_is_const_fn() {
6528 // Fail-before-pass-after pin on [`Dep::fonte`] +
6529 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6530 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6531 // entry's composite / list storage through a `pub const fn`
6532 // stdlib method (`Option::<DepSource>::as_ref` /
6533 // `Vec::<String>::as_slice`, both const-stable since Rust
6534 // 1.83, well within the workspace MSRV). Any future
6535 // accidental downgrade to non-`const` fails the corresponding
6536 // `<name>_via_const_fn` wrapper at caixa-core build time with
6537 // E0015 (`cannot call non-const method`), strictly stronger
6538 // than a runtime `assert!` and side-stepping the destructor-
6539 // in-const restriction the `Dep` fixture's `String` /
6540 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6541 // direct-`const _: () = assert!(...)` residence.
6542 //
6543 // Peer of the sibling per-`Dep` scalar-accessor pair pin
6544 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6545 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6546 // the `const`-eval-surface discipline onto the composite-
6547 // reference and slice-return arms of the outer-`Dep` accessor
6548 // family, closing the four-slot outer surface (`:nome` +
6549 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6550 // posture. The `:opcional` `bool` arm already carries the
6551 // posture through [`Dep::opcional`]'s prior `pub const fn`
6552 // declaration, so this pin lands the last two unlifted
6553 // outer-`Dep` accessors and closes the family.
6554 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6555 d.fonte()
6556 }
6557 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6558 d.caracteristicas()
6559 }
6560 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6561 let empty = Dep::simple("caixa-teia", "^0.1");
6562 assert!(fonte_via_const_fn(&empty).is_none());
6563 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6564 assert!(caracteristicas_via_const_fn(&empty).is_empty());
6565 assert_eq!(
6566 caracteristicas_via_const_fn(&empty),
6567 empty.caracteristicas()
6568 );
6569 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6570 // still empty.
6571 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6572 assert!(fonte_via_const_fn(&git).is_some());
6573 assert_eq!(fonte_via_const_fn(&git), git.fonte());
6574 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6575 // Populated `:caracteristicas` — exercise the non-empty
6576 // slice-view arm to pin the accessor's borrow shape against
6577 // both a `Vec::new()` empty backing buffer and a populated one.
6578 let mut with_features = Dep::simple("caixa-teia", "^0.1");
6579 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6580 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6581 assert_eq!(
6582 caracteristicas_via_const_fn(&with_features),
6583 with_features.caracteristicas()
6584 );
6585 }
6586
6587 #[test]
6588 fn git_dep_carries_tag() {
6589 let d = Dep::git("t", "*", "github:o/r", "v1");
6590 match d.fonte {
6591 Some(DepSource::Git {
6592 ref repo, ref tag, ..
6593 }) => {
6594 assert_eq!(repo, "github:o/r");
6595 assert_eq!(tag.as_deref(), Some("v1"));
6596 }
6597 _ => panic!("expected Git source"),
6598 }
6599 }
6600
6601 #[test]
6602 fn validate_accepts_simple_dep() {
6603 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6604 }
6605
6606 #[test]
6607 fn validate_rejects_empty_nome() {
6608 // The fail-before-pass-after pin for `:nome ""`: the empty-name
6609 // arm fires first so the per-entry parse-side diagnostic doesn't
6610 // emit a useless `nome: ""` reference.
6611 let mut d = Dep::simple("placeholder", "^0.1");
6612 d.nome = String::new();
6613 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6614 }
6615
6616 #[test]
6617 fn validate_rejects_empty_versao() {
6618 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6619 // semver crate accepts the empty string as a wildcard match),
6620 // so the empty-`:versao` arm is structurally necessary even
6621 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6622 // `EmptyChildVersion` ordering on the other two `:versao` axes.
6623 let mut d = Dep::simple("caixa-teia", "ignored");
6624 d.versao = String::new();
6625 let err = d.validate().unwrap_err();
6626 assert!(
6627 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6628 "got {err:?}"
6629 );
6630 }
6631
6632 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6633
6634 #[test]
6635 fn validate_rejects_nome_with_uppercase() {
6636 // The fail-before-pass-after pin: a non-empty but uppercase
6637 // `:nome` silently passed `validate()` on every pre-gate
6638 // codebase because the prior shape only refused the empty
6639 // string. The DNS-1123 violation surfaced far downstream at
6640 // lacre-resolve time when the *target* caixa's `:nome` failed
6641 // its own gate — far from the `:deps` entry, with a diagnostic
6642 // naming the target rather than the dep entry that referenced
6643 // it. Same fail-before-pass-after fixture pinned for
6644 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6645 // and Caixa `:nome` (6c992f8).
6646 let d = Dep::simple("Caixa-Teia", "^0.1");
6647 let err = d.validate().unwrap_err();
6648 assert!(
6649 matches!(
6650 err,
6651 DepError::NomeInvalid { ref nome, ref reason }
6652 if nome == "Caixa-Teia" && reason.contains("uppercase")
6653 ),
6654 "got {err:?}"
6655 );
6656 }
6657
6658 #[test]
6659 fn validate_rejects_nome_with_underscore() {
6660 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6661 // "I'm thinking of Go module names / Python identifiers" leak.
6662 // Same fixture pinned for the peer caixa-identifier axes.
6663 let d = Dep::simple("caixa_teia", "^0.1");
6664 let err = d.validate().unwrap_err();
6665 assert!(
6666 matches!(
6667 err,
6668 DepError::NomeInvalid { ref nome, ref reason }
6669 if nome == "caixa_teia" && reason.contains('_')
6670 ),
6671 "got {err:?}"
6672 );
6673 }
6674
6675 #[test]
6676 fn validate_rejects_nome_with_dot() {
6677 // A `:deps :nome` is a single DNS-1123 *label*, not a
6678 // subdomain — dots are rejected. The `"caixa.teia"` shape is
6679 // the canonical "I confused the dep name with the FQDN /
6680 // namespace" footgun, distinct from the legitimate
6681 // `:fonte :repo "github:org/caixa-teia"` axis.
6682 let d = Dep::simple("caixa.teia", "^0.1");
6683 let err = d.validate().unwrap_err();
6684 assert!(
6685 matches!(
6686 err,
6687 DepError::NomeInvalid { ref nome, ref reason }
6688 if nome == "caixa.teia" && reason.contains('.')
6689 ),
6690 "got {err:?}"
6691 );
6692 }
6693
6694 #[test]
6695 fn validate_rejects_nome_with_leading_hyphen() {
6696 // RFC 1123 requires alphanumeric at both label boundaries.
6697 // Pinned in parity with the peer DNS-1123 fixtures.
6698 let d = Dep::simple("-caixa-teia", "^0.1");
6699 let err = d.validate().unwrap_err();
6700 assert!(
6701 matches!(
6702 err,
6703 DepError::NomeInvalid { ref nome, ref reason }
6704 if nome == "-caixa-teia" && reason.contains("alphanumeric")
6705 ),
6706 "got {err:?}"
6707 );
6708 }
6709
6710 #[test]
6711 fn validate_rejects_nome_with_trailing_hyphen() {
6712 let d = Dep::simple("caixa-teia-", "^0.1");
6713 let err = d.validate().unwrap_err();
6714 assert!(
6715 matches!(
6716 err,
6717 DepError::NomeInvalid { ref nome, ref reason }
6718 if nome == "caixa-teia-" && reason.contains("alphanumeric")
6719 ),
6720 "got {err:?}"
6721 );
6722 }
6723
6724 #[test]
6725 fn validate_rejects_nome_with_slash() {
6726 // The canonical "I copied the GitHub repo path into `:nome`
6727 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6728 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6729 // the local-name slot. Same fixture pinned for `:membros
6730 // :caixa` (3f9d7a0).
6731 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6732 let err = d.validate().unwrap_err();
6733 assert!(
6734 matches!(
6735 err,
6736 DepError::NomeInvalid { ref nome, ref reason }
6737 if nome == "pleme-io/caixa-teia" && reason.contains('/')
6738 ),
6739 "got {err:?}"
6740 );
6741 }
6742
6743 #[test]
6744 fn validate_rejects_nome_too_long() {
6745 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6746 // Built from a valid character set so the length-bound
6747 // diagnostic surfaces before any per-character check (the
6748 // order pin parallel to the per-character predicates inside
6749 // [`crate::render::is_dns_1123_label`]).
6750 let long = "a".repeat(64);
6751 let d = Dep::simple(&long, "^0.1");
6752 let err = d.validate().unwrap_err();
6753 assert!(
6754 matches!(
6755 err,
6756 DepError::NomeInvalid { ref nome, ref reason }
6757 if nome.len() == 64 && reason.contains("max length of 63")
6758 ),
6759 "got {err:?}"
6760 );
6761 }
6762
6763 #[test]
6764 fn validate_accepts_canonical_nome_labels() {
6765 // Positive-control sweep — every form the K8s apiserver
6766 // accepts as a DNS-1123 label must round-trip through
6767 // validate. Covers a hyphen-bearing label, a numeric-suffix
6768 // label, a leading-digit label, a single-character label, and
6769 // a 63-byte (exactly the cap) label — the same fixture set
6770 // the peer `:membros :caixa` / `:children :caixa` positive
6771 // controls pin.
6772 for nome in [
6773 "caixa-teia",
6774 "caixa-resolver2",
6775 "2nd-tier-cache",
6776 "x",
6777 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6778 ] {
6779 Dep::simple(nome, "^0.1")
6780 .validate()
6781 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6782 }
6783 }
6784
6785 #[test]
6786 fn nome_empty_takes_precedence_over_nome_invalid() {
6787 // Ordering pin: `NomeEmpty` is the more self-locating
6788 // diagnostic on `""` and must lead — `is_dns_1123_label` is
6789 // only reached after the empty-check fires at the call site.
6790 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6791 // (3f9d7a0) on the peer caixa-identifier axis.
6792 let mut d = Dep::simple("placeholder", "^0.1");
6793 d.nome = String::new();
6794 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6795 }
6796
6797 #[test]
6798 fn nome_invalid_fires_before_versao_empty() {
6799 // Ordering pin: a malformed `:nome` fires before any `:versao`
6800 // axis check on the *same* entry — the per-entry shape gates
6801 // run top-to-bottom (nome empty → nome shape → versao empty →
6802 // versao parse → fonte shape), so a one-entry caixa.lisp with
6803 // both wrong sees the name-side diagnostic first (the name is
6804 // the self-locating axis — without a valid name, the parse
6805 // diagnostic can't quote `:nome "<bad>"`). Same ordering
6806 // discipline as `membro_caixa_invalid_fires_before_versao_check`
6807 // (3f9d7a0).
6808 let mut d = Dep::simple("Caixa-Teia", "^0.1");
6809 d.versao = String::new();
6810 let err = d.validate().unwrap_err();
6811 assert!(
6812 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6813 "got {err:?}"
6814 );
6815 }
6816
6817 #[test]
6818 fn nome_invalid_fires_before_versao_invalid() {
6819 // Ordering pin: a malformed `:nome` fires before the `:versao`
6820 // parse-side check on the *same* entry. Pin separately from
6821 // the empty-versao ordering so a future re-ordering surfaces
6822 // here, parallel to the b0c8389 / c4213a4 trajectory.
6823 let d = Dep::simple("Caixa-Teia", "^^0.1");
6824 let err = d.validate().unwrap_err();
6825 assert!(
6826 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6827 "got {err:?}"
6828 );
6829 }
6830
6831 #[test]
6832 fn nome_invalid_fires_before_fonte_invalid() {
6833 // Ordering pin: a malformed `:nome` fires before the `:fonte`
6834 // shape check on the *same* entry. The `:fonte` diagnostic
6835 // names the offending dep's `:nome` verbatim (via
6836 // `DepSource::validate(&self.nome)`), so a non-self-locating
6837 // name would taint the downstream diagnostic too — the gate
6838 // ordering keeps both diagnostics individually self-locating.
6839 let mut d = Dep::simple("Caixa-Teia", "^0.1");
6840 d.fonte = Some(DepSource::Git {
6841 repo: String::new(),
6842 tag: None,
6843 rev: None,
6844 branch: None,
6845 });
6846 let err = d.validate().unwrap_err();
6847 assert!(
6848 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6849 "got {err:?}"
6850 );
6851 }
6852
6853 #[test]
6854 fn nome_invalid_diagnostic_carries_offending_name() {
6855 // The diagnostic-shape pin: the error names the offending
6856 // `:nome` value verbatim so the author can grep their
6857 // caixa.lisp without re-running the build, and carries a
6858 // non-empty `reason` from `is_dns_1123_label` so the
6859 // predicate's own wording flows through to the diagnostic.
6860 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6861 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6862 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6863 // share a structurally-equivalent diagnostic family.
6864 let d = Dep::simple("Caixa_Teia", "^0.1");
6865 let err = d.validate().unwrap_err();
6866 let DepError::NomeInvalid { nome, reason } = err else {
6867 panic!("expected NomeInvalid, got other variant");
6868 };
6869 assert_eq!(nome, "Caixa_Teia");
6870 assert!(
6871 !reason.is_empty(),
6872 "NomeInvalid `reason` must carry the predicate's wording verbatim"
6873 );
6874 }
6875
6876 #[test]
6877 fn validate_rejects_invalid_versao_requirement() {
6878 // The fail-before-pass-after pin: a non-empty but malformed
6879 // requirement (`"^bad-version"`) silently passed every pre-gate
6880 // codebase because `:deps :versao` wasn't validated. The parse
6881 // failure surfaced far downstream at lacre-resolve time with a
6882 // `semver::Error` that didn't name which `:deps` entry carried
6883 // the typo. The new gate moves the check to caixa-build time
6884 // at the source caixa.lisp.
6885 let d = Dep::simple("caixa-teia", "^bad-version");
6886 let err = d.validate().unwrap_err();
6887 assert!(
6888 matches!(
6889 err,
6890 DepError::VersaoInvalid { ref nome, ref versao, .. }
6891 if nome == "caixa-teia" && versao == "^bad-version"
6892 ),
6893 "got {err:?}"
6894 );
6895 }
6896
6897 #[test]
6898 fn validate_rejects_versao_with_double_caret_typo() {
6899 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6900 // Cargo-shaped requirement on first glance but fails the parser
6901 // because semver doesn't accept stacked operators. Pin this
6902 // adjacent-shape footgun explicitly so a future relaxation that
6903 // accepts "looks-canonical-but-isn't" forms surfaces here, in
6904 // parity with the `:membros` / `:children` fixtures.
6905 let d = Dep::simple("caixa-teia", "^^0.1");
6906 let err = d.validate().unwrap_err();
6907 assert!(
6908 matches!(
6909 err,
6910 DepError::VersaoInvalid { ref nome, ref versao, .. }
6911 if nome == "caixa-teia" && versao == "^^0.1"
6912 ),
6913 "got {err:?}"
6914 );
6915 }
6916
6917 #[test]
6918 fn validate_rejects_versao_with_v_prefixed_tag() {
6919 // `"v0.1"` is the canonical "git-tag-shape leaking into the
6920 // semver requirement slot" typo — an author copies the
6921 // publish-side git-tag string verbatim into `:versao`, but
6922 // Cargo's semver parser rejects the leading `v`. Same fixture
6923 // pinned for `:membros :versao` (9888b13) and `:children
6924 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6925 // are *accepted* by the semver crate as an `*` wildcard on the
6926 // patch axis — they're a Cargo-side valid shape, not a typo.)
6927 let d = Dep::simple("caixa-teia", "v0.1");
6928 let err = d.validate().unwrap_err();
6929 assert!(
6930 matches!(
6931 err,
6932 DepError::VersaoInvalid { ref nome, ref versao, .. }
6933 if nome == "caixa-teia" && versao == "v0.1"
6934 ),
6935 "got {err:?}"
6936 );
6937 }
6938
6939 #[test]
6940 fn validate_accepts_canonical_versao_forms() {
6941 // The five Cargo-shaped requirement forms `:membros :versao`
6942 // and `:children :versao` already accept via
6943 // `crate::parse_requirement` must pass the deps gate without
6944 // re-validating at the resolver layer. Pin every leg so a
6945 // future tightening of the canonical set surfaces here as a
6946 // test failure.
6947 for form in [
6948 "^0.1", // caret — minor-range pin (the most common shape)
6949 "~0.1.2", // tilde — patch-range pin
6950 "0.1.0", // exact — single-version pin
6951 "*", // wildcard — explicitly any-version
6952 ">=0.1, <2", // multi-range — comma-separated comparators
6953 ] {
6954 Dep::simple("caixa-teia", form)
6955 .validate()
6956 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6957 }
6958 }
6959
6960 #[test]
6961 fn versao_empty_takes_precedence_over_invalid() {
6962 // Order pin: the existing `VersaoEmpty` diagnostic (which
6963 // doesn't try to parse) fires before the new `VersaoInvalid`
6964 // parse-side diagnostic, so an empty `:versao` keeps its
6965 // narrower error message — `parse_requirement("")` would
6966 // otherwise return `Ok(STAR)` and silently pass, but the empty
6967 // arm catches it first.
6968 let mut d = Dep::simple("caixa-teia", "ignored");
6969 d.versao = String::new();
6970 let err = d.validate().unwrap_err();
6971 assert!(
6972 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6973 "got {err:?}"
6974 );
6975 }
6976
6977 #[test]
6978 fn nome_empty_takes_precedence_over_versao_invalid() {
6979 // Order pin: even when `:versao` is malformed and would raise
6980 // its own diagnostic, `:nome ""` fires first because the
6981 // per-entry parse diagnostic needs a non-empty name to be
6982 // self-locating. Mirrors the
6983 // `membros_validation_runs_before_contratos_membership_check`
6984 // ordering on the typed-graph layer.
6985 let mut d = Dep::simple("placeholder", "^bad");
6986 d.nome = String::new();
6987 let err = d.validate().unwrap_err();
6988 assert_eq!(err, DepError::NomeEmpty);
6989 }
6990
6991 #[test]
6992 fn versao_invalid_diagnostic_carries_offending_versao() {
6993 // The diagnostic-shape pin: the error names the offending
6994 // `:versao` value verbatim so the author can grep their
6995 // caixa.lisp without re-running the build, and carries a
6996 // non-empty `reason` from `semver::VersionReq::parse` so the
6997 // parser's own wording flows through to the diagnostic.
6998 let d = Dep::simple("caixa-teia", "not-a-req");
6999 let err = d.validate().unwrap_err();
7000 let DepError::VersaoInvalid {
7001 nome,
7002 versao,
7003 reason,
7004 } = err
7005 else {
7006 panic!("expected VersaoInvalid, got other variant");
7007 };
7008 assert_eq!(nome, "caixa-teia");
7009 assert_eq!(versao, "not-a-req");
7010 assert!(
7011 !reason.is_empty(),
7012 "VersaoInvalid `reason` must carry the parser's wording verbatim"
7013 );
7014 }
7015
7016 // -- :fonte value-shape gate ------------------------------------------
7017
7018 fn dep_with_fonte(fonte: DepSource) -> Dep {
7019 let mut d = Dep::simple("caixa-teia", "^0.1");
7020 d.fonte = Some(fonte);
7021 d
7022 }
7023
7024 #[test]
7025 fn validate_accepts_git_fonte_with_tag() {
7026 // The positive-control pin on the canonical git source — exactly
7027 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
7028 // shape every existing caixa-resolver integration test uses.
7029 let d = dep_with_fonte(DepSource::Git {
7030 repo: "github:pleme-io/caixa-teia".into(),
7031 tag: Some("v0.1.0".into()),
7032 rev: None,
7033 branch: None,
7034 });
7035 d.validate().unwrap();
7036 }
7037
7038 #[test]
7039 fn validate_accepts_git_fonte_with_rev() {
7040 // Each of the three pin axes is independently a valid single-pin
7041 // shape; pin the :rev arm so a future relaxation that only
7042 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
7043 // OID — the canonical `git rev-parse HEAD` emission shape the
7044 // `crate::render::is_git_oid` value-shape gate now requires;
7045 // abbreviated OIDs are ambiguous across repo history and
7046 // rejected at this gate (pinned separately by
7047 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
7048 let d = dep_with_fonte(DepSource::Git {
7049 repo: "github:pleme-io/caixa-teia".into(),
7050 tag: None,
7051 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
7052 branch: None,
7053 });
7054 d.validate().unwrap();
7055 }
7056
7057 #[test]
7058 fn validate_accepts_git_fonte_with_branch() {
7059 // The :branch arm is the third valid single-pin shape — pinned
7060 // separately so the gate-accepts-all-three-pin-axes contract is
7061 // a build-error to relax.
7062 let d = dep_with_fonte(DepSource::Git {
7063 repo: "github:pleme-io/caixa-teia".into(),
7064 tag: None,
7065 rev: None,
7066 branch: Some("main".into()),
7067 });
7068 d.validate().unwrap();
7069 }
7070
7071 #[test]
7072 fn validate_accepts_path_fonte() {
7073 // The positive-control pin on the path source — non-empty
7074 // :caminho, no pin axes (paths have no commit identity). Pinned
7075 // so a future "paths must also pin a rev" tightening surfaces
7076 // here as a structural decision, not a silent break.
7077 let d = dep_with_fonte(DepSource::Path {
7078 caminho: "../caixa-teia".into(),
7079 });
7080 d.validate().unwrap();
7081 }
7082
7083 #[test]
7084 fn validate_rejects_git_fonte_with_empty_repo() {
7085 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
7086 // "v1")`: the empty-repo shape silently passed every pre-gate
7087 // codebase because `:fonte` wasn't validated. The git-clone
7088 // failure surfaced far downstream at lacre-resolve time with no
7089 // field naming which `:deps` entry carried the typo. The new
7090 // gate moves the check to caixa-build time at the source
7091 // caixa.lisp.
7092 let d = dep_with_fonte(DepSource::Git {
7093 repo: String::new(),
7094 tag: Some("v0.1.0".into()),
7095 rev: None,
7096 branch: None,
7097 });
7098 let err = d.validate().unwrap_err();
7099 assert!(
7100 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
7101 "got {err:?}"
7102 );
7103 }
7104
7105 // -- :repo value-shape gate -------------------------------------------
7106 //
7107 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
7108 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
7109 // codebase admitted any non-empty string; the new
7110 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
7111 // URL intersection-floor at validate time, peer with the three pin
7112 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
7113 // `is_git_oid`). Every test in this section is a fail-before /
7114 // pass-after pin on a specific authoring footgun.
7115
7116 #[test]
7117 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
7118 // The canonical paste-from-doc footgun on `:repo` — an author
7119 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
7120 // a doc paragraph. Until this gate landed the empty-repo arm
7121 // passed (the string isn't empty), the resolver issued
7122 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
7123 // surfaced at clone time with a quoting-confused error far from
7124 // the source caixa.lisp. Same paste-from-doc footgun the
7125 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
7126 // axis — now closed on the `:repo` URL axis too.
7127 let d = dep_with_fonte(DepSource::Git {
7128 repo: "github:pleme-io/caixa-teia ".into(),
7129 tag: Some("v0.1.0".into()),
7130 rev: None,
7131 branch: None,
7132 });
7133 let err = d.validate().unwrap_err();
7134 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7135 panic!("expected FonteRepoShape, got other variant");
7136 };
7137 assert_eq!(nome, "caixa-teia");
7138 assert_eq!(repo, "github:pleme-io/caixa-teia ");
7139 assert!(
7140 reason.contains("whitespace"),
7141 "reason must surface the whitespace arm, got {reason:?}"
7142 );
7143 }
7144
7145 #[test]
7146 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
7147 // The canonical CLI-argument-injection footgun at the `git clone`
7148 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
7149 // argv parser read the value as a CLI flag, escaping the
7150 // subprocess argument boundary. The `--` separator workaround
7151 // does not fix the typed slot's accepted set; the gate rejects
7152 // the shape upstream at validate time so the resolver never
7153 // invokes a `git clone -…` subprocess.
7154 let d = dep_with_fonte(DepSource::Git {
7155 repo: "-upload-pack=evil".into(),
7156 tag: Some("v0.1.0".into()),
7157 rev: None,
7158 branch: None,
7159 });
7160 let err = d.validate().unwrap_err();
7161 let DepError::FonteRepoShape { repo, reason, .. } = err else {
7162 panic!("expected FonteRepoShape, got other variant");
7163 };
7164 assert_eq!(repo, "-upload-pack=evil");
7165 assert!(
7166 reason.contains("must not start with `-`"),
7167 "reason must surface the leading-`-` arm, got {reason:?}"
7168 );
7169 }
7170
7171 #[test]
7172 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
7173 // The canonical paste-from-multiline-doc footgun — a `:repo`
7174 // string with an embedded `\n` silently breaks git's URL parser
7175 // and is a class of CRLF-injection at the subprocess-argument
7176 // boundary. Caught by the control-char arm (0x0A < 0x20).
7177 let d = dep_with_fonte(DepSource::Git {
7178 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
7179 tag: Some("v0.1.0".into()),
7180 rev: None,
7181 branch: None,
7182 });
7183 let err = d.validate().unwrap_err();
7184 let DepError::FonteRepoShape { reason, .. } = err else {
7185 panic!("expected FonteRepoShape, got other variant");
7186 };
7187 assert!(
7188 reason.contains("control character"),
7189 "reason must surface the control-char arm, got {reason:?}"
7190 );
7191 }
7192
7193 #[test]
7194 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
7195 // Tab is the sibling whitespace footgun (the canonical
7196 // copy-from-aligned-table paste); pinned separately from the
7197 // space arm so a future relaxation that only catches one
7198 // surfaces here.
7199 let d = dep_with_fonte(DepSource::Git {
7200 repo: "github:pleme-io/caixa-teia\t".into(),
7201 tag: Some("v0.1.0".into()),
7202 rev: None,
7203 branch: None,
7204 });
7205 let err = d.validate().unwrap_err();
7206 assert!(
7207 matches!(
7208 err,
7209 DepError::FonteRepoShape { ref reason, .. }
7210 if reason.contains("whitespace")
7211 ),
7212 "got {err:?}"
7213 );
7214 }
7215
7216 #[test]
7217 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
7218 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
7219 // non-ASCII silently breaks at git's URL parser and round-trips
7220 // inconsistently across NFC/NFD normalization on APFS /
7221 // case-folding filesystems. Same intersection-floor
7222 // [`is_git_ref_name`] enforces on the refname axes.
7223 let d = dep_with_fonte(DepSource::Git {
7224 repo: "https://github.com/pleme-io/café".into(),
7225 tag: Some("v0.1.0".into()),
7226 rev: None,
7227 branch: None,
7228 });
7229 let err = d.validate().unwrap_err();
7230 assert!(
7231 matches!(
7232 err,
7233 DepError::FonteRepoShape { ref reason, .. }
7234 if reason.contains("non-ASCII")
7235 ),
7236 "got {err:?}"
7237 );
7238 }
7239
7240 #[test]
7241 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
7242 // The fail-before-pass-after pin for the canonical paste-from-
7243 // browser-address-bar footgun on `:repo`: an author copies a
7244 // GitHub permalink to a README anchor / line-permalink and
7245 // forgets to trim the `#fragment` tail. Until this arm landed
7246 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
7247 // silently passed every prior arm (no whitespace, no control
7248 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
7249 // or `:`), libcurl's URL parser stripped the `#readme` tail
7250 // before opening the HTTPS transport, and the lacre embedded
7251 // the value verbatim in its per-dep BLAKE3 closure — two
7252 // authors whose values differ only in their fragment anchor
7253 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
7254 // `git clone` but lock to two distinct lacres, defeating the
7255 // THEORY.md §V.2 render-determinism contract. Same value-shape
7256 // axis-floor every peer typed surface enforces; peer `:fonte
7257 // :tag` / `:fonte :branch` already reject the byte-class through
7258 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
7259 // URL grammar admitted) and `:entrada :paths` rejects `#` as
7260 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
7261 let d = dep_with_fonte(DepSource::Git {
7262 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
7263 tag: Some("v0.1.0".into()),
7264 rev: None,
7265 branch: None,
7266 });
7267 let err = d.validate().unwrap_err();
7268 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7269 panic!("expected FonteRepoShape, got other variant");
7270 };
7271 assert_eq!(nome, "caixa-teia");
7272 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
7273 assert!(
7274 reason.contains("must not contain `#`"),
7275 "reason must surface the fragment-`#` arm, got {reason:?}"
7276 );
7277 assert!(
7278 reason.contains("fragment"),
7279 "reason must name the URL fragment grammar, got {reason:?}"
7280 );
7281 }
7282
7283 #[test]
7284 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
7285 // The symmetric paste-from-Nix-flake-ref footgun — an author
7286 // confuses the Nix flake-reference idiom (`github:foo/
7287 // bar#packageName`, where `#packageName` selects a flake
7288 // output) with the bare git `:repo` shape. The pleme-io
7289 // substrate authors compose flakes downstream of caixa
7290 // (caixa-flake renders a flake.nix), so the cross-idiom leak
7291 // is the canonical near-miss: the author writes the
7292 // flake-ref shape into a git `:repo` slot. Pinned separately
7293 // from the HTTPS-anchor arm so a future relaxation that
7294 // narrows to one URL scheme surfaces here.
7295 let d = dep_with_fonte(DepSource::Git {
7296 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
7297 tag: Some("v0.1.0".into()),
7298 rev: None,
7299 branch: None,
7300 });
7301 let err = d.validate().unwrap_err();
7302 let DepError::FonteRepoShape { reason, .. } = err else {
7303 panic!("expected FonteRepoShape, got other variant");
7304 };
7305 assert!(
7306 reason.contains("must not contain `#`"),
7307 "reason must surface the fragment-`#` arm, got {reason:?}"
7308 );
7309 assert!(
7310 reason.contains("Nix flake"),
7311 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
7312 );
7313 }
7314
7315 #[test]
7316 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
7317 // The fail-before-pass-after pin for the canonical paste-from-
7318 // browser-address-bar footgun on `:repo` (peer with the
7319 // a68f818 fragment-`#` arm on the same axis). An author
7320 // copies a GitHub tab deep-link out of the address bar and
7321 // forgets to trim the `?tab=…` query tail. Until this arm
7322 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
7323 // silently passed every prior arm (no whitespace, no control
7324 // chars, no non-ASCII, no `#` fragment, contains a `:`,
7325 // doesn't start with `-` or `:`); GitHub silently ignored
7326 // the `?query` tail and served the same repo regardless;
7327 // the lacre embedded the value verbatim in its per-dep
7328 // BLAKE3 closure — two authors whose values differ only in
7329 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
7330 // `?utm_source=twitter`) resolve to the byte-identical
7331 // upstream `git clone` but lock to two distinct lacres,
7332 // defeating the THEORY.md §V.2 render-determinism contract
7333 // on the same axis the `#` fragment arm closes. Same value-
7334 // shape axis-floor every peer typed surface enforces; peer
7335 // `:fonte :tag` / `:fonte :branch` already reject the byte-
7336 // class through `is_git_ref_name`'s alphabet (refspec glob
7337 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
7338 // :paths` rejects `?` as the query separator in
7339 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
7340 let d = dep_with_fonte(DepSource::Git {
7341 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
7342 tag: Some("v0.1.0".into()),
7343 rev: None,
7344 branch: None,
7345 });
7346 let err = d.validate().unwrap_err();
7347 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7348 panic!("expected FonteRepoShape, got other variant");
7349 };
7350 assert_eq!(nome, "caixa-teia");
7351 assert_eq!(
7352 repo,
7353 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
7354 );
7355 assert!(
7356 reason.contains("must not contain `?`"),
7357 "reason must surface the query-`?` arm, got {reason:?}"
7358 );
7359 assert!(
7360 reason.contains("query"),
7361 "reason must name the URL query grammar, got {reason:?}"
7362 );
7363 }
7364
7365 #[test]
7366 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
7367 // The symmetric paste-from-social-share footgun — an author
7368 // copies a repo URL out of a Slack unfurl / Twitter share /
7369 // newsletter link / Discord embed and forgets to trim the
7370 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
7371 // campaign-tracker tail. Every major social-share / unfurl /
7372 // newsletter platform appends these UTM parameters; the
7373 // canonical near-miss on the `:repo` axis. Pinned separately
7374 // from the GitHub-tab-deep-link arm so a future relaxation
7375 // that narrows to one query-parameter class surfaces here.
7376 let d = dep_with_fonte(DepSource::Git {
7377 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
7378 .into(),
7379 tag: Some("v0.1.0".into()),
7380 rev: None,
7381 branch: None,
7382 });
7383 let err = d.validate().unwrap_err();
7384 let DepError::FonteRepoShape { reason, .. } = err else {
7385 panic!("expected FonteRepoShape, got other variant");
7386 };
7387 assert!(
7388 reason.contains("must not contain `?`"),
7389 "reason must surface the query-`?` arm, got {reason:?}"
7390 );
7391 assert!(
7392 reason.contains("campaign-tracker"),
7393 "reason must name the campaign-tracker paste footgun, got {reason:?}"
7394 );
7395 }
7396
7397 #[test]
7398 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
7399 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
7400 // both per-byte arms inside the same `for &b in s.as_bytes()`
7401 // loop, so the byte that appears first in the value's byte
7402 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
7403 // (fragment before query — unusual URL-grammar but value-
7404 // disjoint at byte level) carries both `#` and `?`; the `#`
7405 // byte appears first, so the fragment-`#` arm fires, surfacing
7406 // the more self-locating diagnostic on the byte the author
7407 // pasted earliest in the URL. Mirrors the peer cascade
7408 // discipline `fonte_repo_control_char_fires_before_fragment`
7409 // pins on the prior `:repo` byte-class arm.
7410 let d = dep_with_fonte(DepSource::Git {
7411 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
7412 tag: Some("v0.1.0".into()),
7413 rev: None,
7414 branch: None,
7415 });
7416 let err = d.validate().unwrap_err();
7417 let DepError::FonteRepoShape { reason, .. } = err else {
7418 panic!("expected FonteRepoShape, got other variant");
7419 };
7420 assert!(
7421 reason.contains("must not contain `#`"),
7422 "reason must surface the fragment-`#` arm (fires before query-`?` when \
7423 `#` byte appears first in value), got {reason:?}"
7424 );
7425 }
7426
7427 #[test]
7428 fn fonte_repo_control_char_fires_before_fragment() {
7429 // Cascade pin: the control-char arm structurally precedes the
7430 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
7431 // positive on both arms (contains LF and `#`), but the narrower
7432 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
7433 // (`control character`) wins so the author sees the more
7434 // self-locating arm first. Mirrors the peer cascade discipline
7435 // every prior `:repo` byte-class arm establishes.
7436 let d = dep_with_fonte(DepSource::Git {
7437 repo: "github:pleme-io/caixa-teia\n#readme".into(),
7438 tag: Some("v0.1.0".into()),
7439 rev: None,
7440 branch: None,
7441 });
7442 let err = d.validate().unwrap_err();
7443 let DepError::FonteRepoShape { reason, .. } = err else {
7444 panic!("expected FonteRepoShape, got other variant");
7445 };
7446 assert!(
7447 reason.contains("control character"),
7448 "reason must surface the control-char arm, got {reason:?}"
7449 );
7450 }
7451
7452 #[test]
7453 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7454 // The fail-before-pass-after pin for the canonical Windows-
7455 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7456 // backslash arm on the sibling `:caminho` path-fonte axis).
7457 // An author pastes a Windows Explorer address-bar / PowerShell
7458 // `Get-Location` output into a `file://` URL slot, producing
7459 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7460 // value silently passed every prior arm (no whitespace, no
7461 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7462 // with `-` or `:`); libcurl's URL parser silently translates
7463 // `\` → `/` on some platforms and refuses it on others, so
7464 // the byte rides verbatim into the lacre's per-dep content-
7465 // address but is silently rewritten / rejected at the wire —
7466 // two authors whose `:repo` values differ only in backslash-
7467 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7468 // resolve to the byte-identical local clone but lock to two
7469 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7470 // render-determinism contract on the same axis the `#`
7471 // fragment and `?` query arms close. Same value-shape axis-
7472 // floor every peer typed surface enforces; the `:caminho`
7473 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7474 let d = dep_with_fonte(DepSource::Git {
7475 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7476 tag: Some("v0.1.0".into()),
7477 rev: None,
7478 branch: None,
7479 });
7480 let err = d.validate().unwrap_err();
7481 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7482 panic!("expected FonteRepoShape, got other variant");
7483 };
7484 assert_eq!(nome, "caixa-teia");
7485 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7486 assert!(
7487 reason.contains("must not contain `\\`"),
7488 "reason must surface the backslash-`\\` arm, got {reason:?}"
7489 );
7490 assert!(
7491 reason.contains("Windows"),
7492 "reason must name the Windows-path-confusion footgun, got {reason:?}"
7493 );
7494 }
7495
7496 #[test]
7497 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7498 // The symmetric Win32-shell-mangled-slashes footgun — an author
7499 // copies `https://github.com/foo/bar` into a Win32 shell that
7500 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7501 // separator-coercion bug), pastes the result into a `:repo`
7502 // slot, and produces `https:\\github.com\foo\bar`. Pinned
7503 // separately from the `file://` Explorer-paste arm so a future
7504 // relaxation that narrows to one URL scheme surfaces here.
7505 let d = dep_with_fonte(DepSource::Git {
7506 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7507 tag: Some("v0.1.0".into()),
7508 rev: None,
7509 branch: None,
7510 });
7511 let err = d.validate().unwrap_err();
7512 let DepError::FonteRepoShape { reason, .. } = err else {
7513 panic!("expected FonteRepoShape, got other variant");
7514 };
7515 assert!(
7516 reason.contains("must not contain `\\`"),
7517 "reason must surface the backslash-`\\` arm, got {reason:?}"
7518 );
7519 assert!(
7520 reason.contains("path separator") || reason.contains("path-segment separator"),
7521 "reason must name the URL path-segment separator grammar, got {reason:?}"
7522 );
7523 }
7524
7525 #[test]
7526 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7527 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7528 // are both per-byte arms inside the same `for &b in s.as_bytes()`
7529 // loop, so the byte that appears first in the value's byte order
7530 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7531 // both `#` and `\`; the `#` byte appears first, so the fragment-
7532 // `#` arm fires, surfacing the more self-locating diagnostic on
7533 // the byte the author pasted earliest in the URL. Mirrors the
7534 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7535 // pins on the prior `:repo` byte-class arm.
7536 let d = dep_with_fonte(DepSource::Git {
7537 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7538 tag: Some("v0.1.0".into()),
7539 rev: None,
7540 branch: None,
7541 });
7542 let err = d.validate().unwrap_err();
7543 let DepError::FonteRepoShape { reason, .. } = err else {
7544 panic!("expected FonteRepoShape, got other variant");
7545 };
7546 assert!(
7547 reason.contains("must not contain `#`"),
7548 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7549 `#` byte appears first in value), got {reason:?}"
7550 );
7551 }
7552
7553 #[test]
7554 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7555 // The fail-before-pass-after pin for the canonical URI Template
7556 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7557 // README quick-start snippet / OpenAPI `servers:` URL / Helm
7558 // chart `home:` template that carries unresolved
7559 // `{org}` / `{repo}` placeholders and pastes the raw template
7560 // into the `:repo` slot, expecting the substrate to resolve the
7561 // placeholder downstream. Until this arm landed the value
7562 // silently passed every prior arm (no whitespace, no control
7563 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7564 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7565 // / `%7D` on the wire, so the byte rides verbatim into the
7566 // lacre's per-dep content-address but round-trips inconsistently
7567 // between the lacre's per-dep content-address and the
7568 // resolver's `git clone <repo>` invocation, defeating the
7569 // THEORY.md §V.2 render-determinism contract on the same axis
7570 // the `#` fragment, `?` query, and `\` backslash arms close;
7571 // every git porcelain entry-point additionally fetches a
7572 // nonexistent literal-`{placeholder}`-named path far from the
7573 // source caixa.lisp.
7574 let d = dep_with_fonte(DepSource::Git {
7575 repo: "https://github.com/{org}/caixa-teia".into(),
7576 tag: Some("v0.1.0".into()),
7577 rev: None,
7578 branch: None,
7579 });
7580 let err = d.validate().unwrap_err();
7581 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7582 panic!("expected FonteRepoShape, got other variant");
7583 };
7584 assert_eq!(nome, "caixa-teia");
7585 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7586 assert!(
7587 reason.contains("must not contain `{`"),
7588 "reason must surface the open-brace `{{` arm, got {reason:?}"
7589 );
7590 assert!(
7591 reason.contains("URI Template") || reason.contains("RFC 6570"),
7592 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7593 );
7594 }
7595
7596 #[test]
7597 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7598 // The symmetric Mustache / Handlebars doubled-brace
7599 // substitution-form footgun every CI / IaC templating engine
7600 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7601 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7602 // chart README quick-start snippet emits. Pinned separately
7603 // from the single-`{` `{org}` arm so a future relaxation that
7604 // narrows to one substitution-form surfaces here.
7605 let d = dep_with_fonte(DepSource::Git {
7606 repo: "https://github.com/{{org}}/caixa-teia".into(),
7607 tag: Some("v0.1.0".into()),
7608 rev: None,
7609 branch: None,
7610 });
7611 let err = d.validate().unwrap_err();
7612 let DepError::FonteRepoShape { reason, .. } = err else {
7613 panic!("expected FonteRepoShape, got other variant");
7614 };
7615 assert!(
7616 reason.contains("must not contain `{`"),
7617 "reason must surface the open-brace `{{` arm, got {reason:?}"
7618 );
7619 }
7620
7621 #[test]
7622 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7623 // Asymmetric `}`-only shape — covers the closing-brace-by-
7624 // itself footgun (an author truncated `{org}/{repo}` mid-edit
7625 // and left a trailing `}` from the prior template fragment,
7626 // or pasted a value that included a closing brace from a
7627 // surrounding shell context). Pinned to ensure the predicate
7628 // refuses each brace independently rather than only when both
7629 // appear — a future regression that ANDs the two byte tests
7630 // surfaces here.
7631 let d = dep_with_fonte(DepSource::Git {
7632 repo: "https://github.com/pleme-io/caixa-teia}".into(),
7633 tag: Some("v0.1.0".into()),
7634 rev: None,
7635 branch: None,
7636 });
7637 let err = d.validate().unwrap_err();
7638 let DepError::FonteRepoShape { reason, .. } = err else {
7639 panic!("expected FonteRepoShape, got other variant");
7640 };
7641 assert!(
7642 reason.contains("must not contain `}`"),
7643 "reason must surface the close-brace `}}` arm, got {reason:?}"
7644 );
7645 }
7646
7647 #[test]
7648 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7649 // Cascade pin: the fragment-`#` arm and the template-`{` /
7650 // `}` arm are both per-byte arms inside the same
7651 // `for &b in s.as_bytes()` loop, so the byte that appears
7652 // first in the value's byte order wins. A `:repo
7653 // "https://github.com/p/x#readme{org}"` carries both `#` and
7654 // `{`; the `#` byte appears first, so the fragment-`#` arm
7655 // fires, surfacing the more self-locating diagnostic on the
7656 // byte the author pasted earliest in the URL. Mirrors the
7657 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7658 // pins on the prior `:repo` byte-class arm.
7659 let d = dep_with_fonte(DepSource::Git {
7660 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7661 tag: Some("v0.1.0".into()),
7662 rev: None,
7663 branch: None,
7664 });
7665 let err = d.validate().unwrap_err();
7666 let DepError::FonteRepoShape { reason, .. } = err else {
7667 panic!("expected FonteRepoShape, got other variant");
7668 };
7669 assert!(
7670 reason.contains("must not contain `#`"),
7671 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7672 `#` byte appears first in value), got {reason:?}"
7673 );
7674 }
7675
7676 #[test]
7677 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7678 // The fail-before-pass-after pin for the canonical
7679 // shell-output-redirection footgun on `:repo`: an author
7680 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7681 // / `… >output.txt`) into the `:repo` slot without trimming
7682 // the redirect. Until this arm landed the value silently
7683 // passed every prior arm (no whitespace, no control chars,
7684 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7685 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7686 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7687 // percent-encode set maps `>` → `%3E` on the wire, so the
7688 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7689 // but is silently rewritten or rejected at libcurl's URL-
7690 // parser layer — two authors whose values differ only in
7691 // their redirect tail (`>build.log` vs nothing) resolve to
7692 // the byte-identical upstream `git clone` but lock to two
7693 // distinct lacres, defeating the THEORY.md §V.2 render-
7694 // determinism contract. Peer with the `:caminho` axis's
7695 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7696 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7697 // byte RFC-3986-reserved set on `:entrada :paths`.
7698 let d = dep_with_fonte(DepSource::Git {
7699 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7700 tag: Some("v0.1.0".into()),
7701 rev: None,
7702 branch: None,
7703 });
7704 let err = d.validate().unwrap_err();
7705 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7706 panic!("expected FonteRepoShape, got other variant");
7707 };
7708 assert_eq!(nome, "caixa-teia");
7709 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7710 assert!(
7711 reason.contains("must not contain `>`"),
7712 "reason must surface the output-redirection `>` arm, got {reason:?}"
7713 );
7714 assert!(
7715 reason.contains("redirection") || reason.contains("'delims'"),
7716 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7717 );
7718 }
7719
7720 #[test]
7721 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7722 // The symmetric shell-input-redirection footgun — an author
7723 // pastes a shell-pipeline head (`git clone <input.url` /
7724 // `cat <README.md`) into the `:repo` slot. Pinned separately
7725 // from the `>`-output arm so a future relaxation that only
7726 // catches one of the two redirect bytes surfaces here. Peer
7727 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7728 // arm which closes both `<` and `>` under the same banner.
7729 let d = dep_with_fonte(DepSource::Git {
7730 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7731 tag: Some("v0.1.0".into()),
7732 rev: None,
7733 branch: None,
7734 });
7735 let err = d.validate().unwrap_err();
7736 let DepError::FonteRepoShape { reason, .. } = err else {
7737 panic!("expected FonteRepoShape, got other variant");
7738 };
7739 assert!(
7740 reason.contains("must not contain `<`"),
7741 "reason must surface the input-redirection `<` arm, got {reason:?}"
7742 );
7743 assert!(
7744 reason.contains("RFC 3986") || reason.contains("'unwise'"),
7745 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7746 );
7747 }
7748
7749 #[test]
7750 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7751 // The fail-before-pass-after pin for the canonical
7752 // paste-from-shell-prompt-with-backticked-substitution footgun
7753 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7754 // `:caminho` path-fonte axis). An author pastes a URL whose
7755 // segment carries a backticked command-substitution wrapper
7756 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7757 // from a doc / README quick-start snippet that expected the
7758 // substrate to substitute the value downstream. Until this arm
7759 // landed the value silently passed every prior arm (no
7760 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7761 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7762 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7763 // 'unwise' set and the WHATWG URL spec's fragment percent-
7764 // encode set maps `` ` `` → `%60` on the wire, so the byte
7765 // rides verbatim into the lacre's per-dep BLAKE3 closure but
7766 // is silently rewritten or rejected at libcurl's URL-parser
7767 // layer — two authors whose values differ only in their
7768 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7769 // byte-identical upstream `git clone` but lock to two distinct
7770 // lacres, defeating the THEORY.md §V.2 render-determinism
7771 // contract. Peer with the `:caminho` axis's
7772 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7773 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7774 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7775 let d = dep_with_fonte(DepSource::Git {
7776 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".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 { nome, repo, reason } = err else {
7783 panic!("expected FonteRepoShape, got other variant");
7784 };
7785 assert_eq!(nome, "caixa-teia");
7786 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7787 assert!(
7788 reason.contains("must not contain `` ` ``"),
7789 "reason must surface the backtick command-substitution arm, got {reason:?}"
7790 );
7791 assert!(
7792 reason.contains("command-substitution") || reason.contains("'unwise'"),
7793 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7794 got {reason:?}"
7795 );
7796 }
7797
7798 #[test]
7799 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7800 // Cascade pin: the fragment-`#` arm and the backtick command-
7801 // substitution arm are both per-byte arms inside the same
7802 // `for &b in s.as_bytes()` loop, so the byte that appears first
7803 // in the value's byte order wins. A `:repo
7804 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7805 // and backtick; the `#` byte appears first, so the fragment-
7806 // `#` arm fires, surfacing the more self-locating diagnostic
7807 // on the byte the author pasted earliest in the URL. Mirrors
7808 // the peer cascade discipline
7809 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7810 // pins on the prior `:repo` byte-class arm.
7811 let d = dep_with_fonte(DepSource::Git {
7812 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
7813 tag: Some("v0.1.0".into()),
7814 rev: None,
7815 branch: None,
7816 });
7817 let err = d.validate().unwrap_err();
7818 let DepError::FonteRepoShape { reason, .. } = err else {
7819 panic!("expected FonteRepoShape, got other variant");
7820 };
7821 assert!(
7822 reason.contains("must not contain `#`"),
7823 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7824 appears first in value), got {reason:?}"
7825 );
7826 }
7827
7828 #[test]
7829 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7830 // Cascade pin: the shell-redirection `<` / `>` arm and the
7831 // backtick command-substitution arm are both per-byte arms
7832 // inside the same `for &b in s.as_bytes()` loop, so the byte
7833 // that appears first in the value's byte order wins. A `:repo
7834 // "https://github.com/p/x>build.log/`whoami`"` carries both
7835 // `>` and backtick; the `>` byte appears first, so the
7836 // shell-redirection arm fires, surfacing the more self-
7837 // locating diagnostic on the byte the author pasted earliest
7838 // in the URL. Pins the natural-order cascade so a future
7839 // reorder of the per-byte arms surfaces here.
7840 let d = dep_with_fonte(DepSource::Git {
7841 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7842 tag: Some("v0.1.0".into()),
7843 rev: None,
7844 branch: None,
7845 });
7846 let err = d.validate().unwrap_err();
7847 let DepError::FonteRepoShape { reason, .. } = err else {
7848 panic!("expected FonteRepoShape, got other variant");
7849 };
7850 assert!(
7851 reason.contains("must not contain `>`"),
7852 "reason must surface the shell-redirection `>` arm (fires before backtick when \
7853 `>` byte appears first in value), got {reason:?}"
7854 );
7855 }
7856
7857 #[test]
7858 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7859 // Cascade pin: the fragment-`#` arm and the shell-redirection
7860 // `<` / `>` arm are both per-byte arms inside the same
7861 // `for &b in s.as_bytes()` loop, so the byte that appears
7862 // first in the value's byte order wins. A `:repo
7863 // "https://github.com/p/x#readme>build.log"` carries both
7864 // `#` and `>`; the `#` byte appears first, so the fragment-
7865 // `#` arm fires, surfacing the more self-locating diagnostic
7866 // on the byte the author pasted earliest in the URL. Mirrors
7867 // the peer cascade discipline
7868 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7869 // pins on the prior `:repo` byte-class arm.
7870 let d = dep_with_fonte(DepSource::Git {
7871 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7872 tag: Some("v0.1.0".into()),
7873 rev: None,
7874 branch: None,
7875 });
7876 let err = d.validate().unwrap_err();
7877 let DepError::FonteRepoShape { reason, .. } = err else {
7878 panic!("expected FonteRepoShape, got other variant");
7879 };
7880 assert!(
7881 reason.contains("must not contain `#`"),
7882 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7883 `#` byte appears first in value), got {reason:?}"
7884 );
7885 }
7886
7887 #[test]
7888 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7889 // The fail-before-pass-after pin for the canonical
7890 // paste-from-shell-prompt-with-piped-pipeline footgun on
7891 // `:repo` (peer with the 124106f pipe arm on the sibling
7892 // `:caminho` path-fonte axis). An author pastes a shell
7893 // pipeline (`git clone <url> | tee build.log`,
7894 // `git ls-remote <url> | head`) into the `:repo` slot,
7895 // forgetting to trim the `| <consumer>` tail. Until this arm
7896 // landed the value silently passed every prior arm (no
7897 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7898 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7899 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7900 // 'unwise' set and the WHATWG URL spec's fragment percent-
7901 // encode set maps `|` → `%7C` on the wire, so the byte rides
7902 // verbatim into the lacre's per-dep BLAKE3 closure but is
7903 // silently rewritten or rejected at libcurl's URL-parser
7904 // layer — two authors whose values differ only in their pipe
7905 // tail (`|tee build.log` vs nothing) resolve to the byte-
7906 // identical upstream `git clone` but lock to two distinct
7907 // lacres, defeating the THEORY.md §V.2 render-determinism
7908 // contract. Peer with the `:caminho` axis's
7909 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7910 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7911 // RFC-3986-reserved set on `:entrada :paths`.
7912 let d = dep_with_fonte(DepSource::Git {
7913 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7914 tag: Some("v0.1.0".into()),
7915 rev: None,
7916 branch: None,
7917 });
7918 let err = d.validate().unwrap_err();
7919 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7920 panic!("expected FonteRepoShape, got other variant");
7921 };
7922 assert_eq!(nome, "caixa-teia");
7923 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7924 assert!(
7925 reason.contains("must not contain `|`"),
7926 "reason must surface the shell-pipe arm, got {reason:?}"
7927 );
7928 assert!(
7929 reason.contains("pipe") || reason.contains("'unwise'"),
7930 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7931 );
7932 }
7933
7934 #[test]
7935 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7936 // Cascade pin: the fragment-`#` arm and the pipe arm are both
7937 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7938 // so the byte that appears first in the value's byte order
7939 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7940 // both `#` and `|`; the `#` byte appears first, so the
7941 // fragment-`#` arm fires, surfacing the more self-locating
7942 // diagnostic on the byte the author pasted earliest in the
7943 // URL. Mirrors the peer cascade discipline
7944 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7945 // pins on the prior `:repo` byte-class arm.
7946 let d = dep_with_fonte(DepSource::Git {
7947 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7948 tag: Some("v0.1.0".into()),
7949 rev: None,
7950 branch: None,
7951 });
7952 let err = d.validate().unwrap_err();
7953 let DepError::FonteRepoShape { reason, .. } = err else {
7954 panic!("expected FonteRepoShape, got other variant");
7955 };
7956 assert!(
7957 reason.contains("must not contain `#`"),
7958 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7959 appears first in value), got {reason:?}"
7960 );
7961 }
7962
7963 #[test]
7964 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7965 // Cascade pin: the backtick arm and the pipe arm are both per-
7966 // byte arms inside the same `for &b in s.as_bytes()` loop, so
7967 // the byte that appears first in the value's byte order wins.
7968 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7969 // `` ` `` and `|`; the backtick byte appears first, so the
7970 // backtick arm fires, surfacing the more self-locating
7971 // diagnostic on the byte the author pasted earliest in the
7972 // URL. Pins the natural-order cascade so a future reorder of
7973 // the per-byte arms surfaces here.
7974 let d = dep_with_fonte(DepSource::Git {
7975 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7976 tag: Some("v0.1.0".into()),
7977 rev: None,
7978 branch: None,
7979 });
7980 let err = d.validate().unwrap_err();
7981 let DepError::FonteRepoShape { reason, .. } = err else {
7982 panic!("expected FonteRepoShape, got other variant");
7983 };
7984 assert!(
7985 reason.contains("must not contain `` ` ``"),
7986 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7987 appears first in value), got {reason:?}"
7988 );
7989 }
7990
7991 #[test]
7992 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7993 // The fail-before-pass-after pin for the canonical
7994 // paste-from-shell-prompt-with-sequential-command-tail footgun
7995 // on `:repo` (peer with the 05c358e `;` arm on the sibling
7996 // `:caminho` path-fonte axis). An author pastes a shell
7997 // one-liner that chained a cleanup tail after the URL
7998 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7999 // echo done`) into the `:repo` slot, forgetting to trim the
8000 // `; <cmd>` tail. Until this arm landed the value silently
8001 // passed every prior `is_git_repo_url` arm (no whitespace, no
8002 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
8003 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
8004 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
8005 // reserved set and the WHATWG URL spec's fragment percent-
8006 // encode set maps `;` → `%3B` on the wire, so the byte rides
8007 // verbatim into the lacre's per-dep BLAKE3 closure but is
8008 // silently rewritten at libcurl's URL-parser layer — two
8009 // authors whose values differ only in their sequential-command
8010 // tail (`; rm -rf build` vs nothing) resolve to the byte-
8011 // identical upstream `git clone` but lock to two distinct
8012 // lacres, defeating the THEORY.md §V.2 render-determinism
8013 // contract. Peer with the `:caminho` axis's
8014 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
8015 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8016 // byte RFC-3986-reserved set on `:entrada :paths`.
8017 let d = dep_with_fonte(DepSource::Git {
8018 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
8019 tag: Some("v0.1.0".into()),
8020 rev: None,
8021 branch: None,
8022 });
8023 let err = d.validate().unwrap_err();
8024 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8025 panic!("expected FonteRepoShape, got other variant");
8026 };
8027 assert_eq!(nome, "caixa-teia");
8028 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
8029 assert!(
8030 reason.contains("must not contain `;`"),
8031 "reason must surface the shell-command-separator arm, got {reason:?}"
8032 );
8033 assert!(
8034 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
8035 "reason must name the shell-command-separator / RFC-3986-sub-delims \
8036 rationale, got {reason:?}"
8037 );
8038 }
8039
8040 #[test]
8041 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
8042 // Cascade pin: the fragment-`#` arm and the semicolon arm are
8043 // both per-byte arms inside the same `for &b in s.as_bytes()`
8044 // loop, so the byte that appears first in the value's byte
8045 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
8046 // carries both `#` and `;`; the `#` byte appears first, so the
8047 // fragment-`#` arm fires, surfacing the more self-locating
8048 // diagnostic on the byte the author pasted earliest in the URL.
8049 // Mirrors the peer cascade discipline
8050 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
8051 // pins on the prior `:repo` byte-class arm.
8052 let d = dep_with_fonte(DepSource::Git {
8053 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
8054 tag: Some("v0.1.0".into()),
8055 rev: None,
8056 branch: None,
8057 });
8058 let err = d.validate().unwrap_err();
8059 let DepError::FonteRepoShape { reason, .. } = err else {
8060 panic!("expected FonteRepoShape, got other variant");
8061 };
8062 assert!(
8063 reason.contains("must not contain `#`"),
8064 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
8065 byte appears first in value), got {reason:?}"
8066 );
8067 }
8068
8069 #[test]
8070 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
8071 // Cascade pin: the pipe arm and the semicolon arm are both
8072 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8073 // so the byte that appears first in the value's byte order
8074 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
8075 // both `|` and `;`; the `|` byte appears first, so the
8076 // pipe arm fires, surfacing the more self-locating diagnostic
8077 // on the byte the author pasted earliest in the URL. Pins the
8078 // natural-order cascade so a future reorder of the per-byte
8079 // arms surfaces here.
8080 let d = dep_with_fonte(DepSource::Git {
8081 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
8082 tag: Some("v0.1.0".into()),
8083 rev: None,
8084 branch: None,
8085 });
8086 let err = d.validate().unwrap_err();
8087 let DepError::FonteRepoShape { reason, .. } = err else {
8088 panic!("expected FonteRepoShape, got other variant");
8089 };
8090 assert!(
8091 reason.contains("must not contain `|`"),
8092 "reason must surface the pipe arm (fires before semicolon when `|` byte \
8093 appears first in value), got {reason:?}"
8094 );
8095 }
8096
8097 #[test]
8098 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
8099 // The fail-before-pass-after pin for the canonical
8100 // paste-from-shell-prompt-with-background-launch-tail footgun
8101 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
8102 // `:caminho` path-fonte axis). An author pastes a shell one-
8103 // liner that detached the clone into the background
8104 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
8105 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
8106 // `&& <cmd>` tail. Until this arm landed the value silently
8107 // passed every prior `is_git_repo_url` arm (no whitespace,
8108 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
8109 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8110 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
8111 // the 'sub-delims' / reserved set and the WHATWG URL spec's
8112 // fragment percent-encode set maps `&` → `%26` on the wire,
8113 // so the byte rides verbatim into the lacre's per-dep
8114 // BLAKE3 closure but is silently rewritten at libcurl's
8115 // URL-parser layer — two authors whose values differ only
8116 // in their background-launch tail (`& sleep 1` vs nothing)
8117 // resolve to the byte-identical upstream `git clone` but
8118 // lock to two distinct lacres, defeating the THEORY.md
8119 // §V.2 render-determinism contract. Peer with the
8120 // `:caminho` axis's `FonteCaminhoShellBackground` arm
8121 // (e12e4f3) on the sibling path-fonte axis, and
8122 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
8123 // reserved set on `:entrada :paths`.
8124 let d = dep_with_fonte(DepSource::Git {
8125 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
8126 tag: Some("v0.1.0".into()),
8127 rev: None,
8128 branch: None,
8129 });
8130 let err = d.validate().unwrap_err();
8131 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8132 panic!("expected FonteRepoShape, got other variant");
8133 };
8134 assert_eq!(nome, "caixa-teia");
8135 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
8136 assert!(
8137 reason.contains("must not contain `&`"),
8138 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
8139 );
8140 assert!(
8141 reason.contains("background-task") || reason.contains("'sub-delims'"),
8142 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
8143 got {reason:?}"
8144 );
8145 }
8146
8147 #[test]
8148 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
8149 // The fail-before-pass-after pin for the symmetric `&&`
8150 // logical-AND build-chain paste footgun: an author pastes
8151 // a `git clone <url> && cd <repo>` build-chain one-liner
8152 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
8153 // is the same `&` byte twice in a row; the per-byte arm
8154 // fires on the first `&` it sees. Pinned separately from
8155 // the single-`&` background-launch shape so a future
8156 // diagnostic-surface change that special-cased the
8157 // doubled-byte form surfaces here.
8158 let d = dep_with_fonte(DepSource::Git {
8159 repo: "github:pleme-io/caixa-teia&&echo".into(),
8160 tag: Some("v0.1.0".into()),
8161 rev: None,
8162 branch: None,
8163 });
8164 let err = d.validate().unwrap_err();
8165 let DepError::FonteRepoShape { reason, .. } = err else {
8166 panic!("expected FonteRepoShape, got other variant");
8167 };
8168 assert!(
8169 reason.contains("must not contain `&`"),
8170 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
8171 shape too, got {reason:?}"
8172 );
8173 }
8174
8175 #[test]
8176 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
8177 // Cascade pin: the fragment-`#` arm and the background-`&`
8178 // arm are both per-byte arms inside the same `for &b in
8179 // s.as_bytes()` loop, so the byte that appears first in the
8180 // value's byte order wins. A `:repo
8181 // "https://github.com/p/x#readme & sleep"` carries both `#`
8182 // and `&`; the `#` byte appears first, so the fragment-`#`
8183 // arm fires, surfacing the more self-locating diagnostic on
8184 // the byte the author pasted earliest in the URL. Mirrors
8185 // the peer cascade discipline
8186 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
8187 // on the prior `:repo` byte-class arm.
8188 let d = dep_with_fonte(DepSource::Git {
8189 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
8190 tag: Some("v0.1.0".into()),
8191 rev: None,
8192 branch: None,
8193 });
8194 let err = d.validate().unwrap_err();
8195 let DepError::FonteRepoShape { reason, .. } = err else {
8196 panic!("expected FonteRepoShape, got other variant");
8197 };
8198 assert!(
8199 reason.contains("must not contain `#`"),
8200 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
8201 byte appears first in value), got {reason:?}"
8202 );
8203 }
8204
8205 #[test]
8206 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
8207 // Cascade pin: the semicolon arm and the background-`&` arm
8208 // are both per-byte arms inside the same `for &b in
8209 // s.as_bytes()` loop, so the byte that appears first in the
8210 // value's byte order wins. A `:repo
8211 // "https://github.com/p/x; rm & sleep"` carries both `;` and
8212 // `&`; the `;` byte appears first, so the semicolon arm
8213 // fires, surfacing the more self-locating diagnostic on the
8214 // byte the author pasted earliest in the URL. Pins the
8215 // natural-order cascade so a future reorder of the per-byte
8216 // arms surfaces here.
8217 let d = dep_with_fonte(DepSource::Git {
8218 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
8219 tag: Some("v0.1.0".into()),
8220 rev: None,
8221 branch: None,
8222 });
8223 let err = d.validate().unwrap_err();
8224 let DepError::FonteRepoShape { reason, .. } = err else {
8225 panic!("expected FonteRepoShape, got other variant");
8226 };
8227 assert!(
8228 reason.contains("must not contain `;`"),
8229 "reason must surface the semicolon arm (fires before background-`&` when `;` \
8230 byte appears first in value), got {reason:?}"
8231 );
8232 }
8233
8234 #[test]
8235 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
8236 // The fail-before-pass-after pin for the canonical
8237 // paste-from-shell-prompt-with-unsubstituted-variable footgun
8238 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
8239 // `:caminho` path-fonte axis). An author pastes a shell one-
8240 // liner that referenced an environment variable
8241 // (`git clone https://github.com/$ORG/x`, `git clone
8242 // github:$USER/repo`) into the `:repo` slot, forgetting to
8243 // substitute the literal value at author time. Until this arm
8244 // landed the value silently passed every prior
8245 // `is_git_repo_url` arm (no whitespace, no control chars, no
8246 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8247 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
8248 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
8249 // reserved set and the WHATWG URL spec's fragment percent-
8250 // encode set maps `$` → `%24` on the wire, so the byte rides
8251 // verbatim into the lacre's per-dep BLAKE3 closure but is
8252 // silently rewritten at libcurl's URL-parser layer — two
8253 // authors whose values differ only in their `$VAR` /
8254 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
8255 // identical upstream `git clone` but lock to two distinct
8256 // lacres, defeating the THEORY.md §V.2 render-determinism
8257 // contract. Beyond determinism, the value is a structural
8258 // host-layout leak: two authors with the same `:repo` slot
8259 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
8260 // different upstreams. Peer with the `:caminho` axis's
8261 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
8262 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8263 // byte RFC-3986-reserved set on `:entrada :paths`.
8264 let d = dep_with_fonte(DepSource::Git {
8265 repo: "https://github.com/$ORG/caixa-teia".into(),
8266 tag: Some("v0.1.0".into()),
8267 rev: None,
8268 branch: None,
8269 });
8270 let err = d.validate().unwrap_err();
8271 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8272 panic!("expected FonteRepoShape, got other variant");
8273 };
8274 assert_eq!(nome, "caixa-teia");
8275 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
8276 assert!(
8277 reason.contains("must not contain `$`"),
8278 "reason must surface the shell-variable-expansion arm, got {reason:?}"
8279 );
8280 assert!(
8281 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
8282 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
8283 rationale, got {reason:?}"
8284 );
8285 }
8286
8287 #[test]
8288 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
8289 // The fail-before-pass-after pin for the symmetric POSIX-
8290 // shell braced `${VAR}` expansion paste footgun: an author
8291 // pastes a CI-manifest line `git clone
8292 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
8293 // Actions / GitLab CI / Drone shape) and forgets to
8294 // substitute the literal value. The `${...}` shape is the
8295 // same `$` byte at the leading position of the expansion;
8296 // the per-byte arm fires on the `$`. Pinned separately from
8297 // the bare-`$VAR` shape so a future diagnostic-surface
8298 // change that special-cased the braced form surfaces here.
8299 let d = dep_with_fonte(DepSource::Git {
8300 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
8301 tag: Some("v0.1.0".into()),
8302 rev: None,
8303 branch: None,
8304 });
8305 let err = d.validate().unwrap_err();
8306 let DepError::FonteRepoShape { reason, .. } = err else {
8307 panic!("expected FonteRepoShape, got other variant");
8308 };
8309 assert!(
8310 reason.contains("must not contain `$`"),
8311 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
8312 shape too, got {reason:?}"
8313 );
8314 }
8315
8316 #[test]
8317 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
8318 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
8319 // arm are both per-byte arms inside the same `for &b in
8320 // s.as_bytes()` loop, so the byte that appears first in the
8321 // value's byte order wins. A `:repo
8322 // "https://github.com/p/x#readme$HOME"` carries both `#` and
8323 // `$`; the `#` byte appears first, so the fragment-`#` arm
8324 // fires, surfacing the more self-locating diagnostic on the
8325 // byte the author pasted earliest in the URL. Mirrors the
8326 // peer cascade discipline
8327 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
8328 // on the prior `:repo` byte-class arm.
8329 let d = dep_with_fonte(DepSource::Git {
8330 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
8331 tag: Some("v0.1.0".into()),
8332 rev: None,
8333 branch: None,
8334 });
8335 let err = d.validate().unwrap_err();
8336 let DepError::FonteRepoShape { reason, .. } = err else {
8337 panic!("expected FonteRepoShape, got other variant");
8338 };
8339 assert!(
8340 reason.contains("must not contain `#`"),
8341 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
8342 `#` byte appears first in value), got {reason:?}"
8343 );
8344 }
8345
8346 #[test]
8347 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
8348 // Cascade pin: the background-`&` arm and the
8349 // var-expansion-`$` arm are both per-byte arms inside the
8350 // same `for &b in s.as_bytes()` loop, so the byte that
8351 // appears first in the value's byte order wins. A `:repo
8352 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
8353 // `$`; the `&` byte appears first, so the background arm
8354 // fires, surfacing the more self-locating diagnostic on the
8355 // byte the author pasted earliest in the URL. Pins the
8356 // natural-order cascade so a future reorder of the per-byte
8357 // arms surfaces here — `$` is the most recent byte-class arm,
8358 // so the cascade-pin sweep extends to cover every immediately
8359 // prior byte arm (`#`, `&`) firing first when ordered ahead
8360 // of `$` in the value.
8361 let d = dep_with_fonte(DepSource::Git {
8362 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
8363 tag: Some("v0.1.0".into()),
8364 rev: None,
8365 branch: None,
8366 });
8367 let err = d.validate().unwrap_err();
8368 let DepError::FonteRepoShape { reason, .. } = err else {
8369 panic!("expected FonteRepoShape, got other variant");
8370 };
8371 assert!(
8372 reason.contains("must not contain `&`"),
8373 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
8374 `&` byte appears first in value), got {reason:?}"
8375 );
8376 }
8377
8378 #[test]
8379 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
8380 // The fail-before-pass-after pin for the canonical
8381 // paste-from-shell-prompt glob footgun on `:repo` (peer with
8382 // the cf9034b `*` / `?` arm on the sibling `:caminho`
8383 // path-fonte axis). An author pastes a shell one-liner that
8384 // referenced a glob expansion (`ls
8385 // github.com/pleme-io/caixa-*`, `git clone
8386 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
8387 // to substitute the literal repo name. Until this arm landed
8388 // the `*` byte silently passed every prior `is_git_repo_url`
8389 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
8390 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
8391 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
8392 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
8393 // the WHATWG URL spec's special-query percent-encode set maps
8394 // `*` → `%2A` on the wire, so the byte rides verbatim into
8395 // the lacre's per-dep BLAKE3 closure but is silently
8396 // rewritten at libcurl's URL-parser layer — two authors
8397 // whose values differ only in their asterisk presence
8398 // resolve to the byte-identical upstream `git clone` but
8399 // lock to two distinct lacres, defeating the THEORY.md §V.2
8400 // render-determinism contract. Peer with the `:caminho`
8401 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
8402 // sibling path-fonte axis, and the `is_git_ref_name`
8403 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
8404 // axes.
8405 let d = dep_with_fonte(DepSource::Git {
8406 repo: "https://github.com/pleme-io/caixa-*".into(),
8407 tag: Some("v0.1.0".into()),
8408 rev: None,
8409 branch: None,
8410 });
8411 let err = d.validate().unwrap_err();
8412 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8413 panic!("expected FonteRepoShape, got other variant");
8414 };
8415 assert_eq!(nome, "caixa-teia");
8416 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
8417 assert!(
8418 reason.contains("must not contain `*`"),
8419 "reason must surface the shell-glob arm, got {reason:?}"
8420 );
8421 assert!(
8422 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
8423 "reason must name the shell-glob / pathname-expansion / \
8424 RFC-3986-sub-delims rationale, got {reason:?}"
8425 );
8426 }
8427
8428 #[test]
8429 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
8430 // The fail-before-pass-after pin for the symmetric bash
8431 // `globstar` recursive-glob paste footgun: an author pastes
8432 // a `ls github.com/pleme-io/**/x` (the canonical
8433 // `globstar`-shopt-enabled recursive-listing tail) into the
8434 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
8435 // the per-byte arm fires on the first `*`. Pinned
8436 // separately from the single-`*` shape so a future
8437 // diagnostic-surface change that special-cased the
8438 // double-`*` form surfaces here.
8439 let d = dep_with_fonte(DepSource::Git {
8440 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
8441 tag: Some("v0.1.0".into()),
8442 rev: None,
8443 branch: None,
8444 });
8445 let err = d.validate().unwrap_err();
8446 let DepError::FonteRepoShape { reason, .. } = err else {
8447 panic!("expected FonteRepoShape, got other variant");
8448 };
8449 assert!(
8450 reason.contains("must not contain `*`"),
8451 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8452 got {reason:?}"
8453 );
8454 }
8455
8456 #[test]
8457 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8458 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8459 // both per-byte arms inside the same `for &b in s.as_bytes()`
8460 // loop, so the byte that appears first in the value's byte
8461 // order wins. A `:repo
8462 // "https://github.com/p/x#readme*tail"` carries both `#` and
8463 // `*`; the `#` byte appears first, so the fragment-`#` arm
8464 // fires, surfacing the more self-locating diagnostic on the
8465 // byte the author pasted earliest in the URL. Mirrors the
8466 // peer cascade discipline
8467 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8468 // on the prior `:repo` byte-class arm.
8469 let d = dep_with_fonte(DepSource::Git {
8470 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8471 tag: Some("v0.1.0".into()),
8472 rev: None,
8473 branch: None,
8474 });
8475 let err = d.validate().unwrap_err();
8476 let DepError::FonteRepoShape { reason, .. } = err else {
8477 panic!("expected FonteRepoShape, got other variant");
8478 };
8479 assert!(
8480 reason.contains("must not contain `#`"),
8481 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8482 appears first in value), got {reason:?}"
8483 );
8484 }
8485
8486 #[test]
8487 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8488 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8489 // arm are both per-byte arms inside the same `for &b in
8490 // s.as_bytes()` loop, so the byte that appears first in the
8491 // value's byte order wins. A `:repo
8492 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8493 // the `$` byte appears first, so the var-expansion arm
8494 // fires, surfacing the more self-locating diagnostic on the
8495 // byte the author pasted earliest in the URL. Pins the
8496 // natural-order cascade so a future reorder of the per-byte
8497 // arms surfaces here — `*` is the most recent byte-class
8498 // arm, so the cascade-pin sweep extends to cover the
8499 // immediately prior `$` byte arm firing first when ordered
8500 // ahead of `*` in the value.
8501 let d = dep_with_fonte(DepSource::Git {
8502 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
8503 tag: Some("v0.1.0".into()),
8504 rev: None,
8505 branch: None,
8506 });
8507 let err = d.validate().unwrap_err();
8508 let DepError::FonteRepoShape { reason, .. } = err else {
8509 panic!("expected FonteRepoShape, got other variant");
8510 };
8511 assert!(
8512 reason.contains("must not contain `$`"),
8513 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8514 byte appears first in value), got {reason:?}"
8515 );
8516 }
8517
8518 #[test]
8519 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8520 // The fail-before-pass-after pin for the canonical paste-from-
8521 // shell-prompt subshell-grouping footgun on `:repo`. An author
8522 // pastes a doc / README snippet carrying a regex-alternation
8523 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8524 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8525 // `:repo` slot, forgetting to substitute one literal org name.
8526 // Until this arm landed the `(` byte silently passed every
8527 // prior `is_git_repo_url` arm (no whitespace, no control
8528 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8529 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8530 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8531 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8532 // URL spec's special-query percent-encode set maps `(` →
8533 // `%28` and `)` → `%29` on the wire, so the byte rides
8534 // verbatim into the lacre's per-dep BLAKE3 closure but is
8535 // silently rewritten at libcurl's URL-parser layer —
8536 // defeating the THEORY.md §V.2 render-determinism contract on
8537 // the same axis the prior twelve byte-class arms close.
8538 let d = dep_with_fonte(DepSource::Git {
8539 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8540 tag: Some("v0.1.0".into()),
8541 rev: None,
8542 branch: None,
8543 });
8544 let err = d.validate().unwrap_err();
8545 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8546 panic!("expected FonteRepoShape, got other variant");
8547 };
8548 assert_eq!(nome, "caixa-teia");
8549 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8550 assert!(
8551 reason.contains("must not contain `(`"),
8552 "reason must surface the subshell-open-paren arm, got {reason:?}"
8553 );
8554 assert!(
8555 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8556 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8557 got {reason:?}"
8558 );
8559 }
8560
8561 #[test]
8562 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8563 // The symmetric arm pin on the closing `)` byte: an author
8564 // pastes a `$(date)` command-substitution wrapper or a
8565 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8566 // Pinned separately from the opening `(` shape so a future
8567 // diagnostic-surface change that only checked one boundary
8568 // surfaces here. The `(` byte appears earlier in the
8569 // canonical regex / subshell wrapper so the per-byte loop
8570 // fires on `(` first; this test exercises a `:repo` value
8571 // carrying only the closing `)` byte (no opening paren) so
8572 // the `)` arm fires directly — pinning the byte-class arm
8573 // independent of order.
8574 let d = dep_with_fonte(DepSource::Git {
8575 repo: "github:pleme-io/caixa-teia)tail".into(),
8576 tag: Some("v0.1.0".into()),
8577 rev: None,
8578 branch: None,
8579 });
8580 let err = d.validate().unwrap_err();
8581 let DepError::FonteRepoShape { reason, .. } = err else {
8582 panic!("expected FonteRepoShape, got other variant");
8583 };
8584 assert!(
8585 reason.contains("must not contain `)`"),
8586 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8587 got {reason:?}"
8588 );
8589 }
8590
8591 #[test]
8592 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8593 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8594 // are both per-byte arms inside the same `for &b in
8595 // s.as_bytes()` loop, so the byte that appears first in the
8596 // value's byte order wins. A `:repo
8597 // "https://github.com/p/x#readme(tail)"` carries both `#` and
8598 // `(`; the `#` byte appears first, so the fragment-`#` arm
8599 // fires, surfacing the more self-locating diagnostic on the
8600 // byte the author pasted earliest in the URL. Mirrors the
8601 // peer cascade discipline
8602 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8603 // on the prior `:repo` byte-class arm.
8604 let d = dep_with_fonte(DepSource::Git {
8605 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8606 tag: Some("v0.1.0".into()),
8607 rev: None,
8608 branch: None,
8609 });
8610 let err = d.validate().unwrap_err();
8611 let DepError::FonteRepoShape { reason, .. } = err else {
8612 panic!("expected FonteRepoShape, got other variant");
8613 };
8614 assert!(
8615 reason.contains("must not contain `#`"),
8616 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8617 byte appears first in value), got {reason:?}"
8618 );
8619 }
8620
8621 #[test]
8622 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8623 // Cascade pin: the glob-`*` arm (the immediate-predecessor
8624 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8625 // per-byte arms inside the same `for &b in s.as_bytes()`
8626 // loop, so the byte that appears first in the value's byte
8627 // order wins. A `:repo
8628 // "https://github.com/p/x-*-(date)"` carries both `*` and
8629 // `(`; the `*` byte appears first, so the glob arm fires,
8630 // surfacing the more self-locating diagnostic on the byte
8631 // the author pasted earliest in the URL. Pins the natural-
8632 // order cascade so a future reorder of the per-byte arms
8633 // surfaces here — `(` is the most recent byte-class arm,
8634 // so the cascade-pin sweep extends to cover the immediately
8635 // prior `*` byte arm firing first when ordered ahead of `(`
8636 // in the value.
8637 let d = dep_with_fonte(DepSource::Git {
8638 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8639 tag: Some("v0.1.0".into()),
8640 rev: None,
8641 branch: None,
8642 });
8643 let err = d.validate().unwrap_err();
8644 let DepError::FonteRepoShape { reason, .. } = err else {
8645 panic!("expected FonteRepoShape, got other variant");
8646 };
8647 assert!(
8648 reason.contains("must not contain `*`"),
8649 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8650 appears first in value), got {reason:?}"
8651 );
8652 }
8653
8654 #[test]
8655 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8656 // The fail-before-pass-after pin for the canonical paste-from-
8657 // doc-shell-quoting footgun on `:repo`. An author copies a
8658 // README quick-start snippet (`$ git clone "https://github.com/
8659 // foo/bar"`) and keeps the surrounding double-quote bytes when
8660 // pasting into the `:repo` slot — the doc wraps the URL in
8661 // double quotes so the shell doesn't re-lex metachars inside,
8662 // but the typed slot is itself a byte-level string parser, not
8663 // a shell context, so the quote bytes ride into the value
8664 // verbatim. Until this arm landed the `"` byte silently passed
8665 // every prior `is_git_repo_url` arm (no whitespace, no control
8666 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8667 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8668 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8669 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8670 // `` ` ``) every URL parser is required to refuse or percent-
8671 // encode, and the WHATWG URL spec's 'C0 control percent-encode
8672 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8673 // into the lacre's per-dep BLAKE3 closure but is silently
8674 // rewritten at libcurl's URL-parser layer, defeating the
8675 // THEORY.md §V.2 render-determinism contract.
8676 let d = dep_with_fonte(DepSource::Git {
8677 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8678 tag: Some("v0.1.0".into()),
8679 rev: None,
8680 branch: None,
8681 });
8682 let err = d.validate().unwrap_err();
8683 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8684 panic!("expected FonteRepoShape, got other variant");
8685 };
8686 assert_eq!(nome, "caixa-teia");
8687 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8688 assert!(
8689 reason.contains("must not contain `\"`"),
8690 "reason must surface the shell-double-quote arm, got {reason:?}"
8691 );
8692 assert!(
8693 reason.contains("double-quote") || reason.contains("'delims'"),
8694 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8695 got {reason:?}"
8696 );
8697 }
8698
8699 #[test]
8700 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8701 // The symmetric stray-quote tail pin: an author pastes only a
8702 // closing `"` from a shell-history line like `git clone
8703 // "https://github.com/foo/bar" && cd …` (the trim went too
8704 // far in one direction but not the other) into the `:repo`
8705 // slot. Pinned separately from the wrapped-quote shape so a
8706 // future diagnostic-surface change that only checked one
8707 // boundary (only leading, only trailing, only paired) surfaces
8708 // here — the per-byte arm fires anywhere `"` appears.
8709 let d = dep_with_fonte(DepSource::Git {
8710 repo: "github:pleme-io/caixa-teia\"".into(),
8711 tag: Some("v0.1.0".into()),
8712 rev: None,
8713 branch: None,
8714 });
8715 let err = d.validate().unwrap_err();
8716 let DepError::FonteRepoShape { reason, .. } = err else {
8717 panic!("expected FonteRepoShape, got other variant");
8718 };
8719 assert!(
8720 reason.contains("must not contain `\"`"),
8721 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8722 got {reason:?}"
8723 );
8724 }
8725
8726 #[test]
8727 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8728 // Cascade pin: the fragment-`#` arm and the double-quote arm
8729 // are both per-byte arms inside the same `for &b in
8730 // s.as_bytes()` loop, so the byte that appears first in the
8731 // value's byte order wins. A `:repo
8732 // "https://github.com/p/x#readme\"tail"` carries both `#` and
8733 // `"`; the `#` byte appears first, so the fragment-`#` arm
8734 // fires, surfacing the more self-locating diagnostic on the
8735 // byte the author pasted earliest in the URL.
8736 let d = dep_with_fonte(DepSource::Git {
8737 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8738 tag: Some("v0.1.0".into()),
8739 rev: None,
8740 branch: None,
8741 });
8742 let err = d.validate().unwrap_err();
8743 let DepError::FonteRepoShape { reason, .. } = err else {
8744 panic!("expected FonteRepoShape, got other variant");
8745 };
8746 assert!(
8747 reason.contains("must not contain `#`"),
8748 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8749 byte appears first in value), got {reason:?}"
8750 );
8751 }
8752
8753 #[test]
8754 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8755 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8756 // byte-class arm, 3b99147) and the double-quote arm are both
8757 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8758 // so the byte that appears first in the value's byte order
8759 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8760 // and `"`; the `(` byte appears first, so the subshell arm
8761 // fires, surfacing the more self-locating diagnostic on the
8762 // byte the author pasted earliest in the URL. Pins the natural-
8763 // order cascade so a future reorder of the per-byte arms
8764 // surfaces here — `"` is the most recent byte-class arm, so
8765 // the cascade-pin sweep extends to cover the immediately prior
8766 // `(` byte arm firing first when ordered ahead of `"` in the
8767 // value.
8768 let d = dep_with_fonte(DepSource::Git {
8769 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8770 tag: Some("v0.1.0".into()),
8771 rev: None,
8772 branch: None,
8773 });
8774 let err = d.validate().unwrap_err();
8775 let DepError::FonteRepoShape { reason, .. } = err else {
8776 panic!("expected FonteRepoShape, got other variant");
8777 };
8778 assert!(
8779 reason.contains("must not contain `(`"),
8780 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8781 byte appears first in value), got {reason:?}"
8782 );
8783 }
8784
8785 #[test]
8786 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8787 // The fail-before-pass-after pin for the canonical paste-from-
8788 // doc-strong-quoting footgun on `:repo`. An author copies a
8789 // security-conscious README quick-start snippet (`$ git clone
8790 // 'https://github.com/foo/bar'`) and keeps the surrounding
8791 // single-quote bytes when pasting into the `:repo` slot — the
8792 // doc strong-quotes the URL so the shell suppresses every form
8793 // of expansion on the bytes inside (no `$`, no backtick, no
8794 // glob, no word-splitting), but the typed slot is itself a
8795 // byte-level string parser, not a shell context, so the quote
8796 // bytes ride into the value verbatim. Until this arm landed the
8797 // `'` byte silently passed every prior `is_git_repo_url` arm
8798 // (no whitespace, no control chars, no non-ASCII, no `#`, no
8799 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8800 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8801 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8802 // set, peer with the `\"` 'delims' double-quote arm and the
8803 // partner ASCII shell-string-delimiter byte every byte-level
8804 // string parser sharing a value-shape with a shell argument
8805 // must refuse on a URL-shaped slot.
8806 let d = dep_with_fonte(DepSource::Git {
8807 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8808 tag: Some("v0.1.0".into()),
8809 rev: None,
8810 branch: None,
8811 });
8812 let err = d.validate().unwrap_err();
8813 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8814 panic!("expected FonteRepoShape, got other variant");
8815 };
8816 assert_eq!(nome, "caixa-teia");
8817 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8818 assert!(
8819 reason.contains("must not contain `'`"),
8820 "reason must surface the shell-single-quote arm, got {reason:?}"
8821 );
8822 assert!(
8823 reason.contains("single-quote") || reason.contains("strong-quote"),
8824 "reason must name the shell-single-quote / strong-quote rationale, \
8825 got {reason:?}"
8826 );
8827 }
8828
8829 #[test]
8830 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8831 // The symmetric English-typography pin: an author writes
8832 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8833 // from-prose idiom every README / commit-message / chat-thread
8834 // reference to a repo carries) expecting the substrate to
8835 // coerce it to a kebab-case slug — but the byte rides into the
8836 // lacre verbatim. Pinned separately from the wrapped-quote
8837 // shape so a future diagnostic-surface change that only checked
8838 // the boundary positions (only leading, only trailing, only
8839 // paired) surfaces here — the per-byte arm fires anywhere `'`
8840 // appears in the value.
8841 let d = dep_with_fonte(DepSource::Git {
8842 repo: "github:pleme-io/repo's-fork".into(),
8843 tag: Some("v0.1.0".into()),
8844 rev: None,
8845 branch: None,
8846 });
8847 let err = d.validate().unwrap_err();
8848 let DepError::FonteRepoShape { reason, .. } = err else {
8849 panic!("expected FonteRepoShape, got other variant");
8850 };
8851 assert!(
8852 reason.contains("must not contain `'`"),
8853 "reason must surface the shell-single-quote arm on the mid-string \
8854 apostrophe shape, got {reason:?}"
8855 );
8856 }
8857
8858 #[test]
8859 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8860 // Cascade pin: the fragment-`#` arm and the single-quote arm
8861 // are both per-byte arms inside the same `for &b in
8862 // s.as_bytes()` loop, so the byte that appears first in the
8863 // value's byte order wins. A `:repo
8864 // "https://github.com/p/x#readme'tail"` carries both `#` and
8865 // `'`; the `#` byte appears first, so the fragment-`#` arm
8866 // fires, surfacing the more self-locating diagnostic on the
8867 // byte the author pasted earliest in the URL.
8868 let d = dep_with_fonte(DepSource::Git {
8869 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8870 tag: Some("v0.1.0".into()),
8871 rev: None,
8872 branch: None,
8873 });
8874 let err = d.validate().unwrap_err();
8875 let DepError::FonteRepoShape { reason, .. } = err else {
8876 panic!("expected FonteRepoShape, got other variant");
8877 };
8878 assert!(
8879 reason.contains("must not contain `#`"),
8880 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8881 byte appears first in value), got {reason:?}"
8882 );
8883 }
8884
8885 #[test]
8886 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8887 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8888 // byte-class arm, 4267d8b) and the single-quote arm are both
8889 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8890 // so the byte that appears first in the value's byte order
8891 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8892 // `'`; the `"` byte appears first, so the double-quote arm
8893 // fires, surfacing the more self-locating diagnostic on the
8894 // byte the author pasted earliest in the URL. Pins the natural-
8895 // order cascade so a future reorder of the per-byte arms
8896 // surfaces here — `'` is the most recent byte-class arm, so
8897 // the cascade-pin sweep extends to cover the immediately prior
8898 // `"` byte arm firing first when ordered ahead of `'` in the
8899 // value.
8900 let d = dep_with_fonte(DepSource::Git {
8901 repo: "github:pleme-io/caixa-teia\"mid'tail".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 { reason, .. } = err else {
8908 panic!("expected FonteRepoShape, got other variant");
8909 };
8910 assert!(
8911 reason.contains("must not contain `\"`"),
8912 "reason must surface the double-quote arm (fires before single-quote when `\"` \
8913 byte appears first in value), got {reason:?}"
8914 );
8915 }
8916
8917 #[test]
8918 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8919 // The fail-before-pass-after pin for the canonical paste-from-
8920 // shell-history footgun on `:repo`. An author copies a `git
8921 // clone <url>!sudo make install` one-liner from a README's
8922 // quick-start snippet, intending the trailing `!sudo` as a
8923 // shell-history-expansion reference but the typed slot is itself
8924 // a byte-level string parser, not a shell context, so the byte
8925 // rides into the value verbatim. Until this arm landed the `!`
8926 // byte silently passed every prior `is_git_repo_url` arm (no
8927 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8928 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8929 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8930 // start with `-` or `:`); bash with the default `histexpand`
8931 // mode rewrites `!command` to the most recent history entry
8932 // beginning with `command`, the canonical RCE-class injection
8933 // vector when the byte rides into a shell argument.
8934 let d = dep_with_fonte(DepSource::Git {
8935 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8936 tag: Some("v0.1.0".into()),
8937 rev: None,
8938 branch: None,
8939 });
8940 let err = d.validate().unwrap_err();
8941 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8942 panic!("expected FonteRepoShape, got other variant");
8943 };
8944 assert_eq!(nome, "caixa-teia");
8945 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8946 assert!(
8947 reason.contains("must not contain `!`"),
8948 "reason must surface the shell-history-expansion arm, got {reason:?}"
8949 );
8950 assert!(
8951 reason.contains("history-expansion") || reason.contains("bang"),
8952 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8953 );
8954 }
8955
8956 #[test]
8957 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8958 // The symmetric `!!` repeat-prior-command pin: an author paste-
8959 // trims a `git clone <url>` retry idiom from shell history that
8960 // expands to the previous command via `!!`. Pinned separately
8961 // from the wrapped `!command` shape so a future diagnostic-
8962 // surface change that only checked the leading or paired-bang
8963 // position surfaces here — the per-byte arm fires anywhere `!`
8964 // appears in the value.
8965 let d = dep_with_fonte(DepSource::Git {
8966 repo: "github:pleme-io/caixa-teia!!".into(),
8967 tag: Some("v0.1.0".into()),
8968 rev: None,
8969 branch: None,
8970 });
8971 let err = d.validate().unwrap_err();
8972 let DepError::FonteRepoShape { reason, .. } = err else {
8973 panic!("expected FonteRepoShape, got other variant");
8974 };
8975 assert!(
8976 reason.contains("must not contain `!`"),
8977 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8978 got {reason:?}"
8979 );
8980 }
8981
8982 #[test]
8983 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8984 // Cascade pin: the fragment-`#` arm and the bang arm are both
8985 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8986 // so the byte that appears first in the value's byte order
8987 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8988 // both `#` and `!`; the `#` byte appears first, so the
8989 // fragment-`#` arm fires, surfacing the more self-locating
8990 // diagnostic on the byte the author pasted earliest in the URL.
8991 let d = dep_with_fonte(DepSource::Git {
8992 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8993 tag: Some("v0.1.0".into()),
8994 rev: None,
8995 branch: None,
8996 });
8997 let err = d.validate().unwrap_err();
8998 let DepError::FonteRepoShape { reason, .. } = err else {
8999 panic!("expected FonteRepoShape, got other variant");
9000 };
9001 assert!(
9002 reason.contains("must not contain `#`"),
9003 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
9004 appears first in value), got {reason:?}"
9005 );
9006 }
9007
9008 #[test]
9009 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
9010 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
9011 // byte-class arm, e7a109f) and the bang arm are both per-byte
9012 // arms inside the same `for &b in s.as_bytes()` loop, so the
9013 // byte that appears first in the value's byte order wins. A
9014 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
9015 // `'` byte appears first, so the single-quote arm fires,
9016 // surfacing the more self-locating diagnostic on the byte the
9017 // author pasted earliest in the URL. Pins the natural-order
9018 // cascade so a future reorder of the per-byte arms surfaces
9019 // here — `!` is the most recent byte-class arm, so the
9020 // cascade-pin sweep extends to cover the immediately prior `'`
9021 // byte arm firing first when ordered ahead of `!` in the value.
9022 let d = dep_with_fonte(DepSource::Git {
9023 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
9024 tag: Some("v0.1.0".into()),
9025 rev: None,
9026 branch: None,
9027 });
9028 let err = d.validate().unwrap_err();
9029 let DepError::FonteRepoShape { reason, .. } = err else {
9030 panic!("expected FonteRepoShape, got other variant");
9031 };
9032 assert!(
9033 reason.contains("must not contain `'`"),
9034 "reason must surface the single-quote arm (fires before bang when `'` byte \
9035 appears first in value), got {reason:?}"
9036 );
9037 }
9038
9039 #[test]
9040 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
9041 // The fail-before-pass-after pin for the canonical
9042 // list-separator-belongs-to-list-grammar footgun on `:repo`.
9043 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
9044 // one-liner from a multi-repo bootstrap doc, intending the
9045 // comma to separate multiple repo entries but the typed
9046 // `:repo` slot names *one* repo (the list-separator belongs
9047 // to the `:deps` list grammar, not to the value). Until this
9048 // arm landed the `,` byte silently passed every prior
9049 // `is_git_repo_url` arm (no whitespace, no control chars, no
9050 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
9051 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
9052 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
9053 // `:`); the byte rode into the lacre's per-dep content-
9054 // address and the resolver's `git clone <repo>` subprocess
9055 // invocation, where no host's repo registry resolved the
9056 // comma-bearing slug.
9057 let d = dep_with_fonte(DepSource::Git {
9058 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
9059 tag: Some("v0.1.0".into()),
9060 rev: None,
9061 branch: None,
9062 });
9063 let err = d.validate().unwrap_err();
9064 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9065 panic!("expected FonteRepoShape, got other variant");
9066 };
9067 assert_eq!(nome, "caixa-teia");
9068 assert_eq!(
9069 repo,
9070 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
9071 );
9072 assert!(
9073 reason.contains("must not contain `,`"),
9074 "reason must surface the list-separator-comma arm, got {reason:?}"
9075 );
9076 assert!(
9077 reason.contains("list-separator") || reason.contains("sub-delims"),
9078 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
9079 got {reason:?}"
9080 );
9081 }
9082
9083 #[test]
9084 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
9085 // The symmetric trailing-`,` paste-from-prose pin: an author
9086 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
9087 // comma every README-prose list-of-projects sentence carries,
9088 // mistakenly retained when the slug is pasted mid-sentence)
9089 // expecting the substrate to coerce it to a kebab-case slug.
9090 // Pinned separately from the wrapped mid-token shape so a
9091 // future diagnostic-surface change that only checked the
9092 // leading or paired-comma position surfaces here — the
9093 // per-byte arm fires anywhere `,` appears in the value.
9094 let d = dep_with_fonte(DepSource::Git {
9095 repo: "github:pleme-io/caixa-feira,".into(),
9096 tag: Some("v0.1.0".into()),
9097 rev: None,
9098 branch: None,
9099 });
9100 let err = d.validate().unwrap_err();
9101 let DepError::FonteRepoShape { reason, .. } = err else {
9102 panic!("expected FonteRepoShape, got other variant");
9103 };
9104 assert!(
9105 reason.contains("must not contain `,`"),
9106 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
9107 got {reason:?}"
9108 );
9109 }
9110
9111 #[test]
9112 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
9113 // Cascade pin: the fragment-`#` arm and the comma arm are
9114 // both per-byte arms inside the same `for &b in s.as_bytes()`
9115 // loop, so the byte that appears first in the value's byte
9116 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
9117 // carries both `#` and `,`; the `#` byte appears first, so
9118 // the fragment-`#` arm fires, surfacing the more self-
9119 // locating diagnostic on the byte the author pasted earliest
9120 // in the URL.
9121 let d = dep_with_fonte(DepSource::Git {
9122 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
9123 tag: Some("v0.1.0".into()),
9124 rev: None,
9125 branch: None,
9126 });
9127 let err = d.validate().unwrap_err();
9128 let DepError::FonteRepoShape { reason, .. } = err else {
9129 panic!("expected FonteRepoShape, got other variant");
9130 };
9131 assert!(
9132 reason.contains("must not contain `#`"),
9133 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
9134 appears first in value), got {reason:?}"
9135 );
9136 }
9137
9138 #[test]
9139 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
9140 // Cascade pin: the bang-`!` arm (the immediate-predecessor
9141 // byte-class arm, 7d53c68) and the comma arm are both
9142 // per-byte arms inside the same `for &b in s.as_bytes()`
9143 // loop, so the byte that appears first in the value's byte
9144 // order wins. A `:repo "github:p/x!mid,tail"` carries both
9145 // `!` and `,`; the `!` byte appears first, so the bang arm
9146 // fires, surfacing the more self-locating diagnostic on the
9147 // byte the author pasted earliest in the URL. Pins the
9148 // natural-order cascade so a future reorder of the per-byte
9149 // arms surfaces here — `,` is the most recent byte-class
9150 // arm, so the cascade-pin sweep extends to cover the
9151 // immediately prior `!` byte arm firing first when ordered
9152 // ahead of `,` in the value.
9153 let d = dep_with_fonte(DepSource::Git {
9154 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
9155 tag: Some("v0.1.0".into()),
9156 rev: None,
9157 branch: None,
9158 });
9159 let err = d.validate().unwrap_err();
9160 let DepError::FonteRepoShape { reason, .. } = err else {
9161 panic!("expected FonteRepoShape, got other variant");
9162 };
9163 assert!(
9164 reason.contains("must not contain `!`"),
9165 "reason must surface the bang arm (fires before comma when `!` byte \
9166 appears first in value), got {reason:?}"
9167 );
9168 }
9169
9170 #[test]
9171 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
9172 // The fail-before-pass-after pin for the canonical
9173 // shell-env-var-assignment-belongs-to-shell-grammar footgun
9174 // on `:repo`. An author copies
9175 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
9176 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
9177 // git clone <url>`, etc. — the canonical
9178 // git-troubleshooting README idiom for a one-shot env-var
9179 // scoped to the `git clone` invocation) from a shell-prompt
9180 // one-liner, intending the `KEY=VALUE` prefix as a shell-
9181 // grammar env-var assignment but the typed `:repo` slot is
9182 // a value parser, not a shell context, so the bytes ride
9183 // into the value verbatim. Until this arm landed the `=`
9184 // byte silently passed every prior `is_git_repo_url` arm
9185 // (no whitespace, no control chars, no non-ASCII, no `#`,
9186 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
9187 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
9188 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
9189 // the byte rode into the lacre's per-dep content-address
9190 // and the resolver's `git clone <repo>` subprocess
9191 // invocation, where the upstream host's git porcelain
9192 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
9193 // path that no host's repo registry resolves.
9194 let d = dep_with_fonte(DepSource::Git {
9195 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
9196 tag: Some("v0.1.0".into()),
9197 rev: None,
9198 branch: None,
9199 });
9200 let err = d.validate().unwrap_err();
9201 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9202 panic!("expected FonteRepoShape, got other variant");
9203 };
9204 assert_eq!(nome, "caixa-teia");
9205 assert_eq!(
9206 repo,
9207 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
9208 );
9209 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
9210 // appears before the ` ` byte at position 21, so the `=`
9211 // arm fires (not the whitespace arm) — both arms guard
9212 // the slot, but the per-byte for-loop scans left-to-right
9213 // and the first matching byte wins.
9214 assert!(
9215 reason.contains("must not contain `=`"),
9216 "reason must surface the equals-`=` arm on the env-var-assignment \
9217 paste shape, got {reason:?}"
9218 );
9219 assert!(
9220 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
9221 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
9222 );
9223 }
9224
9225 #[test]
9226 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
9227 // The symmetric paste-from-gitconfig pin: an author copies
9228 // `url=https://github.com/p/x` from `git config --get-all
9229 // remote.origin.url` output, a `.gitconfig` `[remote
9230 // "origin"] url = https://…` ini-stanza paste, or a
9231 // `git config remote.origin.url <value>` doc snippet,
9232 // intending the `url=` prefix as the ini-key but the typed
9233 // `:repo` slot is a URL value parser, not a gitconfig
9234 // grammar. With no leading whitespace and no earlier-arm
9235 // bytes in the value, the `=` arm itself fires (rather
9236 // than cascading to the whitespace arm as in the env-var
9237 // paste shape). Pinned separately so a future diagnostic-
9238 // surface change that only checked the whitespace-leading
9239 // shape surfaces here — the per-byte arm fires anywhere
9240 // `=` appears in the value.
9241 let d = dep_with_fonte(DepSource::Git {
9242 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
9243 tag: Some("v0.1.0".into()),
9244 rev: None,
9245 branch: None,
9246 });
9247 let err = d.validate().unwrap_err();
9248 let DepError::FonteRepoShape { reason, .. } = err else {
9249 panic!("expected FonteRepoShape, got other variant");
9250 };
9251 assert!(
9252 reason.contains("must not contain `=`"),
9253 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
9254 paste shape, got {reason:?}"
9255 );
9256 assert!(
9257 reason.contains("key-value-separator") || reason.contains("sub-delims"),
9258 "reason must name the key-value-separator / RFC-3986-sub-delims \
9259 rationale, got {reason:?}"
9260 );
9261 }
9262
9263 #[test]
9264 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
9265 // Cascade pin: the fragment-`#` arm and the `=` arm are
9266 // both per-byte arms inside the same `for &b in s.as_bytes()`
9267 // loop, so the byte that appears first in the value's byte
9268 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
9269 // carries both `#` and `=`; the `#` byte appears first, so
9270 // the fragment-`#` arm fires, surfacing the more self-
9271 // locating diagnostic on the byte the author pasted earliest
9272 // in the URL.
9273 let d = dep_with_fonte(DepSource::Git {
9274 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
9275 tag: Some("v0.1.0".into()),
9276 rev: None,
9277 branch: None,
9278 });
9279 let err = d.validate().unwrap_err();
9280 let DepError::FonteRepoShape { reason, .. } = err else {
9281 panic!("expected FonteRepoShape, got other variant");
9282 };
9283 assert!(
9284 reason.contains("must not contain `#`"),
9285 "reason must surface the fragment-`#` arm (fires before equals when \
9286 `#` byte appears first in value), got {reason:?}"
9287 );
9288 }
9289
9290 #[test]
9291 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
9292 // Cascade pin: the comma-`,` arm (the immediate-predecessor
9293 // byte-class arm, 775b80e) and the `=` arm are both per-byte
9294 // arms inside the same `for &b in s.as_bytes()` loop, so
9295 // the byte that appears first in the value's byte order
9296 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
9297 // and `=`; the `,` byte appears first, so the comma arm
9298 // fires, surfacing the more self-locating diagnostic on
9299 // the byte the author pasted earliest in the URL. Pins the
9300 // natural-order cascade so a future reorder of the per-byte
9301 // arms surfaces here — `=` is the most recent byte-class
9302 // arm, so the cascade-pin sweep extends to cover the
9303 // immediately prior `,` byte arm firing first when ordered
9304 // ahead of `=` in the value.
9305 let d = dep_with_fonte(DepSource::Git {
9306 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
9307 tag: Some("v0.1.0".into()),
9308 rev: None,
9309 branch: None,
9310 });
9311 let err = d.validate().unwrap_err();
9312 let DepError::FonteRepoShape { reason, .. } = err else {
9313 panic!("expected FonteRepoShape, got other variant");
9314 };
9315 assert!(
9316 reason.contains("must not contain `,`"),
9317 "reason must surface the comma arm (fires before equals when `,` byte \
9318 appears first in value), got {reason:?}"
9319 );
9320 }
9321
9322 #[test]
9323 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
9324 // The fail-before-pass-after pin for the canonical paste-from-
9325 // browser-address-bar percent-encoded-space footgun on `:repo`.
9326 // An author copies `https://github.com/p/x%20test` from a
9327 // browser address bar (or a percent-encoded README hyperlink,
9328 // or a `curl --data-urlencode` shell-pipeline output)
9329 // intending `%20` as the URL encoding of a literal space; the
9330 // typed `:repo` slot already rejects the literal space byte
9331 // (the whitespace arm at the top of `is_git_repo_url`), so an
9332 // author trying to express "I really meant a space" reaches
9333 // for percent-encoding. Until this arm landed the `%` byte
9334 // silently passed every prior `is_git_repo_url` arm and rode
9335 // verbatim into the lacre's per-dep content-address — but
9336 // libcurl re-percent-encodes `%` to `%25` on the wire (since
9337 // `%` is reserved as the escape-sequence lead-in), so the
9338 // wire request becomes `https://github.com/p/x%2520test`, a
9339 // path the lacre's content-address never names. The classic
9340 // render-determinism violation on the encoding-mechanism axis
9341 // itself.
9342 let d = dep_with_fonte(DepSource::Git {
9343 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
9344 tag: Some("v0.1.0".into()),
9345 rev: None,
9346 branch: None,
9347 });
9348 let err = d.validate().unwrap_err();
9349 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9350 panic!("expected FonteRepoShape, got other variant");
9351 };
9352 assert_eq!(nome, "caixa-teia");
9353 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
9354 assert!(
9355 reason.contains("must not contain `%`"),
9356 "reason must surface the percent-`%` arm on the percent-encoded-space \
9357 paste shape, got {reason:?}"
9358 );
9359 assert!(
9360 reason.contains("percent-encoding") || reason.contains("%25"),
9361 "reason must name the percent-encoding / `%25` re-encoding rationale, \
9362 got {reason:?}"
9363 );
9364 }
9365
9366 #[test]
9367 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
9368 // The symmetric over-encoded-path-separator pin: an author
9369 // writes `:repo "https://github.com/p%2Fx"` intending the
9370 // `%2F` as the URL encoding of `/` (the canonical
9371 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
9372 // footgun every API client library and OAuth redirect-URI
9373 // documentation surfaces — the `/` is the URL-path-separator
9374 // and some templates percent-encode it to escape interpretation
9375 // as a path separator). The GitHub Smart-HTTP transport
9376 // resolves the URL's path-segment grammar before the
9377 // percent-decoding pass, so the value identifies a different
9378 // resource on the wire than the literal-`/` form the lacre's
9379 // content-address must agree with — two authors whose `:repo`
9380 // values differ only in their `/` vs `%2F` presence lock to
9381 // two distinct BLAKE3 closures for the byte-identical upstream
9382 // `git clone`. Pinned separately so a future diagnostic
9383 // surface that only catches the `%20` shape surfaces here too.
9384 let d = dep_with_fonte(DepSource::Git {
9385 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
9386 tag: Some("v0.1.0".into()),
9387 rev: None,
9388 branch: None,
9389 });
9390 let err = d.validate().unwrap_err();
9391 let DepError::FonteRepoShape { reason, .. } = err else {
9392 panic!("expected FonteRepoShape, got other variant");
9393 };
9394 assert!(
9395 reason.contains("must not contain `%`"),
9396 "reason must surface the percent-`%` arm on the over-encoded-path \
9397 shape, got {reason:?}"
9398 );
9399 assert!(
9400 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9401 "reason must name the render-determinism / BLAKE3-closure rationale, \
9402 got {reason:?}"
9403 );
9404 }
9405
9406 #[test]
9407 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
9408 // Cascade pin: the fragment-`#` arm and the `%` arm are both
9409 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9410 // so the byte that appears first in the value's byte order
9411 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
9412 // both `#` and `%`; the `#` byte appears first, so the
9413 // fragment-`#` arm fires, surfacing the more self-locating
9414 // diagnostic on the byte the author pasted earliest in the URL.
9415 let d = dep_with_fonte(DepSource::Git {
9416 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
9417 tag: Some("v0.1.0".into()),
9418 rev: None,
9419 branch: None,
9420 });
9421 let err = d.validate().unwrap_err();
9422 let DepError::FonteRepoShape { reason, .. } = err else {
9423 panic!("expected FonteRepoShape, got other variant");
9424 };
9425 assert!(
9426 reason.contains("must not contain `#`"),
9427 "reason must surface the fragment-`#` arm (fires before percent when \
9428 `#` byte appears first in value), got {reason:?}"
9429 );
9430 }
9431
9432 #[test]
9433 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
9434 // Cascade pin: the equals-`=` arm (the immediate-predecessor
9435 // byte-class arm, acf99af) and the `%` arm are both per-byte
9436 // arms inside the same `for &b in s.as_bytes()` loop, so the
9437 // byte that appears first in the value's byte order wins.
9438 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
9439 // the `=` byte appears first, so the equals arm fires,
9440 // surfacing the more self-locating diagnostic on the byte the
9441 // author pasted earliest in the URL. Pins the natural-order
9442 // cascade so a future reorder of the per-byte arms surfaces
9443 // here — `%` is the most recent byte-class arm, so the
9444 // cascade-pin sweep extends to cover the immediately prior
9445 // `=` byte arm firing first when ordered ahead of `%` in the
9446 // value.
9447 let d = dep_with_fonte(DepSource::Git {
9448 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9449 tag: Some("v0.1.0".into()),
9450 rev: None,
9451 branch: None,
9452 });
9453 let err = d.validate().unwrap_err();
9454 let DepError::FonteRepoShape { reason, .. } = err else {
9455 panic!("expected FonteRepoShape, got other variant");
9456 };
9457 assert!(
9458 reason.contains("must not contain `=`"),
9459 "reason must surface the equals arm (fires before percent when `=` byte \
9460 appears first in value), got {reason:?}"
9461 );
9462 }
9463
9464 #[test]
9465 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9466 // The fail-before-pass-after pin for the canonical paste-from-
9467 // shell-history footgun on `:repo`. An author copies a
9468 // `git clone <url>` line from their terminal followed by a
9469 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9470 // history shorthand (the `^old^new^` form re-runs the prior
9471 // history entry with the first `old` substituted by `new`,
9472 // bash's default behavior on interactive sessions with
9473 // `set -o histexpand`), forgetting to trim the trailing
9474 // `^...^...` shell-history fragment from the URL value. The
9475 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9476 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9477 // classes), the WHATWG URL spec's 'fragment percent-encode
9478 // set' maps `^` → `%5E` on the wire, so the byte rides
9479 // verbatim into the lacre's per-dep content-address but
9480 // libcurl re-encodes it to `%5E` at `git clone` time — the
9481 // classic render-determinism violation on the same axis the
9482 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9483 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9484 // `#` arms close.
9485 let d = dep_with_fonte(DepSource::Git {
9486 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9487 tag: Some("v0.1.0".into()),
9488 rev: None,
9489 branch: None,
9490 });
9491 let err = d.validate().unwrap_err();
9492 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9493 panic!("expected FonteRepoShape, got other variant");
9494 };
9495 assert_eq!(nome, "caixa-teia");
9496 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9497 assert!(
9498 reason.contains("must not contain `^`"),
9499 "reason must surface the caret-`^` arm on the paste-from-shell-history \
9500 shape, got {reason:?}"
9501 );
9502 assert!(
9503 reason.contains("history-substitution") || reason.contains("%5E"),
9504 "reason must name the shell-history-substitution / `%5E` wire-encoding \
9505 rationale, got {reason:?}"
9506 );
9507 }
9508
9509 #[test]
9510 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9511 // The symmetric paste-from-doc-grep-pipeline footgun: an
9512 // author writes `:repo "github:p/^archived"` after copying a
9513 // `grep '^archived'` regex-anchor / negation idiom from a
9514 // doc / README quick-listing snippet, expecting the substrate
9515 // to coerce it to a literal repo name. The byte rides
9516 // verbatim into the lacre's per-dep content-address and
9517 // diverges from the byte-identical literal `archived` form
9518 // every other author authored — the canonical render-
9519 // determinism violation pin on the second footgun shape the
9520 // caret-`^` arm closes.
9521 let d = dep_with_fonte(DepSource::Git {
9522 repo: "github:pleme-io/^archived".into(),
9523 tag: Some("v0.1.0".into()),
9524 rev: None,
9525 branch: None,
9526 });
9527 let err = d.validate().unwrap_err();
9528 let DepError::FonteRepoShape { reason, .. } = err else {
9529 panic!("expected FonteRepoShape, got other variant");
9530 };
9531 assert!(
9532 reason.contains("must not contain `^`"),
9533 "reason must surface the caret-`^` arm on the regex-anchor shape, \
9534 got {reason:?}"
9535 );
9536 assert!(
9537 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9538 "reason must name the render-determinism / BLAKE3-closure rationale, \
9539 got {reason:?}"
9540 );
9541 }
9542
9543 #[test]
9544 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9545 // Cascade pin: the `%` arm (the immediate-predecessor byte-
9546 // class arm, a323db8) and the `^` arm are both per-byte arms
9547 // inside the same `for &b in s.as_bytes()` loop, so the byte
9548 // that appears first in the value's byte order wins. A
9549 // `:repo "https://github.com/p/x%20mid^tail"` carries both
9550 // `%` and `^`; the `%` byte appears first, so the percent
9551 // arm fires, surfacing the more self-locating diagnostic on
9552 // the byte the author pasted earliest in the URL. Pins the
9553 // natural-order cascade so a future reorder of the per-byte
9554 // arms surfaces here — `^` is the most recent byte-class arm,
9555 // so the cascade-pin sweep extends to cover the immediately
9556 // prior `%` byte arm firing first when ordered ahead of `^`
9557 // in the value.
9558 let d = dep_with_fonte(DepSource::Git {
9559 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9560 tag: Some("v0.1.0".into()),
9561 rev: None,
9562 branch: None,
9563 });
9564 let err = d.validate().unwrap_err();
9565 let DepError::FonteRepoShape { reason, .. } = err else {
9566 panic!("expected FonteRepoShape, got other variant");
9567 };
9568 assert!(
9569 reason.contains("must not contain `%`"),
9570 "reason must surface the percent arm (fires before caret when `%` byte \
9571 appears first in value), got {reason:?}"
9572 );
9573 }
9574
9575 #[test]
9576 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9577 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9578 // (no `github:` prefix, no scheme). Every documented form
9579 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9580 // `file://`, or `git@host:path`); a bare `org/repo` is
9581 // ambiguous (`git clone` reads as a relative filesystem path
9582 // rather than the GitHub-shorthand expansion the author
9583 // probably intended) and the gate rejects the shape upstream.
9584 let d = dep_with_fonte(DepSource::Git {
9585 repo: "pleme-io/caixa-teia".into(),
9586 tag: Some("v0.1.0".into()),
9587 rev: None,
9588 branch: None,
9589 });
9590 let err = d.validate().unwrap_err();
9591 let DepError::FonteRepoShape { reason, .. } = err else {
9592 panic!("expected FonteRepoShape, got other variant");
9593 };
9594 assert!(
9595 reason.contains("must contain a `:`"),
9596 "reason must surface the missing-`:` arm, got {reason:?}"
9597 );
9598 assert!(
9599 reason.contains("github:"),
9600 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9601 );
9602 }
9603
9604 #[test]
9605 fn validate_rejects_git_fonte_with_repo_leading_colon() {
9606 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9607 // scheme that no git porcelain entry-point accepts. Pinned
9608 // separately from the missing-`:` arm because a value with a
9609 // leading `:` does technically contain a `:` separator; the
9610 // shape gate rejects on a dedicated arm so the diagnostic
9611 // names the specific footgun.
9612 let d = dep_with_fonte(DepSource::Git {
9613 repo: ":pleme-io/caixa-teia".into(),
9614 tag: Some("v0.1.0".into()),
9615 rev: None,
9616 branch: None,
9617 });
9618 let err = d.validate().unwrap_err();
9619 let DepError::FonteRepoShape { reason, .. } = err else {
9620 panic!("expected FonteRepoShape, got other variant");
9621 };
9622 assert!(
9623 reason.contains("must not start with `:`"),
9624 "reason must surface the leading-`:` arm, got {reason:?}"
9625 );
9626 }
9627
9628 #[test]
9629 fn validate_rejects_git_fonte_with_repo_too_long() {
9630 // The cap arm — a `:repo` value longer than
9631 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9632 // structurally untenable on every realistic landing site (the
9633 // resolver's `git clone` invocation, the future M4 CR
9634 // materializer's per-dep `repo:` axis); a value of that length
9635 // is almost certainly a paste-from-binary slug.
9636 let too_long = format!(
9637 "github:pleme-io/{}",
9638 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9639 );
9640 let d = dep_with_fonte(DepSource::Git {
9641 repo: too_long.clone(),
9642 tag: Some("v0.1.0".into()),
9643 rev: None,
9644 branch: None,
9645 });
9646 let err = d.validate().unwrap_err();
9647 let DepError::FonteRepoShape { reason, .. } = err else {
9648 panic!("expected FonteRepoShape, got other variant");
9649 };
9650 assert!(
9651 reason.contains("2048"),
9652 "reason must name the cap, got {reason:?}"
9653 );
9654 }
9655
9656 #[test]
9657 fn validate_accepts_canonical_git_fonte_repo_shapes() {
9658 // The positive-control sweep: every documented author shape on
9659 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9660 // must pass the value-shape gate. Pinned so a future tightening
9661 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9662 // here as a structural decision. Each form is exercised with the
9663 // same canonical `:tag` pin so only the `:repo` axis varies.
9664 for repo in [
9665 // The pleme-io registry-shorthand convention — `github:org/repo`.
9666 "github:pleme-io/caixa-teia",
9667 // Other host-aliased shorthands (the resolver's pluggable
9668 // host-prefix table).
9669 "gitlab:pleme-io/caixa-teia",
9670 "codeberg:pleme-io/caixa-teia",
9671 "sourcehut:~pleme-io/caixa-teia",
9672 // Full HTTPS URL with and without `.git` suffix.
9673 "https://github.com/pleme-io/caixa-teia",
9674 "https://github.com/pleme-io/caixa-teia.git",
9675 // HTTP (rare; dev / mirror).
9676 "http://example.com/pleme-io/caixa-teia.git",
9677 // SSH URL.
9678 "ssh://git@github.com/pleme-io/caixa-teia.git",
9679 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9680 // Scp-style SSH — the canonical `git@host:path` short form.
9681 "git@github.com:pleme-io/caixa-teia.git",
9682 "git@git.example.com:team/private.git",
9683 // Anonymous git protocol.
9684 "git://git.example.com/pleme-io/caixa-teia.git",
9685 // Local file URL (dev path).
9686 "file:///tmp/caixa-teia",
9687 ] {
9688 let d = dep_with_fonte(DepSource::Git {
9689 repo: repo.into(),
9690 tag: Some("v0.1.0".into()),
9691 rev: None,
9692 branch: None,
9693 });
9694 d.validate()
9695 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9696 }
9697 }
9698
9699 #[test]
9700 fn fonte_repo_empty_takes_precedence_over_shape() {
9701 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9702 // diagnostic; doesn't try to parse the URL shape) fires before
9703 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9704 // keeps its narrower error message. Mirrors
9705 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9706 // on the ordering layer.
9707 let d = dep_with_fonte(DepSource::Git {
9708 repo: String::new(),
9709 tag: Some("v0.1.0".into()),
9710 rev: None,
9711 branch: None,
9712 });
9713 let err = d.validate().unwrap_err();
9714 assert!(
9715 matches!(err, DepError::FonteRepoEmpty { .. }),
9716 "got {err:?}"
9717 );
9718 }
9719
9720 #[test]
9721 fn fonte_repo_shape_fires_before_pin_missing() {
9722 // Order pin: a malformed `:repo` value on a dep with no pin set
9723 // surfaces the `:repo` shape diagnostic (the more self-locating
9724 // axis — the `:repo` is the load-bearing identity of the source;
9725 // a missing pin is downstream from "do we even know the repo")
9726 // rather than collapsing onto the pin-missing diagnostic. The
9727 // shape gate runs inline before the pin enumeration in
9728 // `DepSource::validate`.
9729 let d = dep_with_fonte(DepSource::Git {
9730 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9731 tag: None,
9732 rev: None,
9733 branch: None,
9734 });
9735 let err = d.validate().unwrap_err();
9736 assert!(
9737 matches!(err, DepError::FonteRepoShape { .. }),
9738 "got {err:?}"
9739 );
9740 }
9741
9742 #[test]
9743 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9744 // The diagnostic-shape pin: the error names the offending
9745 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9746 // so the author can grep their caixa.lisp without re-running
9747 // the build. Mirrors the diagnostic-shape sweep on every prior
9748 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9749 let d = dep_with_fonte(DepSource::Git {
9750 repo: "pleme-io/caixa-teia".into(),
9751 tag: Some("v0.1.0".into()),
9752 rev: None,
9753 branch: None,
9754 });
9755 let err = d.validate().unwrap_err();
9756 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9757 panic!("expected FonteRepoShape, got other variant");
9758 };
9759 assert_eq!(nome, "caixa-teia");
9760 assert_eq!(repo, "pleme-io/caixa-teia");
9761 assert!(
9762 !reason.is_empty(),
9763 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9764 );
9765 }
9766
9767 #[test]
9768 fn validate_rejects_git_fonte_with_no_pin() {
9769 // The fail-before-pass-after pin for the canonical
9770 // `(:tipo git :repo "github:pleme-io/x")` shape with no
9771 // :tag/:rev/:branch — until this gate landed the resolver's
9772 // ResolveError::MissingPin surfaced at fetch time, far from the
9773 // source caixa.lisp. The new gate moves the check to validate
9774 // time and names the offending dep.
9775 let d = dep_with_fonte(DepSource::Git {
9776 repo: "github:pleme-io/caixa-teia".into(),
9777 tag: None,
9778 rev: None,
9779 branch: None,
9780 });
9781 let err = d.validate().unwrap_err();
9782 assert!(
9783 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9784 "got {err:?}"
9785 );
9786 }
9787
9788 #[test]
9789 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9790 // The canonical "pin drift" footgun: an author writes
9791 // `:tag "v1"` and later adds `:branch "main"` without removing
9792 // the :tag, and the resolver silently picks :tag (precedence
9793 // :rev > :tag > :branch). The :branch was dropped with no
9794 // diagnostic. The gate now rejects multi-pin shapes so the
9795 // author makes the precedence explicit at the source.
9796 let d = dep_with_fonte(DepSource::Git {
9797 repo: "github:pleme-io/caixa-teia".into(),
9798 tag: Some("v0.1.0".into()),
9799 rev: None,
9800 branch: Some("main".into()),
9801 });
9802 let err = d.validate().unwrap_err();
9803 let DepError::FontePinAmbiguous { nome, pins } = err else {
9804 panic!("expected FontePinAmbiguous");
9805 };
9806 assert_eq!(nome, "caixa-teia");
9807 assert!(pins.contains(":tag"));
9808 assert!(pins.contains(":branch"));
9809 assert!(!pins.contains(":rev"));
9810 }
9811
9812 #[test]
9813 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9814 // Sibling arm of the pin-drift footgun: :tag + :rev set
9815 // simultaneously. Pinned separately so a future relaxation
9816 // that only catches the (:tag, :branch) pair surfaces here.
9817 let d = dep_with_fonte(DepSource::Git {
9818 repo: "github:pleme-io/caixa-teia".into(),
9819 tag: Some("v0.1.0".into()),
9820 rev: Some("c0ffee".into()),
9821 branch: None,
9822 });
9823 let err = d.validate().unwrap_err();
9824 let DepError::FontePinAmbiguous { nome, pins } = err else {
9825 panic!("expected FontePinAmbiguous");
9826 };
9827 assert_eq!(nome, "caixa-teia");
9828 assert!(pins.contains(":tag"));
9829 assert!(pins.contains(":rev"));
9830 }
9831
9832 #[test]
9833 fn validate_rejects_git_fonte_with_all_three_pins() {
9834 // The maximal ambiguity case — every pin axis set. Pinned so a
9835 // future relaxation that only catches pairs surfaces here. The
9836 // diagnostic must enumerate every offending axis so the author
9837 // sees the full set, not just the first match.
9838 let d = dep_with_fonte(DepSource::Git {
9839 repo: "github:pleme-io/caixa-teia".into(),
9840 tag: Some("v0.1.0".into()),
9841 rev: Some("c0ffee".into()),
9842 branch: Some("main".into()),
9843 });
9844 let err = d.validate().unwrap_err();
9845 let DepError::FontePinAmbiguous { nome, pins } = err else {
9846 panic!("expected FontePinAmbiguous");
9847 };
9848 assert_eq!(nome, "caixa-teia");
9849 assert!(pins.contains(":tag"));
9850 assert!(pins.contains(":rev"));
9851 assert!(pins.contains(":branch"));
9852 }
9853
9854 #[test]
9855 fn validate_rejects_git_fonte_with_empty_tag_pin() {
9856 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9857 // inner string is empty. Distinct from FontePinMissing (where
9858 // every axis is None) — pinned separately so a future
9859 // tightening collapsing them surfaces here as a structural
9860 // decision.
9861 let d = dep_with_fonte(DepSource::Git {
9862 repo: "github:pleme-io/caixa-teia".into(),
9863 tag: Some(String::new()),
9864 rev: None,
9865 branch: None,
9866 });
9867 let err = d.validate().unwrap_err();
9868 let DepError::FontePinEmpty { nome, pin } = err else {
9869 panic!("expected FontePinEmpty");
9870 };
9871 assert_eq!(nome, "caixa-teia");
9872 assert_eq!(pin, ":tag");
9873 }
9874
9875 #[test]
9876 fn validate_rejects_git_fonte_with_empty_rev_pin() {
9877 // Sibling arm — the empty-pin diagnostic names which axis
9878 // carries the empty value, so the author's grep target is
9879 // unambiguous.
9880 let d = dep_with_fonte(DepSource::Git {
9881 repo: "github:pleme-io/caixa-teia".into(),
9882 tag: None,
9883 rev: Some(String::new()),
9884 branch: None,
9885 });
9886 let err = d.validate().unwrap_err();
9887 let DepError::FontePinEmpty { nome, pin } = err else {
9888 panic!("expected FontePinEmpty");
9889 };
9890 assert_eq!(nome, "caixa-teia");
9891 assert_eq!(pin, ":rev");
9892 }
9893
9894 #[test]
9895 fn validate_rejects_path_fonte_with_empty_caminho() {
9896 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9897 // until this gate landed the resolver's
9898 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9899 // fetch time — not actionable. The new gate moves the check to
9900 // validate time and names the offending dep.
9901 let d = dep_with_fonte(DepSource::Path {
9902 caminho: String::new(),
9903 });
9904 let err = d.validate().unwrap_err();
9905 assert!(
9906 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9907 "got {err:?}"
9908 );
9909 }
9910
9911 #[test]
9912 fn validate_rejects_path_fonte_with_absolute_caminho() {
9913 // The fail-before-pass-after pin for the absolute-`:caminho`
9914 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9915 // Until this gate landed an absolute `:caminho` silently
9916 // passed validate; the lacre pipeline embedded the
9917 // host-specific filesystem path verbatim in its
9918 // content-address (`conteudo: format!("path:{caminho}")`,
9919 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9920 // differed per machine — the build succeeded but two CI
9921 // runners with different `${HOME}` layouts emitted two
9922 // distinct lacres for the byte-identical caixa, silently
9923 // breaking the THEORY.md §V.2 render-determinism contract
9924 // far from the source caixa.lisp. The new gate moves the
9925 // check to validate time and names the offending dep +
9926 // caminho verbatim.
9927 let d = dep_with_fonte(DepSource::Path {
9928 caminho: "/home/me/work/caixa-teia".into(),
9929 });
9930 let err = d.validate().unwrap_err();
9931 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9932 panic!("expected FonteCaminhoAbsolute, got other variant");
9933 };
9934 assert_eq!(nome, "caixa-teia");
9935 assert_eq!(caminho, "/home/me/work/caixa-teia");
9936 }
9937
9938 #[test]
9939 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9940 // The canonical sibling-workspace dep form
9941 // (`:caminho "../caixa-teia"`) remains accepted. The
9942 // absolute-path gate above is specifically narrower than the
9943 // shared [`crate::render::is_sandboxed_relative_path`]
9944 // predicate (which additionally forbids `..` traversal): a
9945 // local-path dep's canonical author surface is the in-tree
9946 // sibling-workspace path, so a full sandboxed-relative-path
9947 // lift would structurally reject every legitimate path-fonte
9948 // dep. Pinned so a future tightening to the full predicate
9949 // surfaces here as a structural decision, not a silent break.
9950 let d = dep_with_fonte(DepSource::Path {
9951 caminho: "../caixa-teia".into(),
9952 });
9953 d.validate().unwrap();
9954 }
9955
9956 #[test]
9957 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9958 // A multi-segment relative `:caminho`
9959 // (`"vendor/forks/caixa-teia"`) remains accepted — the
9960 // absolute-path gate brackets the host-layout-leaking shape
9961 // at the leading-`/` boundary only; every relative shape past
9962 // the empty arm continues to pass. Pinned alongside the
9963 // `..`-traversal positive control so a future tightening
9964 // surfaces the full set of legitimate relative forms here
9965 // rather than at a downstream consumer.
9966 let d = dep_with_fonte(DepSource::Path {
9967 caminho: "vendor/forks/caixa-teia".into(),
9968 });
9969 d.validate().unwrap();
9970 }
9971
9972 #[test]
9973 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9974 // The fail-before-pass-after pin for the tilde-expansion
9975 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9976 // Until this gate landed the b94fd83 absolute arm let `~/foo`
9977 // through (`Path::is_absolute` returns false on a leading `~`
9978 // — the tilde is a shell-expansion convention, not a POSIX
9979 // path component), so the lacre embedded the value verbatim
9980 // and the resolver folded it through `Path::join` without
9981 // expansion, looking for a literal `./~/work/caixa-teia`
9982 // subdirectory and failing at resolve time with a
9983 // `No such file or directory` error far from the source
9984 // caixa.lisp. The new gate moves the check to validate time
9985 // and names the offending dep + caminho verbatim.
9986 let d = dep_with_fonte(DepSource::Path {
9987 caminho: "~/work/caixa-teia".into(),
9988 });
9989 let err = d.validate().unwrap_err();
9990 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9991 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9992 };
9993 assert_eq!(nome, "caixa-teia");
9994 assert_eq!(caminho, "~/work/caixa-teia");
9995 }
9996
9997 #[test]
9998 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9999 // The bare `~` form (canonical "I meant `$HOME` and forgot
10000 // the rest"): both the leading-tilde arm catches it and the
10001 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
10002 // sweeps through the same arm. Pinned both to ensure the
10003 // gate doesn't narrow to `~/` only.
10004 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
10005 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10006 let err = d.validate().unwrap_err();
10007 assert!(
10008 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10009 "{s:?} → {err:?}",
10010 );
10011 }
10012 }
10013
10014 #[test]
10015 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
10016 // The leading-`~` is the canonical shell-expansion footgun —
10017 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
10018 // backup-file-suffix idiom) is a legitimate POSIX path byte
10019 // with no shell-expansion semantic at the leading position.
10020 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
10021 // sweep that would break every legitimate-shape backup-file
10022 // path.
10023 let d = dep_with_fonte(DepSource::Path {
10024 caminho: "../foo~bar/caixa-teia".into(),
10025 });
10026 d.validate().unwrap();
10027 }
10028
10029 #[test]
10030 fn fonte_caminho_empty_fires_before_tilde_expansion() {
10031 // Cascade pin: the empty arm structurally precedes the
10032 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
10033 // pin establishes the precedence at the diagnostic-shape
10034 // level should a future codec round-trip ever produce a
10035 // probe-as-both value. Mirrors the peer
10036 // `fonte_repo_empty_fires_before_pin_missing` cascade
10037 // discipline.
10038 let d = dep_with_fonte(DepSource::Path {
10039 caminho: String::new(),
10040 });
10041 let err = d.validate().unwrap_err();
10042 assert!(
10043 matches!(err, DepError::FonteCaminhoEmpty { .. }),
10044 "got {err:?}",
10045 );
10046 }
10047
10048 #[test]
10049 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
10050 // Diagnostic-shape pin (peer with
10051 // `validate_rejects_path_fonte_with_absolute_caminho`'s
10052 // payload assertion): the error's Display surfaces both the
10053 // offending `:nome` and the offending `:caminho` verbatim
10054 // so a `feira lint` run can render the diagnostic without
10055 // re-parsing.
10056 let d = dep_with_fonte(DepSource::Path {
10057 caminho: "~alice/dev/caixa-teia".into(),
10058 });
10059 let rendered = d.validate().unwrap_err().to_string();
10060 assert!(
10061 rendered.contains("caixa-teia"),
10062 "diagnostic must name the offending dep: {rendered}",
10063 );
10064 assert!(
10065 rendered.contains("~alice/dev/caixa-teia"),
10066 "diagnostic must quote the offending caminho: {rendered}",
10067 );
10068 assert!(
10069 rendered.contains('~'),
10070 "diagnostic must reference the tilde footgun: {rendered}",
10071 );
10072 }
10073
10074 #[test]
10075 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
10076 // The fail-before-pass-after pin for the shell-variable-
10077 // expansion `:caminho` shape: `(:tipo path :caminho
10078 // "$HOME/work/caixa-teia")`. Until this gate landed the
10079 // b94fd83 absolute arm + the a5c248e tilde arm both let
10080 // `$HOME/foo` through (`Path::is_absolute` returns false on
10081 // a leading `$` — the `$` is a shell convention, not a POSIX
10082 // path component; `starts_with('~')` returns false too), so
10083 // the lacre embedded the value verbatim and the resolver
10084 // folded it through `Path::join` without `$`-expansion,
10085 // looking for a literal `./$HOME/work/caixa-teia`
10086 // subdirectory and failing at resolve time with a
10087 // `No such file or directory` error far from the source
10088 // caixa.lisp. The new gate moves the check to validate time
10089 // and names the offending dep + caminho verbatim.
10090 let d = dep_with_fonte(DepSource::Path {
10091 caminho: "$HOME/work/caixa-teia".into(),
10092 });
10093 let err = d.validate().unwrap_err();
10094 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
10095 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
10096 };
10097 assert_eq!(nome, "caixa-teia");
10098 assert_eq!(caminho, "$HOME/work/caixa-teia");
10099 }
10100
10101 #[test]
10102 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
10103 // Sweep over every leading-`$` shape: the `${VAR}`-braced
10104 // form (canonical "paste-from-CI-manifest" footgun every
10105 // GitHub Actions / GitLab CI / Drone manifest carries on
10106 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
10107 // canonical "I'm referencing a per-user config dir"),
10108 // and the bare `$` (canonical "I meant `$HOME` and forgot
10109 // the rest"). All shapes route through the same gate's
10110 // byte check. Pinned so the gate doesn't narrow to a
10111 // single shape (e.g. `$HOME/` only).
10112 for s in [
10113 "${HOME}/work/caixa-teia",
10114 "${WORKSPACE}/caixa-teia",
10115 "$XDG_CONFIG_HOME/caixa",
10116 "$",
10117 ] {
10118 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10119 let err = d.validate().unwrap_err();
10120 assert!(
10121 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10122 "{s:?} → {err:?}",
10123 );
10124 }
10125 }
10126
10127 #[test]
10128 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
10129 // The `$` byte is the canonical shell-variable-expansion /
10130 // command-substitution / arithmetic-expansion sentinel and
10131 // is rejected at *every* position on the `:caminho` axis: the
10132 // leading arm surfaces `FonteCaminhoVarExpansion`, the
10133 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
10134 // (6620f39). Pinned so a future arm doesn't narrow the gate
10135 // back to the leading position and re-open the paste-from-
10136 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
10137 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
10138 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
10139 // the lacre content-address (`path:{caminho}`,
10140 // caixa-resolver/src/resolve.rs:189).
10141 let d = dep_with_fonte(DepSource::Path {
10142 caminho: "../foo$bar/caixa-teia".into(),
10143 });
10144 let err = d.validate().unwrap_err();
10145 assert!(
10146 matches!(
10147 err,
10148 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
10149 ),
10150 "got {err:?}",
10151 );
10152 }
10153
10154 #[test]
10155 fn fonte_caminho_tilde_fires_before_var_expansion() {
10156 // Cascade pin: the tilde arm structurally precedes the var
10157 // arm (the bytes `~` and `$` don't overlap at the leading
10158 // position), but the pin establishes the precedence at the
10159 // diagnostic-shape level should a future codec round-trip
10160 // ever produce a probe-as-both value. Mirrors the peer
10161 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
10162 // discipline on the immediate-predecessor arm.
10163 let d = dep_with_fonte(DepSource::Path {
10164 caminho: "~/work/caixa-teia".into(),
10165 });
10166 let err = d.validate().unwrap_err();
10167 assert!(
10168 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10169 "got {err:?}",
10170 );
10171 }
10172
10173 #[test]
10174 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
10175 // Diagnostic-shape pin (peer with
10176 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
10177 // payload assertion on the immediate-predecessor arm): the
10178 // error's Display surfaces both the offending `:nome` and
10179 // the offending `:caminho` verbatim plus the `$` footgun
10180 // character itself so a `feira lint` run can render the
10181 // diagnostic without re-parsing.
10182 let d = dep_with_fonte(DepSource::Path {
10183 caminho: "${WORKSPACE}/caixa-teia".into(),
10184 });
10185 let rendered = d.validate().unwrap_err().to_string();
10186 assert!(
10187 rendered.contains("caixa-teia"),
10188 "diagnostic must name the offending dep: {rendered}",
10189 );
10190 assert!(
10191 rendered.contains("${WORKSPACE}/caixa-teia"),
10192 "diagnostic must quote the offending caminho: {rendered}",
10193 );
10194 assert!(
10195 rendered.contains('$'),
10196 "diagnostic must reference the dollar footgun: {rendered}",
10197 );
10198 }
10199
10200 #[test]
10201 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
10202 // The fail-before-pass-after pin for the load-bearing NUL byte:
10203 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
10204 // routes the path through `CString::new` which fails with
10205 // `NulError`); until this gate landed a `:caminho
10206 // "../caixa\0teia"` silently passed validate, the lacre
10207 // pipeline embedded the value verbatim, and the failure
10208 // surfaced at the resolver's `Path::join` → `CString::new`
10209 // boundary with a non-self-locating `NulError` far from the
10210 // source caixa.lisp. The new gate moves the check to validate
10211 // time and names the offending dep + caminho + offending byte
10212 // verbatim.
10213 let d = dep_with_fonte(DepSource::Path {
10214 caminho: "../caixa\0teia".into(),
10215 });
10216 let err = d.validate().unwrap_err();
10217 let DepError::FonteCaminhoControlChar {
10218 nome,
10219 caminho,
10220 byte,
10221 } = err
10222 else {
10223 panic!("expected FonteCaminhoControlChar, got {err:?}");
10224 };
10225 assert_eq!(nome, "caixa-teia");
10226 assert_eq!(caminho, "../caixa\0teia");
10227 assert_eq!(byte, 0x00);
10228 }
10229
10230 #[test]
10231 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
10232 // The canonical paste-from-multiline-doc footgun on `:caminho`
10233 // — author copies `"../caixa-teia\n"` (trailing newline) out
10234 // of a multi-line code-fence or, worse, a `:caminho
10235 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
10236 // injection sibling on the path axis the `is_git_repo_url`
10237 // control-char arm already closes on `:repo`). Pinned
10238 // separately from the NUL arm so a future relaxation that
10239 // catches one but not the other surfaces here.
10240 let d = dep_with_fonte(DepSource::Path {
10241 caminho: "../caixa-teia\n".into(),
10242 });
10243 let err = d.validate().unwrap_err();
10244 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10245 panic!("expected FonteCaminhoControlChar, got {err:?}");
10246 };
10247 assert_eq!(byte, 0x0A);
10248 }
10249
10250 #[test]
10251 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
10252 // The CRLF sibling of the LF arm — Windows-line-ending
10253 // paste-from-multiline-doc on a `\r\n`-terminated buffer
10254 // leaves a stray `\r` mid-string after the LF strip. Pinned
10255 // separately from the LF arm so a future relaxation that
10256 // only catches LF surfaces here.
10257 let d = dep_with_fonte(DepSource::Path {
10258 caminho: "../caixa-teia\r".into(),
10259 });
10260 let err = d.validate().unwrap_err();
10261 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10262 panic!("expected FonteCaminhoControlChar, got {err:?}");
10263 };
10264 assert_eq!(byte, 0x0D);
10265 }
10266
10267 #[test]
10268 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
10269 // The canonical paste-from-aligned-table footgun — a `\t`
10270 // mid-`:caminho` is invisible in most editors but rides
10271 // through the lacre's content-address verbatim, so two
10272 // paste-from-distinct-tables (one editor strips tabs, one
10273 // preserves them) yield divergent lacres for the byte-
10274 // identical-looking caixa. Pinned separately from the
10275 // whitespace-shaped LF/CR arms so a future relaxation that
10276 // narrows to line-terminator-only surfaces here.
10277 let d = dep_with_fonte(DepSource::Path {
10278 caminho: "../caixa\tteia".into(),
10279 });
10280 let err = d.validate().unwrap_err();
10281 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10282 panic!("expected FonteCaminhoControlChar, got {err:?}");
10283 };
10284 assert_eq!(byte, 0x09);
10285 }
10286
10287 #[test]
10288 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
10289 // The DEL byte (`0x7F`) closes the upper-end paste-from-
10290 // binary-blob footgun — the gate's contract is `b < 0x20 ||
10291 // b == 0x7F`, matching the `is_git_repo_url` /
10292 // `is_git_ref_name` predicates' control-char arms. Pinned
10293 // separately from the lower-range arms so a future narrowing
10294 // to `< 0x20` only surfaces here.
10295 let d = dep_with_fonte(DepSource::Path {
10296 caminho: "../caixa\x7fteia".into(),
10297 });
10298 let err = d.validate().unwrap_err();
10299 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10300 panic!("expected FonteCaminhoControlChar, got {err:?}");
10301 };
10302 assert_eq!(byte, 0x7F);
10303 }
10304
10305 #[test]
10306 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
10307 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
10308 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
10309 // are opaque byte sequences and UTF-8 multi-byte sequences
10310 // are a legitimate filename shape (the `café-teia/foo` idiom).
10311 // Pinned so the gate doesn't widen to a full ASCII-only sweep
10312 // that would break every legitimate-shape UTF-8 path.
10313 let d = dep_with_fonte(DepSource::Path {
10314 caminho: "../café-teia/foo".into(),
10315 });
10316 d.validate().unwrap();
10317 }
10318
10319 #[test]
10320 fn fonte_caminho_var_fires_before_control_char() {
10321 // Cascade pin: the var-expansion arm structurally precedes the
10322 // control-char arm. A value like `"$\n"` probes positive on
10323 // both arms (`starts_with('$')` and contains LF), but the
10324 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
10325 // wins so the author sees the more self-locating shell-
10326 // expansion arm first. Mirrors the
10327 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10328 // discipline on the immediate-predecessor arm.
10329 let d = dep_with_fonte(DepSource::Path {
10330 caminho: "$HOME\n".into(),
10331 });
10332 let err = d.validate().unwrap_err();
10333 assert!(
10334 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10335 "got {err:?}",
10336 );
10337 }
10338
10339 #[test]
10340 fn validate_rejects_path_fonte_with_leading_space_caminho() {
10341 // The fail-before-pass-after pin for the leading ASCII space
10342 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
10343 // Until this gate landed the b94fd83 absolute arm + the a5c248e
10344 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
10345 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
10346 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
10347 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
10348 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
10349 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
10350 // are caught, but the most common whitespace `0x20` space is
10351 // not). The lacre embedded the value verbatim and the resolver
10352 // folded it through `Path::join` looking for a literal `./ ../
10353 // caixa-teia` subdirectory and failing at resolve time with a
10354 // non-self-locating `No such file or directory` error far from
10355 // the source caixa.lisp. The new gate moves the check to
10356 // validate time and names the offending dep + caminho verbatim.
10357 let d = dep_with_fonte(DepSource::Path {
10358 caminho: " ../caixa-teia".into(),
10359 });
10360 let err = d.validate().unwrap_err();
10361 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
10362 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
10363 };
10364 assert_eq!(nome, "caixa-teia");
10365 assert_eq!(caminho, " ../caixa-teia");
10366 }
10367
10368 #[test]
10369 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
10370 // The aligned-doc paste footgun sweep: more than one leading
10371 // space (`" ../caixa-teia"` — the canonical "I selected the
10372 // aligned column from a four-`:fonte`-entry `:deps` block"
10373 // paste) routes through the same gate's `starts_with(' ')`
10374 // byte check. Pinned so the gate doesn't narrow to a
10375 // single-space prefix.
10376 let d = dep_with_fonte(DepSource::Path {
10377 caminho: " ../caixa-teia".into(),
10378 });
10379 let err = d.validate().unwrap_err();
10380 assert!(
10381 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10382 "got {err:?}",
10383 );
10384 }
10385
10386 #[test]
10387 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
10388 // The leading-space is the canonical paste-from-aligned-doc
10389 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
10390 // canonical "I have a directory with a space in its name"
10391 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
10392 // legitimate path with no whitespace-leak semantic at the
10393 // non-leading position. Pinned so the gate doesn't widen to a
10394 // full no-space-anywhere sweep that would break every
10395 // legitimate-shape space-in-filename path.
10396 let d = dep_with_fonte(DepSource::Path {
10397 caminho: "../my dir/caixa-teia".into(),
10398 });
10399 d.validate().unwrap();
10400 }
10401
10402 #[test]
10403 fn fonte_caminho_var_fires_before_leading_whitespace() {
10404 // Cascade pin: the var-expansion arm structurally precedes the
10405 // leading-whitespace arm. A value like `"$ "` would probe positive
10406 // on var (`starts_with('$')`) but the leading-byte arms walk
10407 // left-to-right so the var arm fires on the leading `$` before
10408 // the leading-whitespace arm probes. Mirrors the
10409 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10410 // discipline on the immediate-predecessor arms.
10411 let d = dep_with_fonte(DepSource::Path {
10412 caminho: "$VAR".into(),
10413 });
10414 let err = d.validate().unwrap_err();
10415 assert!(
10416 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10417 "got {err:?}",
10418 );
10419 }
10420
10421 #[test]
10422 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
10423 // Cascade pin: the leading-whitespace arm structurally precedes
10424 // the control-char arm. A value like `" ../foo\n"` probes
10425 // positive on both (starts with space AND contains LF), but
10426 // the narrower leading-byte diagnostic
10427 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
10428 // more self-locating paste-from-aligned-doc arm first. Mirrors
10429 // the `fonte_caminho_var_fires_before_control_char` cascade
10430 // discipline on the immediate-predecessor arm.
10431 let d = dep_with_fonte(DepSource::Path {
10432 caminho: " ../foo\n".into(),
10433 });
10434 let err = d.validate().unwrap_err();
10435 assert!(
10436 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10437 "got {err:?}",
10438 );
10439 }
10440
10441 #[test]
10442 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10443 // Diagnostic-shape pin (peer with
10444 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10445 // payload assertion on the immediate-predecessor arm): the
10446 // error's Display surfaces both the offending `:nome` and the
10447 // offending `:caminho` verbatim, so a `feira lint` run can
10448 // render the diagnostic without re-parsing and the author can
10449 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10450 // one edit.
10451 let d = dep_with_fonte(DepSource::Path {
10452 caminho: " ../caixa-teia".into(),
10453 });
10454 let rendered = d.validate().unwrap_err().to_string();
10455 assert!(
10456 rendered.contains("caixa-teia"),
10457 "diagnostic must name the offending dep: {rendered}",
10458 );
10459 assert!(
10460 rendered.contains(" ../caixa-teia"),
10461 "diagnostic must quote the offending caminho: {rendered}",
10462 );
10463 assert!(
10464 rendered.contains("space"),
10465 "diagnostic must name the space footgun: {rendered}",
10466 );
10467 }
10468
10469 #[test]
10470 fn fonte_caminho_absolute_fires_before_control_char() {
10471 // Cascade pin on the sibling leading-byte arm: a leading `/`
10472 // value with embedded control byte (`"/etc/passwd\n"`) routes
10473 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10474 // — the host-layout-leak diagnostic is the load-bearing axis,
10475 // the control byte is the secondary observation. Same precedence
10476 // logic on every prior leading-byte arm.
10477 let d = dep_with_fonte(DepSource::Path {
10478 caminho: "/etc/passwd\n".into(),
10479 });
10480 let err = d.validate().unwrap_err();
10481 assert!(
10482 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10483 "got {err:?}",
10484 );
10485 }
10486
10487 #[test]
10488 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10489 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10490 // injection `:caminho` shape sweep. Until this gate landed
10491 // every prior leading-byte arm passed a leading-`-` value
10492 // through: `Path::is_absolute` returns false on `-` (the
10493 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10494 // `starts_with('$')` / `starts_with(' ')` all return false,
10495 // and `0x2D` sits outside the control-byte set. The lacre
10496 // embedded the value verbatim and the resolver folded it
10497 // through `Path::join` looking for a literal `./-rf` /
10498 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10499 // `Path::join` time is non-self-locating but harmless, while
10500 // the failure at every downstream `git -C {caminho}` /
10501 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10502 // is arbitrary-CLI-arg-injection because none of those
10503 // porcelains carry a `--` argument-list terminator between
10504 // the flag block and the path argument. The new arm moves the
10505 // rejection to `Caixa::from_lisp` boundary time and names
10506 // the offending dep + caminho verbatim.
10507 //
10508 // Sweep spans the canonical CLI-arg-injection shapes matching
10509 // the peer sweep on the sibling `is_git_ref_name` /
10510 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10511 // `find -rf` reinterpretation vector), `-C` (the `git -C`
10512 // change-directory-config-injection paste), long-flag
10513 // `--upload-pack=cat /etc/passwd` (the canonical
10514 // arbitrary-command-execution vector on every git porcelain
10515 // entry point), git-config-injection `--config=core.merge=ours`,
10516 // and the degenerate single-byte `-` value.
10517 for caminho in [
10518 "-rf",
10519 "-C",
10520 "--upload-pack=cat /etc/passwd",
10521 "--config=core.merge=ours",
10522 "-",
10523 ] {
10524 let d = dep_with_fonte(DepSource::Path {
10525 caminho: caminho.into(),
10526 });
10527 let err = d.validate().unwrap_err();
10528 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10529 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10530 };
10531 assert_eq!(nome, "caixa-teia");
10532 assert_eq!(got, caminho);
10533 }
10534 }
10535
10536 #[test]
10537 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10538 // The leading-`-` is the canonical CLI-arg-injection footgun
10539 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10540 // canonical kebab-separator-between-alphanumeric-segments
10541 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10542 // — a mid-path segment starting with `-`, still a legitimate
10543 // POSIX filename byte at that non-leading position because the
10544 // subprocess reads the whole `{caminho}` value as one positional
10545 // argument, so only the very first byte of the composite path
10546 // string is at the CLI-arg-injection boundary) is a legitimate
10547 // path with no CLI-flag-reinterpretation semantic at the non-
10548 // leading position of the top-level value. Pinned so the gate
10549 // doesn't widen to a full no-`-`-anywhere sweep that would
10550 // break every legitimate-shape kebab-in-filename path (i.e.
10551 // essentially every sibling-workspace caixa dep).
10552 for caminho in [
10553 "../caixa-teia",
10554 "../caixa-teia/-hidden",
10555 "./my-lib",
10556 "../foo-bar/baz",
10557 ] {
10558 let d = dep_with_fonte(DepSource::Path {
10559 caminho: caminho.into(),
10560 });
10561 d.validate()
10562 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10563 }
10564 }
10565
10566 #[test]
10567 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10568 // Cascade pin: the leading-whitespace arm structurally precedes
10569 // the leading-hyphen arm. A value like `" -rf"` probes positive
10570 // on both (leading space AND, one byte in, a `-` — though the
10571 // leading-hyphen arm probes only the very first byte so it
10572 // wouldn't fire on this value; the pin instead documents the
10573 // arm order on the more common "leading space then a hyphen"
10574 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10575 // The narrower leading-space diagnostic (the paste-from-aligned-
10576 // doc footgun) wins so the author sees the more self-locating
10577 // whitespace arm first. Mirrors the
10578 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10579 // discipline on the immediate-predecessor arm.
10580 let d = dep_with_fonte(DepSource::Path {
10581 caminho: " -rf".into(),
10582 });
10583 let err = d.validate().unwrap_err();
10584 assert!(
10585 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10586 "got {err:?}",
10587 );
10588 }
10589
10590 #[test]
10591 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10592 // Cascade pin: the leading-hyphen arm structurally precedes
10593 // the control-char arm. A value like `"-rf\n"` probes positive
10594 // on both (starts with `-` AND contains LF), but the narrower
10595 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10596 // the author sees the more self-locating CLI-arg-injection arm
10597 // first. Mirrors the
10598 // `fonte_caminho_leading_whitespace_fires_before_control_char`
10599 // cascade discipline on the immediate-predecessor arm.
10600 let d = dep_with_fonte(DepSource::Path {
10601 caminho: "-rf\n".into(),
10602 });
10603 let err = d.validate().unwrap_err();
10604 assert!(
10605 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10606 "got {err:?}",
10607 );
10608 }
10609
10610 #[test]
10611 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10612 // Diagnostic-shape pin (peer with
10613 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10614 // payload assertion on the immediate-predecessor arm): the
10615 // error's Display surfaces both the offending `:nome` and the
10616 // offending `:caminho` verbatim plus the CLI-argument-injection
10617 // vocabulary, so a `feira lint` run can render the diagnostic
10618 // without re-parsing and the author can grep their caixa.lisp
10619 // for `:caminho "<value>"` and fix it in one edit.
10620 let d = dep_with_fonte(DepSource::Path {
10621 caminho: "--upload-pack=cat /etc/passwd".into(),
10622 });
10623 let rendered = d.validate().unwrap_err().to_string();
10624 assert!(
10625 rendered.contains("caixa-teia"),
10626 "diagnostic must name the offending dep: {rendered}",
10627 );
10628 assert!(
10629 rendered.contains("--upload-pack=cat /etc/passwd"),
10630 "diagnostic must quote the offending caminho: {rendered}",
10631 );
10632 assert!(
10633 rendered.contains("CLI-argument-injection"),
10634 "diagnostic must name the CLI-argument-injection vector: {rendered}",
10635 );
10636 assert!(
10637 rendered.contains("`-`"),
10638 "diagnostic must name the offending byte: {rendered}",
10639 );
10640 }
10641
10642 #[test]
10643 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10644 // Diagnostic-shape pin (peer with
10645 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10646 // payload assertion on the immediate-predecessor arm): the
10647 // error's Display surfaces the offending `:nome`, the
10648 // offending `:caminho` verbatim, and the offending byte in
10649 // hex form (`0x09` for tab) so a `feira lint` run can render
10650 // the diagnostic without re-parsing.
10651 let d = dep_with_fonte(DepSource::Path {
10652 caminho: "../caixa\tteia".into(),
10653 });
10654 let rendered = d.validate().unwrap_err().to_string();
10655 assert!(
10656 rendered.contains("caixa-teia"),
10657 "diagnostic must name the offending dep: {rendered}",
10658 );
10659 assert!(
10660 rendered.contains("../caixa\tteia"),
10661 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10662 );
10663 assert!(
10664 rendered.contains("0x09"),
10665 "diagnostic must name the offending byte in hex: {rendered:?}",
10666 );
10667 }
10668
10669 #[test]
10670 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10671 // The fail-before-pass-after pin for the canonical Windows-
10672 // path-separator paste footgun: an author who pastes a path
10673 // from Windows-Explorer's `Copy as path`, PowerShell's
10674 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10675 // produces `..\caixa-teia`-shape values that silently passed
10676 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10677 // false; `\` is neither a leading-byte sentinel nor a
10678 // control byte). On POSIX resolvers the value rides through
10679 // `Path::join` as a literal directory name and fails at
10680 // resolve time with `No such file or directory`; on Windows
10681 // resolvers the value resolves to the parent's sibling — two
10682 // distinct directories for the byte-identical caixa.lisp.
10683 // The new arm moves the rejection to validate time and names
10684 // the offending dep + caminho verbatim.
10685 let d = dep_with_fonte(DepSource::Path {
10686 caminho: "..\\caixa-teia".into(),
10687 });
10688 let err = d.validate().unwrap_err();
10689 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10690 panic!("expected FonteCaminhoBackslash, got {err:?}");
10691 };
10692 assert_eq!(nome, "caixa-teia");
10693 assert_eq!(caminho, "..\\caixa-teia");
10694 }
10695
10696 #[test]
10697 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10698 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10699 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10700 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10701 // false (POSIX absolute paths start with `/`, drive letters
10702 // are not a POSIX concept), so the b94fd83 absolute arm
10703 // doesn't fire; the value contains `\` bytes that this arm
10704 // now catches with the more self-locating Windows-path-
10705 // separator diagnostic. Pinned separately from the bare
10706 // `..\caixa-teia` shape so a future arm that targets only
10707 // leading-`..\` doesn't regress the drive-letter coverage.
10708 let d = dep_with_fonte(DepSource::Path {
10709 caminho: "C:\\work\\caixa-teia".into(),
10710 });
10711 let err = d.validate().unwrap_err();
10712 assert!(
10713 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10714 "got {err:?}",
10715 );
10716 }
10717
10718 #[test]
10719 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10720 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10721 // PowerShell tab-completion-on-a-directory append). Pinned
10722 // separately from the embedded-`\` shape so the gate's
10723 // contract is "any `\` anywhere", not "any `\` not at end".
10724 let d = dep_with_fonte(DepSource::Path {
10725 caminho: "..\\caixa-teia\\".into(),
10726 });
10727 let err = d.validate().unwrap_err();
10728 assert!(
10729 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10730 "got {err:?}",
10731 );
10732 }
10733
10734 #[test]
10735 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10736 // The positive-control pin: the gate targets `\` only,
10737 // never `/`. The canonical relative POSIX path
10738 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10739 // so legitimate nested-directory deps aren't broken. Pinned
10740 // so the gate doesn't accidentally widen to a "no path
10741 // separators at all" sweep.
10742 let d = dep_with_fonte(DepSource::Path {
10743 caminho: "../caixa-teia/foo/bar".into(),
10744 });
10745 d.validate().unwrap();
10746 }
10747
10748 #[test]
10749 fn fonte_caminho_control_char_fires_before_backslash() {
10750 // Cascade pin: the control-char arm structurally precedes the
10751 // backslash arm. A value like `"..\caixa\0teia"` probes
10752 // positive on both (`\` byte + NUL byte), but the control-
10753 // char diagnostic wins so the author sees the more self-
10754 // locating POSIX-syscall-rejected-byte diagnostic first
10755 // (NUL outright breaks `CString::new` at every `std::fs`
10756 // syscall boundary; the `\` divergence is the cross-OS-
10757 // separator axis). Mirrors the
10758 // `fonte_caminho_var_fires_before_control_char` cascade
10759 // discipline on the immediate-predecessor arm.
10760 let d = dep_with_fonte(DepSource::Path {
10761 caminho: "..\\caixa\0teia".into(),
10762 });
10763 let err = d.validate().unwrap_err();
10764 assert!(
10765 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10766 "got {err:?}",
10767 );
10768 }
10769
10770 #[test]
10771 fn fonte_caminho_absolute_fires_before_backslash() {
10772 // Cascade pin on the load-bearing leading-byte arm: a leading
10773 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10774 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10775 // — the host-layout-leak diagnostic is the load-bearing
10776 // axis, the `\` byte is the secondary observation. Same
10777 // precedence logic as every prior leading-byte arm.
10778 let d = dep_with_fonte(DepSource::Path {
10779 caminho: "/etc/passwd\\foo".into(),
10780 });
10781 let err = d.validate().unwrap_err();
10782 assert!(
10783 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10784 "got {err:?}",
10785 );
10786 }
10787
10788 #[test]
10789 fn fonte_caminho_var_fires_before_backslash() {
10790 // Cascade pin on the var-expansion arm: a leading-`$` value
10791 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10792 // PowerShell-env-var paste-from-CI-manifest footgun) routes
10793 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10794 // The shell-expansion diagnostic is the more self-locating
10795 // axis since both the leading `$` and the embedded `\`
10796 // are Windows-shell artifacts but the `$` is the root-cause
10797 // surface (an author who removes the `$` is likely to leave
10798 // the `\` too).
10799 let d = dep_with_fonte(DepSource::Path {
10800 caminho: "$WORKSPACE\\caixa-teia".into(),
10801 });
10802 let err = d.validate().unwrap_err();
10803 assert!(
10804 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10805 "got {err:?}",
10806 );
10807 }
10808
10809 #[test]
10810 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10811 // Diagnostic-shape pin (peer with the prior
10812 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10813 // on every preceding arm): the error's Display surfaces the
10814 // offending `:nome` and the offending `:caminho` verbatim
10815 // so a `feira lint` run can render the diagnostic without
10816 // re-parsing.
10817 let d = dep_with_fonte(DepSource::Path {
10818 caminho: "..\\caixa-teia".into(),
10819 });
10820 let rendered = d.validate().unwrap_err().to_string();
10821 assert!(
10822 rendered.contains("caixa-teia"),
10823 "diagnostic must name the offending dep: {rendered}",
10824 );
10825 assert!(
10826 rendered.contains("..\\caixa-teia"),
10827 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10828 );
10829 assert!(
10830 rendered.contains('\\'),
10831 "diagnostic must reference the backslash footgun: {rendered:?}",
10832 );
10833 }
10834
10835 #[test]
10836 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10837 // The fail-before-pass-after pin for the canonical trailing-`/`
10838 // paste footgun: an author who shell-tab-completes a sibling
10839 // directory (every interactive shell — bash/zsh/fish/nushell —
10840 // appends `/` on tab-completing a directory) produces
10841 // `"../caixa-teia/"`-shape values that silently passed every
10842 // prior arm (the leading byte is `.`, no control bytes, no
10843 // backslash). `Path::join` resolves both shapes to the same
10844 // directory at the resolver, but the lacre embeds the value
10845 // verbatim and the BLAKE3 closures diverge across two
10846 // workstations whose authors differ only in tab-completion
10847 // habits.
10848 let d = dep_with_fonte(DepSource::Path {
10849 caminho: "../caixa-teia/".into(),
10850 });
10851 let err = d.validate().unwrap_err();
10852 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10853 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10854 };
10855 assert_eq!(nome, "caixa-teia");
10856 assert_eq!(caminho, "../caixa-teia/");
10857 }
10858
10859 #[test]
10860 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10861 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10862 // directory and tab-completed it" footgun). Pinned separately
10863 // from the canonical `"../caixa-teia/"` shape so the gate's
10864 // contract is "any trailing `/`", not "trailing `/` after a leaf
10865 // name".
10866 let d = dep_with_fonte(DepSource::Path {
10867 caminho: "./".into(),
10868 });
10869 let err = d.validate().unwrap_err();
10870 assert!(
10871 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10872 "got {err:?}",
10873 );
10874 }
10875
10876 #[test]
10877 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10878 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10879 // that double-templated `${VAR}/` over an already-`/`-suffixed
10880 // path" footgun). The gate fires on the last byte being `/`
10881 // regardless of how many `/` precede it; the arm contract is
10882 // "the value ends with `/`", structurally.
10883 let d = dep_with_fonte(DepSource::Path {
10884 caminho: "../caixa-teia//".into(),
10885 });
10886 let err = d.validate().unwrap_err();
10887 assert!(
10888 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10889 "got {err:?}",
10890 );
10891 }
10892
10893 #[test]
10894 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10895 // The `"../"` shape (the canonical "I want the parent" tab-
10896 // completion footgun on a bare `..` path). Pinned separately so
10897 // the gate doesn't accidentally narrow to "trailing `/` only on
10898 // multi-segment paths".
10899 let d = dep_with_fonte(DepSource::Path {
10900 caminho: "../".into(),
10901 });
10902 let err = d.validate().unwrap_err();
10903 assert!(
10904 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10905 "got {err:?}",
10906 );
10907 }
10908
10909 #[test]
10910 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10911 // The positive-control pin: the gate targets the trailing byte
10912 // only, never internal `/` separators. The canonical nested
10913 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10914 // to validate cleanly so legitimate deeply-nested deps aren't
10915 // broken. Pinned so the gate doesn't accidentally widen to a
10916 // "no `/` separators anywhere" sweep that would defeat the
10917 // entire path-fonte author surface.
10918 let d = dep_with_fonte(DepSource::Path {
10919 caminho: "../caixa-teia/foo/bar".into(),
10920 });
10921 d.validate().unwrap();
10922 }
10923
10924 #[test]
10925 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10926 // The positive-control pin on the degenerate single-`.` shape
10927 // (the canonical "the caixa.lisp's own directory" idiom). The
10928 // gate fires on the trailing byte being `/`, not on the path
10929 // being short, so `"."` (one byte, not `/`) must continue to
10930 // validate cleanly.
10931 let d = dep_with_fonte(DepSource::Path {
10932 caminho: ".".into(),
10933 });
10934 d.validate().unwrap();
10935 }
10936
10937 #[test]
10938 fn fonte_caminho_control_char_fires_before_trailing_slash() {
10939 // Cascade pin: the control-char arm structurally precedes the
10940 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10941 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10942 // (control bytes are the paste-from-multiline-doc footgun the
10943 // d624c8d arm already closes). Mirrors the
10944 // `fonte_caminho_control_char_fires_before_backslash` cascade
10945 // discipline on the immediate-predecessor arm.
10946 let d = dep_with_fonte(DepSource::Path {
10947 caminho: "../foo\n/".into(),
10948 });
10949 let err = d.validate().unwrap_err();
10950 assert!(
10951 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10952 "got {err:?}",
10953 );
10954 }
10955
10956 #[test]
10957 fn fonte_caminho_backslash_fires_before_trailing_slash() {
10958 // Cascade pin on the backslash arm: a value like `"..\foo/"`
10959 // ends in `/` but the embedded `\` is the load-bearing
10960 // diagnostic (the cross-host-OS-separator divergence vector
10961 // the 3a4e1d7 arm closes). Same precedence logic as the prior
10962 // narrower-diagnostic-first cascade.
10963 let d = dep_with_fonte(DepSource::Path {
10964 caminho: "..\\caixa-teia/".into(),
10965 });
10966 let err = d.validate().unwrap_err();
10967 assert!(
10968 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10969 "got {err:?}",
10970 );
10971 }
10972
10973 #[test]
10974 fn fonte_caminho_absolute_fires_before_trailing_slash() {
10975 // Cascade pin on the load-bearing leading-byte arm: a leading
10976 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10977 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10978 // — the host-layout-leak diagnostic is the load-bearing axis,
10979 // the trailing `/` is the secondary observation. Same
10980 // precedence logic as every prior leading-byte arm.
10981 let d = dep_with_fonte(DepSource::Path {
10982 caminho: "/etc/passwd/".into(),
10983 });
10984 let err = d.validate().unwrap_err();
10985 assert!(
10986 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10987 "got {err:?}",
10988 );
10989 }
10990
10991 #[test]
10992 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10993 // Diagnostic-shape pin (peer with the prior
10994 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10995 // every preceding arm): the error's Display surfaces the
10996 // offending `:nome` and the offending `:caminho` verbatim so a
10997 // `feira lint` run can render the diagnostic without re-parsing.
10998 let d = dep_with_fonte(DepSource::Path {
10999 caminho: "../caixa-teia/".into(),
11000 });
11001 let rendered = d.validate().unwrap_err().to_string();
11002 assert!(
11003 rendered.contains("caixa-teia"),
11004 "diagnostic must name the offending dep: {rendered}",
11005 );
11006 assert!(
11007 rendered.contains("../caixa-teia/"),
11008 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11009 );
11010 assert!(
11011 rendered.contains("trailing"),
11012 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
11013 );
11014 }
11015
11016 // -- :caminho shell-redirection metacharacter arm -----------------------
11017
11018 #[test]
11019 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
11020 // The fail-before-pass-after pin for the canonical output-redirection
11021 // paste footgun: an author copies a shell pipeline tail
11022 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
11023 // line including the `> build.log` redirect" idiom) and silently
11024 // passed every prior arm (`Path::is_absolute` false on `..`, no
11025 // control bytes, no backslash, doesn't end in `/`). The lacre
11026 // embedded the value verbatim, the resolver folded it through
11027 // `Path::join` looking for a literal `./../caixa-teia>build.log`
11028 // subdirectory, and the failure surfaced at resolve time with a
11029 // non-self-locating `No such file or directory` error. The new arm
11030 // moves the rejection to validate time and names the offending dep
11031 // + caminho + byte verbatim.
11032 let d = dep_with_fonte(DepSource::Path {
11033 caminho: "../caixa-teia>build.log".into(),
11034 });
11035 let err = d.validate().unwrap_err();
11036 let DepError::FonteCaminhoShellRedirection {
11037 nome,
11038 caminho,
11039 byte,
11040 } = err
11041 else {
11042 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11043 };
11044 assert_eq!(nome, "caixa-teia");
11045 assert_eq!(caminho, "../caixa-teia>build.log");
11046 assert_eq!(byte, b'>');
11047 }
11048
11049 #[test]
11050 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
11051 // The symmetric input-redirection paste shape
11052 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
11053 // `command < input.lisp` line from a tatara-lisp REPL log"
11054 // idiom). Pinned separately from the `>` shape so the gate's
11055 // contract is "any `<` or `>` anywhere", not single-byte coverage.
11056 let d = dep_with_fonte(DepSource::Path {
11057 caminho: "../caixa-teia<input.lisp".into(),
11058 });
11059 let err = d.validate().unwrap_err();
11060 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
11061 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11062 };
11063 assert_eq!(byte, b'<');
11064 }
11065
11066 #[test]
11067 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
11068 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
11069 // "I forgot the source side of the redirect" idiom). Pinned
11070 // separately from the embedded-byte shapes so the gate covers
11071 // every position, not only mid-path.
11072 let d = dep_with_fonte(DepSource::Path {
11073 caminho: ">../caixa-teia".into(),
11074 });
11075 let err = d.validate().unwrap_err();
11076 assert!(
11077 matches!(
11078 err,
11079 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11080 ),
11081 "got {err:?}",
11082 );
11083 }
11084
11085 #[test]
11086 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
11087 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
11088 // the canonical "I copied a `>>` append redirect" idiom). The arm
11089 // fires on the first `>` encountered; pinned so a future arm that
11090 // tries to distinguish `>` from `>>` doesn't break the broader
11091 // contract.
11092 let d = dep_with_fonte(DepSource::Path {
11093 caminho: "../caixa-teia>>build.log".into(),
11094 });
11095 let err = d.validate().unwrap_err();
11096 assert!(
11097 matches!(
11098 err,
11099 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11100 ),
11101 "got {err:?}",
11102 );
11103 }
11104
11105 #[test]
11106 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
11107 // The positive-control pin: the gate targets only `<` / `>`,
11108 // never adjacent printable ASCII or POSIX-valid bytes. The
11109 // canonical relative POSIX path (`"../caixa-teia"`) and a
11110 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
11111 // continue to validate cleanly so the gate doesn't widen to a
11112 // "no printable punctuation anywhere" sweep that would defeat
11113 // the entire path-fonte author surface.
11114 let d = dep_with_fonte(DepSource::Path {
11115 caminho: "../caixa-teia/foo/bar".into(),
11116 });
11117 d.validate().unwrap();
11118 }
11119
11120 #[test]
11121 fn fonte_caminho_backslash_fires_before_shell_redirection() {
11122 // Cascade pin on the immediate-predecessor arm: a value carrying
11123 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
11124 // canonical "I pasted a Windows-shell command with output
11125 // redirect" footgun) routes through `FonteCaminhoBackslash` not
11126 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
11127 // divergence is the load-bearing axis (an author who removes
11128 // the `\` is the root-cause edit; the `>` falls away in the
11129 // same edit since it's downstream of the Windows-shell
11130 // convention).
11131 let d = dep_with_fonte(DepSource::Path {
11132 caminho: "..\\caixa-teia>build.log".into(),
11133 });
11134 let err = d.validate().unwrap_err();
11135 assert!(
11136 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11137 "got {err:?}",
11138 );
11139 }
11140
11141 #[test]
11142 fn fonte_caminho_control_char_fires_before_shell_redirection() {
11143 // Cascade pin on the embedded-control-byte arm: a value carrying
11144 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
11145 // canonical paste-from-multiline-doc footgun where a newline
11146 // landed mid-caminho) routes through `FonteCaminhoControlChar`
11147 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
11148 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11149 // load-bearing axis on every value that probes positive for
11150 // both — mirrors the cascade discipline on every prior arm.
11151 let d = dep_with_fonte(DepSource::Path {
11152 caminho: "../foo\n>bar".into(),
11153 });
11154 let err = d.validate().unwrap_err();
11155 assert!(
11156 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11157 "got {err:?}",
11158 );
11159 }
11160
11161 #[test]
11162 fn fonte_caminho_absolute_fires_before_shell_redirection() {
11163 // Cascade pin on the load-bearing leading-byte arm: a leading
11164 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
11165 // routes through `FonteCaminhoAbsolute` not
11166 // `FonteCaminhoShellRedirection` — the host-layout-leak
11167 // diagnostic is the load-bearing axis, the `>` byte is the
11168 // secondary observation. Same precedence logic as every prior
11169 // leading-byte arm.
11170 let d = dep_with_fonte(DepSource::Path {
11171 caminho: "/etc/passwd>out".into(),
11172 });
11173 let err = d.validate().unwrap_err();
11174 assert!(
11175 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11176 "got {err:?}",
11177 );
11178 }
11179
11180 #[test]
11181 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
11182 // Cascade pin on the immediate-successor arm: a value carrying
11183 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
11184 // canonical "I tab-completed a path that already had a
11185 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
11186 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11187 // the more semantic-locating axis (an author who removes the
11188 // `<` / `>` typically also drops the trailing separator since
11189 // both are paste-from-shell artifacts).
11190 let d = dep_with_fonte(DepSource::Path {
11191 caminho: "../foo></".into(),
11192 });
11193 let err = d.validate().unwrap_err();
11194 assert!(
11195 matches!(
11196 err,
11197 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11198 ),
11199 "got {err:?}",
11200 );
11201 }
11202
11203 #[test]
11204 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
11205 // Diagnostic-shape pin (peer with
11206 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
11207 // payload assertion on the closest peer arm that also carries a
11208 // `byte` field): the error's Display surfaces the offending
11209 // `:nome`, the offending `:caminho` verbatim, and the offending
11210 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
11211 // run can render the diagnostic without re-parsing.
11212 let d = dep_with_fonte(DepSource::Path {
11213 caminho: "../caixa-teia>build.log".into(),
11214 });
11215 let rendered = d.validate().unwrap_err().to_string();
11216 assert!(
11217 rendered.contains("caixa-teia"),
11218 "diagnostic must name the offending dep: {rendered}",
11219 );
11220 assert!(
11221 rendered.contains("../caixa-teia>build.log"),
11222 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11223 );
11224 assert!(
11225 rendered.contains("0x3e"),
11226 "diagnostic must name the offending byte in hex: {rendered:?}",
11227 );
11228 assert!(
11229 rendered.contains("redirection"),
11230 "diagnostic must name the shell-redirection footgun: {rendered:?}",
11231 );
11232 }
11233
11234 // -- :caminho shell-pipe metacharacter arm ----------------------------
11235
11236 #[test]
11237 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
11238 // The fail-before-pass-after pin for the canonical shell-pipe
11239 // paste footgun: an author copies a shell-history line
11240 // (`"../caixa-teia | grep foo"` — the canonical "I selected
11241 // the whole `ls dir | grep` line out of zsh history") and
11242 // silently passed every prior arm (`Path::is_absolute` false
11243 // on `..`, no control bytes, no backslash, no `<` / `>`,
11244 // doesn't end in `/`). The lacre embedded the value verbatim,
11245 // the resolver folded it through `Path::join` looking for a
11246 // literal `./../caixa-teia | grep foo` subdirectory, and the
11247 // failure surfaced at resolve time with a non-self-locating
11248 // `No such file or directory` error. The new arm moves the
11249 // rejection to validate time and names the offending dep +
11250 // caminho verbatim.
11251 let d = dep_with_fonte(DepSource::Path {
11252 caminho: "../caixa-teia | grep foo".into(),
11253 });
11254 let err = d.validate().unwrap_err();
11255 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
11256 panic!("expected FonteCaminhoShellPipe, got {err:?}");
11257 };
11258 assert_eq!(nome, "caixa-teia");
11259 assert_eq!(caminho, "../caixa-teia | grep foo");
11260 }
11261
11262 #[test]
11263 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
11264 // Leading-position `|` shape (`"|../caixa-teia"` — the
11265 // degenerate "I forgot the source side of the pipe" idiom).
11266 // Pinned separately from the embedded-byte shape so the gate
11267 // covers every position, not only mid-path.
11268 let d = dep_with_fonte(DepSource::Path {
11269 caminho: "|../caixa-teia".into(),
11270 });
11271 let err = d.validate().unwrap_err();
11272 assert!(
11273 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11274 "got {err:?}",
11275 );
11276 }
11277
11278 #[test]
11279 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
11280 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
11281 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
11282 // idiom). The arm fires on the first `|` encountered; pinned
11283 // so a future arm that tries to distinguish `|` from `||`
11284 // doesn't break the broader contract.
11285 let d = dep_with_fonte(DepSource::Path {
11286 caminho: "../caixa-teia||fallback".into(),
11287 });
11288 let err = d.validate().unwrap_err();
11289 assert!(
11290 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11291 "got {err:?}",
11292 );
11293 }
11294
11295 #[test]
11296 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
11297 // The positive-control pin: the gate targets only `|`, never
11298 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11299 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11300 // pathed variant with adjacent printable punctuation
11301 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11302 // cleanly so the gate doesn't widen to a "no printable
11303 // punctuation anywhere" sweep that would defeat the entire
11304 // path-fonte author surface.
11305 let d = dep_with_fonte(DepSource::Path {
11306 caminho: "../caixa-teia/sub-dir.v2".into(),
11307 });
11308 d.validate().unwrap();
11309 }
11310
11311 #[test]
11312 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
11313 // Cascade pin on the immediate-predecessor arm: a value carrying
11314 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
11315 // canonical "I pasted a `cmd < input | tee` pipeline tail"
11316 // footgun) routes through `FonteCaminhoShellRedirection` not
11317 // `FonteCaminhoShellPipe`. The input/output redirection
11318 // metachar carries the more self-locating `byte: u8` payload
11319 // (it names which of `<` or `>` triggered), so the prior arm
11320 // wins on every probe-as-both value — same cascade discipline
11321 // every prior `:caminho` arm establishes.
11322 let d = dep_with_fonte(DepSource::Path {
11323 caminho: "../caixa-teia<input|tee".into(),
11324 });
11325 let err = d.validate().unwrap_err();
11326 assert!(
11327 matches!(
11328 err,
11329 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
11330 ),
11331 "got {err:?}",
11332 );
11333 }
11334
11335 #[test]
11336 fn fonte_caminho_backslash_fires_before_shell_pipe() {
11337 // Cascade pin on the upstream backslash arm: a value carrying
11338 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
11339 // "I pasted a Windows-shell command with pipe to tee"
11340 // footgun) routes through `FonteCaminhoBackslash` not
11341 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
11342 // divergence is the load-bearing axis on every probe-as-both
11343 // value (an author who removes the `\` is the root-cause edit;
11344 // the `|` falls away in the same edit since it's downstream of
11345 // the Windows-shell convention).
11346 let d = dep_with_fonte(DepSource::Path {
11347 caminho: "..\\caixa-teia|tee".into(),
11348 });
11349 let err = d.validate().unwrap_err();
11350 assert!(
11351 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11352 "got {err:?}",
11353 );
11354 }
11355
11356 #[test]
11357 fn fonte_caminho_control_char_fires_before_shell_pipe() {
11358 // Cascade pin on the embedded-control-byte arm: a value
11359 // carrying both a control byte and `|` (`"../foo\n|bar"` —
11360 // the canonical paste-from-multiline-doc footgun where a
11361 // newline landed mid-caminho) routes through
11362 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
11363 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11364 // diagnostic is the load-bearing axis on every value that
11365 // probes positive for both — mirrors the cascade discipline
11366 // on every prior arm.
11367 let d = dep_with_fonte(DepSource::Path {
11368 caminho: "../foo\n|bar".into(),
11369 });
11370 let err = d.validate().unwrap_err();
11371 assert!(
11372 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11373 "got {err:?}",
11374 );
11375 }
11376
11377 #[test]
11378 fn fonte_caminho_absolute_fires_before_shell_pipe() {
11379 // Cascade pin on the load-bearing leading-byte arm: a leading
11380 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
11381 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
11382 // — the host-layout-leak diagnostic is the load-bearing axis,
11383 // the `|` byte is the secondary observation. Same precedence
11384 // logic as every prior leading-byte arm.
11385 let d = dep_with_fonte(DepSource::Path {
11386 caminho: "/etc/passwd|tee".into(),
11387 });
11388 let err = d.validate().unwrap_err();
11389 assert!(
11390 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11391 "got {err:?}",
11392 );
11393 }
11394
11395 #[test]
11396 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
11397 // Cascade pin on the immediate-successor arm: a value carrying
11398 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
11399 // "I tab-completed a path that already had a pipeline tail"
11400 // footgun) routes through `FonteCaminhoShellPipe` not
11401 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11402 // the more semantic-locating axis (an author who removes the
11403 // `|` typically also drops the trailing separator since both
11404 // are paste-from-shell artifacts).
11405 let d = dep_with_fonte(DepSource::Path {
11406 caminho: "../foo|tee/".into(),
11407 });
11408 let err = d.validate().unwrap_err();
11409 assert!(
11410 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11411 "got {err:?}",
11412 );
11413 }
11414
11415 #[test]
11416 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
11417 // Diagnostic-shape pin (peer with
11418 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
11419 // on the closest single-byte peer arm): the error's Display
11420 // surfaces the offending `:nome` and the offending `:caminho`
11421 // verbatim, and names the shell-pipe footgun explicitly so a
11422 // `feira lint` run can render the diagnostic without
11423 // re-parsing.
11424 let d = dep_with_fonte(DepSource::Path {
11425 caminho: "../caixa-teia | grep foo".into(),
11426 });
11427 let rendered = d.validate().unwrap_err().to_string();
11428 assert!(
11429 rendered.contains("caixa-teia"),
11430 "diagnostic must name the offending dep: {rendered}",
11431 );
11432 assert!(
11433 rendered.contains("../caixa-teia | grep foo"),
11434 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11435 );
11436 assert!(
11437 rendered.contains('|'),
11438 "diagnostic must reference the pipe footgun: {rendered:?}",
11439 );
11440 assert!(
11441 rendered.contains("pipe"),
11442 "diagnostic must name the shell-pipe footgun: {rendered:?}",
11443 );
11444 }
11445
11446 // -- :caminho shell-command-separator metacharacter arm ---------------
11447
11448 #[test]
11449 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11450 // The fail-before-pass-after pin for the canonical shell-command-
11451 // separator paste footgun: an author copies a shell one-liner
11452 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11453 // whole `cd path; do-thing` chain out of a shell-history block")
11454 // and silently passed every prior arm (`Path::is_absolute` false
11455 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11456 // doesn't end in `/`). The lacre embedded the value verbatim, the
11457 // resolver folded it through `Path::join` looking for a literal
11458 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11459 // surfaced at resolve time with a non-self-locating `No such file
11460 // or directory` error. The new arm moves the rejection to validate
11461 // time and names the offending dep + caminho verbatim.
11462 let d = dep_with_fonte(DepSource::Path {
11463 caminho: "../caixa-teia; rm -rf build".into(),
11464 });
11465 let err = d.validate().unwrap_err();
11466 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11467 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11468 };
11469 assert_eq!(nome, "caixa-teia");
11470 assert_eq!(caminho, "../caixa-teia; rm -rf build");
11471 }
11472
11473 #[test]
11474 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11475 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11476 // "I forgot the prior command side of the separator" idiom).
11477 // Pinned separately from the embedded-byte shape so the gate
11478 // covers every position, not only mid-path.
11479 let d = dep_with_fonte(DepSource::Path {
11480 caminho: ";../caixa-teia".into(),
11481 });
11482 let err = d.validate().unwrap_err();
11483 assert!(
11484 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11485 "got {err:?}",
11486 );
11487 }
11488
11489 #[test]
11490 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11491 // The POSIX `case` arm `;;` terminator shape
11492 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11493 // arm tail" idiom). The arm fires on the first `;` encountered;
11494 // pinned so a future arm that tries to distinguish `;` from `;;`
11495 // doesn't break the broader contract.
11496 let d = dep_with_fonte(DepSource::Path {
11497 caminho: "../caixa-teia;;next".into(),
11498 });
11499 let err = d.validate().unwrap_err();
11500 assert!(
11501 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11502 "got {err:?}",
11503 );
11504 }
11505
11506 #[test]
11507 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11508 // The positive-control pin: the gate targets only `;`, never
11509 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11510 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11511 // pathed variant with adjacent printable punctuation
11512 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11513 // cleanly so the gate doesn't widen to a "no printable
11514 // punctuation anywhere" sweep that would defeat the entire
11515 // path-fonte author surface.
11516 let d = dep_with_fonte(DepSource::Path {
11517 caminho: "../caixa-teia/sub-dir.v2".into(),
11518 });
11519 d.validate().unwrap();
11520 }
11521
11522 #[test]
11523 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11524 // Cascade pin on the immediate-predecessor arm: a value carrying
11525 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11526 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11527 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11528 // pipeline-tail paste is the load-bearing root-cause edit on
11529 // every probe-as-both value (an author who removes the `|`
11530 // typically also drops the trailing `; cleanup` since both are
11531 // the same paste-from-shell-history artifact) — same cascade
11532 // discipline every prior `:caminho` arm establishes.
11533 let d = dep_with_fonte(DepSource::Path {
11534 caminho: "../caixa-teia | tee; rm".into(),
11535 });
11536 let err = d.validate().unwrap_err();
11537 assert!(
11538 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11539 "got {err:?}",
11540 );
11541 }
11542
11543 #[test]
11544 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11545 // Cascade pin on the upstream shell-redirection arm: a value
11546 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11547 // the canonical "I pasted a `cmd > log; cleanup` chain"
11548 // footgun) routes through `FonteCaminhoShellRedirection` not
11549 // `FonteCaminhoShellSemicolon`. The input/output redirection
11550 // metachar carries the more self-locating `byte: u8` payload
11551 // (it names which of `<` or `>` triggered), so the prior arm
11552 // wins on every probe-as-both value.
11553 let d = dep_with_fonte(DepSource::Path {
11554 caminho: "../caixa-teia>log; rm".into(),
11555 });
11556 let err = d.validate().unwrap_err();
11557 assert!(
11558 matches!(
11559 err,
11560 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11561 ),
11562 "got {err:?}",
11563 );
11564 }
11565
11566 #[test]
11567 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11568 // Cascade pin on the upstream backslash arm: a value carrying
11569 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11570 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11571 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11572 // The cross-host-OS-separator divergence is the load-bearing axis
11573 // on every probe-as-both value (an author who removes the `\` is
11574 // the root-cause edit; the `;` falls away in the same edit since
11575 // it's downstream of the Windows-shell convention).
11576 let d = dep_with_fonte(DepSource::Path {
11577 caminho: "..\\caixa-teia;rm".into(),
11578 });
11579 let err = d.validate().unwrap_err();
11580 assert!(
11581 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11582 "got {err:?}",
11583 );
11584 }
11585
11586 #[test]
11587 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11588 // Cascade pin on the embedded-control-byte arm: a value carrying
11589 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11590 // paste-from-multiline-doc footgun where a newline landed mid-
11591 // caminho) routes through `FonteCaminhoControlChar` not
11592 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11593 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11594 // on every value that probes positive for both — mirrors the
11595 // cascade discipline on every prior arm.
11596 let d = dep_with_fonte(DepSource::Path {
11597 caminho: "../foo\n;bar".into(),
11598 });
11599 let err = d.validate().unwrap_err();
11600 assert!(
11601 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11602 "got {err:?}",
11603 );
11604 }
11605
11606 #[test]
11607 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11608 // Cascade pin on the load-bearing leading-byte arm: a leading
11609 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11610 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11611 // — the host-layout-leak diagnostic is the load-bearing axis,
11612 // the `;` byte is the secondary observation. Same precedence
11613 // logic as every prior leading-byte arm.
11614 let d = dep_with_fonte(DepSource::Path {
11615 caminho: "/etc/passwd;rm".into(),
11616 });
11617 let err = d.validate().unwrap_err();
11618 assert!(
11619 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11620 "got {err:?}",
11621 );
11622 }
11623
11624 #[test]
11625 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11626 // Cascade pin on the immediate-successor arm: a value carrying
11627 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11628 // "I tab-completed a path that already had a `; cleanup` tail"
11629 // footgun) routes through `FonteCaminhoShellSemicolon` not
11630 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11631 // the more semantic-locating axis (an author who removes the
11632 // `;` typically also drops the trailing separator since both
11633 // are paste-from-shell artifacts).
11634 let d = dep_with_fonte(DepSource::Path {
11635 caminho: "../foo;rm/".into(),
11636 });
11637 let err = d.validate().unwrap_err();
11638 assert!(
11639 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11640 "got {err:?}",
11641 );
11642 }
11643
11644 #[test]
11645 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11646 // Diagnostic-shape pin (peer with
11647 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11648 // on the closest single-byte peer arm): the error's Display
11649 // surfaces the offending `:nome` and the offending `:caminho`
11650 // verbatim, and names the shell-command-separator footgun
11651 // explicitly so a `feira lint` run can render the diagnostic
11652 // without re-parsing.
11653 let d = dep_with_fonte(DepSource::Path {
11654 caminho: "../caixa-teia; rm -rf build".into(),
11655 });
11656 let rendered = d.validate().unwrap_err().to_string();
11657 assert!(
11658 rendered.contains("caixa-teia"),
11659 "diagnostic must name the offending dep: {rendered}",
11660 );
11661 assert!(
11662 rendered.contains("../caixa-teia; rm -rf build"),
11663 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11664 );
11665 assert!(
11666 rendered.contains(';'),
11667 "diagnostic must reference the semicolon footgun: {rendered:?}",
11668 );
11669 assert!(
11670 rendered.contains("command-separator"),
11671 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11672 );
11673 }
11674
11675 #[test]
11676 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11677 // The fail-before-pass-after pin for the canonical shell-
11678 // background-task paste footgun: an author copies a shell one-
11679 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11680 // the whole `cd path & sleep 1` background-launch out of a
11681 // shell-history block") and silently passed every prior arm
11682 // (`Path::is_absolute` false on `..`, no control bytes, no
11683 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11684 // The lacre embedded the value verbatim, the resolver folded it
11685 // through `Path::join` looking for a literal `./../caixa-teia &
11686 // sleep 1` subdirectory, and the failure surfaced at resolve
11687 // time with a non-self-locating `No such file or directory`
11688 // error. The new arm moves the rejection to validate time and
11689 // names the offending dep + caminho verbatim.
11690 let d = dep_with_fonte(DepSource::Path {
11691 caminho: "../caixa-teia & sleep 1".into(),
11692 });
11693 let err = d.validate().unwrap_err();
11694 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11695 panic!("expected FonteCaminhoShellBackground, got {err:?}");
11696 };
11697 assert_eq!(nome, "caixa-teia");
11698 assert_eq!(caminho, "../caixa-teia & sleep 1");
11699 }
11700
11701 #[test]
11702 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11703 // Leading-position `&` shape (`"&../caixa-teia"` — the
11704 // degenerate "I forgot the prior command side of the
11705 // background terminator" idiom). Pinned separately from the
11706 // embedded-byte shape so the gate covers every position, not
11707 // only mid-path.
11708 let d = dep_with_fonte(DepSource::Path {
11709 caminho: "&../caixa-teia".into(),
11710 });
11711 let err = d.validate().unwrap_err();
11712 assert!(
11713 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11714 "got {err:?}",
11715 );
11716 }
11717
11718 #[test]
11719 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11720 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11721 // canonical "I copied a `cd path && make` build chain" idiom
11722 // every Makefile / shell-script wraps). The arm fires on the
11723 // first `&` encountered; pinned so a future arm that tries to
11724 // distinguish `&` from `&&` doesn't break the broader contract.
11725 let d = dep_with_fonte(DepSource::Path {
11726 caminho: "../caixa-teia && make".into(),
11727 });
11728 let err = d.validate().unwrap_err();
11729 assert!(
11730 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11731 "got {err:?}",
11732 );
11733 }
11734
11735 #[test]
11736 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11737 // The positive-control pin: the gate targets only `&`, never
11738 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11739 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11740 // pathed variant with adjacent printable punctuation
11741 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11742 // cleanly so the gate doesn't widen to a "no printable
11743 // punctuation anywhere" sweep that would defeat the entire
11744 // path-fonte author surface.
11745 let d = dep_with_fonte(DepSource::Path {
11746 caminho: "../caixa-teia/sub-dir.v2".into(),
11747 });
11748 d.validate().unwrap();
11749 }
11750
11751 #[test]
11752 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11753 // Cascade pin on the immediate-predecessor arm: a value carrying
11754 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11755 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11756 // routes through `FonteCaminhoShellSemicolon` not
11757 // `FonteCaminhoShellBackground`. The sequential-command-
11758 // separator paste is the more common shell-history paste idiom
11759 // on every probe-as-both value (an author who removes the `;`
11760 // typically also drops the trailing `& sleep` since both are
11761 // paste-from-shell-history artifacts) — same cascade discipline
11762 // every prior `:caminho` arm establishes.
11763 let d = dep_with_fonte(DepSource::Path {
11764 caminho: "../caixa-teia; rm & sleep".into(),
11765 });
11766 let err = d.validate().unwrap_err();
11767 assert!(
11768 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11769 "got {err:?}",
11770 );
11771 }
11772
11773 #[test]
11774 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11775 // Cascade pin on the upstream shell-pipe arm: a value carrying
11776 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11777 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11778 // chain" footgun) routes through `FonteCaminhoShellPipe` not
11779 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11780 // load-bearing root-cause edit on every probe-as-both value.
11781 let d = dep_with_fonte(DepSource::Path {
11782 caminho: "../caixa-teia | tee & sleep".into(),
11783 });
11784 let err = d.validate().unwrap_err();
11785 assert!(
11786 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11787 "got {err:?}",
11788 );
11789 }
11790
11791 #[test]
11792 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11793 // Cascade pin on the upstream shell-redirection arm: a value
11794 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11795 // the canonical "I pasted a `cmd > log & sleep` background-
11796 // redirect chain" footgun) routes through
11797 // `FonteCaminhoShellRedirection` not
11798 // `FonteCaminhoShellBackground`. The input/output redirection
11799 // metachar carries the more self-locating `byte: u8` payload
11800 // (it names which of `<` or `>` triggered), so the prior arm
11801 // wins on every probe-as-both value.
11802 let d = dep_with_fonte(DepSource::Path {
11803 caminho: "../caixa-teia>log & sleep".into(),
11804 });
11805 let err = d.validate().unwrap_err();
11806 assert!(
11807 matches!(
11808 err,
11809 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11810 ),
11811 "got {err:?}",
11812 );
11813 }
11814
11815 #[test]
11816 fn fonte_caminho_backslash_fires_before_shell_background() {
11817 // Cascade pin on the upstream backslash arm: a value carrying
11818 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11819 // "I pasted a Windows-shell `cd ..\path & sleep` background-
11820 // launch chain") routes through `FonteCaminhoBackslash` not
11821 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11822 // divergence is the load-bearing axis on every probe-as-both
11823 // value (an author who removes the `\` is the root-cause edit;
11824 // the `&` falls away in the same edit since it's downstream of
11825 // the Windows-shell convention).
11826 let d = dep_with_fonte(DepSource::Path {
11827 caminho: "..\\caixa-teia & sleep".into(),
11828 });
11829 let err = d.validate().unwrap_err();
11830 assert!(
11831 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11832 "got {err:?}",
11833 );
11834 }
11835
11836 #[test]
11837 fn fonte_caminho_control_char_fires_before_shell_background() {
11838 // Cascade pin on the embedded-control-byte arm: a value
11839 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11840 // the canonical paste-from-multiline-doc footgun where a
11841 // newline landed mid-caminho) routes through
11842 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11843 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11844 // diagnostic is the load-bearing axis on every value that
11845 // probes positive for both — mirrors the cascade discipline on
11846 // every prior arm.
11847 let d = dep_with_fonte(DepSource::Path {
11848 caminho: "../foo\n&sleep".into(),
11849 });
11850 let err = d.validate().unwrap_err();
11851 assert!(
11852 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11853 "got {err:?}",
11854 );
11855 }
11856
11857 #[test]
11858 fn fonte_caminho_absolute_fires_before_shell_background() {
11859 // Cascade pin on the load-bearing leading-byte arm: a leading
11860 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11861 // through `FonteCaminhoAbsolute` not
11862 // `FonteCaminhoShellBackground` — the host-layout-leak
11863 // diagnostic is the load-bearing axis, the `&` byte is the
11864 // secondary observation. Same precedence logic as every prior
11865 // leading-byte arm.
11866 let d = dep_with_fonte(DepSource::Path {
11867 caminho: "/etc/passwd & sleep".into(),
11868 });
11869 let err = d.validate().unwrap_err();
11870 assert!(
11871 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11872 "got {err:?}",
11873 );
11874 }
11875
11876 #[test]
11877 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11878 // Cascade pin on the immediate-successor arm: a value carrying
11879 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11880 // canonical "I tab-completed a path that already had a `&
11881 // sleep` background-launch tail" footgun) routes through
11882 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11883 // The embedded shell-metachar is the more semantic-locating
11884 // axis (an author who removes the `&` typically also drops
11885 // the trailing separator since both are paste-from-shell
11886 // artifacts).
11887 let d = dep_with_fonte(DepSource::Path {
11888 caminho: "../foo&sleep/".into(),
11889 });
11890 let err = d.validate().unwrap_err();
11891 assert!(
11892 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11893 "got {err:?}",
11894 );
11895 }
11896
11897 #[test]
11898 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11899 // Diagnostic-shape pin (peer with
11900 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11901 // on the closest single-byte peer arm): the error's Display
11902 // surfaces the offending `:nome` and the offending `:caminho`
11903 // verbatim, and names the shell-background / logical-AND
11904 // footgun explicitly so a `feira lint` run can render the
11905 // diagnostic without re-parsing.
11906 let d = dep_with_fonte(DepSource::Path {
11907 caminho: "../caixa-teia & sleep 1".into(),
11908 });
11909 let rendered = d.validate().unwrap_err().to_string();
11910 assert!(
11911 rendered.contains("caixa-teia"),
11912 "diagnostic must name the offending dep: {rendered}",
11913 );
11914 assert!(
11915 rendered.contains("../caixa-teia & sleep 1"),
11916 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11917 );
11918 assert!(
11919 rendered.contains('&'),
11920 "diagnostic must reference the ampersand footgun: {rendered:?}",
11921 );
11922 assert!(
11923 rendered.contains("background") || rendered.contains("list-AND"),
11924 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11925 );
11926 }
11927
11928 #[test]
11929 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11930 // The fail-before-pass-after pin for the canonical shell-
11931 // command-substitution paste footgun: an author copies a
11932 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11933 // — the canonical "I pasted a path that included a `pwd`
11934 // / `whoami` / `date` legacy command-substitution expansion
11935 // out of a shell-history block") and silently passed every
11936 // prior arm (`Path::is_absolute` false on `..`, no control
11937 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11938 // end in `/`). The lacre embedded the value verbatim, the
11939 // resolver folded it through `Path::join` looking for a
11940 // literal `./../caixa-teia/`whoami`` subdirectory, and the
11941 // failure surfaced at resolve time with a non-self-locating
11942 // `No such file or directory` error. The new arm moves the
11943 // rejection to validate time and names the offending dep +
11944 // caminho verbatim.
11945 let d = dep_with_fonte(DepSource::Path {
11946 caminho: "../caixa-teia/`whoami`".into(),
11947 });
11948 let err = d.validate().unwrap_err();
11949 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11950 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11951 };
11952 assert_eq!(nome, "caixa-teia");
11953 assert_eq!(caminho, "../caixa-teia/`whoami`");
11954 }
11955
11956 #[test]
11957 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11958 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11959 // the canonical `<backtick>pwd<backtick>/path` working-
11960 // directory expansion shape every shell-side path-composition
11961 // idiom carries). Pinned separately from the embedded-byte
11962 // shape so the gate covers every position, not only mid-path.
11963 let d = dep_with_fonte(DepSource::Path {
11964 caminho: "`pwd`/caixa-teia".into(),
11965 });
11966 let err = d.validate().unwrap_err();
11967 assert!(
11968 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11969 "got {err:?}",
11970 );
11971 }
11972
11973 #[test]
11974 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11975 // Trailing-position backtick shape (`"../caixa-teia`"` — the
11976 // degenerate "I selected an unbalanced backtick out of a
11977 // shell-history block" idiom that probes for the cascade's
11978 // last-byte handling). The trailing-`/` arm fires only on
11979 // last-byte `/`; an unbalanced trailing backtick must route
11980 // through this arm regardless of position.
11981 let d = dep_with_fonte(DepSource::Path {
11982 caminho: "../caixa-teia`".into(),
11983 });
11984 let err = d.validate().unwrap_err();
11985 assert!(
11986 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11987 "got {err:?}",
11988 );
11989 }
11990
11991 #[test]
11992 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11993 // The canonical balanced-pair shape (``"../<backtick>cat
11994 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11995 // command-injection paste idiom every shell-side hardening
11996 // guide enumerates first). The arm fires on the first
11997 // backtick encountered; pinned so a future arm that tries to
11998 // distinguish the opening from the closing byte doesn't break
11999 // the broader contract.
12000 let d = dep_with_fonte(DepSource::Path {
12001 caminho: "../`cat /etc/passwd`".into(),
12002 });
12003 let err = d.validate().unwrap_err();
12004 assert!(
12005 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12006 "got {err:?}",
12007 );
12008 }
12009
12010 #[test]
12011 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
12012 // The positive-control pin: the gate targets only the
12013 // backtick byte, never adjacent printable ASCII or POSIX-
12014 // valid bytes. The canonical relative POSIX path
12015 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
12016 // adjacent printable punctuation
12017 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
12018 // cleanly so the gate doesn't widen to a "no printable
12019 // punctuation anywhere" sweep that would defeat the entire
12020 // path-fonte author surface.
12021 let d = dep_with_fonte(DepSource::Path {
12022 caminho: "../caixa-teia/sub-dir.v2".into(),
12023 });
12024 d.validate().unwrap();
12025 }
12026
12027 #[test]
12028 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
12029 // Cascade pin on the immediate-predecessor arm: a value
12030 // carrying both `&` and a backtick (``"../caixa-teia &
12031 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
12032 // `cmd & <backtick>sleep N<backtick>` background-launch +
12033 // command-substitution chain" footgun) routes through
12034 // `FonteCaminhoShellBackground` not
12035 // `FonteCaminhoShellCommandSubstitution`. The background-
12036 // launch tail is the more common shell-history paste idiom
12037 // on every probe-as-both value — same cascade discipline
12038 // every prior `:caminho` arm establishes.
12039 let d = dep_with_fonte(DepSource::Path {
12040 caminho: "../caixa-teia & `sleep 1`".into(),
12041 });
12042 let err = d.validate().unwrap_err();
12043 assert!(
12044 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12045 "got {err:?}",
12046 );
12047 }
12048
12049 #[test]
12050 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
12051 // Cascade pin on the upstream shell-semicolon arm: a value
12052 // carrying both `;` and a backtick (``"../caixa-teia;
12053 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12054 // `cmd; <backtick>follow-up<backtick>` sequential-chain
12055 // footgun) routes through `FonteCaminhoShellSemicolon` not
12056 // `FonteCaminhoShellCommandSubstitution`. The sequential-
12057 // command-separator paste is the load-bearing root-cause
12058 // edit on every probe-as-both value.
12059 let d = dep_with_fonte(DepSource::Path {
12060 caminho: "../caixa-teia; `whoami`".into(),
12061 });
12062 let err = d.validate().unwrap_err();
12063 assert!(
12064 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12065 "got {err:?}",
12066 );
12067 }
12068
12069 #[test]
12070 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
12071 // Cascade pin on the upstream shell-pipe arm: a value
12072 // carrying both `|` and a backtick (``"../caixa-teia |
12073 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
12074 // command-substitution paste idiom) routes through
12075 // `FonteCaminhoShellPipe` not
12076 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
12077 // paste is the load-bearing root-cause edit on every
12078 // probe-as-both value.
12079 let d = dep_with_fonte(DepSource::Path {
12080 caminho: "../caixa-teia | `tee log`".into(),
12081 });
12082 let err = d.validate().unwrap_err();
12083 assert!(
12084 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12085 "got {err:?}",
12086 );
12087 }
12088
12089 #[test]
12090 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
12091 // Cascade pin on the upstream shell-redirection arm: a value
12092 // carrying both `>` and a backtick (``"../caixa-teia>log
12093 // <backtick>date<backtick>"`` — the canonical "I pasted a
12094 // `cmd > log <backtick>date<backtick>` redirect-plus-
12095 // substitution chain" footgun) routes through
12096 // `FonteCaminhoShellRedirection` not
12097 // `FonteCaminhoShellCommandSubstitution`. The input/output
12098 // redirection metachar carries the more self-locating `byte`
12099 // payload (it names which of `<` or `>` triggered), so the
12100 // prior arm wins on every probe-as-both value.
12101 let d = dep_with_fonte(DepSource::Path {
12102 caminho: "../caixa-teia>log `date`".into(),
12103 });
12104 let err = d.validate().unwrap_err();
12105 assert!(
12106 matches!(
12107 err,
12108 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12109 ),
12110 "got {err:?}",
12111 );
12112 }
12113
12114 #[test]
12115 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
12116 // Cascade pin on the upstream backslash arm: a value
12117 // carrying both `\` and a backtick (``"..\caixa-teia
12118 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12119 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
12120 // chain") routes through `FonteCaminhoBackslash` not
12121 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
12122 // separator divergence is the load-bearing axis on every
12123 // probe-as-both value (an author who removes the `\` is the
12124 // root-cause edit; the backtick falls away in the same edit
12125 // since it's downstream of the Windows-shell convention).
12126 let d = dep_with_fonte(DepSource::Path {
12127 caminho: "..\\caixa-teia `whoami`".into(),
12128 });
12129 let err = d.validate().unwrap_err();
12130 assert!(
12131 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12132 "got {err:?}",
12133 );
12134 }
12135
12136 #[test]
12137 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
12138 // Cascade pin on the embedded-control-byte arm: a value
12139 // carrying both a control byte and a backtick (`"../foo\n
12140 // `whoami`"` — the canonical paste-from-multiline-doc
12141 // footgun where a newline landed mid-caminho between two
12142 // paste fragments) routes through `FonteCaminhoControlChar`
12143 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
12144 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
12145 // is the load-bearing axis on every value that probes
12146 // positive for both — mirrors the cascade discipline on
12147 // every prior arm.
12148 let d = dep_with_fonte(DepSource::Path {
12149 caminho: "../foo\n`whoami`".into(),
12150 });
12151 let err = d.validate().unwrap_err();
12152 assert!(
12153 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12154 "got {err:?}",
12155 );
12156 }
12157
12158 #[test]
12159 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
12160 // Cascade pin on the load-bearing leading-byte arm: a
12161 // leading `/` value with embedded backtick (``"/etc/passwd
12162 // <backtick>whoami<backtick>"``) routes through
12163 // `FonteCaminhoAbsolute` not
12164 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
12165 // leak diagnostic is the load-bearing axis, the backtick
12166 // byte is the secondary observation. Same precedence logic
12167 // as every prior leading-byte arm.
12168 let d = dep_with_fonte(DepSource::Path {
12169 caminho: "/etc/passwd `whoami`".into(),
12170 });
12171 let err = d.validate().unwrap_err();
12172 assert!(
12173 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12174 "got {err:?}",
12175 );
12176 }
12177
12178 #[test]
12179 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
12180 // Cascade pin on the immediate-successor arm: a value
12181 // carrying both a backtick and a trailing `/`
12182 // (``"../`whoami`/"`` — the canonical "I tab-completed a
12183 // path that already had a backticked `whoami` substitution
12184 // tail" footgun) routes through
12185 // `FonteCaminhoShellCommandSubstitution` not
12186 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12187 // is the more semantic-locating axis (an author who removes
12188 // the backtick typically also drops the trailing separator
12189 // since both are paste-from-shell artifacts).
12190 let d = dep_with_fonte(DepSource::Path {
12191 caminho: "../`whoami`/".into(),
12192 });
12193 let err = d.validate().unwrap_err();
12194 assert!(
12195 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12196 "got {err:?}",
12197 );
12198 }
12199
12200 #[test]
12201 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
12202 // Diagnostic-shape pin (peer with
12203 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
12204 // on the closest single-byte peer arm): the error's Display
12205 // surfaces the offending `:nome` and the offending `:caminho`
12206 // verbatim, and names the shell-command-substitution footgun
12207 // explicitly so a `feira lint` run can render the diagnostic
12208 // without re-parsing.
12209 let d = dep_with_fonte(DepSource::Path {
12210 caminho: "../caixa-teia/`whoami`".into(),
12211 });
12212 let rendered = d.validate().unwrap_err().to_string();
12213 assert!(
12214 rendered.contains("caixa-teia"),
12215 "diagnostic must name the offending dep: {rendered}",
12216 );
12217 assert!(
12218 rendered.contains("../caixa-teia/`whoami`"),
12219 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12220 );
12221 assert!(
12222 rendered.contains('`'),
12223 "diagnostic must reference the backtick footgun: {rendered:?}",
12224 );
12225 assert!(
12226 rendered.contains("command-substitution"),
12227 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
12228 );
12229 }
12230
12231 #[test]
12232 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
12233 // The fail-before-pass-after pin for the canonical pathname-
12234 // expansion paste footgun: an author copies an `ls
12235 // ../caixa-teia/*` shell-listing tail into the `:caminho`
12236 // slot and silently passes every prior arm
12237 // (`Path::is_absolute` false on `..`, no control bytes, no
12238 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
12239 // doesn't end in `/`). The lacre embedded the value
12240 // verbatim, the resolver folded it through `Path::join`
12241 // looking for a literal `./../caixa-teia/*` subdirectory,
12242 // and the failure surfaced at resolve time with a non-self-
12243 // locating `No such file or directory` error. The new arm
12244 // moves the rejection to validate time and names the
12245 // offending dep + caminho + byte verbatim.
12246 let d = dep_with_fonte(DepSource::Path {
12247 caminho: "../caixa-teia/*".into(),
12248 });
12249 let err = d.validate().unwrap_err();
12250 let DepError::FonteCaminhoShellGlob {
12251 nome,
12252 caminho,
12253 byte,
12254 } = err
12255 else {
12256 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12257 };
12258 assert_eq!(nome, "caixa-teia");
12259 assert_eq!(caminho, "../caixa-teia/*");
12260 assert_eq!(byte, b'*');
12261 }
12262
12263 #[test]
12264 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
12265 // The symmetric single-char-wildcard paste shape
12266 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
12267 // out of shell history" idiom). Pinned separately from the
12268 // `*` shape so the gate's contract is "any `*` or `?`
12269 // anywhere", not single-byte coverage.
12270 let d = dep_with_fonte(DepSource::Path {
12271 caminho: "../foo?".into(),
12272 });
12273 let err = d.validate().unwrap_err();
12274 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
12275 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12276 };
12277 assert_eq!(byte, b'?');
12278 }
12279
12280 #[test]
12281 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
12282 // Leading-position `*` shape (`"*/caixa-teia"` — the
12283 // degenerate "I selected only the wildcard prefix out of a
12284 // shell-glob expression" idiom). Pinned separately from the
12285 // embedded-byte shapes so the gate covers every position,
12286 // not only mid-path.
12287 let d = dep_with_fonte(DepSource::Path {
12288 caminho: "*/caixa-teia".into(),
12289 });
12290 let err = d.validate().unwrap_err();
12291 assert!(
12292 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12293 "got {err:?}",
12294 );
12295 }
12296
12297 #[test]
12298 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
12299 // The bash/zsh `globstar` recursive-glob shape
12300 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
12301 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
12302 // The arm fires on the first `*` encountered; pinned so a
12303 // future arm that tries to distinguish single `*` from
12304 // double `**` doesn't break the broader contract.
12305 let d = dep_with_fonte(DepSource::Path {
12306 caminho: "../caixa-teia/**/foo".into(),
12307 });
12308 let err = d.validate().unwrap_err();
12309 assert!(
12310 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12311 "got {err:?}",
12312 );
12313 }
12314
12315 #[test]
12316 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
12317 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
12318 // — the "I selected `*.lisp` to mean every Lisp source file
12319 // in the dep root" footgun the prior arms structurally
12320 // cannot catch since `.` is a POSIX-valid path-component
12321 // byte). Pinned so the gate's contract covers the most
12322 // idiomatic glob-paste shape every author meets first.
12323 let d = dep_with_fonte(DepSource::Path {
12324 caminho: "../caixa-teia/*.lisp".into(),
12325 });
12326 let err = d.validate().unwrap_err();
12327 assert!(
12328 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12329 "got {err:?}",
12330 );
12331 }
12332
12333 #[test]
12334 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
12335 // The positive-control pin: the gate targets only `*` /
12336 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
12337 // The canonical relative POSIX path (`"../caixa-teia"`) and
12338 // a nested deeply-pathed variant with adjacent printable
12339 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12340 // to validate cleanly so the gate doesn't widen to a "no
12341 // printable punctuation anywhere" sweep that would defeat
12342 // the entire path-fonte author surface.
12343 let d = dep_with_fonte(DepSource::Path {
12344 caminho: "../caixa-teia/sub-dir.v2".into(),
12345 });
12346 d.validate().unwrap();
12347 }
12348
12349 #[test]
12350 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
12351 // Cascade pin on the immediate-predecessor arm: a value
12352 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
12353 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
12354 // command-substitution + glob chain") routes through
12355 // `FonteCaminhoShellCommandSubstitution` not
12356 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
12357 // injection vector is the load-bearing root-cause edit on
12358 // every probe-as-both value — same cascade discipline every
12359 // prior `:caminho` arm establishes.
12360 let d = dep_with_fonte(DepSource::Path {
12361 caminho: "../`whoami`/*".into(),
12362 });
12363 let err = d.validate().unwrap_err();
12364 assert!(
12365 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12366 "got {err:?}",
12367 );
12368 }
12369
12370 #[test]
12371 fn fonte_caminho_shell_background_fires_before_shell_glob() {
12372 // Cascade pin on the upstream shell-background arm: a value
12373 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
12374 // canonical "I pasted a `cmd & ls /*` background + glob
12375 // chain" footgun) routes through `FonteCaminhoShellBackground`
12376 // not `FonteCaminhoShellGlob`. The background-launch tail is
12377 // the load-bearing root-cause edit on every probe-as-both
12378 // value.
12379 let d = dep_with_fonte(DepSource::Path {
12380 caminho: "../caixa-teia & ls /*".into(),
12381 });
12382 let err = d.validate().unwrap_err();
12383 assert!(
12384 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12385 "got {err:?}",
12386 );
12387 }
12388
12389 #[test]
12390 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
12391 // Cascade pin on the upstream shell-semicolon arm: a value
12392 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
12393 // canonical sequential-cleanup + glob paste idiom) routes
12394 // through `FonteCaminhoShellSemicolon` not
12395 // `FonteCaminhoShellGlob`. The sequential-command-separator
12396 // paste is the load-bearing root-cause edit on every
12397 // probe-as-both value.
12398 let d = dep_with_fonte(DepSource::Path {
12399 caminho: "../caixa-teia; rm *".into(),
12400 });
12401 let err = d.validate().unwrap_err();
12402 assert!(
12403 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12404 "got {err:?}",
12405 );
12406 }
12407
12408 #[test]
12409 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
12410 // Cascade pin on the upstream shell-pipe arm: a value
12411 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
12412 // canonical pipeline-to-glob paste idiom) routes through
12413 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
12414 // pipeline-tail paste is the load-bearing root-cause edit
12415 // on every probe-as-both value.
12416 let d = dep_with_fonte(DepSource::Path {
12417 caminho: "../caixa-teia | ls *".into(),
12418 });
12419 let err = d.validate().unwrap_err();
12420 assert!(
12421 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12422 "got {err:?}",
12423 );
12424 }
12425
12426 #[test]
12427 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
12428 // Cascade pin on the upstream shell-redirection arm: a value
12429 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
12430 // canonical "I pasted a `cmd > log *` redirect-plus-glob
12431 // chain" footgun) routes through
12432 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
12433 // The input/output redirection metachar carries the more
12434 // self-locating `byte` payload (it names which of `<` or `>`
12435 // triggered), so the prior arm wins on every probe-as-both
12436 // value.
12437 let d = dep_with_fonte(DepSource::Path {
12438 caminho: "../caixa-teia>log *".into(),
12439 });
12440 let err = d.validate().unwrap_err();
12441 assert!(
12442 matches!(
12443 err,
12444 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12445 ),
12446 "got {err:?}",
12447 );
12448 }
12449
12450 #[test]
12451 fn fonte_caminho_backslash_fires_before_shell_glob() {
12452 // Cascade pin on the upstream backslash arm: a value
12453 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12454 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12455 // expression" footgun) routes through
12456 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12457 // cross-host-OS-separator divergence is the load-bearing
12458 // axis on every probe-as-both value (an author who removes
12459 // the `\` is the root-cause edit; the `*` falls away in the
12460 // same edit since it's downstream of the Windows-shell
12461 // convention).
12462 let d = dep_with_fonte(DepSource::Path {
12463 caminho: "..\\caixa-teia\\*".into(),
12464 });
12465 let err = d.validate().unwrap_err();
12466 assert!(
12467 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12468 "got {err:?}",
12469 );
12470 }
12471
12472 #[test]
12473 fn fonte_caminho_control_char_fires_before_shell_glob() {
12474 // Cascade pin on the embedded-control-byte arm: a value
12475 // carrying both a control byte and `*` (`"../foo\n*"` — the
12476 // canonical paste-from-multiline-doc footgun where a
12477 // newline landed mid-caminho between two paste fragments)
12478 // routes through `FonteCaminhoControlChar` not
12479 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12480 // NUL-`CString::new`-fail diagnostic is the load-bearing
12481 // axis on every value that probes positive for both —
12482 // mirrors the cascade discipline on every prior arm.
12483 let d = dep_with_fonte(DepSource::Path {
12484 caminho: "../foo\n*".into(),
12485 });
12486 let err = d.validate().unwrap_err();
12487 assert!(
12488 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12489 "got {err:?}",
12490 );
12491 }
12492
12493 #[test]
12494 fn fonte_caminho_absolute_fires_before_shell_glob() {
12495 // Cascade pin on the load-bearing leading-byte arm: a
12496 // leading `/` value with embedded `*` (`"/etc/*"`) routes
12497 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12498 // — the host-layout-leak diagnostic is the load-bearing
12499 // axis, the glob byte is the secondary observation. Same
12500 // precedence logic as every prior leading-byte arm.
12501 let d = dep_with_fonte(DepSource::Path {
12502 caminho: "/etc/*".into(),
12503 });
12504 let err = d.validate().unwrap_err();
12505 assert!(
12506 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12507 "got {err:?}",
12508 );
12509 }
12510
12511 #[test]
12512 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12513 // Cascade pin on the immediate-successor arm: a value
12514 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12515 // canonical "I tab-completed a path that already had a
12516 // glob-expansion tail" footgun) routes through
12517 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12518 // The embedded shell-metachar is the more semantic-locating
12519 // axis (an author who removes the `*` typically also drops
12520 // the trailing separator since both are paste-from-shell
12521 // artifacts).
12522 let d = dep_with_fonte(DepSource::Path {
12523 caminho: "../foo*/".into(),
12524 });
12525 let err = d.validate().unwrap_err();
12526 assert!(
12527 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12528 "got {err:?}",
12529 );
12530 }
12531
12532 #[test]
12533 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12534 // Diagnostic-shape pin (peer with
12535 // `fonte_caminho_shell_redirection_diagnostic_*` on the
12536 // closest two-byte peer arm): the error's Display surfaces
12537 // the offending `:nome`, the offending `:caminho` verbatim,
12538 // the offending byte's hex / character form, and names the
12539 // shell-glob / pathname-expansion footgun explicitly so a
12540 // `feira lint` run can render the diagnostic without
12541 // re-parsing.
12542 let d = dep_with_fonte(DepSource::Path {
12543 caminho: "../caixa-teia/*.lisp".into(),
12544 });
12545 let rendered = d.validate().unwrap_err().to_string();
12546 assert!(
12547 rendered.contains("caixa-teia"),
12548 "diagnostic must name the offending dep: {rendered}",
12549 );
12550 assert!(
12551 rendered.contains("../caixa-teia/*.lisp"),
12552 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12553 );
12554 assert!(
12555 rendered.contains("0x2a"),
12556 "diagnostic must surface the offending byte hex: {rendered:?}",
12557 );
12558 assert!(
12559 rendered.contains("glob"),
12560 "diagnostic must name the shell-glob footgun: {rendered:?}",
12561 );
12562 assert!(
12563 rendered.contains("pathname-expansion"),
12564 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12565 );
12566 }
12567
12568 #[test]
12569 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12570 // The fail-before-pass-after pin for the canonical modern-Bourne
12571 // command-substitution paste footgun: an author copies a
12572 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12573 // `$(<cmd>)` expansion would land the current date as a
12574 // subdirectory name and silently passed every prior arm
12575 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12576 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12577 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12578 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12579 // sits mid-path). The lacre embedded the value verbatim, the
12580 // resolver folded it through `Path::join` looking for a literal
12581 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12582 // surfaced at resolve time with a non-self-locating `No such
12583 // file or directory` error. The new arm moves the rejection to
12584 // validate time and names the offending dep + caminho + byte
12585 // verbatim. The arm fires on the first `(` encountered (the
12586 // opening byte of `$(date)`).
12587 let d = dep_with_fonte(DepSource::Path {
12588 caminho: "../caixa-teia/$(date)/build".into(),
12589 });
12590 let err = d.validate().unwrap_err();
12591 let DepError::FonteCaminhoShellSubshellGrouping {
12592 nome,
12593 caminho,
12594 byte,
12595 } = err
12596 else {
12597 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12598 };
12599 assert_eq!(nome, "caixa-teia");
12600 assert_eq!(caminho, "../caixa-teia/$(date)/build");
12601 assert_eq!(byte, b'(');
12602 }
12603
12604 #[test]
12605 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12606 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12607 // the degenerate "I selected an unbalanced closing paren out of
12608 // a shell-history block" idiom that probes for the cascade's
12609 // last-byte handling on a value carrying only the closing byte).
12610 // Pinned separately from the open-paren shape so the gate's
12611 // contract is "any `(` or `)` anywhere", not single-byte
12612 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12613 // caminho_carrying_question_glob` shape on the immediate-
12614 // predecessor `FonteCaminhoShellGlob` arm.
12615 let d = dep_with_fonte(DepSource::Path {
12616 caminho: "../caixa-teia)".into(),
12617 });
12618 let err = d.validate().unwrap_err();
12619 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12620 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12621 };
12622 assert_eq!(byte, b')');
12623 }
12624
12625 #[test]
12626 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12627 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12628 // canonical "I selected a `(cd foo)` subshell-grouping prefix
12629 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12630 // Pinned separately from the embedded-byte shape so the gate
12631 // covers every position, not only mid-path.
12632 let d = dep_with_fonte(DepSource::Path {
12633 caminho: "(cd foo)/caixa-teia".into(),
12634 });
12635 let err = d.validate().unwrap_err();
12636 assert!(
12637 matches!(
12638 err,
12639 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12640 ),
12641 "got {err:?}",
12642 );
12643 }
12644
12645 #[test]
12646 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12647 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12648 // — the canonical "I copied a `(pwd)` working-directory-probe
12649 // subshell-grouping idiom every shell-history block carries"
12650 // footgun). The value carries no other cascade-preceding
12651 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12652 // `*` / `?`) so the arm fires on the first `(` encountered;
12653 // pinned so a future arm that tries to distinguish the
12654 // opening from the closing byte doesn't break the broader
12655 // contract. Mirrors the peer
12656 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12657 // backtick_pair` shape on the upstream `FonteCaminhoShell\
12658 // CommandSubstitution` arm.
12659 let d = dep_with_fonte(DepSource::Path {
12660 caminho: "../(pwd)/caixa-teia".into(),
12661 });
12662 let err = d.validate().unwrap_err();
12663 assert!(
12664 matches!(
12665 err,
12666 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12667 ),
12668 "got {err:?}",
12669 );
12670 }
12671
12672 #[test]
12673 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12674 // The positive-control pin: the gate targets only `(` / `)`,
12675 // never adjacent printable ASCII or POSIX-valid bytes. The
12676 // canonical relative POSIX path (`"../caixa-teia"`) and a
12677 // nested deeply-pathed variant with adjacent printable
12678 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12679 // validate cleanly so the gate doesn't widen to a "no printable
12680 // punctuation anywhere" sweep that would defeat the entire
12681 // path-fonte author surface.
12682 let d = dep_with_fonte(DepSource::Path {
12683 caminho: "../caixa-teia/sub-dir.v2".into(),
12684 });
12685 d.validate().unwrap();
12686 }
12687
12688 #[test]
12689 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12690 // Cascade pin on the immediate-predecessor arm: a value
12691 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12692 // canonical "I pasted a glob expansion followed by a
12693 // subshell-grouping tail" footgun) routes through
12694 // `FonteCaminhoShellGlob` not
12695 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12696 // shape is the more common shell-history paste idiom on every
12697 // probe-as-both value — same cascade discipline every prior
12698 // `:caminho` arm establishes.
12699 let d = dep_with_fonte(DepSource::Path {
12700 caminho: "../caixa-teia/*(date)".into(),
12701 });
12702 let err = d.validate().unwrap_err();
12703 assert!(
12704 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12705 "got {err:?}",
12706 );
12707 }
12708
12709 #[test]
12710 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12711 // Cascade pin on the upstream shell-command-substitution arm: a
12712 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12713 // — the canonical "I pasted a legacy-backtick + modern-paren
12714 // command-substitution chain" footgun) routes through
12715 // `FonteCaminhoShellCommandSubstitution` not
12716 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12717 // command-injection vector is the load-bearing root-cause edit
12718 // on every probe-as-both value.
12719 let d = dep_with_fonte(DepSource::Path {
12720 caminho: "../`whoami`/$(date)".into(),
12721 });
12722 let err = d.validate().unwrap_err();
12723 assert!(
12724 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12725 "got {err:?}",
12726 );
12727 }
12728
12729 #[test]
12730 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12731 // Cascade pin on the upstream shell-background arm: a value
12732 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12733 // the canonical "I pasted a `cmd & (cd foo)` background-launch
12734 // + subshell-grouping chain" footgun) routes through
12735 // `FonteCaminhoShellBackground` not
12736 // `FonteCaminhoShellSubshellGrouping`. The background-launch
12737 // tail is the load-bearing root-cause edit on every probe-as-
12738 // both value.
12739 let d = dep_with_fonte(DepSource::Path {
12740 caminho: "../caixa-teia & (cd foo)".into(),
12741 });
12742 let err = d.validate().unwrap_err();
12743 assert!(
12744 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12745 "got {err:?}",
12746 );
12747 }
12748
12749 #[test]
12750 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12751 // Cascade pin on the upstream shell-semicolon arm: a value
12752 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12753 // the canonical sequential-cleanup + subshell-grouping paste
12754 // idiom) routes through `FonteCaminhoShellSemicolon` not
12755 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12756 // separator paste is the load-bearing root-cause edit on
12757 // every probe-as-both value.
12758 let d = dep_with_fonte(DepSource::Path {
12759 caminho: "../caixa-teia; (cd foo)".into(),
12760 });
12761 let err = d.validate().unwrap_err();
12762 assert!(
12763 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12764 "got {err:?}",
12765 );
12766 }
12767
12768 #[test]
12769 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12770 // Cascade pin on the upstream shell-pipe arm: a value carrying
12771 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12772 // canonical pipeline-to-subshell-grouping paste idiom) routes
12773 // through `FonteCaminhoShellPipe` not
12774 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12775 // is the load-bearing root-cause edit on every probe-as-both
12776 // value.
12777 let d = dep_with_fonte(DepSource::Path {
12778 caminho: "../caixa-teia | (tee log)".into(),
12779 });
12780 let err = d.validate().unwrap_err();
12781 assert!(
12782 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12783 "got {err:?}",
12784 );
12785 }
12786
12787 #[test]
12788 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12789 // Cascade pin on the upstream shell-redirection arm: a value
12790 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12791 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12792 // plus-subshell-grouping chain" footgun) routes through
12793 // `FonteCaminhoShellRedirection` not
12794 // `FonteCaminhoShellSubshellGrouping`. The input/output
12795 // redirection metachar carries the more self-locating `byte`
12796 // payload (it names which of `<` or `>` triggered), so the
12797 // prior arm wins on every probe-as-both value.
12798 let d = dep_with_fonte(DepSource::Path {
12799 caminho: "../caixa-teia>log (cd foo)".into(),
12800 });
12801 let err = d.validate().unwrap_err();
12802 assert!(
12803 matches!(
12804 err,
12805 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12806 ),
12807 "got {err:?}",
12808 );
12809 }
12810
12811 #[test]
12812 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12813 // Cascade pin on the upstream backslash arm: a value carrying
12814 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12815 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12816 // through `FonteCaminhoBackslash` not
12817 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12818 // separator divergence is the load-bearing axis on every
12819 // probe-as-both value (an author who removes the `\` is the
12820 // root-cause edit; the `(` falls away in the same edit since
12821 // it's downstream of the Windows-shell convention).
12822 let d = dep_with_fonte(DepSource::Path {
12823 caminho: "..\\caixa-teia\\(cd foo)".into(),
12824 });
12825 let err = d.validate().unwrap_err();
12826 assert!(
12827 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12828 "got {err:?}",
12829 );
12830 }
12831
12832 #[test]
12833 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12834 // Cascade pin on the embedded-control-byte arm: a value
12835 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12836 // the canonical paste-from-multiline-doc footgun where a
12837 // newline landed mid-caminho between two paste fragments)
12838 // routes through `FonteCaminhoControlChar` not
12839 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12840 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12841 // load-bearing axis on every value that probes positive for
12842 // both — mirrors the cascade discipline on every prior arm.
12843 let d = dep_with_fonte(DepSource::Path {
12844 caminho: "../foo\n(cd bar)".into(),
12845 });
12846 let err = d.validate().unwrap_err();
12847 assert!(
12848 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12849 "got {err:?}",
12850 );
12851 }
12852
12853 #[test]
12854 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12855 // Cascade pin on the load-bearing leading-byte arm: a leading
12856 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12857 // through `FonteCaminhoAbsolute` not
12858 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12859 // diagnostic is the load-bearing axis, the subshell-grouping
12860 // byte is the secondary observation. Same precedence logic as
12861 // every prior leading-byte arm.
12862 let d = dep_with_fonte(DepSource::Path {
12863 caminho: "/etc/(cd foo)".into(),
12864 });
12865 let err = d.validate().unwrap_err();
12866 assert!(
12867 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12868 "got {err:?}",
12869 );
12870 }
12871
12872 #[test]
12873 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12874 // Cascade pin on the upstream leading-`$` var-expansion arm: a
12875 // value carrying both a leading `$` and a `(` (`"$(date)/\
12876 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12877 // command-substitution at the head of a sibling-workspace
12878 // path" footgun) routes through `FonteCaminhoVarExpansion` not
12879 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12880 // shell-variable-expansion is the more self-locating diagnostic
12881 // on values that probe as both — same load-bearing-leading-
12882 // byte cascade discipline every prior `:caminho` arm
12883 // establishes. Closing both halves of `$(<cmd>)` structurally
12884 // (leading `$` here, trailing `)` on the new arm) excludes the
12885 // entire modern Bourne command-substitution surface from the
12886 // typed `:caminho` accepted set; the cascade preserves the
12887 // narrower leading-byte diagnostic on values that probe both
12888 // halves at the canonical leading position.
12889 let d = dep_with_fonte(DepSource::Path {
12890 caminho: "$(date)/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_subshell_grouping_fires_before_trailing_slash() {
12901 // Cascade pin on the immediate-successor arm: a value carrying
12902 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12903 // "I tab-completed a path that already had a subshell-grouping
12904 // expansion tail" footgun) routes through
12905 // `FonteCaminhoShellSubshellGrouping` not
12906 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12907 // the more semantic-locating axis (an author who removes the
12908 // `(` typically also drops the trailing separator since both
12909 // are paste-from-shell artifacts).
12910 let d = dep_with_fonte(DepSource::Path {
12911 caminho: "../(cd foo)/".into(),
12912 });
12913 let err = d.validate().unwrap_err();
12914 assert!(
12915 matches!(
12916 err,
12917 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12918 ),
12919 "got {err:?}",
12920 );
12921 }
12922
12923 #[test]
12924 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12925 // Diagnostic-shape pin (peer with
12926 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12927 // on the closest two-byte peer arm): the error's Display
12928 // surfaces the offending `:nome`, the offending `:caminho`
12929 // verbatim, the offending byte's hex / character form, and
12930 // names the shell-subshell-grouping footgun explicitly so a
12931 // `feira lint` run can render the diagnostic without re-
12932 // parsing.
12933 let d = dep_with_fonte(DepSource::Path {
12934 caminho: "../caixa-teia/$(date)/build".into(),
12935 });
12936 let rendered = d.validate().unwrap_err().to_string();
12937 assert!(
12938 rendered.contains("caixa-teia"),
12939 "diagnostic must name the offending dep: {rendered}",
12940 );
12941 assert!(
12942 rendered.contains("../caixa-teia/$(date)/build"),
12943 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12944 );
12945 assert!(
12946 rendered.contains("0x28"),
12947 "diagnostic must surface the offending byte hex: {rendered:?}",
12948 );
12949 assert!(
12950 rendered.contains("subshell-grouping"),
12951 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12952 );
12953 assert!(
12954 rendered.contains("command-substitution"),
12955 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12956 {rendered:?}",
12957 );
12958 }
12959
12960 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12961 //
12962 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12963 // `)`) byte-pair arm: the same per-byte cascade with the same
12964 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12965 // `}` brace-expansion / URI-Template placeholder axis. The peer
12966 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12967 // byte pair on the sibling `:fonte :repo` axis under the same
12968 // banner.
12969
12970 #[test]
12971 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12972 // The fail-before-pass-after pin for the canonical paste-from-
12973 // shell-history brace-expansion footgun: an author copies a
12974 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12975 // liner whose `{a,b}` brace expansion fans across two siblings
12976 // and silently passed every prior arm (`Path::is_absolute`
12977 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12978 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12979 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12980 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12981 // value starts with `..` not `$`). The lacre embedded the
12982 // value verbatim, the resolver folded it through `Path::join`
12983 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12984 // subdirectory, and the failure surfaced at resolve time with
12985 // a non-self-locating `No such file or directory` error. The
12986 // new arm moves the rejection to validate time and names the
12987 // offending dep + caminho + byte verbatim. The arm fires on
12988 // the first `{` encountered.
12989 let d = dep_with_fonte(DepSource::Path {
12990 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12991 });
12992 let err = d.validate().unwrap_err();
12993 let DepError::FonteCaminhoShellBraceExpansion {
12994 nome,
12995 caminho,
12996 byte,
12997 } = err
12998 else {
12999 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13000 };
13001 assert_eq!(nome, "caixa-teia");
13002 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
13003 assert_eq!(byte, b'{');
13004 }
13005
13006 #[test]
13007 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
13008 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
13009 // the degenerate "I selected an unbalanced closing brace out
13010 // of a shell-history block" idiom that probes for the
13011 // cascade's last-byte handling on a value carrying only the
13012 // closing byte). Pinned separately from the open-brace shape
13013 // so the gate's contract is "any `{` or `}` anywhere", not
13014 // single-byte coverage. Mirrors the peer
13015 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
13016 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
13017 // arm.
13018 let d = dep_with_fonte(DepSource::Path {
13019 caminho: "../caixa-teia}".into(),
13020 });
13021 let err = d.validate().unwrap_err();
13022 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
13023 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13024 };
13025 assert_eq!(byte, b'}');
13026 }
13027
13028 #[test]
13029 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
13030 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
13031 // — the canonical "I selected a `{a,b}` brace-expansion prefix
13032 // out of a shell-history one-liner" idiom). Pinned separately
13033 // from the embedded-byte shape so the gate covers every
13034 // position, not only mid-path.
13035 let d = dep_with_fonte(DepSource::Path {
13036 caminho: "{caixa-teia,caixa-helm}/build".into(),
13037 });
13038 let err = d.validate().unwrap_err();
13039 assert!(
13040 matches!(
13041 err,
13042 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13043 ),
13044 "got {err:?}",
13045 );
13046 }
13047
13048 #[test]
13049 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
13050 // The canonical URI-Template / Mustache / Helm doubled-brace
13051 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
13052 // "I copied a `https://github.com/{{org}}/caixa-teia` README
13053 // quick-start / OpenAPI spec / Helm chart `home:` template
13054 // and forgot to substitute the placeholder" footgun). The arm
13055 // fires on the first `{` encountered; pinned so the gate's
13056 // coverage extends from the bare-brace shell-history shape to
13057 // the doubled-brace URI-Template / templating-engine shape.
13058 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
13059 // sibling `:fonte :repo` axis.
13060 let d = dep_with_fonte(DepSource::Path {
13061 caminho: "../{{org}}/caixa-teia".into(),
13062 });
13063 let err = d.validate().unwrap_err();
13064 assert!(
13065 matches!(
13066 err,
13067 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13068 ),
13069 "got {err:?}",
13070 );
13071 }
13072
13073 #[test]
13074 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
13075 // The canonical bash brace-range-expansion shape (`"../caixa-
13076 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
13077 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
13078 // sequence-range form to the `{a,b,c}` comma-separated form).
13079 // The arm fires on the first `{` encountered; pinned so the
13080 // gate's coverage extends from the comma-separated form to
13081 // the integer-range form.
13082 let d = dep_with_fonte(DepSource::Path {
13083 caminho: "../caixa-v{1..10}".into(),
13084 });
13085 let err = d.validate().unwrap_err();
13086 assert!(
13087 matches!(
13088 err,
13089 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13090 ),
13091 "got {err:?}",
13092 );
13093 }
13094
13095 #[test]
13096 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
13097 // The positive-control pin: the gate targets only `{` / `}`,
13098 // never adjacent printable ASCII or POSIX-valid bytes. The
13099 // canonical relative POSIX path (`"../caixa-teia"`) and a
13100 // nested deeply-pathed variant with adjacent printable
13101 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
13102 // validate cleanly so the gate doesn't widen to a "no
13103 // printable punctuation anywhere" sweep that would defeat
13104 // the entire path-fonte author surface. Peer with
13105 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
13106 // on the immediate-predecessor arm.
13107 let d = dep_with_fonte(DepSource::Path {
13108 caminho: "../caixa-teia/sub-dir.v2".into(),
13109 });
13110 d.validate().unwrap();
13111 }
13112
13113 #[test]
13114 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
13115 // Cascade pin on the immediate-predecessor arm: a value
13116 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
13117 // canonical "I pasted a subshell-grouping followed by a
13118 // brace-expansion tail" footgun) routes through
13119 // `FonteCaminhoShellSubshellGrouping` not
13120 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
13121 // shape is the more semantic-locating axis on every probe-
13122 // as-both value because it closes both halves of the modern
13123 // Bourne `$(<cmd>)` command-substitution surface — same
13124 // cascade discipline every prior `:caminho` arm establishes.
13125 let d = dep_with_fonte(DepSource::Path {
13126 caminho: "../(cd foo)/{a,b}".into(),
13127 });
13128 let err = d.validate().unwrap_err();
13129 assert!(
13130 matches!(
13131 err,
13132 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13133 ),
13134 "got {err:?}",
13135 );
13136 }
13137
13138 #[test]
13139 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
13140 // Cascade pin on the upstream shell-glob arm: a value carrying
13141 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
13142 // "I pasted a glob expansion followed by a brace-expansion
13143 // tail" footgun) routes through `FonteCaminhoShellGlob` not
13144 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
13145 // shape is the load-bearing root-cause edit on every
13146 // probe-as-both value.
13147 let d = dep_with_fonte(DepSource::Path {
13148 caminho: "../caixa-teia/*{a,b}".into(),
13149 });
13150 let err = d.validate().unwrap_err();
13151 assert!(
13152 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13153 "got {err:?}",
13154 );
13155 }
13156
13157 #[test]
13158 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
13159 // Cascade pin on the upstream shell-command-substitution arm:
13160 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
13161 // — the canonical "I pasted a legacy-backtick command-
13162 // substitution followed by a brace-expansion fan-out" footgun)
13163 // routes through `FonteCaminhoShellCommandSubstitution` not
13164 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
13165 // command-injection vector is the load-bearing root-cause
13166 // edit on every probe-as-both value.
13167 let d = dep_with_fonte(DepSource::Path {
13168 caminho: "../`whoami`/{a,b}".into(),
13169 });
13170 let err = d.validate().unwrap_err();
13171 assert!(
13172 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13173 "got {err:?}",
13174 );
13175 }
13176
13177 #[test]
13178 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
13179 // Cascade pin on the upstream shell-background arm: a value
13180 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
13181 // canonical "I pasted a `cmd & {fork-fan}` background-launch
13182 // + brace-expansion chain" footgun) routes through
13183 // `FonteCaminhoShellBackground` not
13184 // `FonteCaminhoShellBraceExpansion`. The background-launch
13185 // tail is the load-bearing root-cause edit on every
13186 // probe-as-both value.
13187 let d = dep_with_fonte(DepSource::Path {
13188 caminho: "../caixa-teia & {a,b}".into(),
13189 });
13190 let err = d.validate().unwrap_err();
13191 assert!(
13192 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13193 "got {err:?}",
13194 );
13195 }
13196
13197 #[test]
13198 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
13199 // Cascade pin on the upstream shell-semicolon arm: a value
13200 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
13201 // canonical sequential-cleanup + brace-expansion paste
13202 // idiom) routes through `FonteCaminhoShellSemicolon` not
13203 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
13204 // separator paste is the load-bearing root-cause edit on
13205 // every probe-as-both value.
13206 let d = dep_with_fonte(DepSource::Path {
13207 caminho: "../caixa-teia; {a,b}".into(),
13208 });
13209 let err = d.validate().unwrap_err();
13210 assert!(
13211 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13212 "got {err:?}",
13213 );
13214 }
13215
13216 #[test]
13217 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
13218 // Cascade pin on the upstream shell-pipe arm: a value
13219 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
13220 // — the canonical pipeline-to-brace-expansion paste idiom)
13221 // routes through `FonteCaminhoShellPipe` not
13222 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
13223 // is the load-bearing root-cause edit on every probe-as-
13224 // both value.
13225 let d = dep_with_fonte(DepSource::Path {
13226 caminho: "../caixa-teia | {tee,cat}".into(),
13227 });
13228 let err = d.validate().unwrap_err();
13229 assert!(
13230 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13231 "got {err:?}",
13232 );
13233 }
13234
13235 #[test]
13236 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
13237 // Cascade pin on the upstream shell-redirection arm: a value
13238 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
13239 // the canonical "I pasted a `cmd > log {a,b}` redirect-
13240 // plus-brace-expansion chain" footgun) routes through
13241 // `FonteCaminhoShellRedirection` not
13242 // `FonteCaminhoShellBraceExpansion`. The input/output
13243 // redirection metachar carries the more self-locating
13244 // `byte` payload, so the prior arm wins on every probe-
13245 // as-both value.
13246 let d = dep_with_fonte(DepSource::Path {
13247 caminho: "../caixa-teia>log {a,b}".into(),
13248 });
13249 let err = d.validate().unwrap_err();
13250 assert!(
13251 matches!(
13252 err,
13253 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13254 ),
13255 "got {err:?}",
13256 );
13257 }
13258
13259 #[test]
13260 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
13261 // Cascade pin on the upstream backslash arm: a value
13262 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
13263 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
13264 // chain") routes through `FonteCaminhoBackslash` not
13265 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
13266 // separator divergence is the load-bearing axis on every
13267 // probe-as-both value.
13268 let d = dep_with_fonte(DepSource::Path {
13269 caminho: "..\\caixa-teia\\{a,b}".into(),
13270 });
13271 let err = d.validate().unwrap_err();
13272 assert!(
13273 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13274 "got {err:?}",
13275 );
13276 }
13277
13278 #[test]
13279 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
13280 // Cascade pin on the embedded-control-byte arm: a value
13281 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
13282 // the canonical paste-from-multiline-doc footgun where a
13283 // newline landed mid-caminho between two paste fragments)
13284 // routes through `FonteCaminhoControlChar` not
13285 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
13286 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13287 // load-bearing axis on every value that probes positive for
13288 // both — mirrors the cascade discipline on every prior arm.
13289 let d = dep_with_fonte(DepSource::Path {
13290 caminho: "../foo\n{a,b}".into(),
13291 });
13292 let err = d.validate().unwrap_err();
13293 assert!(
13294 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13295 "got {err:?}",
13296 );
13297 }
13298
13299 #[test]
13300 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
13301 // Cascade pin on the load-bearing leading-byte arm: a
13302 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
13303 // routes through `FonteCaminhoAbsolute` not
13304 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
13305 // diagnostic is the load-bearing axis, the brace-expansion
13306 // byte is the secondary observation. Same precedence logic
13307 // as every prior leading-byte arm.
13308 let d = dep_with_fonte(DepSource::Path {
13309 caminho: "/etc/{a,b}".into(),
13310 });
13311 let err = d.validate().unwrap_err();
13312 assert!(
13313 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13314 "got {err:?}",
13315 );
13316 }
13317
13318 #[test]
13319 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
13320 // Cascade pin on the upstream leading-`$` var-expansion
13321 // arm: a value carrying both a leading `$` and a `{`
13322 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
13323 // `${ORG}` shell-variable + curly-brace expansion at the
13324 // head of a sibling-workspace path" footgun) routes through
13325 // `FonteCaminhoVarExpansion` not
13326 // `FonteCaminhoShellBraceExpansion`. The leading-byte
13327 // shell-variable-expansion is the more self-locating
13328 // diagnostic on values that probe as both — same
13329 // load-bearing-leading-byte cascade discipline every prior
13330 // `:caminho` arm establishes.
13331 let d = dep_with_fonte(DepSource::Path {
13332 caminho: "${ORG}/caixa-teia".into(),
13333 });
13334 let err = d.validate().unwrap_err();
13335 assert!(
13336 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13337 "got {err:?}",
13338 );
13339 }
13340
13341 #[test]
13342 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
13343 // Cascade pin on the immediate-successor arm: a value
13344 // carrying both `{` and a trailing `/`
13345 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
13346 // tab-completed a path that already had a brace-expansion
13347 // expansion tail" footgun) routes through
13348 // `FonteCaminhoShellBraceExpansion` not
13349 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13350 // is the more semantic-locating axis (an author who removes
13351 // the `{` typically also drops the trailing separator since
13352 // both are paste-from-shell artifacts).
13353 let d = dep_with_fonte(DepSource::Path {
13354 caminho: "../{caixa-teia,caixa-helm}/".into(),
13355 });
13356 let err = d.validate().unwrap_err();
13357 assert!(
13358 matches!(
13359 err,
13360 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13361 ),
13362 "got {err:?}",
13363 );
13364 }
13365
13366 #[test]
13367 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13368 // Diagnostic-shape pin (peer with
13369 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13370 // on the closest two-byte peer arm): the error's Display
13371 // surfaces the offending `:nome`, the offending `:caminho`
13372 // verbatim, the offending byte's hex / character form, and
13373 // names the shell-brace-expansion / URI-Template footgun
13374 // explicitly so a `feira lint` run can render the diagnostic
13375 // without re-parsing.
13376 let d = dep_with_fonte(DepSource::Path {
13377 caminho: "../{caixa-teia,caixa-helm}/build".into(),
13378 });
13379 let rendered = d.validate().unwrap_err().to_string();
13380 assert!(
13381 rendered.contains("caixa-teia"),
13382 "diagnostic must name the offending dep: {rendered}",
13383 );
13384 assert!(
13385 rendered.contains("../{caixa-teia,caixa-helm}/build"),
13386 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13387 );
13388 assert!(
13389 rendered.contains("0x7b"),
13390 "diagnostic must surface the offending byte hex: {rendered:?}",
13391 );
13392 assert!(
13393 rendered.contains("brace-expansion"),
13394 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
13395 );
13396 assert!(
13397 rendered.contains("URI Template"),
13398 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
13399 {rendered:?}",
13400 );
13401 }
13402
13403 #[test]
13404 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
13405 // The canonical paste-from-shell-history bracket-glob /
13406 // character-class footgun: an author copies a
13407 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
13408 // `[a-z]` POSIX glob character-class matches every lowercase-
13409 // ASCII-suffix sibling caixa directory and silently passed
13410 // every prior arm (`Path::is_absolute` false on `..`, no
13411 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
13412 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
13413 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
13414 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13415 // value starts with `..` not `$`). The lacre embedded the
13416 // value verbatim, the resolver folded it through
13417 // `Path::join` looking for a literal `./../caixa-[a-z]/
13418 // build` subdirectory, and the failure surfaced at resolve
13419 // time with a non-self-locating `No such file or directory`
13420 // error. The new arm moves the rejection to validate time
13421 // and names the offending dep + caminho + byte verbatim.
13422 // The arm fires on the first `[` encountered.
13423 let d = dep_with_fonte(DepSource::Path {
13424 caminho: "../caixa-[a-z]/build".into(),
13425 });
13426 let err = d.validate().unwrap_err();
13427 let DepError::FonteCaminhoShellBracketExpansion {
13428 nome,
13429 caminho,
13430 byte,
13431 } = err
13432 else {
13433 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13434 };
13435 assert_eq!(nome, "caixa-teia");
13436 assert_eq!(caminho, "../caixa-[a-z]/build");
13437 assert_eq!(byte, b'[');
13438 }
13439
13440 #[test]
13441 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13442 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13443 // — the degenerate "I selected an unbalanced closing bracket
13444 // out of a glob character-class block" idiom that probes for
13445 // the cascade's last-byte handling on a value carrying only
13446 // the closing byte). Pinned separately from the open-bracket
13447 // shape so the gate's contract is "any `[` or `]` anywhere",
13448 // not single-byte coverage. Mirrors the peer
13449 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13450 // shape on the immediate-predecessor
13451 // `FonteCaminhoShellBraceExpansion` arm.
13452 let d = dep_with_fonte(DepSource::Path {
13453 caminho: "../caixa-teia]".into(),
13454 });
13455 let err = d.validate().unwrap_err();
13456 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13457 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13458 };
13459 assert_eq!(byte, b']');
13460 }
13461
13462 #[test]
13463 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13464 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13465 // canonical "I selected a `[caixa-teia]` TOML-table-header /
13466 // glob-character-class prefix out of an aligned config /
13467 // shell-history one-liner" idiom). Pinned separately from
13468 // the embedded-byte shape so the gate covers every position,
13469 // not only mid-path.
13470 let d = dep_with_fonte(DepSource::Path {
13471 caminho: "[caixa-teia]/build".into(),
13472 });
13473 let err = d.validate().unwrap_err();
13474 assert!(
13475 matches!(
13476 err,
13477 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13478 ),
13479 "got {err:?}",
13480 );
13481 }
13482
13483 #[test]
13484 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13485 // The canonical TOML inline-array / YAML flow-sequence
13486 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13487 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13488 // inline-array out of a sibling-Cargo manifest" cross-idiom
13489 // leak; the symmetric YAML flow-sequence form `paths: [/a,
13490 // /b]` paste-from-values.yaml shape carries the same
13491 // bracket pair). The arm fires on the first `[` encountered;
13492 // pinned so the gate's coverage extends from the bare-
13493 // bracket glob-character-class shape to the TOML / YAML /
13494 // JSON array-literal shape.
13495 let d = dep_with_fonte(DepSource::Path {
13496 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13497 });
13498 let err = d.validate().unwrap_err();
13499 assert!(
13500 matches!(
13501 err,
13502 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13503 ),
13504 "got {err:?}",
13505 );
13506 }
13507
13508 #[test]
13509 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13510 // The canonical POSIX `test` / `[` builtin command paste
13511 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13512 // script conditional every paste-from-shell-script idiom
13513 // carries; bash's `[[ <expr> ]]` extended-test grammar
13514 // would surface the same byte pair). The arm fires on the
13515 // first `[` encountered; pinned so the gate's coverage
13516 // extends from the embedded-glob-character-class shape to
13517 // the leading-`test`-builtin / extended-test form.
13518 let d = dep_with_fonte(DepSource::Path {
13519 caminho: "../[ -d caixa-teia ]".into(),
13520 });
13521 let err = d.validate().unwrap_err();
13522 assert!(
13523 matches!(
13524 err,
13525 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13526 ),
13527 "got {err:?}",
13528 );
13529 }
13530
13531 #[test]
13532 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13533 // The positive-control pin: the gate targets only `[` /
13534 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13535 // The canonical relative POSIX path (`"../caixa-teia"`) and
13536 // a nested deeply-pathed variant with adjacent printable
13537 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13538 // to validate cleanly so the gate doesn't widen to a "no
13539 // printable punctuation anywhere" sweep that would defeat
13540 // the entire path-fonte author surface. Peer with
13541 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13542 // on the immediate-predecessor arm.
13543 let d = dep_with_fonte(DepSource::Path {
13544 caminho: "../caixa-teia/sub-dir.v2".into(),
13545 });
13546 d.validate().unwrap();
13547 }
13548
13549 #[test]
13550 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13551 // Cascade pin on the immediate-predecessor arm: a value
13552 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13553 // canonical "I pasted a brace-expansion fan followed by a
13554 // glob-character-class tail" footgun) routes through
13555 // `FonteCaminhoShellBraceExpansion` not
13556 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13557 // fan is the load-bearing root-cause edit on every
13558 // probe-as-both value because the bracket-class tail
13559 // typically rides on a prior brace-expansion expansion;
13560 // same cascade discipline every prior `:caminho` arm
13561 // establishes.
13562 let d = dep_with_fonte(DepSource::Path {
13563 caminho: "../{a,b}[ch]".into(),
13564 });
13565 let err = d.validate().unwrap_err();
13566 assert!(
13567 matches!(
13568 err,
13569 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13570 ),
13571 "got {err:?}",
13572 );
13573 }
13574
13575 #[test]
13576 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13577 // Cascade pin on the upstream shell-subshell-grouping arm:
13578 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13579 // the canonical "I pasted a subshell-grouping followed by
13580 // a glob-character-class tail" footgun) routes through
13581 // `FonteCaminhoShellSubshellGrouping` not
13582 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13583 // `$(<cmd>)` command-substitution boundary is the load-
13584 // bearing axis on every probe-as-both value.
13585 let d = dep_with_fonte(DepSource::Path {
13586 caminho: "../(cd foo)/[ch]".into(),
13587 });
13588 let err = d.validate().unwrap_err();
13589 assert!(
13590 matches!(
13591 err,
13592 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13593 ),
13594 "got {err:?}",
13595 );
13596 }
13597
13598 #[test]
13599 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13600 // Cascade pin on the upstream shell-glob arm: a value
13601 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13602 // canonical "I pasted a `*.[ch]` C-source-file glob whose
13603 // unbounded `*` precedes the bracket character-class"
13604 // footgun) routes through `FonteCaminhoShellGlob` not
13605 // `FonteCaminhoShellBracketExpansion`. The unbounded
13606 // pathname-expansion sentinel is the load-bearing root-
13607 // cause edit on every probe-as-both value — the unbounded
13608 // `*` carries the more aggressive expansion vector than
13609 // the bounded `[ch]` class, so the prior arm wins.
13610 let d = dep_with_fonte(DepSource::Path {
13611 caminho: "../caixa-teia/*[ch]".into(),
13612 });
13613 let err = d.validate().unwrap_err();
13614 assert!(
13615 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13616 "got {err:?}",
13617 );
13618 }
13619
13620 #[test]
13621 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13622 // Cascade pin on the upstream shell-command-substitution
13623 // arm: a value carrying both a backtick and `[`
13624 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13625 // legacy-backtick command-substitution followed by a
13626 // glob-character-class tail" footgun) routes through
13627 // `FonteCaminhoShellCommandSubstitution` not
13628 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13629 // command-injection vector is the load-bearing root-cause
13630 // edit on every probe-as-both value.
13631 let d = dep_with_fonte(DepSource::Path {
13632 caminho: "../`whoami`/[ch]".into(),
13633 });
13634 let err = d.validate().unwrap_err();
13635 assert!(
13636 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13637 "got {err:?}",
13638 );
13639 }
13640
13641 #[test]
13642 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13643 // Cascade pin on the upstream shell-background arm: a
13644 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13645 // — the canonical "I pasted a `cmd & [glob]` background-
13646 // launch + bracket-class chain" footgun) routes through
13647 // `FonteCaminhoShellBackground` not
13648 // `FonteCaminhoShellBracketExpansion`. The background-
13649 // launch tail is the load-bearing root-cause edit on
13650 // every probe-as-both value.
13651 let d = dep_with_fonte(DepSource::Path {
13652 caminho: "../caixa-teia & [ch]".into(),
13653 });
13654 let err = d.validate().unwrap_err();
13655 assert!(
13656 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13657 "got {err:?}",
13658 );
13659 }
13660
13661 #[test]
13662 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13663 // Cascade pin on the upstream shell-semicolon arm: a value
13664 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13665 // canonical sequential-cleanup + bracket-class paste
13666 // idiom) routes through `FonteCaminhoShellSemicolon` not
13667 // `FonteCaminhoShellBracketExpansion`. The sequential-
13668 // command-separator paste is the load-bearing root-cause
13669 // edit on every probe-as-both value.
13670 let d = dep_with_fonte(DepSource::Path {
13671 caminho: "../caixa-teia; [ch]".into(),
13672 });
13673 let err = d.validate().unwrap_err();
13674 assert!(
13675 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13676 "got {err:?}",
13677 );
13678 }
13679
13680 #[test]
13681 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13682 // Cascade pin on the upstream shell-pipe arm: a value
13683 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13684 // the canonical pipeline-to-bracket-class paste idiom)
13685 // routes through `FonteCaminhoShellPipe` not
13686 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13687 // paste is the load-bearing root-cause edit on every
13688 // probe-as-both value.
13689 let d = dep_with_fonte(DepSource::Path {
13690 caminho: "../caixa-teia | [tee]".into(),
13691 });
13692 let err = d.validate().unwrap_err();
13693 assert!(
13694 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13695 "got {err:?}",
13696 );
13697 }
13698
13699 #[test]
13700 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13701 // Cascade pin on the upstream shell-redirection arm: a
13702 // value carrying both `>` and `[` (`"../caixa-teia>log
13703 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13704 // redirect-plus-bracket chain" footgun) routes through
13705 // `FonteCaminhoShellRedirection` not
13706 // `FonteCaminhoShellBracketExpansion`. The input/output
13707 // redirection metachar carries the more self-locating
13708 // `byte` payload, so the prior arm wins on every
13709 // probe-as-both value.
13710 let d = dep_with_fonte(DepSource::Path {
13711 caminho: "../caixa-teia>log [ch]".into(),
13712 });
13713 let err = d.validate().unwrap_err();
13714 assert!(
13715 matches!(
13716 err,
13717 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13718 ),
13719 "got {err:?}",
13720 );
13721 }
13722
13723 #[test]
13724 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13725 // Cascade pin on the upstream backslash arm: a value
13726 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13727 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13728 // chain") routes through `FonteCaminhoBackslash` not
13729 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13730 // separator divergence is the load-bearing axis on every
13731 // probe-as-both value.
13732 let d = dep_with_fonte(DepSource::Path {
13733 caminho: "..\\caixa-teia\\[ch]".into(),
13734 });
13735 let err = d.validate().unwrap_err();
13736 assert!(
13737 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13738 "got {err:?}",
13739 );
13740 }
13741
13742 #[test]
13743 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13744 // Cascade pin on the embedded-control-byte arm: a value
13745 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13746 // the canonical paste-from-multiline-doc footgun where a
13747 // newline landed mid-caminho between two paste fragments)
13748 // routes through `FonteCaminhoControlChar` not
13749 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13750 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13751 // the load-bearing axis on every value that probes
13752 // positive for both — mirrors the cascade discipline on
13753 // every prior arm.
13754 let d = dep_with_fonte(DepSource::Path {
13755 caminho: "../foo\n[ch]".into(),
13756 });
13757 let err = d.validate().unwrap_err();
13758 assert!(
13759 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13760 "got {err:?}",
13761 );
13762 }
13763
13764 #[test]
13765 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13766 // Cascade pin on the load-bearing leading-byte arm: a
13767 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13768 // routes through `FonteCaminhoAbsolute` not
13769 // `FonteCaminhoShellBracketExpansion` — the host-layout-
13770 // leak diagnostic is the load-bearing axis, the bracket-
13771 // expansion byte is the secondary observation. Same
13772 // precedence logic as every prior leading-byte arm.
13773 let d = dep_with_fonte(DepSource::Path {
13774 caminho: "/etc/[ch]".into(),
13775 });
13776 let err = d.validate().unwrap_err();
13777 assert!(
13778 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13779 "got {err:?}",
13780 );
13781 }
13782
13783 #[test]
13784 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13785 // Cascade pin on the upstream leading-`$` var-expansion
13786 // arm: a value carrying both a leading `$` and a `[`
13787 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13788 // variable + bracket-class at the head of a sibling-
13789 // workspace path" footgun) routes through
13790 // `FonteCaminhoVarExpansion` not
13791 // `FonteCaminhoShellBracketExpansion`. The leading-byte
13792 // shell-variable-expansion is the more self-locating
13793 // diagnostic on values that probe as both — same
13794 // load-bearing-leading-byte cascade discipline every
13795 // prior `:caminho` arm establishes.
13796 let d = dep_with_fonte(DepSource::Path {
13797 caminho: "$DIR/[ch]".into(),
13798 });
13799 let err = d.validate().unwrap_err();
13800 assert!(
13801 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13802 "got {err:?}",
13803 );
13804 }
13805
13806 #[test]
13807 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13808 // Cascade pin on the immediate-successor arm: a value
13809 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13810 // the canonical "I tab-completed a path that already had
13811 // a bracket-glob-character-class expansion tail" footgun)
13812 // routes through `FonteCaminhoShellBracketExpansion` not
13813 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13814 // is the more semantic-locating axis (an author who
13815 // removes the `[` typically also drops the trailing
13816 // separator since both are paste-from-shell artifacts).
13817 let d = dep_with_fonte(DepSource::Path {
13818 caminho: "../[a-z]/".into(),
13819 });
13820 let err = d.validate().unwrap_err();
13821 assert!(
13822 matches!(
13823 err,
13824 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13825 ),
13826 "got {err:?}",
13827 );
13828 }
13829
13830 #[test]
13831 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13832 // Diagnostic-shape pin (peer with
13833 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13834 // on the closest two-byte peer arm): the error's Display
13835 // surfaces the offending `:nome`, the offending `:caminho`
13836 // verbatim, the offending byte's hex / character form, and
13837 // names the shell-bracket-expansion / glob-character-class
13838 // footgun explicitly so a `feira lint` run can render the
13839 // diagnostic without re-parsing.
13840 let d = dep_with_fonte(DepSource::Path {
13841 caminho: "../caixa-[a-z]/build".into(),
13842 });
13843 let rendered = d.validate().unwrap_err().to_string();
13844 assert!(
13845 rendered.contains("caixa-teia"),
13846 "diagnostic must name the offending dep: {rendered}",
13847 );
13848 assert!(
13849 rendered.contains("../caixa-[a-z]/build"),
13850 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13851 );
13852 assert!(
13853 rendered.contains("0x5b"),
13854 "diagnostic must surface the offending byte hex: {rendered:?}",
13855 );
13856 assert!(
13857 rendered.contains("bracket-expansion"),
13858 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13859 );
13860 assert!(
13861 rendered.contains("glob-character-class"),
13862 "diagnostic must reference the POSIX glob-character-class vocabulary: \
13863 {rendered:?}",
13864 );
13865 }
13866
13867 #[test]
13868 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13869 // The canonical paste-from-shell-history strong-quoted
13870 // sibling-workspace-path footgun: an author copies a
13871 // `cd '../caixa-teia'` shell-history one-liner whose strong-
13872 // quoting preserved the path across a whitespace paste
13873 // boundary and silently passed every prior arm
13874 // (`Path::is_absolute` false on `'..`, no control bytes, no
13875 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13876 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13877 // doesn't end in `/`; the leading-`$` f4efe9c
13878 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13879 // value starts with `'` not `$`). The lacre embedded the
13880 // value verbatim, the resolver folded it through
13881 // `Path::join` looking for a literal `./'../caixa-teia'`
13882 // subdirectory, and the failure surfaced at resolve time
13883 // with a non-self-locating `No such file or directory`
13884 // error. The new arm moves the rejection to validate time
13885 // and names the offending dep + caminho + byte verbatim.
13886 // The arm fires on the first `'` encountered.
13887 let d = dep_with_fonte(DepSource::Path {
13888 caminho: "'../caixa-teia'".into(),
13889 });
13890 let err = d.validate().unwrap_err();
13891 let DepError::FonteCaminhoShellQuoteGrouping {
13892 nome,
13893 caminho,
13894 byte,
13895 } = err
13896 else {
13897 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13898 };
13899 assert_eq!(nome, "caixa-teia");
13900 assert_eq!(caminho, "'../caixa-teia'");
13901 assert_eq!(byte, b'\'');
13902 }
13903
13904 #[test]
13905 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13906 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13907 // — the canonical paste-from-JSON-config / paste-from-YAML-
13908 // flow-scalar / paste-from-TOML-basic-string / paste-from-
13909 // tatara-lisp-string-literal cross-idiom leak). Pinned
13910 // separately from the single-quote shape so the gate's
13911 // contract is "any `'` or `\"` anywhere", not single-byte
13912 // coverage. Mirrors the peer
13913 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13914 // shape on the immediate-predecessor
13915 // `FonteCaminhoShellBracketExpansion` arm.
13916 let d = dep_with_fonte(DepSource::Path {
13917 caminho: "\"../caixa-teia\"".into(),
13918 });
13919 let err = d.validate().unwrap_err();
13920 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13921 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13922 };
13923 assert_eq!(byte, b'"');
13924 }
13925
13926 #[test]
13927 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13928 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13929 // canonical "I pasted a JSON key-value pair fragment into
13930 // the middle of the path" idiom). Pinned separately from
13931 // the leading-byte shape so the gate covers every position,
13932 // not only leading.
13933 let d = dep_with_fonte(DepSource::Path {
13934 caminho: "../\"caixa-teia\"".into(),
13935 });
13936 let err = d.validate().unwrap_err();
13937 assert!(
13938 matches!(
13939 err,
13940 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13941 ),
13942 "got {err:?}",
13943 );
13944 }
13945
13946 #[test]
13947 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13948 // The canonical YAML double-quoted flow-scalar cross-idiom
13949 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13950 // `path: \"...\"` YAML flow-scalar entry out of an aligned
13951 // values.yaml / K8s manifest and dropped it verbatim into
13952 // the `:caminho` slot including the `path: ` key prefix"
13953 // paste-idiom). The arm fires on the first `"` encountered;
13954 // pinned so the gate's coverage extends from the bare-quote
13955 // paste shape to the aligned-YAML-manifest cross-idiom-leak
13956 // shape.
13957 let d = dep_with_fonte(DepSource::Path {
13958 caminho: "path: \"../caixa-teia\"".into(),
13959 });
13960 let err = d.validate().unwrap_err();
13961 assert!(
13962 matches!(
13963 err,
13964 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13965 ),
13966 "got {err:?}",
13967 );
13968 }
13969
13970 #[test]
13971 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13972 // The positive-control pin: the gate targets only `'` /
13973 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13974 // The canonical relative POSIX path (`"../caixa-teia"`) and
13975 // a nested deeply-pathed variant with adjacent printable
13976 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13977 // to validate cleanly so the gate doesn't widen to a "no
13978 // printable punctuation anywhere" sweep that would defeat
13979 // the entire path-fonte author surface. Peer with
13980 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13981 // on the immediate-predecessor arm.
13982 let d = dep_with_fonte(DepSource::Path {
13983 caminho: "../caixa-teia/sub-dir.v2".into(),
13984 });
13985 d.validate().unwrap();
13986 }
13987
13988 #[test]
13989 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13990 // Cascade pin on the immediate-predecessor arm: a value
13991 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13992 // "I pasted a glob-character-class followed by a strong-
13993 // quoted literal tail" footgun) routes through
13994 // `FonteCaminhoShellBracketExpansion` not
13995 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13996 // expansion is the load-bearing root-cause edit on every
13997 // probe-as-both value; same cascade discipline every prior
13998 // `:caminho` arm establishes.
13999 let d = dep_with_fonte(DepSource::Path {
14000 caminho: "../[a-z]'x'".into(),
14001 });
14002 let err = d.validate().unwrap_err();
14003 assert!(
14004 matches!(
14005 err,
14006 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14007 ),
14008 "got {err:?}",
14009 );
14010 }
14011
14012 #[test]
14013 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
14014 // Cascade pin on the upstream shell-brace-expansion arm: a
14015 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
14016 // canonical "I pasted a brace-expansion fan followed by a
14017 // strong-quoted literal tail" footgun) routes through
14018 // `FonteCaminhoShellBraceExpansion` not
14019 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
14020 // is the load-bearing root-cause edit on every probe-as-
14021 // both value.
14022 let d = dep_with_fonte(DepSource::Path {
14023 caminho: "../{a,b}'x'".into(),
14024 });
14025 let err = d.validate().unwrap_err();
14026 assert!(
14027 matches!(
14028 err,
14029 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14030 ),
14031 "got {err:?}",
14032 );
14033 }
14034
14035 #[test]
14036 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
14037 // Cascade pin on the upstream shell-subshell-grouping arm:
14038 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
14039 // the canonical "I pasted a subshell-grouping followed by
14040 // a strong-quoted literal tail" footgun) routes through
14041 // `FonteCaminhoShellSubshellGrouping` not
14042 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
14043 // `$(<cmd>)` command-substitution boundary is the load-
14044 // bearing axis on every probe-as-both value.
14045 let d = dep_with_fonte(DepSource::Path {
14046 caminho: "../(cd foo)/'x'".into(),
14047 });
14048 let err = d.validate().unwrap_err();
14049 assert!(
14050 matches!(
14051 err,
14052 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14053 ),
14054 "got {err:?}",
14055 );
14056 }
14057
14058 #[test]
14059 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
14060 // Cascade pin on the upstream shell-glob arm: a value
14061 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
14062 // canonical "I pasted a `*` unbounded pathname-expansion
14063 // followed by a strong-quoted literal tail" footgun) routes
14064 // through `FonteCaminhoShellGlob` not
14065 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
14066 // expansion sentinel is the load-bearing root-cause edit
14067 // on every probe-as-both value.
14068 let d = dep_with_fonte(DepSource::Path {
14069 caminho: "../caixa-teia/*'x'".into(),
14070 });
14071 let err = d.validate().unwrap_err();
14072 assert!(
14073 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14074 "got {err:?}",
14075 );
14076 }
14077
14078 #[test]
14079 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
14080 // Cascade pin on the upstream shell-command-substitution
14081 // arm: a value carrying both a backtick and `'`
14082 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
14083 // legacy-backtick command-substitution followed by a
14084 // strong-quoted literal tail" footgun) routes through
14085 // `FonteCaminhoShellCommandSubstitution` not
14086 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
14087 // command-injection vector is the load-bearing root-cause
14088 // edit on every probe-as-both value.
14089 let d = dep_with_fonte(DepSource::Path {
14090 caminho: "../`whoami`/'x'".into(),
14091 });
14092 let err = d.validate().unwrap_err();
14093 assert!(
14094 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14095 "got {err:?}",
14096 );
14097 }
14098
14099 #[test]
14100 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
14101 // Cascade pin on the upstream shell-background arm: a value
14102 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
14103 // canonical "I pasted a `cmd & 'literal'` background-launch
14104 // + quote chain" footgun) routes through
14105 // `FonteCaminhoShellBackground` not
14106 // `FonteCaminhoShellQuoteGrouping`. The background-launch
14107 // tail is the load-bearing root-cause edit on every
14108 // probe-as-both value.
14109 let d = dep_with_fonte(DepSource::Path {
14110 caminho: "../caixa-teia & 'x'".into(),
14111 });
14112 let err = d.validate().unwrap_err();
14113 assert!(
14114 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14115 "got {err:?}",
14116 );
14117 }
14118
14119 #[test]
14120 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
14121 // Cascade pin on the upstream shell-semicolon arm: a value
14122 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
14123 // canonical sequential-cleanup + quote paste idiom) routes
14124 // through `FonteCaminhoShellSemicolon` not
14125 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
14126 // separator paste is the load-bearing root-cause edit on
14127 // every probe-as-both value.
14128 let d = dep_with_fonte(DepSource::Path {
14129 caminho: "../caixa-teia; 'x'".into(),
14130 });
14131 let err = d.validate().unwrap_err();
14132 assert!(
14133 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14134 "got {err:?}",
14135 );
14136 }
14137
14138 #[test]
14139 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
14140 // Cascade pin on the upstream shell-pipe arm: a value
14141 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
14142 // canonical pipeline-to-quoted-literal paste idiom) routes
14143 // through `FonteCaminhoShellPipe` not
14144 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
14145 // is the load-bearing root-cause edit on every probe-as-
14146 // both value.
14147 let d = dep_with_fonte(DepSource::Path {
14148 caminho: "../caixa-teia | 'x'".into(),
14149 });
14150 let err = d.validate().unwrap_err();
14151 assert!(
14152 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14153 "got {err:?}",
14154 );
14155 }
14156
14157 #[test]
14158 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
14159 // Cascade pin on the upstream shell-redirection arm: a
14160 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
14161 // — the canonical "I pasted a `cmd > log 'literal'`
14162 // redirect-plus-quote chain" footgun) routes through
14163 // `FonteCaminhoShellRedirection` not
14164 // `FonteCaminhoShellQuoteGrouping`. The input/output
14165 // redirection metachar carries the more self-locating
14166 // `byte` payload, so the prior arm wins on every probe-as-
14167 // both value.
14168 let d = dep_with_fonte(DepSource::Path {
14169 caminho: "../caixa-teia>log 'x'".into(),
14170 });
14171 let err = d.validate().unwrap_err();
14172 assert!(
14173 matches!(
14174 err,
14175 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14176 ),
14177 "got {err:?}",
14178 );
14179 }
14180
14181 #[test]
14182 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
14183 // Cascade pin on the upstream backslash arm: a value
14184 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
14185 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
14186 // chain" footgun) routes through `FonteCaminhoBackslash`
14187 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
14188 // separator divergence is the load-bearing axis on every
14189 // probe-as-both value.
14190 let d = dep_with_fonte(DepSource::Path {
14191 caminho: "..\\caixa-teia\\'x'".into(),
14192 });
14193 let err = d.validate().unwrap_err();
14194 assert!(
14195 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14196 "got {err:?}",
14197 );
14198 }
14199
14200 #[test]
14201 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
14202 // Cascade pin on the embedded-control-byte arm: a value
14203 // carrying both a control byte and `'` (`"../foo\n'x'"` —
14204 // the canonical paste-from-multiline-doc footgun where a
14205 // newline landed mid-caminho between two paste fragments)
14206 // routes through `FonteCaminhoControlChar` not
14207 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
14208 // rejected-byte / NUL-`CString::new`-fail diagnostic is
14209 // the load-bearing axis on every value that probes
14210 // positive for both — mirrors the cascade discipline on
14211 // every prior arm.
14212 let d = dep_with_fonte(DepSource::Path {
14213 caminho: "../foo\n'x'".into(),
14214 });
14215 let err = d.validate().unwrap_err();
14216 assert!(
14217 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14218 "got {err:?}",
14219 );
14220 }
14221
14222 #[test]
14223 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
14224 // Cascade pin on the load-bearing leading-byte arm: a
14225 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
14226 // through `FonteCaminhoAbsolute` not
14227 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
14228 // diagnostic is the load-bearing axis, the quote byte is
14229 // the secondary observation. Same precedence logic as every
14230 // prior leading-byte arm.
14231 let d = dep_with_fonte(DepSource::Path {
14232 caminho: "/etc/'x'".into(),
14233 });
14234 let err = d.validate().unwrap_err();
14235 assert!(
14236 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14237 "got {err:?}",
14238 );
14239 }
14240
14241 #[test]
14242 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
14243 // Cascade pin on the upstream leading-`$` var-expansion
14244 // arm: a value carrying both a leading `$` and a `'`
14245 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
14246 // variable + quoted literal at the head of a sibling-
14247 // workspace path" footgun) routes through
14248 // `FonteCaminhoVarExpansion` not
14249 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
14250 // shell-variable-expansion is the more self-locating
14251 // diagnostic on values that probe as both — same
14252 // load-bearing-leading-byte cascade discipline every
14253 // prior `:caminho` arm establishes.
14254 let d = dep_with_fonte(DepSource::Path {
14255 caminho: "$DIR/'x'".into(),
14256 });
14257 let err = d.validate().unwrap_err();
14258 assert!(
14259 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14260 "got {err:?}",
14261 );
14262 }
14263
14264 #[test]
14265 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
14266 // Cascade pin on the immediate-successor arm: a value
14267 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
14268 // — the canonical "I tab-completed a path whose strong-
14269 // quoted body already carried the quoting from a shell-
14270 // history paste" footgun) routes through
14271 // `FonteCaminhoShellQuoteGrouping` not
14272 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14273 // is the more semantic-locating axis (an author who removes
14274 // the `'` typically also drops the trailing separator since
14275 // both are paste-from-shell artifacts).
14276 let d = dep_with_fonte(DepSource::Path {
14277 caminho: "../'caixa-teia'/".into(),
14278 });
14279 let err = d.validate().unwrap_err();
14280 assert!(
14281 matches!(
14282 err,
14283 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14284 ),
14285 "got {err:?}",
14286 );
14287 }
14288
14289 #[test]
14290 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
14291 // Diagnostic-shape pin (peer with
14292 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14293 // on the closest two-byte peer arm): the error's Display
14294 // surfaces the offending `:nome`, the offending `:caminho`
14295 // verbatim, the offending byte's hex / character form, and
14296 // names the shell-quote-grouping / cross-config-DSL-string-
14297 // literal-delimiter footgun explicitly so a `feira lint`
14298 // run can render the diagnostic without re-parsing.
14299 let d = dep_with_fonte(DepSource::Path {
14300 caminho: "'../caixa-teia'".into(),
14301 });
14302 let rendered = d.validate().unwrap_err().to_string();
14303 assert!(
14304 rendered.contains("caixa-teia"),
14305 "diagnostic must name the offending dep: {rendered}",
14306 );
14307 assert!(
14308 rendered.contains("'../caixa-teia'"),
14309 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14310 );
14311 assert!(
14312 rendered.contains("0x27"),
14313 "diagnostic must surface the offending byte hex: {rendered:?}",
14314 );
14315 assert!(
14316 rendered.contains("quote-grouping"),
14317 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
14318 );
14319 assert!(
14320 rendered.contains("string-literal"),
14321 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
14322 vocabulary: {rendered:?}",
14323 );
14324 }
14325
14326 #[test]
14327 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
14328 // The canonical paste-from-shell-history-with-trailing-
14329 // annotation footgun: an author pastes a `cd ../caixa-teia
14330 // # legacy sibling` shell-history one-liner whose unquoted `#`
14331 // comment-lead separates the path from an inline annotation.
14332 // The POSIX shell trims the annotation to `../caixa-teia`
14333 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
14334 // `Path::is_absolute` returns false on `..`, `#` is neither
14335 // a leading-byte sentinel nor a control byte nor `\` nor
14336 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
14337 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
14338 // `"`, and the value's last byte isn't `/` — so the value
14339 // silently passed every prior arm. The resolver folded the
14340 // value through `Path::join` looking for a literal
14341 // `./../caixa-teia # legacy sibling` subdirectory and the
14342 // failure surfaced at resolve time with a non-self-locating
14343 // `No such file or directory` error. The new arm moves the
14344 // rejection to validate time and names the offending dep +
14345 // caminho + byte verbatim.
14346 let d = dep_with_fonte(DepSource::Path {
14347 caminho: "../caixa-teia # legacy sibling".into(),
14348 });
14349 let err = d.validate().unwrap_err();
14350 let DepError::FonteCaminhoShellComment {
14351 nome,
14352 caminho,
14353 byte,
14354 } = err
14355 else {
14356 panic!("expected FonteCaminhoShellComment, got {err:?}");
14357 };
14358 assert_eq!(nome, "caixa-teia");
14359 assert_eq!(caminho, "../caixa-teia # legacy sibling");
14360 assert_eq!(byte, b'#');
14361 }
14362
14363 #[test]
14364 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
14365 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
14366 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
14367 // canonical "I copied a `path: ../caixa-teia # pin` YAML
14368 // scalar-plus-comment entry out of an aligned values.yaml and
14369 // dropped it verbatim into the `:caminho` slot" paste-idiom).
14370 // Pinned separately from the shell-history shape so the
14371 // gate's coverage extends from the single-space `#` shape to
14372 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
14373 // requires the `#` to be preceded by whitespace to lex as a
14374 // comment (bare `foo#bar` is a single scalar); the double-
14375 // space paste from an aligned manifest is the canonical
14376 // shape.
14377 let d = dep_with_fonte(DepSource::Path {
14378 caminho: "../caixa-teia # pin".into(),
14379 });
14380 let err = d.validate().unwrap_err();
14381 assert!(
14382 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14383 "got {err:?}",
14384 );
14385 }
14386
14387 #[test]
14388 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
14389 // The URL-fragment-identifier paste shape
14390 // (`"../caixa-teia#readme"` — the canonical
14391 // paste-from-browser-address-bar permalink shape where the
14392 // browser preserved the `#anchor` tail on the copy). Pinned
14393 // separately from the whitespace-separated shell / YAML
14394 // comment shapes so the gate covers the unpadded RFC 3986
14395 // §3.5 fragment-delimiter position too, not only positions
14396 // preceded by unquoted whitespace. Peer with the immediate-
14397 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
14398 // (a68f818) which closes the same byte under the same URL-
14399 // fragment-identifier banner.
14400 let d = dep_with_fonte(DepSource::Path {
14401 caminho: "../caixa-teia#readme".into(),
14402 });
14403 let err = d.validate().unwrap_err();
14404 assert!(
14405 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14406 "got {err:?}",
14407 );
14408 }
14409
14410 #[test]
14411 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
14412 // Leading-position `#` shape (`"#../caixa-teia"` — the
14413 // "I copied a shell-comment-out entry from a commented-out
14414 // dep row" footgun). Pinned separately from the embedded
14415 // shapes so the gate covers every position, not only
14416 // whitespace-preceded / mid-value.
14417 let d = dep_with_fonte(DepSource::Path {
14418 caminho: "#../caixa-teia".into(),
14419 });
14420 let err = d.validate().unwrap_err();
14421 assert!(
14422 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14423 "got {err:?}",
14424 );
14425 }
14426
14427 #[test]
14428 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
14429 // The positive-control pin: the gate targets only `#`,
14430 // never adjacent printable ASCII or POSIX-valid bytes. The
14431 // canonical relative POSIX path (`"../caixa-teia"`) and a
14432 // nested deeply-pathed variant with adjacent printable
14433 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14434 // to validate cleanly so the gate doesn't widen to a "no
14435 // printable punctuation anywhere" sweep that would defeat
14436 // the entire path-fonte author surface. Peer with
14437 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
14438 // on the immediate-predecessor arm.
14439 let d = dep_with_fonte(DepSource::Path {
14440 caminho: "../caixa-teia/sub-dir.v2".into(),
14441 });
14442 d.validate().unwrap();
14443 }
14444
14445 #[test]
14446 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14447 // Cascade pin on the immediate-predecessor arm: a value
14448 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14449 // "I pasted a strong-quoted literal followed by a URL-
14450 // fragment permalink tail" footgun) routes through
14451 // `FonteCaminhoShellQuoteGrouping` not
14452 // `FonteCaminhoShellComment`. The shell-string-literal-
14453 // delimiter is the load-bearing root-cause edit on every
14454 // probe-as-both value; same cascade discipline every prior
14455 // `:caminho` arm establishes.
14456 let d = dep_with_fonte(DepSource::Path {
14457 caminho: "../'x'#pin".into(),
14458 });
14459 let err = d.validate().unwrap_err();
14460 assert!(
14461 matches!(
14462 err,
14463 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14464 ),
14465 "got {err:?}",
14466 );
14467 }
14468
14469 #[test]
14470 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14471 // Cascade pin on the upstream shell-bracket-expansion arm:
14472 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14473 // canonical "I pasted a glob-character-class followed by a
14474 // URL-fragment tail" footgun) routes through
14475 // `FonteCaminhoShellBracketExpansion` not
14476 // `FonteCaminhoShellComment`. The glob-character-class
14477 // expansion is the load-bearing root-cause edit on every
14478 // probe-as-both value.
14479 let d = dep_with_fonte(DepSource::Path {
14480 caminho: "../[a-z]#pin".into(),
14481 });
14482 let err = d.validate().unwrap_err();
14483 assert!(
14484 matches!(
14485 err,
14486 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14487 ),
14488 "got {err:?}",
14489 );
14490 }
14491
14492 #[test]
14493 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14494 // Cascade pin on the upstream shell-brace-expansion arm: a
14495 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14496 // canonical "I pasted a brace-expansion fan followed by a
14497 // URL-fragment tail" footgun) routes through
14498 // `FonteCaminhoShellBraceExpansion` not
14499 // `FonteCaminhoShellComment`. The brace-expansion fan is the
14500 // load-bearing root-cause edit on every probe-as-both value.
14501 let d = dep_with_fonte(DepSource::Path {
14502 caminho: "../{a,b}#pin".into(),
14503 });
14504 let err = d.validate().unwrap_err();
14505 assert!(
14506 matches!(
14507 err,
14508 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14509 ),
14510 "got {err:?}",
14511 );
14512 }
14513
14514 #[test]
14515 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14516 // Cascade pin on the upstream shell-subshell-grouping arm:
14517 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14518 // the canonical "I pasted a subshell-grouping followed by a
14519 // URL-fragment tail" footgun) routes through
14520 // `FonteCaminhoShellSubshellGrouping` not
14521 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14522 // command-substitution boundary is the load-bearing axis on
14523 // every probe-as-both value.
14524 let d = dep_with_fonte(DepSource::Path {
14525 caminho: "../(cd foo)#pin".into(),
14526 });
14527 let err = d.validate().unwrap_err();
14528 assert!(
14529 matches!(
14530 err,
14531 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14532 ),
14533 "got {err:?}",
14534 );
14535 }
14536
14537 #[test]
14538 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14539 // Cascade pin on the upstream shell-glob arm: a value
14540 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14541 // canonical "I pasted a `*` unbounded pathname-expansion
14542 // followed by a URL-fragment tail" footgun) routes through
14543 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14544 // The unbounded pathname-expansion sentinel is the load-
14545 // bearing root-cause edit on every probe-as-both value.
14546 let d = dep_with_fonte(DepSource::Path {
14547 caminho: "../caixa-teia/*#pin".into(),
14548 });
14549 let err = d.validate().unwrap_err();
14550 assert!(
14551 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14552 "got {err:?}",
14553 );
14554 }
14555
14556 #[test]
14557 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14558 // Cascade pin on the upstream shell-command-substitution
14559 // arm: a value carrying both a backtick and `#`
14560 // (``"../`whoami`#pin"`` — the canonical "I pasted a
14561 // legacy-backtick command-substitution followed by a URL-
14562 // fragment tail" footgun) routes through
14563 // `FonteCaminhoShellCommandSubstitution` not
14564 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14565 // injection vector is the load-bearing root-cause edit on
14566 // every probe-as-both value.
14567 let d = dep_with_fonte(DepSource::Path {
14568 caminho: "../`whoami`#pin".into(),
14569 });
14570 let err = d.validate().unwrap_err();
14571 assert!(
14572 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14573 "got {err:?}",
14574 );
14575 }
14576
14577 #[test]
14578 fn fonte_caminho_shell_background_fires_before_shell_comment() {
14579 // Cascade pin on the upstream shell-background arm: a value
14580 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14581 // the canonical "I pasted a `cmd &` background-launch
14582 // followed by a URL-fragment tail" footgun) routes through
14583 // `FonteCaminhoShellBackground` not
14584 // `FonteCaminhoShellComment`. The background-launch tail is
14585 // the load-bearing root-cause edit on every probe-as-both
14586 // value.
14587 let d = dep_with_fonte(DepSource::Path {
14588 caminho: "../caixa-teia&pin#tail".into(),
14589 });
14590 let err = d.validate().unwrap_err();
14591 assert!(
14592 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14593 "got {err:?}",
14594 );
14595 }
14596
14597 #[test]
14598 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14599 // Cascade pin on the upstream shell-semicolon arm: a value
14600 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14601 // the canonical sequential-cleanup + URL-fragment paste
14602 // idiom) routes through `FonteCaminhoShellSemicolon` not
14603 // `FonteCaminhoShellComment`. The sequential-command-
14604 // separator paste is the load-bearing root-cause edit on
14605 // every probe-as-both value.
14606 let d = dep_with_fonte(DepSource::Path {
14607 caminho: "../caixa-teia;pin#tail".into(),
14608 });
14609 let err = d.validate().unwrap_err();
14610 assert!(
14611 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14612 "got {err:?}",
14613 );
14614 }
14615
14616 #[test]
14617 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14618 // Cascade pin on the upstream shell-pipe arm: a value
14619 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14620 // the canonical pipeline-to-URL-fragment paste idiom) routes
14621 // through `FonteCaminhoShellPipe` not
14622 // `FonteCaminhoShellComment`. The pipeline-tail paste is
14623 // the load-bearing root-cause edit on every probe-as-both
14624 // value.
14625 let d = dep_with_fonte(DepSource::Path {
14626 caminho: "../caixa-teia|pin#tail".into(),
14627 });
14628 let err = d.validate().unwrap_err();
14629 assert!(
14630 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14631 "got {err:?}",
14632 );
14633 }
14634
14635 #[test]
14636 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14637 // Cascade pin on the upstream shell-redirection arm: a
14638 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14639 // — the canonical "I pasted a `cmd > log` redirect followed
14640 // by a URL-fragment tail" footgun) routes through
14641 // `FonteCaminhoShellRedirection` not
14642 // `FonteCaminhoShellComment`. The input/output redirection
14643 // metachar carries the more self-locating `byte` payload,
14644 // so the prior arm wins on every probe-as-both value.
14645 let d = dep_with_fonte(DepSource::Path {
14646 caminho: "../caixa-teia>log#pin".into(),
14647 });
14648 let err = d.validate().unwrap_err();
14649 assert!(
14650 matches!(
14651 err,
14652 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14653 ),
14654 "got {err:?}",
14655 );
14656 }
14657
14658 #[test]
14659 fn fonte_caminho_backslash_fires_before_shell_comment() {
14660 // Cascade pin on the upstream backslash arm: a value
14661 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14662 // canonical "I pasted a Windows-shell path followed by a
14663 // URL-fragment tail" footgun) routes through
14664 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14665 // The cross-host-OS-separator divergence is the load-
14666 // bearing axis on every probe-as-both value.
14667 let d = dep_with_fonte(DepSource::Path {
14668 caminho: "..\\caixa-teia#pin".into(),
14669 });
14670 let err = d.validate().unwrap_err();
14671 assert!(
14672 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14673 "got {err:?}",
14674 );
14675 }
14676
14677 #[test]
14678 fn fonte_caminho_control_char_fires_before_shell_comment() {
14679 // Cascade pin on the embedded-control-byte arm: a value
14680 // carrying both a control byte and `#` (`"../foo\n#pin"` —
14681 // the canonical paste-from-multiline-doc footgun where a
14682 // newline landed mid-caminho between the path and an
14683 // annotation) routes through `FonteCaminhoControlChar` not
14684 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14685 // byte diagnostic is the load-bearing axis on every value
14686 // that probes positive for both — mirrors the cascade
14687 // discipline on every prior arm.
14688 let d = dep_with_fonte(DepSource::Path {
14689 caminho: "../foo\n#pin".into(),
14690 });
14691 let err = d.validate().unwrap_err();
14692 assert!(
14693 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14694 "got {err:?}",
14695 );
14696 }
14697
14698 #[test]
14699 fn fonte_caminho_absolute_fires_before_shell_comment() {
14700 // Cascade pin on the load-bearing leading-byte arm: a
14701 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14702 // routes through `FonteCaminhoAbsolute` not
14703 // `FonteCaminhoShellComment` — the host-layout-leak
14704 // diagnostic is the load-bearing axis, the fragment byte is
14705 // the secondary observation. Same precedence logic as every
14706 // prior leading-byte arm.
14707 let d = dep_with_fonte(DepSource::Path {
14708 caminho: "/etc/foo#pin".into(),
14709 });
14710 let err = d.validate().unwrap_err();
14711 assert!(
14712 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14713 "got {err:?}",
14714 );
14715 }
14716
14717 #[test]
14718 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14719 // Cascade pin on the upstream leading-`$` var-expansion
14720 // arm: a value carrying both a leading `$` and a `#`
14721 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14722 // shell-variable at the head of a sibling-workspace path
14723 // followed by a URL-fragment tail" footgun) routes through
14724 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14725 // The leading-byte shell-variable-expansion is the more
14726 // self-locating diagnostic on values that probe as both.
14727 let d = dep_with_fonte(DepSource::Path {
14728 caminho: "$DIR/foo#pin".into(),
14729 });
14730 let err = d.validate().unwrap_err();
14731 assert!(
14732 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14733 "got {err:?}",
14734 );
14735 }
14736
14737 #[test]
14738 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14739 // Cascade pin on the immediate-successor arm: a value
14740 // carrying both `#` and a trailing `/`
14741 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14742 // a URL-fragment-carrying path" footgun) routes through
14743 // `FonteCaminhoShellComment` not
14744 // `FonteCaminhoTrailingSlash`. The embedded fragment /
14745 // comment-lead byte is the more semantic-locating axis (an
14746 // author who removes the `#pin` fragment typically also
14747 // drops the trailing separator since both are paste-from-
14748 // URL / paste-from-shell-tab-completion artifacts).
14749 let d = dep_with_fonte(DepSource::Path {
14750 caminho: "../caixa-teia#pin/".into(),
14751 });
14752 let err = d.validate().unwrap_err();
14753 assert!(
14754 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14755 "got {err:?}",
14756 );
14757 }
14758
14759 #[test]
14760 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14761 // Diagnostic-shape pin (peer with
14762 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14763 // on the immediate-predecessor arm): the error's Display
14764 // surfaces the offending `:nome`, the offending `:caminho`
14765 // verbatim, the offending byte's hex / character form, and
14766 // names the shell-comment / URL-fragment-identifier /
14767 // YAML-comment cross-config-DSL footgun explicitly so a
14768 // `feira lint` run can render the diagnostic without
14769 // re-parsing.
14770 let d = dep_with_fonte(DepSource::Path {
14771 caminho: "../caixa-teia#readme".into(),
14772 });
14773 let rendered = d.validate().unwrap_err().to_string();
14774 assert!(
14775 rendered.contains("caixa-teia"),
14776 "diagnostic must name the offending dep: {rendered}",
14777 );
14778 assert!(
14779 rendered.contains("../caixa-teia#readme"),
14780 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14781 );
14782 assert!(
14783 rendered.contains("0x23"),
14784 "diagnostic must surface the offending byte hex: {rendered:?}",
14785 );
14786 assert!(
14787 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14788 "diagnostic must name the shell-comment footgun: {rendered:?}",
14789 );
14790 assert!(
14791 rendered.contains("fragment") || rendered.contains("URL-fragment"),
14792 "diagnostic must reference the URL-fragment-identifier vocabulary: \
14793 {rendered:?}",
14794 );
14795 }
14796
14797 #[test]
14798 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14799 // The canonical paste-from-browser-address-bar percent-
14800 // encoded-space footgun: an author copies `../caixa%20teia`
14801 // out of a URL-encoded README hyperlink / browser address
14802 // bar / percent-encoded permalink expecting `%20` to decode
14803 // to a literal space at the filesystem layer. POSIX
14804 // `std::path::Path` treats `%` as a literal path-component
14805 // byte, so `Path::join` looks for a literal
14806 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14807 // returns false on `..`, `%` is neither a leading-byte
14808 // sentinel nor a control byte nor `\` nor `<` / `>` nor
14809 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14810 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14811 // and the value's last byte isn't `/` — so the value
14812 // silently passed every prior arm. The new arm moves the
14813 // rejection to validate time and names the offending dep +
14814 // caminho + byte verbatim.
14815 let d = dep_with_fonte(DepSource::Path {
14816 caminho: "../caixa%20teia".into(),
14817 });
14818 let err = d.validate().unwrap_err();
14819 let DepError::FonteCaminhoUrlPercentEncoding {
14820 nome,
14821 caminho,
14822 byte,
14823 } = err
14824 else {
14825 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14826 };
14827 assert_eq!(nome, "caixa-teia");
14828 assert_eq!(caminho, "../caixa%20teia");
14829 assert_eq!(byte, b'%');
14830 }
14831
14832 #[test]
14833 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14834 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14835 // intending the `%2F` as the URL encoding of `/`) locks a
14836 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14837 // the byte-identical `path:../caixa/teia` form. Pinned
14838 // separately from the space-encoded shape so the gate's
14839 // coverage extends past the single canonical `%20` example
14840 // to any two-hex-digit percent-encoded sequence.
14841 let d = dep_with_fonte(DepSource::Path {
14842 caminho: "../caixa%2Fteia".into(),
14843 });
14844 let err = d.validate().unwrap_err();
14845 assert!(
14846 matches!(
14847 err,
14848 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14849 ),
14850 "got {err:?}",
14851 );
14852 }
14853
14854 #[test]
14855 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14856 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14857 // where `%` isn't followed by two hex digits) — every
14858 // WHATWG-conformant URL parser rejects the value at parse
14859 // time per RFC 3986 §2.1, but the byte would silently ride
14860 // into the lacre before the resolver subprocess crosses the
14861 // URL-parser boundary. Pinned separately from the well-
14862 // formed `%HH` shapes so the gate covers every percent-
14863 // occurrence, not only strictly-conformant escapes.
14864 let d = dep_with_fonte(DepSource::Path {
14865 caminho: "../caixa-teia%foo".into(),
14866 });
14867 let err = d.validate().unwrap_err();
14868 assert!(
14869 matches!(
14870 err,
14871 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14872 ),
14873 "got {err:?}",
14874 );
14875 }
14876
14877 #[test]
14878 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14879 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14880 // — the canonical paste-from-top-of-doc YAML directive
14881 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14882 // separately from embedded shapes so the gate covers the
14883 // leading-position `%` too, not only mid-value occurrences.
14884 let d = dep_with_fonte(DepSource::Path {
14885 caminho: "%YAML/../caixa-teia".into(),
14886 });
14887 let err = d.validate().unwrap_err();
14888 assert!(
14889 matches!(
14890 err,
14891 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14892 ),
14893 "got {err:?}",
14894 );
14895 }
14896
14897 #[test]
14898 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14899 // The printf-format-specifier paste shape
14900 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14901 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14902 // 134 format-string-injection vector). Pinned separately
14903 // from the URL-encoding shapes so the gate's rationale
14904 // extends past the RFC 3986 axis to the C / POSIX printf
14905 // format-directive-lead axis.
14906 let d = dep_with_fonte(DepSource::Path {
14907 caminho: "../caixa-%s-teia".into(),
14908 });
14909 let err = d.validate().unwrap_err();
14910 assert!(
14911 matches!(
14912 err,
14913 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14914 ),
14915 "got {err:?}",
14916 );
14917 }
14918
14919 #[test]
14920 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14921 // The positive-control pin: the gate targets only `%`,
14922 // never adjacent printable ASCII or POSIX-valid bytes. The
14923 // canonical relative POSIX path (`"../caixa-teia"`) and a
14924 // nested deeply-pathed variant with adjacent printable
14925 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14926 // to validate cleanly so the gate doesn't widen to a "no
14927 // printable punctuation anywhere" sweep that would defeat
14928 // the entire path-fonte author surface. Peer with
14929 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14930 // on the immediate-predecessor arm.
14931 let d = dep_with_fonte(DepSource::Path {
14932 caminho: "../caixa-teia/sub-dir.v2".into(),
14933 });
14934 d.validate().unwrap();
14935 }
14936
14937 #[test]
14938 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14939 // Cascade pin on the immediate-predecessor arm: a value
14940 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14941 // canonical "I pasted a URL-fragment permalink followed by a
14942 // percent-encoded space tail" footgun) routes through
14943 // `FonteCaminhoShellComment` not
14944 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14945 // identifier is the load-bearing downstream-truncation edit
14946 // on every probe-as-both value; same cascade discipline
14947 // every prior `:caminho` arm establishes.
14948 let d = dep_with_fonte(DepSource::Path {
14949 caminho: "../caixa-teia#pin%20".into(),
14950 });
14951 let err = d.validate().unwrap_err();
14952 assert!(
14953 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14954 "got {err:?}",
14955 );
14956 }
14957
14958 #[test]
14959 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14960 // Cascade pin on the upstream shell-quote-grouping arm: a
14961 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14962 // canonical "I pasted a strong-quoted literal followed by
14963 // a percent-encoded space" footgun) routes through
14964 // `FonteCaminhoShellQuoteGrouping` not
14965 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14966 // literal-delimiter is the load-bearing root-cause edit on
14967 // every probe-as-both value.
14968 let d = dep_with_fonte(DepSource::Path {
14969 caminho: "../'x'%20teia".into(),
14970 });
14971 let err = d.validate().unwrap_err();
14972 assert!(
14973 matches!(
14974 err,
14975 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14976 ),
14977 "got {err:?}",
14978 );
14979 }
14980
14981 #[test]
14982 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14983 // Cascade pin on the upstream backslash arm: a value
14984 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14985 // canonical "I pasted a Windows-shell path followed by a
14986 // percent-encoded space" footgun) routes through
14987 // `FonteCaminhoBackslash` not
14988 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14989 // separator divergence is the load-bearing root-cause edit
14990 // on every probe-as-both value.
14991 let d = dep_with_fonte(DepSource::Path {
14992 caminho: "..\\caixa%20teia".into(),
14993 });
14994 let err = d.validate().unwrap_err();
14995 assert!(
14996 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14997 "got {err:?}",
14998 );
14999 }
15000
15001 #[test]
15002 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
15003 // Cascade pin on the upstream control-char arm: a value
15004 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
15005 // the canonical "I pasted a paste-from-binary-blob path
15006 // followed by a percent-encoded space" footgun) routes
15007 // through `FonteCaminhoControlChar` not
15008 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
15009 // rejected byte is the load-bearing root-cause edit on
15010 // every probe-as-both value.
15011 let d = dep_with_fonte(DepSource::Path {
15012 caminho: "../caixa\0%20teia".into(),
15013 });
15014 let err = d.validate().unwrap_err();
15015 assert!(
15016 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
15017 "got {err:?}",
15018 );
15019 }
15020
15021 #[test]
15022 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
15023 // Cascade pin on the upstream absolute-path arm: a value
15024 // that's both absolute and carries `%` (`"/etc/passwd%20"`
15025 // — the canonical "I pasted an absolute path with a
15026 // percent-encoded space tail" footgun) routes through
15027 // `FonteCaminhoAbsolute` not
15028 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
15029 // the load-bearing root-cause edit on every probe-as-both
15030 // value.
15031 let d = dep_with_fonte(DepSource::Path {
15032 caminho: "/etc/passwd%20".into(),
15033 });
15034 let err = d.validate().unwrap_err();
15035 assert!(
15036 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
15037 "got {err:?}",
15038 );
15039 }
15040
15041 #[test]
15042 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
15043 // Cascade pin on the upstream var-expansion arm: a value
15044 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
15045 // — the canonical "I pasted a `$HOME`-rooted path with a
15046 // percent-encoded space" footgun) routes through
15047 // `FonteCaminhoVarExpansion` not
15048 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
15049 // expansion is the load-bearing root-cause edit on every
15050 // probe-as-both value.
15051 let d = dep_with_fonte(DepSource::Path {
15052 caminho: "$HOME/caixa%20teia".into(),
15053 });
15054 let err = d.validate().unwrap_err();
15055 assert!(
15056 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15057 "got {err:?}",
15058 );
15059 }
15060
15061 #[test]
15062 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
15063 // Cascade pin on the immediate-successor arm: a value
15064 // carrying both `%` and a trailing `/`
15065 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
15066 // percent-encoded-space-carrying path" footgun) routes
15067 // through `FonteCaminhoUrlPercentEncoding` not
15068 // `FonteCaminhoTrailingSlash`. The embedded percent-
15069 // encoding-escape byte is the more semantic-locating axis
15070 // (an author who decodes the `%20` to a literal space is
15071 // likely to also tab-strip the trailing separator since
15072 // both are paste-from-URL / paste-from-shell-tab-completion
15073 // artifacts).
15074 let d = dep_with_fonte(DepSource::Path {
15075 caminho: "../caixa%20teia/".into(),
15076 });
15077 let err = d.validate().unwrap_err();
15078 assert!(
15079 matches!(
15080 err,
15081 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15082 ),
15083 "got {err:?}",
15084 );
15085 }
15086
15087 #[test]
15088 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
15089 // Diagnostic-shape pin (peer with
15090 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
15091 // on the immediate-predecessor arm): the error's Display
15092 // surfaces the offending `:nome`, the offending `:caminho`
15093 // verbatim, the offending byte's hex / character form, and
15094 // names the URL-percent-encoding-escape / printf-format-
15095 // specifier footgun explicitly so a `feira lint` run can
15096 // render the diagnostic without re-parsing.
15097 let d = dep_with_fonte(DepSource::Path {
15098 caminho: "../caixa%20teia".into(),
15099 });
15100 let rendered = d.validate().unwrap_err().to_string();
15101 assert!(
15102 rendered.contains("caixa-teia"),
15103 "diagnostic must name the offending dep: {rendered}",
15104 );
15105 assert!(
15106 rendered.contains("../caixa%20teia"),
15107 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15108 );
15109 assert!(
15110 rendered.contains("0x25"),
15111 "diagnostic must surface the offending byte hex: {rendered:?}",
15112 );
15113 assert!(
15114 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
15115 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
15116 );
15117 assert!(
15118 rendered.contains("printf") || rendered.contains("format-specifier"),
15119 "diagnostic must reference the printf-format-specifier vocabulary: \
15120 {rendered:?}",
15121 );
15122 }
15123
15124 #[test]
15125 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
15126 // The canonical embedded-`$` shell-variable-expansion paste
15127 // shape (`"../foo$HOME/bar"` — an author copies a partially-
15128 // substituted shell one-liner where the leading segment is a
15129 // literal `../foo` while the mid segment carries the un-
15130 // substituted `$HOME` template). The leading-`$` position is
15131 // already gated by the f4efe9c leading-byte arm which routes
15132 // through `FonteCaminhoVarExpansion`; this arm closes the
15133 // last positional gap on `$` — every position on the axis is
15134 // structurally rejected.
15135 let d = dep_with_fonte(DepSource::Path {
15136 caminho: "../foo$HOME/bar".into(),
15137 });
15138 let err = d.validate().unwrap_err();
15139 let DepError::FonteCaminhoShellVariableExpansion {
15140 nome,
15141 caminho,
15142 byte,
15143 } = err
15144 else {
15145 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
15146 };
15147 assert_eq!(nome, "caixa-teia");
15148 assert_eq!(caminho, "../foo$HOME/bar");
15149 assert_eq!(byte, b'$');
15150 }
15151
15152 #[test]
15153 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
15154 // The symmetric braced-CI-manifest paste shape
15155 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
15156 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
15157 // footgun). Pinned separately from the bare-`$VAR` shape so
15158 // the gate covers both POSIX shell §2.6 Parameter Expansion
15159 // syntactic forms, not only the unbraced variant. The
15160 // embedded `{` byte in `${...}` is also caught by the 598b770
15161 // shell-brace-expansion arm but that arm fires earlier in
15162 // the cascade — the `$` arm's coverage extends to `${...}`
15163 // structurally, so the diagnostic asserted here is the
15164 // brace-expansion one (which is a valid outcome; the point
15165 // of the pin is that the value never survives validation).
15166 let d = dep_with_fonte(DepSource::Path {
15167 caminho: "../foo${WORKSPACE}/bar".into(),
15168 });
15169 let err = d.validate().unwrap_err();
15170 assert!(
15171 matches!(
15172 err,
15173 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
15174 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15175 ),
15176 "got {err:?}",
15177 );
15178 }
15179
15180 #[test]
15181 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
15182 // The paste-from-shell-prompt command-substitution idiom
15183 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
15184 // `$VAR` shape so the gate's rationale extends to POSIX shell
15185 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
15186 // legacy `` `<cmd>` `` form is already closed by the c370458
15187 // backtick arm). The embedded `(` byte in `$(...)` is also
15188 // caught structurally by the 0633c91 shell-subshell-grouping
15189 // arm which fires earlier in the cascade — the diagnostic
15190 // asserted here is either outcome, since both structurally
15191 // reject the value; the point of the pin is that the value
15192 // never survives validation.
15193 let d = dep_with_fonte(DepSource::Path {
15194 caminho: "../foo$(whoami)/bar".into(),
15195 });
15196 let err = d.validate().unwrap_err();
15197 assert!(
15198 matches!(
15199 err,
15200 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
15201 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15202 ),
15203 "got {err:?}",
15204 );
15205 }
15206
15207 #[test]
15208 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
15209 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
15210 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
15211 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
15212 // idiom copied into a caminho template). None of the prior
15213 // shell-metachar arms cover this shape (`1` is a bare digit;
15214 // no `(` / `{` / letter follows the `$`), so the arm is the
15215 // sole gate on the shape.
15216 let d = dep_with_fonte(DepSource::Path {
15217 caminho: "../foo$1/bar".into(),
15218 });
15219 let err = d.validate().unwrap_err();
15220 assert!(
15221 matches!(
15222 err,
15223 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15224 ),
15225 "got {err:?}",
15226 );
15227 }
15228
15229 #[test]
15230 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
15231 // The positive-control pin (peer with
15232 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
15233 // on the immediate-predecessor arm): the gate targets only
15234 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
15235 // A relative POSIX path carrying dashes / dots / slashes /
15236 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15237 // validate cleanly so the gate doesn't widen to a "no
15238 // printable punctuation anywhere" sweep that would defeat
15239 // the entire path-fonte author surface.
15240 let d = dep_with_fonte(DepSource::Path {
15241 caminho: "../caixa-teia/sub-dir.v2".into(),
15242 });
15243 d.validate().unwrap();
15244 }
15245
15246 #[test]
15247 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
15248 // Cascade pin on the leading-`$` sibling arm at line 540: a
15249 // value starting with `$` and carrying an embedded `$` too
15250 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
15251 // fully-templated CI path with two un-substituted variables")
15252 // routes through `FonteCaminhoVarExpansion` not
15253 // `FonteCaminhoShellVariableExpansion`. The leading-byte
15254 // host-layout-leak is the load-bearing self-locating axis
15255 // (the leading position dominates the semantic-locating
15256 // rationale on every probe-as-both value); the embedded
15257 // arm's positional-agnostic sweep catches only values whose
15258 // leading byte doesn't route through the earlier leading-
15259 // byte arms.
15260 let d = dep_with_fonte(DepSource::Path {
15261 caminho: "$HOME/foo$WORKSPACE/bar".into(),
15262 });
15263 let err = d.validate().unwrap_err();
15264 assert!(
15265 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15266 "got {err:?}",
15267 );
15268 }
15269
15270 #[test]
15271 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
15272 // Cascade pin on the immediate-predecessor arm: a value
15273 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
15274 // — the canonical "I pasted a percent-encoded space adjacent
15275 // to a `$HOME` template") routes through
15276 // `FonteCaminhoUrlPercentEncoding` not
15277 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
15278 // encoding-escape byte is the more semantic-locating axis
15279 // (the paste-from-browser-address-bar shape is the load-
15280 // bearing self-locating edit); same cascade discipline every
15281 // prior `:caminho` arm establishes.
15282 let d = dep_with_fonte(DepSource::Path {
15283 caminho: "../foo%20$HOME/bar".into(),
15284 });
15285 let err = d.validate().unwrap_err();
15286 assert!(
15287 matches!(
15288 err,
15289 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15290 ),
15291 "got {err:?}",
15292 );
15293 }
15294
15295 #[test]
15296 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
15297 // Cascade pin on the immediate-successor arm: a value
15298 // carrying both embedded `$` and a trailing `/`
15299 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
15300 // `$HOME`-template-carrying path") routes through
15301 // `FonteCaminhoShellVariableExpansion` not
15302 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
15303 // expansion byte is the more semantic-locating axis on
15304 // probe-as-both values (an author who substitutes the
15305 // `$HOME` template with a literal value is likely to also
15306 // tab-strip the trailing separator).
15307 let d = dep_with_fonte(DepSource::Path {
15308 caminho: "../foo$HOME/bar/".into(),
15309 });
15310 let err = d.validate().unwrap_err();
15311 assert!(
15312 matches!(
15313 err,
15314 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15315 ),
15316 "got {err:?}",
15317 );
15318 }
15319
15320 #[test]
15321 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15322 // Diagnostic-shape pin (peer with
15323 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
15324 // on the immediate-predecessor arm): the error's Display
15325 // surfaces the offending `:nome`, the offending `:caminho`
15326 // verbatim, the offending byte's hex / character form, and
15327 // names the shell-variable-expansion / command-substitution
15328 // footgun explicitly so a `feira lint` run can render the
15329 // diagnostic without re-parsing.
15330 let d = dep_with_fonte(DepSource::Path {
15331 caminho: "../foo$HOME/bar".into(),
15332 });
15333 let rendered = d.validate().unwrap_err().to_string();
15334 assert!(
15335 rendered.contains("caixa-teia"),
15336 "diagnostic must name the offending dep: {rendered}",
15337 );
15338 assert!(
15339 rendered.contains("../foo$HOME/bar"),
15340 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15341 );
15342 assert!(
15343 rendered.contains("0x24"),
15344 "diagnostic must surface the offending byte hex: {rendered:?}",
15345 );
15346 assert!(
15347 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
15348 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
15349 );
15350 assert!(
15351 rendered.contains("command-substitution") || rendered.contains("command substitution"),
15352 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
15353 );
15354 }
15355
15356 #[test]
15357 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
15358 // The fail-before-pass-after pin for the canonical paste-from-
15359 // shell-history footgun on `:caminho`. An author copies a `cd
15360 // ../caixa-teia && !sudo make install` one-liner from a quick-
15361 // start README, intending the trailing `!sudo` as a shell-
15362 // history-expansion reference but the typed slot is itself a
15363 // byte-level string parser, not a shell context, so the byte
15364 // rides into the value verbatim. Until this arm landed the `!`
15365 // byte silently passed every prior `:caminho` cascade arm
15366 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
15367 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
15368 // `#` / `%` / `$`); bash with the default `histexpand` mode
15369 // rewrites `!command` to the most recent history entry
15370 // beginning with `command`, the canonical RCE-class injection
15371 // vector when the byte rides into a shell argument executed
15372 // under `bash -i` (the operator-notebook interactive shell).
15373 let d = dep_with_fonte(DepSource::Path {
15374 caminho: "../caixa-teia!sudo".into(),
15375 });
15376 let err = d.validate().unwrap_err();
15377 let DepError::FonteCaminhoShellHistoryExpansion {
15378 nome,
15379 caminho,
15380 byte,
15381 } = err
15382 else {
15383 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
15384 };
15385 assert_eq!(nome, "caixa-teia");
15386 assert_eq!(caminho, "../caixa-teia!sudo");
15387 assert_eq!(byte, b'!');
15388 }
15389
15390 #[test]
15391 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
15392 // The symmetric `!!` repeat-prior-command paste idiom (peer with
15393 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
15394 // on `is_git_repo_url`). Pinned separately from the wrapped
15395 // `!command` shape so a future diagnostic-surface change that
15396 // only checked the leading or paired-bang position surfaces
15397 // here — the per-byte arm fires anywhere `!` appears in the
15398 // value, including at consecutive positions in the middle.
15399 let d = dep_with_fonte(DepSource::Path {
15400 caminho: "../foo!!/bar".into(),
15401 });
15402 let err = d.validate().unwrap_err();
15403 assert!(
15404 matches!(
15405 err,
15406 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15407 ),
15408 "got {err:?}",
15409 );
15410 }
15411
15412 #[test]
15413 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
15414 // The English-typography enthusiasm-form paste-from-prose
15415 // idiom: an author writes `:caminho "../caixa-teia!"`
15416 // expecting the substrate to coerce it to a kebab-case slug.
15417 // Pinned separately from the `!<word>` shell-history shape so
15418 // the gate's rationale extends to the paste-from-prose surface
15419 // (the same rationale the peer `is_git_repo_url` bang arm at
15420 // 7d53c68 covers). None of the prior shell-metachar arms cover
15421 // this shape (no `!<word>` reference and no `!!` repeat), so
15422 // the arm is the sole gate on the shape.
15423 let d = dep_with_fonte(DepSource::Path {
15424 caminho: "../caixa-teia!".into(),
15425 });
15426 let err = d.validate().unwrap_err();
15427 assert!(
15428 matches!(
15429 err,
15430 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15431 ),
15432 "got {err:?}",
15433 );
15434 }
15435
15436 #[test]
15437 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
15438 // The positive-control pin (peer with
15439 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
15440 // on the immediate-predecessor arm): the gate targets only
15441 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15442 // A relative POSIX path carrying dashes / dots / slashes /
15443 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15444 // validate cleanly so the gate doesn't widen to a "no
15445 // printable punctuation anywhere" sweep that would defeat
15446 // the entire path-fonte author surface.
15447 let d = dep_with_fonte(DepSource::Path {
15448 caminho: "../caixa-teia/sub-dir.v2".into(),
15449 });
15450 d.validate().unwrap();
15451 }
15452
15453 #[test]
15454 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15455 // Cascade pin on the immediate-predecessor arm: a value
15456 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15457 // — the canonical "I pasted a `$HOME`-templated path adjacent
15458 // to a trailing `!sudo` history-expansion") routes through
15459 // `FonteCaminhoShellVariableExpansion` not
15460 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15461 // expansion byte is the more semantic-locating axis on
15462 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15463 // template shape is the load-bearing self-locating edit);
15464 // same cascade discipline every prior `:caminho` arm
15465 // establishes.
15466 let d = dep_with_fonte(DepSource::Path {
15467 caminho: "../foo$HOME/bar!sudo".into(),
15468 });
15469 let err = d.validate().unwrap_err();
15470 assert!(
15471 matches!(
15472 err,
15473 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15474 ),
15475 "got {err:?}",
15476 );
15477 }
15478
15479 #[test]
15480 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15481 // Cascade pin on the immediate-successor arm: a value carrying
15482 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15483 // — the canonical "I tab-completed a `!sudo`-carrying path")
15484 // routes through `FonteCaminhoShellHistoryExpansion` not
15485 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15486 // expansion byte is the more semantic-locating axis on probe-
15487 // as-both values (an author who removes the `!sudo` history
15488 // reference is likely to also tab-strip the trailing separator).
15489 let d = dep_with_fonte(DepSource::Path {
15490 caminho: "../caixa-teia!sudo/".into(),
15491 });
15492 let err = d.validate().unwrap_err();
15493 assert!(
15494 matches!(
15495 err,
15496 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15497 ),
15498 "got {err:?}",
15499 );
15500 }
15501
15502 #[test]
15503 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15504 // Diagnostic-shape pin (peer with
15505 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15506 // on the immediate-predecessor arm): the error's Display
15507 // surfaces the offending `:nome`, the offending `:caminho`
15508 // verbatim, the offending byte's hex / character form, and
15509 // names the shell-history-expansion / bang-operator footgun
15510 // explicitly so a `feira lint` run can render the diagnostic
15511 // without re-parsing.
15512 let d = dep_with_fonte(DepSource::Path {
15513 caminho: "../caixa-teia!sudo".into(),
15514 });
15515 let rendered = d.validate().unwrap_err().to_string();
15516 assert!(
15517 rendered.contains("caixa-teia"),
15518 "diagnostic must name the offending dep: {rendered}",
15519 );
15520 assert!(
15521 rendered.contains("../caixa-teia!sudo"),
15522 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15523 );
15524 assert!(
15525 rendered.contains("0x21"),
15526 "diagnostic must surface the offending byte hex: {rendered:?}",
15527 );
15528 assert!(
15529 rendered.contains("history-expansion") || rendered.contains("history expansion"),
15530 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15531 );
15532 assert!(
15533 rendered.contains("bang"),
15534 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15535 );
15536 }
15537
15538 #[test]
15539 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15540 // The fail-before-pass-after pin for the canonical paste-from-
15541 // shell-history-quick-substitution footgun on `:caminho`. An
15542 // author copies a `git clone <bad-url>` line from their terminal,
15543 // corrects it via bash's `^bad^good` quick-substitution history
15544 // operator (bash reference §9.3, `set -o histexpand` mode's
15545 // default for interactive sessions), and pastes the trailing
15546 // `^bad^good` substitution fragment into a `:caminho` value
15547 // without trimming the leading `git clone` prefix — the byte
15548 // rides into the manifest verbatim. Until this arm landed the
15549 // `^` byte silently passed every prior `:caminho` cascade arm
15550 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15551 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15552 // `%` / `$` / `!`); bash with the default `histexpand` mode
15553 // rewrites the prior command's `bad` string to `good` and re-
15554 // executes it, the paired-operator half of the `set -o
15555 // histexpand` feature the peer `!` arm already closes the prefix
15556 // half of. The peer `is_git_repo_url` axis rejects the byte at
15557 // 49e142f under the same shell-history-substitution / RFC-3986-
15558 // unwise banner.
15559 let d = dep_with_fonte(DepSource::Path {
15560 caminho: "../foo^bad^good".into(),
15561 });
15562 let err = d.validate().unwrap_err();
15563 let DepError::FonteCaminhoShellHistorySubstitution {
15564 nome,
15565 caminho,
15566 byte,
15567 } = err
15568 else {
15569 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15570 };
15571 assert_eq!(nome, "caixa-teia");
15572 assert_eq!(caminho, "../foo^bad^good");
15573 assert_eq!(byte, b'^');
15574 }
15575
15576 #[test]
15577 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15578 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15579 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15580 // on `is_git_repo_url`). An author copies a `grep '^archived'`
15581 // regex-anchor / negation idiom from a doc snippet and the byte
15582 // rides in verbatim. Pinned separately from the `^old^new^`
15583 // quick-substitution shape so a future diagnostic-surface change
15584 // that only checked the paired-caret history-substitution
15585 // position surfaces here — the per-byte arm fires anywhere `^`
15586 // appears in the value, including at a solitary leading-of-
15587 // segment position.
15588 let d = dep_with_fonte(DepSource::Path {
15589 caminho: "../foo/^archived".into(),
15590 });
15591 let err = d.validate().unwrap_err();
15592 assert!(
15593 matches!(
15594 err,
15595 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15596 ),
15597 "got {err:?}",
15598 );
15599 }
15600
15601 #[test]
15602 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15603 // The trailing-`^` history-substitution-open shape — an author
15604 // starts typing a `^bad^good` quick-substitution but pastes only
15605 // the leading `^` sentinel before context-switching (a bash-
15606 // reference §9.3 valid histexpand prefix on its own — even a
15607 // solitary `^` on the prior command's whole re-execution shape).
15608 // Pinned separately from the `^old^new^` full-form and the leading-
15609 // of-segment `^archived` regex-anchor shape so the gate's
15610 // rationale extends to the paste-from-shell-history-with-only-
15611 // the-first-byte-selected surface. None of the prior shell-
15612 // metachar arms cover this shape.
15613 let d = dep_with_fonte(DepSource::Path {
15614 caminho: "../caixa-teia^".into(),
15615 });
15616 let err = d.validate().unwrap_err();
15617 assert!(
15618 matches!(
15619 err,
15620 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15621 ),
15622 "got {err:?}",
15623 );
15624 }
15625
15626 #[test]
15627 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15628 // The positive-control pin (peer with
15629 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15630 // on the immediate-predecessor arm): the gate targets only
15631 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15632 // A relative POSIX path carrying dashes / dots / slashes /
15633 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15634 // continue to validate cleanly so the gate doesn't widen to
15635 // a "no printable punctuation anywhere" sweep that would
15636 // defeat the entire path-fonte author surface.
15637 let d = dep_with_fonte(DepSource::Path {
15638 caminho: "../caixa-teia/sub_v2.rc".into(),
15639 });
15640 d.validate().unwrap();
15641 }
15642
15643 #[test]
15644 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15645 // Cascade pin on the immediate-predecessor arm: a value carrying
15646 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15647 // canonical "I pasted a `!sudo` history-reference next to a
15648 // `^bad^good` quick-substitution") routes through
15649 // `FonteCaminhoShellHistoryExpansion` not
15650 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15651 // the more semantic-locating axis on probe-as-both values (an
15652 // author who removes the `!sudo` reference is likely to also
15653 // strip the paired `^` substitution fragment); same cascade
15654 // discipline every prior `:caminho` arm establishes.
15655 let d = dep_with_fonte(DepSource::Path {
15656 caminho: "../foo!sudo^bad^good".into(),
15657 });
15658 let err = d.validate().unwrap_err();
15659 assert!(
15660 matches!(
15661 err,
15662 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15663 ),
15664 "got {err:?}",
15665 );
15666 }
15667
15668 #[test]
15669 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15670 // Cascade pin on the immediate-successor arm: a value carrying
15671 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15672 // the canonical "I tab-completed a `^bad^good`-carrying path")
15673 // routes through `FonteCaminhoShellHistorySubstitution` not
15674 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15675 // substitution byte is the more semantic-locating axis on probe-
15676 // as-both values (an author who removes the `^bad^good`
15677 // substitution fragment is likely to also tab-strip the trailing
15678 // separator).
15679 let d = dep_with_fonte(DepSource::Path {
15680 caminho: "../foo^bad^good/".into(),
15681 });
15682 let err = d.validate().unwrap_err();
15683 assert!(
15684 matches!(
15685 err,
15686 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15687 ),
15688 "got {err:?}",
15689 );
15690 }
15691
15692 #[test]
15693 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15694 {
15695 // Diagnostic-shape pin (peer with
15696 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15697 // on the immediate-predecessor arm): the error's Display
15698 // surfaces the offending `:nome`, the offending `:caminho`
15699 // verbatim, the offending byte's hex form, and names the
15700 // shell-history-substitution / RFC-3986-'unwise' / regex-
15701 // negation footgun explicitly so a `feira lint` run can render
15702 // the diagnostic without re-parsing.
15703 let d = dep_with_fonte(DepSource::Path {
15704 caminho: "../foo^bad^good".into(),
15705 });
15706 let rendered = d.validate().unwrap_err().to_string();
15707 assert!(
15708 rendered.contains("caixa-teia"),
15709 "diagnostic must name the offending dep: {rendered}",
15710 );
15711 assert!(
15712 rendered.contains("../foo^bad^good"),
15713 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15714 );
15715 assert!(
15716 rendered.contains("0x5e") || rendered.contains("0x5E"),
15717 "diagnostic must surface the offending byte hex: {rendered:?}",
15718 );
15719 assert!(
15720 rendered.contains("history-substitution") || rendered.contains("history substitution"),
15721 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15722 );
15723 assert!(
15724 rendered.contains("unwise"),
15725 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15726 );
15727 }
15728
15729 #[test]
15730 fn fonte_repo_empty_fires_before_pin_missing() {
15731 // Order pin: empty `:repo` is the more self-locating diagnostic
15732 // (every git source needs a repo; the pin discussion is
15733 // secondary), so it fires before the pin-missing arm even when
15734 // both are violated. Mirrors the
15735 // `nome_empty_takes_precedence_over_versao_invalid` ordering
15736 // discipline on the per-entry layer.
15737 let d = dep_with_fonte(DepSource::Git {
15738 repo: String::new(),
15739 tag: None,
15740 rev: None,
15741 branch: None,
15742 });
15743 let err = d.validate().unwrap_err();
15744 assert!(
15745 matches!(err, DepError::FonteRepoEmpty { .. }),
15746 "got {err:?}"
15747 );
15748 }
15749
15750 #[test]
15751 fn fonte_pin_missing_fires_before_pin_empty() {
15752 // Order pin: a fully-None pin set is structurally distinct from
15753 // a Some(empty) pin — the first surfaces as FontePinMissing
15754 // (no axis chosen), the second as FontePinEmpty (axis chosen
15755 // but value blank). Pin the disjoint relationship so a future
15756 // unification collapses to one variant only as a structural
15757 // decision.
15758 let d = dep_with_fonte(DepSource::Git {
15759 repo: "github:pleme-io/caixa-teia".into(),
15760 tag: None,
15761 rev: None,
15762 branch: None,
15763 });
15764 assert!(matches!(
15765 d.validate().unwrap_err(),
15766 DepError::FontePinMissing { .. }
15767 ));
15768 }
15769
15770 #[test]
15771 fn nome_empty_takes_precedence_over_fonte_invalid() {
15772 // Order pin: a per-entry diagnostic without a non-empty :nome
15773 // can't be self-locating, so :nome "" fires first even when
15774 // :fonte is also malformed. Mirrors
15775 // `nome_empty_takes_precedence_over_versao_invalid` on the
15776 // adjacent axis.
15777 let mut d = dep_with_fonte(DepSource::Git {
15778 repo: String::new(),
15779 tag: None,
15780 rev: None,
15781 branch: None,
15782 });
15783 d.nome = String::new();
15784 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15785 }
15786
15787 #[test]
15788 fn versao_invalid_takes_precedence_over_fonte_invalid() {
15789 // Order pin: the :versao parse-side diagnostic is narrower than
15790 // the :fonte shape diagnostic — a malformed :versao always names
15791 // the parser's reason, which is more actionable than the
15792 // :fonte gate's "the pins are wrong" wording. Pin the ordering
15793 // so a re-ordering surfaces here.
15794 let mut d = dep_with_fonte(DepSource::Git {
15795 repo: String::new(),
15796 tag: None,
15797 rev: None,
15798 branch: None,
15799 });
15800 d.versao = "v0.1".into();
15801 let err = d.validate().unwrap_err();
15802 assert!(
15803 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15804 "got {err:?}"
15805 );
15806 }
15807
15808 #[test]
15809 fn fonte_invalid_diagnostic_carries_offending_nome() {
15810 // The diagnostic-shape pin: every :fonte error variant names
15811 // the offending dep's :nome verbatim, so the author can grep
15812 // caixa.lisp for the `:nome "<n>"` block and fix it in one
15813 // edit. Cover all seven variants so a future variant addition
15814 // forces a parallel diagnostic-shape decision.
15815 for (case, fonte) in [
15816 (
15817 "repo-empty",
15818 DepSource::Git {
15819 repo: String::new(),
15820 tag: Some("v1".into()),
15821 rev: None,
15822 branch: None,
15823 },
15824 ),
15825 (
15826 "repo-shape",
15827 DepSource::Git {
15828 repo: "github:p/x ".into(),
15829 tag: Some("v1".into()),
15830 rev: None,
15831 branch: None,
15832 },
15833 ),
15834 (
15835 "pin-missing",
15836 DepSource::Git {
15837 repo: "github:p/x".into(),
15838 tag: None,
15839 rev: None,
15840 branch: None,
15841 },
15842 ),
15843 (
15844 "pin-ambiguous",
15845 DepSource::Git {
15846 repo: "github:p/x".into(),
15847 tag: Some("v1".into()),
15848 rev: None,
15849 branch: Some("main".into()),
15850 },
15851 ),
15852 (
15853 "pin-empty",
15854 DepSource::Git {
15855 repo: "github:p/x".into(),
15856 tag: Some(String::new()),
15857 rev: None,
15858 branch: None,
15859 },
15860 ),
15861 (
15862 "caminho-empty",
15863 DepSource::Path {
15864 caminho: String::new(),
15865 },
15866 ),
15867 (
15868 "caminho-absolute",
15869 DepSource::Path {
15870 caminho: "/home/me/work/caixa-teia".into(),
15871 },
15872 ),
15873 ] {
15874 let d = dep_with_fonte(fonte);
15875 let msg = d
15876 .validate()
15877 .expect_err(&format!("{case}: expected fonte error"))
15878 .to_string();
15879 assert!(
15880 msg.contains("\"caixa-teia\""),
15881 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15882 );
15883 }
15884 }
15885
15886 // -- :tag / :branch value-shape gate ----------------------------------
15887
15888 #[test]
15889 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15890 // The canonical paste-from-doc footgun on `:tag` — author
15891 // copies `"v0.1.0 "` (trailing space) out of a release-notes
15892 // paragraph. Until this gate landed the empty-pin arm passed
15893 // (the string isn't empty), the resolver issued
15894 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15895 // surfaced at clone time with a quoting-confused git error
15896 // far from the source caixa.lisp. The new gate moves the
15897 // check to caixa-build time and names the offending dep +
15898 // pin + value verbatim.
15899 let d = dep_with_fonte(DepSource::Git {
15900 repo: "github:pleme-io/caixa-teia".into(),
15901 tag: Some("v0.1.0 ".into()),
15902 rev: None,
15903 branch: None,
15904 });
15905 let err = d.validate().unwrap_err();
15906 let DepError::FontePinShape {
15907 nome,
15908 pin,
15909 value,
15910 reason,
15911 } = err
15912 else {
15913 panic!("expected FontePinShape, got other variant");
15914 };
15915 assert_eq!(nome, "caixa-teia");
15916 assert_eq!(pin, ":tag");
15917 assert_eq!(value, "v0.1.0 ");
15918 assert!(
15919 reason.contains("whitespace"),
15920 "reason must surface the whitespace arm, got {reason:?}"
15921 );
15922 }
15923
15924 #[test]
15925 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15926 // The `.lock` suffix is git's atomic-rename guard for
15927 // in-flight ref updates — a refname ending in `.lock` is
15928 // unwritable on disk. Pinned separately from the whitespace
15929 // arm so a future relaxation that admits one but not the
15930 // other surfaces here.
15931 let d = dep_with_fonte(DepSource::Git {
15932 repo: "github:pleme-io/caixa-teia".into(),
15933 tag: Some("v0.1.0.lock".into()),
15934 rev: None,
15935 branch: None,
15936 });
15937 let err = d.validate().unwrap_err();
15938 let DepError::FontePinShape {
15939 pin, value, reason, ..
15940 } = err
15941 else {
15942 panic!("expected FontePinShape, got other variant");
15943 };
15944 assert_eq!(pin, ":tag");
15945 assert_eq!(value, "v0.1.0.lock");
15946 assert!(
15947 reason.contains(".lock"),
15948 "reason must surface the .lock arm, got {reason:?}"
15949 );
15950 }
15951
15952 #[test]
15953 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15954 // The canonical "branch name with spaces" footgun (`feature
15955 // foo`, `release branch`) — git's refname parser rejects raw
15956 // whitespace, and the failure surfaces at `git checkout
15957 // 'feature foo'` time with a quoting-confused error far from
15958 // the source caixa.lisp. Pinned on the `:branch` axis so the
15959 // gate-applies-to-both-:tag-and-:branch contract is a build-
15960 // error to relax.
15961 let d = dep_with_fonte(DepSource::Git {
15962 repo: "github:pleme-io/caixa-teia".into(),
15963 tag: None,
15964 rev: None,
15965 branch: Some("feature/foo bar".into()),
15966 });
15967 let err = d.validate().unwrap_err();
15968 let DepError::FontePinShape {
15969 pin, value, reason, ..
15970 } = err
15971 else {
15972 panic!("expected FontePinShape, got other variant");
15973 };
15974 assert_eq!(pin, ":branch");
15975 assert_eq!(value, "feature/foo bar");
15976 assert!(
15977 reason.contains("whitespace"),
15978 "reason must surface the whitespace arm, got {reason:?}"
15979 );
15980 }
15981
15982 #[test]
15983 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15984 // The `refs/heads/main` shape — the canonical "I copied the
15985 // fully-qualified ref out of `git show-ref` instead of the
15986 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15987 // at clone time, so this resolves to a literal ref named
15988 // `refs/heads/refs/heads/main` on disk; the silent double-
15989 // prefix is the load-bearing reason to gate at validate.
15990 // The diagnostic must enumerate the leaf the author probably
15991 // meant (`"main"`) so the fix is one edit.
15992 let d = dep_with_fonte(DepSource::Git {
15993 repo: "github:pleme-io/caixa-teia".into(),
15994 tag: None,
15995 rev: None,
15996 branch: Some("refs/heads/main".into()),
15997 });
15998 let err = d.validate().unwrap_err();
15999 let DepError::FontePinShape {
16000 pin, value, reason, ..
16001 } = err
16002 else {
16003 panic!("expected FontePinShape, got other variant");
16004 };
16005 assert_eq!(pin, ":branch");
16006 assert_eq!(value, "refs/heads/main");
16007 assert!(
16008 reason.contains("fully-qualified"),
16009 "reason must surface the qualified-prefix arm, got {reason:?}"
16010 );
16011 assert!(
16012 reason.contains("\"main\""),
16013 "reason must quote the leaf the author probably meant, got {reason:?}"
16014 );
16015 }
16016
16017 #[test]
16018 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
16019 // Sibling arm of the qualified-prefix gate on the `:tag`
16020 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
16021 // footgun). Pinned separately so a future relaxation that
16022 // only catches the `:branch` arm surfaces here.
16023 let d = dep_with_fonte(DepSource::Git {
16024 repo: "github:pleme-io/caixa-teia".into(),
16025 tag: Some("refs/tags/v0.1.0".into()),
16026 rev: None,
16027 branch: None,
16028 });
16029 let err = d.validate().unwrap_err();
16030 let DepError::FontePinShape {
16031 pin, value, reason, ..
16032 } = err
16033 else {
16034 panic!("expected FontePinShape, got other variant");
16035 };
16036 assert_eq!(pin, ":tag");
16037 assert_eq!(value, "refs/tags/v0.1.0");
16038 assert!(
16039 reason.contains("fully-qualified"),
16040 "reason must surface the qualified-prefix arm, got {reason:?}"
16041 );
16042 assert!(
16043 reason.contains("\"v0.1.0\""),
16044 "reason must quote the leaf the author probably meant, got {reason:?}"
16045 );
16046 }
16047
16048 #[test]
16049 fn validate_rejects_git_fonte_with_branch_named_at() {
16050 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
16051 // unsourceable. Pinned so a future relaxation that admits
16052 // any single-character refname surfaces here.
16053 let d = dep_with_fonte(DepSource::Git {
16054 repo: "github:pleme-io/caixa-teia".into(),
16055 tag: None,
16056 rev: None,
16057 branch: Some("@".into()),
16058 });
16059 let err = d.validate().unwrap_err();
16060 let DepError::FontePinShape { pin, value, .. } = err else {
16061 panic!("expected FontePinShape, got other variant");
16062 };
16063 assert_eq!(pin, ":branch");
16064 assert_eq!(value, "@");
16065 }
16066
16067 #[test]
16068 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
16069 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
16070 // a `:tag "../escape"` (path-traversal-shaped slug) silently
16071 // passes parse and surfaces as a refname-parse error or, on
16072 // older git, a literal `../escape` checkout that escapes the
16073 // refs/ directory tree. Pinned separately from the
16074 // qualified-prefix arm so a future relaxation that catches
16075 // one but not the other surfaces here.
16076 let d = dep_with_fonte(DepSource::Git {
16077 repo: "github:pleme-io/caixa-teia".into(),
16078 tag: Some("../escape".into()),
16079 rev: None,
16080 branch: None,
16081 });
16082 let err = d.validate().unwrap_err();
16083 let DepError::FontePinShape { pin, value, .. } = err else {
16084 panic!("expected FontePinShape, got other variant");
16085 };
16086 assert_eq!(pin, ":tag");
16087 assert_eq!(value, "../escape");
16088 }
16089
16090 #[test]
16091 fn validate_accepts_git_fonte_with_hierarchical_branch() {
16092 // The positive-control pin: hierarchical refnames with one or
16093 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
16094 // canonical idiom) round-trip through the gate. Pinned
16095 // separately from the leaf-`"main"` positive control so a
16096 // future tightening that rejects all multi-component refnames
16097 // surfaces here.
16098 let d = dep_with_fonte(DepSource::Git {
16099 repo: "github:pleme-io/caixa-teia".into(),
16100 tag: None,
16101 rev: None,
16102 branch: Some("feature/checkout-rewrite".into()),
16103 });
16104 d.validate().unwrap();
16105 }
16106
16107 #[test]
16108 fn validate_accepts_git_fonte_with_prerelease_tag() {
16109 // The positive-control pin: semver pre-release shape
16110 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
16111 // (only consecutive `..` and trailing `.` are rejected), the
16112 // mid-component hyphen is allowed. Pinned separately from
16113 // the bare-`"v0.1.0"` positive control so a future tightening
16114 // that rejects pre-release tags surfaces here.
16115 let d = dep_with_fonte(DepSource::Git {
16116 repo: "github:pleme-io/caixa-teia".into(),
16117 tag: Some("v0.1.0-alpha.1".into()),
16118 rev: None,
16119 branch: None,
16120 });
16121 d.validate().unwrap();
16122 }
16123
16124 #[test]
16125 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
16126 // The `:rev` axis is routed through `crate::render::is_git_oid`
16127 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
16128 // value with refname-shape punctuation (here, a `:` mid-string
16129 // — would be a refname violation under `is_git_ref_name` too)
16130 // is rejected at the OID-shape gate. The two predicates
16131 // partition the `:fonte` pin axes structurally: an `:rev` value
16132 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
16133 // *still* rejected here because every refname character outside
16134 // `[0-9a-f]` fails the OID gate. Same shape as
16135 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
16136 // on the refname-shaped axes — the diagnostic names the
16137 // offending dep + pin + value verbatim. The flip-from-accept
16138 // case the prior `:tag`/`:branch` gate left as a "future axis"
16139 // (e70d213) — now landed.
16140 let d = dep_with_fonte(DepSource::Git {
16141 repo: "github:pleme-io/caixa-teia".into(),
16142 tag: None,
16143 rev: Some("c0ffee:notarefname".into()),
16144 branch: None,
16145 });
16146 let err = d.validate().unwrap_err();
16147 let DepError::FontePinShape {
16148 nome,
16149 pin,
16150 value,
16151 reason,
16152 } = err
16153 else {
16154 panic!("expected FontePinShape, got other variant");
16155 };
16156 assert_eq!(nome, "caixa-teia");
16157 assert_eq!(pin, ":rev");
16158 assert_eq!(value, "c0ffee:notarefname");
16159 assert!(
16160 !reason.is_empty(),
16161 "FontePinShape `reason` must carry the predicate's wording verbatim"
16162 );
16163 }
16164
16165 #[test]
16166 fn validate_accepts_git_fonte_with_rev_full_sha1() {
16167 // The positive-control pin on the SHA-1 OID width: exactly 40
16168 // lowercase hex characters — the canonical `git rev-parse HEAD`
16169 // emission on a SHA-1-hashed repository (the default on every
16170 // pre-2.42 git and the canonical pleme-io substrate hash).
16171 // Pinned separately from the SHA-256 positive control so a
16172 // future tightening that only admits one width surfaces here.
16173 let d = dep_with_fonte(DepSource::Git {
16174 repo: "github:pleme-io/caixa-teia".into(),
16175 tag: None,
16176 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
16177 branch: None,
16178 });
16179 d.validate().unwrap();
16180 }
16181
16182 #[test]
16183 fn validate_accepts_git_fonte_with_rev_full_sha256() {
16184 // The positive-control pin on the SHA-256 OID width: exactly
16185 // 64 lowercase hex characters — `git`'s
16186 // `extensions.objectFormat = sha256` emission (GA since Git
16187 // 2.42 / Oct 2023). The substrate admits either canonical
16188 // width so an `:rev` authored against a SHA-256-hashed
16189 // upstream round-trips through the gate without per-repo
16190 // configuration. Pinned separately from the SHA-1 positive
16191 // control so a future tightening that drops one width surfaces
16192 // here as a structural decision.
16193 let d = dep_with_fonte(DepSource::Git {
16194 repo: "github:pleme-io/caixa-teia".into(),
16195 tag: None,
16196 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
16197 branch: None,
16198 });
16199 d.validate().unwrap();
16200 }
16201
16202 #[test]
16203 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
16204 // The canonical `git log --short` / `git rev-parse --short HEAD`
16205 // paste-from-release-notes footgun: a 7-char prefix (git's
16206 // default `core.abbrev`) silently passes string emptiness
16207 // checks and resolves to one commit today, but becomes ambiguous
16208 // tomorrow as the repo grows. Until this gate landed the empty-
16209 // pin arm passed (the string isn't empty) and the resolver
16210 // accepted the prefix through git's separate prefix-lookup pass
16211 // — defeating the reproducibility contract `:rev` carries vs.
16212 // `:tag` / `:branch`. The new gate moves the check to caixa-
16213 // build time and names the offending dep + pin + value verbatim.
16214 let d = dep_with_fonte(DepSource::Git {
16215 repo: "github:pleme-io/caixa-teia".into(),
16216 tag: None,
16217 rev: Some("c0ffee0".into()),
16218 branch: None,
16219 });
16220 let err = d.validate().unwrap_err();
16221 let DepError::FontePinShape {
16222 pin, value, reason, ..
16223 } = err
16224 else {
16225 panic!("expected FontePinShape, got other variant");
16226 };
16227 assert_eq!(pin, ":rev");
16228 assert_eq!(value, "c0ffee0");
16229 assert!(
16230 reason.contains("abbreviated") || reason.contains("ambiguous"),
16231 "reason must surface the abbreviation arm, got {reason:?}"
16232 );
16233 }
16234
16235 #[test]
16236 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
16237 // The canonical "I pasted the SHA in uppercase" footgun: `git
16238 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
16239 // bearing `:rev` round-trips inconsistently across the
16240 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
16241 // equality-check pipeline and fails the lacre's content-
16242 // addressing probe with a confusing case-only diff. Pinned
16243 // separately from the non-hex arm so a future relaxation that
16244 // admits one but not the other surfaces here.
16245 let d = dep_with_fonte(DepSource::Git {
16246 repo: "github:pleme-io/caixa-teia".into(),
16247 tag: None,
16248 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
16249 branch: None,
16250 });
16251 let err = d.validate().unwrap_err();
16252 let DepError::FontePinShape {
16253 pin, value, reason, ..
16254 } = err
16255 else {
16256 panic!("expected FontePinShape, got other variant");
16257 };
16258 assert_eq!(pin, ":rev");
16259 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
16260 assert!(
16261 reason.contains("uppercase"),
16262 "reason must surface the uppercase arm, got {reason:?}"
16263 );
16264 }
16265
16266 #[test]
16267 fn validate_rejects_git_fonte_with_rev_refname_value() {
16268 // The cross-axis mis-slot footgun: `:rev "main"` — the author
16269 // conflated `:rev` (hex commit ID, immutable) and `:branch`
16270 // (mutable ref pointing at whatever HEAD is today). Until this
16271 // gate landed the resolver silently dispatched on the value
16272 // shape ("`main` doesn't look like a SHA, fall back to
16273 // refname"), defeating the `:rev` reproducibility contract.
16274 // The new gate rejects every non-hex value on the `:rev` axis,
16275 // so the `:rev`/`:branch` boundary is structurally enforced —
16276 // a refname in the `:rev` slot is a build error, not a
16277 // resolver-time silent reinterpretation.
16278 let d = dep_with_fonte(DepSource::Git {
16279 repo: "github:pleme-io/caixa-teia".into(),
16280 tag: None,
16281 rev: Some("main".into()),
16282 branch: None,
16283 });
16284 let err = d.validate().unwrap_err();
16285 let DepError::FontePinShape {
16286 pin, value, reason, ..
16287 } = err
16288 else {
16289 panic!("expected FontePinShape, got other variant");
16290 };
16291 assert_eq!(pin, ":rev");
16292 assert_eq!(value, "main");
16293 // 4 chars `main` fails the length arm before the character arm,
16294 // so the diagnostic surfaces the abbreviation wording (same
16295 // path the `c0ffee0` 7-char fixture lands on); the structural
16296 // assertion is just that the `:rev "main"` value is rejected.
16297 assert!(
16298 !reason.is_empty(),
16299 "FontePinShape reason must be non-empty for refname-shaped :rev"
16300 );
16301 }
16302
16303 #[test]
16304 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
16305 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
16306 // conflated `:rev` and `:tag`. Pinned separately from the
16307 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
16308 // that catches one but not the other surfaces here. The
16309 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
16310 // assertion is just that the cross-axis mis-slot is a build
16311 // error, regardless of which sub-arm surfaces the diagnostic
16312 // (`is_git_oid` rejects at the first violation; longer
16313 // tag-shape values would hit the non-hex arm instead).
16314 let d = dep_with_fonte(DepSource::Git {
16315 repo: "github:pleme-io/caixa-teia".into(),
16316 tag: None,
16317 rev: Some("v0.1.0".into()),
16318 branch: None,
16319 });
16320 let err = d.validate().unwrap_err();
16321 let DepError::FontePinShape {
16322 pin, value, reason, ..
16323 } = err
16324 else {
16325 panic!("expected FontePinShape, got other variant");
16326 };
16327 assert_eq!(pin, ":rev");
16328 assert_eq!(value, "v0.1.0");
16329 assert!(
16330 !reason.is_empty(),
16331 "FontePinShape reason must be non-empty for tag-shaped :rev"
16332 );
16333 }
16334
16335 #[test]
16336 fn validate_rejects_git_fonte_with_rev_too_long() {
16337 // Boundary case on the upper end: 41 hex chars — one past the
16338 // SHA-1 width, well below the SHA-256 width. Pin so a future
16339 // relaxation that admits "long enough to be a SHA" without
16340 // matching either canonical width surfaces here. The diagnostic
16341 // names the offending length verbatim so the author's grep
16342 // target is unambiguous (either trim one char or paste the
16343 // full SHA-256).
16344 let too_long: String = "0".repeat(41);
16345 let d = dep_with_fonte(DepSource::Git {
16346 repo: "github:pleme-io/caixa-teia".into(),
16347 tag: None,
16348 rev: Some(too_long.clone()),
16349 branch: None,
16350 });
16351 let err = d.validate().unwrap_err();
16352 let DepError::FontePinShape {
16353 pin, value, reason, ..
16354 } = err
16355 else {
16356 panic!("expected FontePinShape, got other variant");
16357 };
16358 assert_eq!(pin, ":rev");
16359 assert_eq!(value, too_long);
16360 assert!(
16361 reason.contains("41"),
16362 "reason must surface the offending length verbatim, got {reason:?}"
16363 );
16364 }
16365
16366 #[test]
16367 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
16368 // The canonical paste-from-doc footgun on `:rev` — author
16369 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
16370 // commit-message paragraph. Until this gate landed the empty-
16371 // pin arm passed (the string isn't empty), the resolver issued
16372 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
16373 // clone time with a quoting-confused git error far from the
16374 // source caixa.lisp. The new gate moves the check to caixa-
16375 // build time. Length is 41 (40 hex + space) so the length arm
16376 // fires first — pinned separately from the pure-length arm to
16377 // ensure the diagnostic surfaces *some* parser wording, not
16378 // silently pass through.
16379 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
16380 let d = dep_with_fonte(DepSource::Git {
16381 repo: "github:pleme-io/caixa-teia".into(),
16382 tag: None,
16383 rev: Some(with_space.clone()),
16384 branch: None,
16385 });
16386 let err = d.validate().unwrap_err();
16387 let DepError::FontePinShape {
16388 pin, value, reason, ..
16389 } = err
16390 else {
16391 panic!("expected FontePinShape, got other variant");
16392 };
16393 assert_eq!(pin, ":rev");
16394 assert_eq!(value, with_space);
16395 assert!(
16396 !reason.is_empty(),
16397 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
16398 );
16399 }
16400
16401 #[test]
16402 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
16403 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
16404 // variant on this axis names the offending dep's `:nome` + the
16405 // `:rev` axis + the offending value verbatim, so the author's
16406 // grep target is the literal `:rev "<value>"` block in
16407 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
16408 // carries_offending_nome_pin_value` test on the refname-shaped
16409 // (`:tag` / `:branch`) axes.
16410 let d = dep_with_fonte(DepSource::Git {
16411 repo: "github:p/x".into(),
16412 tag: None,
16413 rev: Some("not-a-sha".into()),
16414 branch: None,
16415 });
16416 let msg = d
16417 .validate()
16418 .expect_err(":rev: expected FontePinShape")
16419 .to_string();
16420 assert!(
16421 msg.contains("\"caixa-teia\""),
16422 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16423 );
16424 assert!(
16425 msg.contains(":rev"),
16426 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
16427 );
16428 assert!(
16429 msg.contains("not-a-sha"),
16430 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
16431 );
16432 }
16433
16434 #[test]
16435 fn fonte_pin_empty_fires_before_pin_shape() {
16436 // Order pin: a `Some("")` `:tag` is the more self-locating
16437 // diagnostic (the author chose an axis but left it blank;
16438 // grep is unambiguous), so it fires before the shape gate
16439 // even when both arms would match. Pinned so a future
16440 // reordering surfaces here. Mirrors the
16441 // `fonte_repo_empty_fires_before_pin_missing` ordering
16442 // discipline on the peer per-axis arms.
16443 let d = dep_with_fonte(DepSource::Git {
16444 repo: "github:pleme-io/caixa-teia".into(),
16445 tag: Some(String::new()),
16446 rev: None,
16447 branch: None,
16448 });
16449 assert!(matches!(
16450 d.validate().unwrap_err(),
16451 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16452 ));
16453 }
16454
16455 #[test]
16456 fn fonte_pin_shape_fires_after_repo_empty() {
16457 // Order pin: `:repo ""` is the more self-locating axis
16458 // (every git source needs a repo; the per-pin shape gate is
16459 // secondary), so the repo-empty arm fires before the
16460 // per-pin shape arm even when both are violated. Pinned so
16461 // a future reordering surfaces here. Mirrors
16462 // `fonte_repo_empty_fires_before_pin_missing` on the
16463 // adjacent axis pair.
16464 let d = dep_with_fonte(DepSource::Git {
16465 repo: String::new(),
16466 tag: Some("v0.1.0 ".into()),
16467 rev: None,
16468 branch: None,
16469 });
16470 assert!(matches!(
16471 d.validate().unwrap_err(),
16472 DepError::FonteRepoEmpty { .. }
16473 ));
16474 }
16475
16476 #[test]
16477 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16478 // Diagnostic-shape pin across both refname-shaped axes
16479 // (`:tag` + `:branch`): every `FontePinShape` variant names
16480 // the offending dep's `:nome` + the offending pin axis + the
16481 // offending value verbatim, so the author's grep target is
16482 // unambiguous (the literal `:tag "<value>"` / `:branch
16483 // "<value>"` lands in caixa.lisp with quotes). Cover both
16484 // pin axes so a future variant addition forces a parallel
16485 // diagnostic-shape decision.
16486 for (pin_label, fonte) in [
16487 (
16488 ":tag",
16489 DepSource::Git {
16490 repo: "github:p/x".into(),
16491 tag: Some("v0.1.0~1".into()),
16492 rev: None,
16493 branch: None,
16494 },
16495 ),
16496 (
16497 ":branch",
16498 DepSource::Git {
16499 repo: "github:p/x".into(),
16500 tag: None,
16501 rev: None,
16502 branch: Some("feature/foo*".into()),
16503 },
16504 ),
16505 ] {
16506 let d = dep_with_fonte(fonte);
16507 let msg = d
16508 .validate()
16509 .expect_err(&format!("{pin_label}: expected FontePinShape"))
16510 .to_string();
16511 assert!(
16512 msg.contains("\"caixa-teia\""),
16513 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16514 );
16515 assert!(
16516 msg.contains(pin_label),
16517 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16518 );
16519 }
16520 }
16521
16522 #[test]
16523 fn git_source_json_round_trip() {
16524 let src = DepSource::Git {
16525 repo: "github:pleme-io/caixa-teia".into(),
16526 tag: Some("v0.1.0".into()),
16527 rev: None,
16528 branch: None,
16529 };
16530 let s = serde_json::to_string(&src).unwrap();
16531 assert!(s.contains(&format!(
16532 r#""{tipo}":"{git}""#,
16533 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16534 git = crate::render::DEP_SOURCE_TIPO_GIT,
16535 )));
16536 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16537 assert!(s.contains(r#""tag":"v0.1.0""#));
16538 assert!(!s.contains("rev"));
16539 assert!(!s.contains("branch"));
16540 let round: DepSource = serde_json::from_str(&s).unwrap();
16541 assert_eq!(round, src);
16542 }
16543
16544 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16545 //
16546 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16547 // attribute on [`DepSource`] pins three load-bearing byte-sequences
16548 // that flow into every serialized `Dep.fonte` block: the outer
16549 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16550 // the two admitted variant-tag values `"git"` / `"path"` the
16551 // `rename_all = "lowercase"` attribute pins as the discriminator's
16552 // closed-set arms. The three pin tests below round-trip a
16553 // fully-populated variant of each arm through
16554 // [`serde_json::to_value`] and assert each canonical byte-sequence
16555 // appears at its axis — pins a hypothetical future
16556 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16557 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16558 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16559 // at build time rather than at fetch time when the resolver's
16560 // `Dep.fonte` dispatch silently fails to match on the drifted
16561 // discriminator. Same "serialize-and-check" discipline the peer
16562 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16563 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16564 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16565 // family in caixa-core lacking a lifted peer.
16566
16567 #[test]
16568 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16569 // Fail-before-pass-after: a future `tag = "type"` at the derive
16570 // attribute would serialize under `"type":"git"`, and this test
16571 // would trip because `"tipo"` no longer appears at the emitted
16572 // discriminator key. A future `rename_all = "kebab-case"` /
16573 // `"snake_case"` (both no-ops on `Git` since it lacks internal
16574 // word boundaries) is caught by the sibling
16575 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16576 // pin below (Path has no internal boundary either but the pair
16577 // catches any per-arm inconsistency). A future variant rename
16578 // `Git` → `Repository` would emit `"tipo":"repository"` and
16579 // trip this pin.
16580 let src = DepSource::Git {
16581 repo: "github:pleme-io/caixa-teia".into(),
16582 tag: Some("v0.1.0".into()),
16583 rev: None,
16584 branch: None,
16585 };
16586 let json = serde_json::to_value(&src).unwrap();
16587 let obj = json.as_object().expect("Git serializes as a JSON object");
16588 assert_eq!(
16589 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16590 .and_then(serde_json::Value::as_str),
16591 Some(crate::render::DEP_SOURCE_TIPO_GIT),
16592 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16593 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16594 detected in {json}"
16595 );
16596 }
16597
16598 #[test]
16599 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16600 // Fail-before-pass-after: a future variant rename `Path` →
16601 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16602 // this pin. A per-consumer disambiguation as the `defcaixa`
16603 // macro stabilizes ("caminho" → "path" for English-uniformity)
16604 // is scoped to the inner field key, not the discriminator; this
16605 // pin is orthogonal to that and catches only the outer
16606 // discriminator drift.
16607 let src = DepSource::Path {
16608 caminho: "../caixa-teia".into(),
16609 };
16610 let json = serde_json::to_value(&src).unwrap();
16611 let obj = json.as_object().expect("Path serializes as a JSON object");
16612 assert_eq!(
16613 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16614 .and_then(serde_json::Value::as_str),
16615 Some(crate::render::DEP_SOURCE_TIPO_PATH),
16616 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16617 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16618 detected in {json}"
16619 );
16620 }
16621
16622 #[test]
16623 fn dep_source_key_consts_are_pairwise_distinct() {
16624 // Cross-axis collapse detector: a hypothetical future edit that
16625 // accidentally set two of the three consts to the same byte
16626 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16627 // pass every per-arm serialize pin above but silently collapse
16628 // the discriminator's closed-set arms onto one another; this pin
16629 // catches the collapse at build time.
16630 assert_ne!(
16631 crate::render::DEP_SOURCE_KEY_TIPO,
16632 crate::render::DEP_SOURCE_TIPO_GIT,
16633 );
16634 assert_ne!(
16635 crate::render::DEP_SOURCE_KEY_TIPO,
16636 crate::render::DEP_SOURCE_TIPO_PATH,
16637 );
16638 assert_ne!(
16639 crate::render::DEP_SOURCE_TIPO_GIT,
16640 crate::render::DEP_SOURCE_TIPO_PATH,
16641 );
16642 }
16643
16644 #[test]
16645 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16646 // Shape pin against `rename_all` drift: the two variant-tag
16647 // consts must be ASCII-lowercase-only to match the
16648 // `rename_all = "lowercase"` attribute the derive uses; a future
16649 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16650 // would emit `"GIT"` / `"Git"` instead and trip this pin.
16651 for (label, s) in [
16652 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16653 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16654 ] {
16655 assert!(!s.is_empty(), "{label} must not be empty");
16656 assert!(
16657 s.bytes().all(|b| b.is_ascii_lowercase()),
16658 "{label} must be ASCII-lowercase-only (matching \
16659 rename_all = \"lowercase\"), got {s:?}",
16660 );
16661 }
16662 }
16663
16664 // ── per-entry :caracteristicas set-not-multiset gate ────────────
16665 //
16666 // Every Vec-keyed-by-name authoring surface on the typed Caixa
16667 // surface that identifies its entries by a name field now uniformly
16668 // closes the set-not-multiset discipline at build time (cite
16669 // `validate_caracteristicas`'s peer-axis enumeration). The
16670 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16671 // set-shaped (a feature is either enabled or not — there is no
16672 // `feature × 2` semantic), so two entries naming the same feature
16673 // are a redundant declaration the caixa-resolver's lacre pipeline
16674 // would silently dedup at resolve time. The empty-feature arm
16675 // closes the parallel "operationally-meaningless value" axis on
16676 // the same slot. Same linear-walk + `HashSet` + first-collision
16677 // shape every peer set gate uses; same empty-first cascade every
16678 // peer per-entry shape + duplicate gate uses (the empty-feature
16679 // axis is the more-actionable defect since two `""` entries would
16680 // both report `caracteristica: ""` under a duplicate-first
16681 // ordering, with no way to distinguish the offending site).
16682
16683 fn dep_with_features(features: &[&str]) -> Dep {
16684 Dep {
16685 nome: "caixa-teia".into(),
16686 versao: "^0.1".into(),
16687 fonte: None,
16688 opcional: false,
16689 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16690 }
16691 }
16692
16693 #[test]
16694 fn validate_rejects_empty_caracteristica() {
16695 // Fail-before-pass-after pin: every pre-gate codebase accepted
16696 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16697 // imposed no per-entry shape contract), the dep validated, and
16698 // the empty feature would have reached the future caixa-resolver
16699 // lacre pipeline as a no-op feature enable — silently dropping
16700 // the author's intent far from the source `caixa.lisp`. The new
16701 // gate surfaces the structural defect at the typed-validate
16702 // surface with a self-locating diagnostic naming the offending
16703 // dep's `:nome`.
16704 let d = dep_with_features(&[""]);
16705 assert!(
16706 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16707 "expected CaracteristicaEmpty, got {:?}",
16708 d.validate(),
16709 );
16710 }
16711
16712 #[test]
16713 fn validate_rejects_duplicate_caracteristica() {
16714 // Fail-before-pass-after pin on the set-not-multiset arm: the
16715 // feature-toggle slot is set-shaped, so `(:caracteristicas
16716 // ("http" "http"))` is a redundant declaration the lacre
16717 // pipeline dedupes silently at resolve time. The diagnostic
16718 // names the offending dep + the colliding feature verbatim so
16719 // the author can grep their caixa.lisp for `:caracteristicas`
16720 // and fix it in one edit. First-collision determinism is
16721 // pinned separately below.
16722 let d = dep_with_features(&["http", "http"]);
16723 assert!(
16724 matches!(
16725 d.validate().unwrap_err(),
16726 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16727 if nome == "caixa-teia" && caracteristica == "http"
16728 ),
16729 "expected CaracteristicaDuplicate, got {:?}",
16730 d.validate(),
16731 );
16732 }
16733
16734 #[test]
16735 fn validate_accepts_distinct_caracteristicas() {
16736 // The canonical authoring shape — every feature distinct — must
16737 // remain a clean pass (positive control sweep). Covers the
16738 // canonical kebab-case feature names a target caixa typically
16739 // declares.
16740 dep_with_features(&["http", "json", "tls"])
16741 .validate()
16742 .unwrap();
16743 }
16744
16745 #[test]
16746 fn validate_accepts_single_caracteristica() {
16747 // Single-element list is the minimum non-empty shape; passes
16748 // the gate as the identity of the duplicate check (no second
16749 // entry to collide with).
16750 dep_with_features(&["http"]).validate().unwrap();
16751 }
16752
16753 #[test]
16754 fn validate_accepts_empty_caracteristicas_list() {
16755 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16756 // produces `caracteristicas: Vec::new()`; the empty list is
16757 // the gate's empty-set identity and passes vacuously. Pin
16758 // this so a future tightening that requires ≥1 feature
16759 // surfaces here as a test failure rather than a silent
16760 // contract narrowing.
16761 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16762 assert!(dep_with_features(&[]).validate().is_ok());
16763 }
16764
16765 #[test]
16766 fn validate_caracteristica_empty_fires_before_duplicate() {
16767 // Empty-first cascade: an entry with an empty feature *and*
16768 // duplicate entries surfaces the empty diagnostic first. The
16769 // empty-feature axis is the more-actionable defect since
16770 // `caracteristica: ""` is unambiguous; under duplicate-first
16771 // ordering the diagnostic could report the empty string from
16772 // either of two empty entries with no way to distinguish.
16773 // Mirrors the peer empty-before-duplicate ordering
16774 // discipline every per-entry shape + duplicate gate establishes
16775 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16776 // `DuplicateChildCaixa`, `validate_membros`'s
16777 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16778 let d = dep_with_features(&["", "http", "http"]);
16779 assert!(matches!(
16780 d.validate().unwrap_err(),
16781 DepError::CaracteristicaEmpty { .. }
16782 ));
16783 }
16784
16785 #[test]
16786 fn validate_caracteristica_duplicate_first_collision_determinism() {
16787 // Three matching entries: the second occurrence surfaces the
16788 // diagnostic (the second is the first *collision* — the first
16789 // entry is the establishing one, not a duplicate). Mirrors
16790 // every peer first-collision posture
16791 // (`SupervisorError::DuplicateChildCaixa` reports the second
16792 // collision, `AplicacaoError::MembroDuplicate` reports the
16793 // second, `DepError::DuplicateNome` reports the second).
16794 // Pinning this so a future shortcut that flips to last-
16795 // collision (or non-deterministic) surfaces here.
16796 let d = dep_with_features(&["http", "http", "http"]);
16797 assert!(matches!(
16798 d.validate().unwrap_err(),
16799 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16800 ));
16801 }
16802
16803 #[test]
16804 fn validate_per_entry_shape_fires_before_caracteristicas() {
16805 // Per-entry shape precedence: a dep with a malformed `:nome`
16806 // (uppercase) AND duplicate `:caracteristicas` surfaces the
16807 // narrower `NomeInvalid` diagnostic first, not the set-gate
16808 // diagnostic. The `:nome` is the self-locating axis (every
16809 // diagnostic from the caracteristicas gate quotes the
16810 // offending dep's `:nome` to anchor the grep target —
16811 // surfacing the malformed name first keeps that anchor
16812 // valid). Same precedence shape every peer per-entry-shape
16813 // arm establishes against its peer set-gate
16814 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16815 // on the cross-entry `:nome` axis).
16816 let d = Dep {
16817 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16818 versao: "^0.1".into(),
16819 fonte: None,
16820 opcional: false,
16821 caracteristicas: vec!["http".into(), "http".into()],
16822 };
16823 assert!(matches!(
16824 d.validate().unwrap_err(),
16825 DepError::NomeInvalid { .. }
16826 ));
16827 }
16828
16829 // ── per-entry :caracteristicas value-shape gate ──────────────────
16830 //
16831 // Until this gate landed `:caracteristicas` only refused the empty
16832 // string and cross-entry duplicates: a non-empty distinct but
16833 // structurally invalid feature name silently passed validate and the
16834 // failure surfaced at `cargo metadata` time as Cargo's
16835 // `restricted_names::validate_feature_name` parser rejection, far from
16836 // the source `caixa.lisp` with no field naming which `:deps` entry's
16837 // `:caracteristicas` carried the typo. The lifted predicate makes the
16838 // Cargo-feature-name-grammar intersection-floor a substrate-level
16839 // invariant at validate time. Same trajectory as the eight peer
16840 // value-shape predicates each typed surface downstream of a structured
16841 // grammar already follows.
16842
16843 #[test]
16844 fn validate_rejects_caracteristica_with_leading_plus() {
16845 // Fail-before-pass-after pin on the canonical Cargo
16846 // `+<feature>` activation-form-in-feature-name-slot footgun.
16847 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16848 // `+optional-feature` as an enablement of a previously-disabled
16849 // feature; pasting that activation form into `:caracteristicas`
16850 // (which names the feature itself) silently passed pre-gate and
16851 // failed at `cargo metadata` parse time.
16852 let d = dep_with_features(&["+http"]);
16853 let err = d.validate().unwrap_err();
16854 assert!(
16855 matches!(
16856 err,
16857 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16858 if nome == "caixa-teia" && caracteristica == "+http"
16859 ),
16860 "expected CaracteristicaInvalid, got {err:?}"
16861 );
16862 }
16863
16864 #[test]
16865 fn validate_rejects_caracteristica_with_leading_hyphen() {
16866 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16867 // is a legitimate continuation character (kebab-case feature
16868 // names like `runtime-tokio` pass) but Cargo rejects it at the
16869 // start; the structural defect — and its CLI-argument-injection
16870 // adjacency at any downstream Cargo subprocess invocation — is
16871 // closed at validate time, not at `cargo metadata` time.
16872 let d = dep_with_features(&["-json"]);
16873 let err = d.validate().unwrap_err();
16874 assert!(
16875 matches!(
16876 err,
16877 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16878 ),
16879 "expected CaracteristicaInvalid, got {err:?}"
16880 );
16881 }
16882
16883 #[test]
16884 fn validate_rejects_caracteristica_with_leading_dot() {
16885 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16886 // a legitimate continuation character (version-suffix shapes
16887 // like `feat.v2` pass) but the leading-dot form is the
16888 // canonical dotted-version-suffix-as-feature-name confusion.
16889 let d = dep_with_features(&[".feat"]);
16890 let err = d.validate().unwrap_err();
16891 assert!(matches!(
16892 err,
16893 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16894 ));
16895 }
16896
16897 #[test]
16898 fn validate_rejects_caracteristica_with_whitespace() {
16899 // Fail-before-pass-after pin on the embedded-whitespace footgun:
16900 // a feature name with a space inside is structurally a multi-
16901 // token blob (the canonical paste-from-doc footgun, or an
16902 // accidental `"http server"` where the author meant
16903 // `"http-server"`).
16904 let d = dep_with_features(&["http feature"]);
16905 let err = d.validate().unwrap_err();
16906 assert!(matches!(
16907 err,
16908 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16909 ));
16910 }
16911
16912 #[test]
16913 fn validate_rejects_caracteristica_with_comma() {
16914 // Fail-before-pass-after pin on the embedded-comma footgun:
16915 // the list-separator-belongs-to-the-list-grammar
16916 // miscomprehension where the author writes
16917 // `:caracteristicas ("http,json")` intending two features but
16918 // the `Vec<String>` field consumes the bare token as one entry.
16919 let d = dep_with_features(&["http,json"]);
16920 let err = d.validate().unwrap_err();
16921 assert!(matches!(
16922 err,
16923 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16924 ));
16925 }
16926
16927 #[test]
16928 fn validate_rejects_caracteristica_with_slash() {
16929 // Fail-before-pass-after pin on the embedded-slash footgun:
16930 // Cargo's `dep/feat` namespaced-dep syntax applies inside
16931 // `[dependencies.<dep>.features]` list entries that already
16932 // name the parent dep (so the syntax says "enable feature
16933 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16934 // per-dep already (a sibling slot on the `Dep` itself), so the
16935 // segment separator within an entry must be `-`, `_`, `+`,
16936 // or `.`. The diagnostic remediation points at the canonical
16937 // Cargo namespaced-dep discipline.
16938 let d = dep_with_features(&["http/json"]);
16939 let err = d.validate().unwrap_err();
16940 assert!(matches!(
16941 err,
16942 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16943 ));
16944 }
16945
16946 #[test]
16947 fn validate_rejects_caracteristica_with_non_ascii() {
16948 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16949 // byte footgun: NFC-vs-NFD normalization across filesystems
16950 // silently rewrites the feature-key, breaking the lacre's
16951 // content-addressing invariant. Pinned at a canonical
16952 // smart-quote-paste shape (`café`) where the raw `é` byte is the
16953 // documented APFS round-trip break.
16954 let d = dep_with_features(&["caf\u{e9}"]);
16955 let err = d.validate().unwrap_err();
16956 assert!(matches!(
16957 err,
16958 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16959 ));
16960 }
16961
16962 #[test]
16963 fn validate_rejects_caracteristica_with_control_character() {
16964 // Fail-before-pass-after pin on the embedded-control-character
16965 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16966 // feature name is the canonical paste-from-multiline-doc
16967 // footgun the predicate's reason wording specifically calls out.
16968 let d = dep_with_features(&["http\njson"]);
16969 let err = d.validate().unwrap_err();
16970 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16971 }
16972
16973 #[test]
16974 fn validate_accepts_canonical_caracteristicas_shapes() {
16975 // Positive control sweep: every canonical Cargo feature name
16976 // shape the pleme-io ecosystem uses must still pass. Mirrors
16977 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16978 // sweep — drift between either landing site and the predicate's
16979 // accepted set is a build error visible at this pair of tests,
16980 // not a per-renderer "this passed validate but failed at
16981 // cargo metadata time" surprise on the next acceptance.
16982 for s in [
16983 "http",
16984 "json",
16985 "derive",
16986 "serde_json",
16987 "runtime-tokio",
16988 "tokio.full",
16989 "v0.1",
16990 "http+json",
16991 "_internal",
16992 "__private",
16993 "default",
16994 "rt-multi-thread",
16995 "feat.v2",
16996 ] {
16997 let d = dep_with_features(&[s]);
16998 d.validate().unwrap_or_else(|e| {
16999 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
17000 });
17001 }
17002 }
17003
17004 #[test]
17005 fn validate_caracteristica_empty_fires_before_invalid() {
17006 // Cascade precedence pin: an entry list with both an empty
17007 // feature AND an invalid-shape feature surfaces the
17008 // `CaracteristicaEmpty` arm first (the empty value carries no
17009 // self-locating data — `caracteristica: ""` is the diagnostic
17010 // with no way to anchor a grep target — so closing the empty
17011 // axis first preserves the per-entry-shape diagnostic's
17012 // self-locating discipline). Same empty-first cascade every
17013 // peer per-entry shape gate establishes
17014 // (`SupervisorSpec::validate`'s `EmptyChildName` before
17015 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
17016 // before `MembroCaixaInvalid`).
17017 let d = dep_with_features(&["", "+http"]);
17018 assert!(matches!(
17019 d.validate().unwrap_err(),
17020 DepError::CaracteristicaEmpty { .. }
17021 ));
17022 }
17023
17024 #[test]
17025 fn validate_caracteristica_invalid_fires_before_duplicate() {
17026 // Per-entry-shape precedence pin: an entry list with the same
17027 // invalid feature shape declared twice surfaces the
17028 // `CaracteristicaInvalid` diagnostic on the first entry, not
17029 // the `CaracteristicaDuplicate` on the second collision. The
17030 // per-entry shape gate fires before the cross-entry set gate
17031 // — same precedence shape every peer two-arm-plus-set gate
17032 // establishes (`SupervisorSpec::validate`'s
17033 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
17034 // `validate_membros`'s `MembroCaixaInvalid` before
17035 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
17036 // cross-list `DuplicateNome`).
17037 let d = dep_with_features(&["+http", "+http"]);
17038 assert!(matches!(
17039 d.validate().unwrap_err(),
17040 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
17041 ));
17042 }
17043
17044 #[test]
17045 fn validate_rejects_caracteristica_at_65_byte_boundary() {
17046 // Boundary pin on the 64-byte cap — both the boundary-accepting
17047 // case and the boundary-exceeding case in one place, so a
17048 // future cap shift surfaces both arms simultaneously, mirroring
17049 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
17050 // predicate-level pin at the dep-axis landing site.
17051 let max_ok = "a".repeat(64);
17052 dep_with_features(&[&max_ok])
17053 .validate()
17054 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
17055 let too_long = "a".repeat(65);
17056 let d = dep_with_features(&[&too_long]);
17057 assert!(matches!(
17058 d.validate().unwrap_err(),
17059 DepError::CaracteristicaInvalid { .. }
17060 ));
17061 }
17062
17063 // ── self-dep cross-slot gate ─────────────────────────────────────
17064
17065 #[test]
17066 fn validate_no_self_dep_rejects_self_in_deps() {
17067 // A caixa whose `:deps` lists its own `:nome` is a one-node
17068 // cycle in the lacre closure's dep-graph traversal — rejected,
17069 // naming the parent and the offending list tag.
17070 let deps = vec![
17071 Dep::simple("caixa-teia", "^0.1"),
17072 Dep::simple("orquestra", "^0.1"),
17073 ];
17074 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17075 assert!(
17076 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17077 "got {err:?}"
17078 );
17079 }
17080
17081 #[test]
17082 fn validate_no_self_dep_rejects_self_in_deps_dev() {
17083 // Same gate on the `:deps-dev` axis — neither dep list is a
17084 // second-class citizen on the self-edge invariant.
17085 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17086 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17087 assert!(
17088 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17089 "got {err:?}"
17090 );
17091 }
17092
17093 #[test]
17094 fn validate_no_self_dep_deps_fires_before_deps_dev() {
17095 // Walk order pin: a caixa that self-references on both lists
17096 // surfaces the `:deps` arm first — the load-bearing axis the
17097 // lacre closure resolves at every build. Mirrors the canonical
17098 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
17099 let deps = vec![Dep::simple("orquestra", "^0.1")];
17100 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
17101 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
17102 assert!(
17103 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17104 "got {err:?}"
17105 );
17106 }
17107
17108 #[test]
17109 fn validate_no_self_dep_accepts_distinct_names() {
17110 // Positive control: every dep names a distinct caixa. The
17111 // canonical author surface — peer of
17112 // [`validate_no_self_supervision_accepts_distinct_children`].
17113 let deps = vec![
17114 Dep::simple("caixa-teia", "^0.1"),
17115 Dep::simple("caixa-arch", "^0.1"),
17116 ];
17117 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
17118 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
17119 }
17120
17121 #[test]
17122 fn validate_no_self_dep_empty_lists_pass() {
17123 // A caixa with no declared deps has nothing to self-reference —
17124 // the gate is vacuously satisfied. Peer of
17125 // [`validate_no_self_supervision_empty_children_is_ok`].
17126 validate_no_self_dep(&[], &[], "orquestra").unwrap();
17127 }
17128
17129 #[test]
17130 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
17131 // Diagnostic-shape pin (peer with
17132 // [`validate_no_self_supervision`]'s diagnostic): the error's
17133 // Display surfaces both the offending list tag and the
17134 // parent's `:nome` verbatim, so the author can grep their
17135 // caixa.lisp for the offending block in one edit. Names
17136 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
17137 // surface — every legitimate "I want to use code from this
17138 // caixa" intent routes through one of those three slots.
17139 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17140 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
17141 .unwrap_err()
17142 .to_string();
17143 assert!(
17144 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17145 "diagnostic must name the offending list tag: {rendered}",
17146 );
17147 assert!(
17148 rendered.contains("orquestra"),
17149 "diagnostic must quote the parent caixa name: {rendered}",
17150 );
17151 assert!(
17152 rendered.contains(":bibliotecas"),
17153 "diagnostic must point at the corrective code-surface slot: {rendered}",
17154 );
17155 }
17156
17157 #[test]
17158 fn validate_no_self_dep_accepts_coincidental_substring_match() {
17159 // Identity is exact-string equality, not substring — a dep
17160 // named `"orquestra-helper"` is a distinct caixa even when the
17161 // parent is `"orquestra"`. Pin the exact-match discipline so a
17162 // future relaxation that uses `contains` surfaces here, peer
17163 // with the supervision-tree and Aplicacao-membership gates
17164 // which all use exact-string equality on the typed identity.
17165 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
17166 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17167 }
17168
17169 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
17170
17171 #[test]
17172 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
17173 // Scalar-value pin: the two author-facing kebab-case labels the
17174 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
17175 // the two-list dep-graph slot axis, one arm per typed slot.
17176 // Mirrors the peer scalar-value pin the sibling
17177 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
17178 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
17179 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
17180 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
17181 // (882f498) M3 top-level author-labels, and
17182 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
17183 // Supervisor top-level author-labels carry, so every kind-scoped
17184 // typed-slot-family axis routes through one canonical per-arm
17185 // declaration.
17186 //
17187 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
17188 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
17189 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
17190 // for symmetry) lands as an edit to exactly one const, and
17191 // every consumer that reaches for the label picks it up at
17192 // build time rather than at runtime as a downstream mismatch on
17193 // a `DepError::DuplicateNome { list: … }` diagnostic far from
17194 // the rename's commit.
17195 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
17196 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
17197 }
17198
17199 #[test]
17200 fn dep_author_key_consts_are_pairwise_distinct() {
17201 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
17202 // must not collapse onto one byte-string. A future copy-paste
17203 // slip that renamed both consts to the same value (or a rebrand
17204 // that dropped the `-dev` suffix from one but not the other)
17205 // would leave every `DepError::DuplicateNome { list: … }`
17206 // diagnostic naming an unattributable list — the linter would
17207 // route the author to the wrong caixa.lisp block, or the
17208 // cross-list precedence gate
17209 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
17210 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
17211 // duplicate. Peer of the sibling
17212 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
17213 // other top-level kind-scoped slot-family axes carry
17214 // (implicitly held by their different byte-values today).
17215 assert_ne!(
17216 crate::render::DEP_AUTHOR_KEY_DEPS,
17217 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17218 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
17219 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
17220 self-locates the offending block in the author's caixa.lisp",
17221 );
17222 }
17223
17224 #[test]
17225 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
17226 // Production-through-const pin: the two per-arm list tags
17227 // [`validate_no_self_dep`] threads onto the `list:` field of a
17228 // returned [`DepError::DepIsSelf`] route through the lifted
17229 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
17230 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
17231 // the walker (a rename that reaches one arm but not the const,
17232 // or vice versa) surfaces here at build time rather than at
17233 // runtime as a `feira lint` diagnostic naming the wrong list
17234 // tag. Mirror of the peer
17235 // [`crate::Caixa::declared_servico_slots`] production tagger
17236 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
17237 // onto the two-list dep-graph gate.
17238 let deps = vec![Dep::simple("orquestra", "^0.1")];
17239 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17240 let DepError::DepIsSelf { list, .. } = err else {
17241 panic!("expected DepIsSelf from :deps walk");
17242 };
17243 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
17244
17245 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17246 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17247 let DepError::DepIsSelf { list, .. } = err else {
17248 panic!("expected DepIsSelf from :deps-dev walk");
17249 };
17250 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
17251 }
17252
17253 // ── Dep::nome accessor pins ───────────────────────────────────────
17254 //
17255 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
17256 // projection over the plain-shorthand / explicit-git / explicit-path
17257 // fixture triad the [`Dep`] docstring lists (so the accessor's
17258 // accept-set is exercised across every author-surface `:fonte`
17259 // shape); by-borrow pointer identity so the projection stays
17260 // zero-copy at every consumer site; and validate-composition through
17261 // the [`validate_no_self_dep`] cross-slot gate reading its
17262 // parent-name equality check through the lifted accessor rather than
17263 // the raw field.
17264
17265 #[test]
17266 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
17267 // Plain-shorthand form (`:fonte None`).
17268 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
17269 // Explicit git-source form with a tag pin — same accessor path.
17270 assert_eq!(
17271 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
17272 "caixa-teia",
17273 );
17274 // Explicit path-source form.
17275 assert_eq!(
17276 Dep {
17277 nome: "caixa-teia".to_string(),
17278 versao: "0.1.0".to_string(),
17279 fonte: Some(DepSource::Path {
17280 caminho: "../caixa-teia".to_string(),
17281 }),
17282 opcional: false,
17283 caracteristicas: Vec::new(),
17284 }
17285 .nome(),
17286 "caixa-teia",
17287 );
17288 // The empty-string `:nome` sentinel (which [`Dep::validate`]
17289 // refuses through the [`DepError::NomeEmpty`] arm) still round-
17290 // trips as an empty `&str` through the accessor — the accessor is
17291 // a projection, not a gate; the gate is [`Dep::validate`].
17292 assert_eq!(Dep::simple("", "^0.1").nome(), "");
17293 }
17294
17295 #[test]
17296 fn dep_nome_is_by_borrow_pointer_identity() {
17297 // Zero-copy pin: the accessor must borrow into the field's own
17298 // storage, not clone. If a future rewrite regresses to
17299 // `self.nome.clone().leak()` or an owned-buffer shape, the two
17300 // pointers diverge and this pin fails at build time.
17301 let d = Dep::simple("caixa-teia", "^0.1");
17302 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
17303 }
17304
17305 // ── Dep::versao_requirement accessor pins ─────────────────────────
17306 //
17307 // Three coherence pins on the lifted `Dep::versao_requirement`
17308 // accessor: byte-equal projection over the plain-shorthand /
17309 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
17310 // lists plus the empty-sentinel that round-trips as `""` (the accessor
17311 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
17312 // borrow pointer identity so the projection stays zero-copy at every
17313 // consumer site; and validate-composition through the
17314 // [`crate::render::require_valid_versao_requirement`] cascade reading
17315 // its requirement-shape check through the lifted accessor rather than
17316 // the raw field.
17317 #[test]
17318 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
17319 // Plain-shorthand form (`:fonte None`).
17320 assert_eq!(
17321 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
17322 "^0.1",
17323 );
17324 // Explicit git-source form with a tag pin — same accessor path.
17325 assert_eq!(
17326 Dep::git(
17327 "caixa-teia",
17328 "~0.1.2",
17329 "github:pleme-io/caixa-teia",
17330 "v0.1.0"
17331 )
17332 .versao_requirement(),
17333 "~0.1.2",
17334 );
17335 // Explicit path-source form.
17336 assert_eq!(
17337 Dep {
17338 nome: "caixa-teia".to_string(),
17339 versao: "0.1.0".to_string(),
17340 fonte: Some(DepSource::Path {
17341 caminho: "../caixa-teia".to_string(),
17342 }),
17343 opcional: false,
17344 caracteristicas: Vec::new(),
17345 }
17346 .versao_requirement(),
17347 "0.1.0",
17348 );
17349 // The wildcard requirement (`"*"`) — the shorthand
17350 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
17351 // verbatim through the accessor as `"*"`, same byte-shape the
17352 // author wrote.
17353 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
17354 // The empty-string `:versao` sentinel (which [`Dep::validate`]
17355 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
17356 // trips as an empty `&str` through the accessor — the accessor is
17357 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
17358 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
17359 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
17360 }
17361
17362 #[test]
17363 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
17364 // Zero-copy pin: the accessor must borrow into the field's own
17365 // storage, not clone. If a future rewrite regresses to
17366 // `self.versao.clone().leak()` or an owned-buffer shape, the two
17367 // pointers diverge and this pin fails at build time. Peer of the
17368 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
17369 // discipline extended onto the requirement-carrying axis.
17370 let d = Dep::simple("caixa-teia", "^0.1");
17371 assert!(std::ptr::eq(
17372 d.versao_requirement().as_ptr(),
17373 d.versao.as_ptr(),
17374 ));
17375 }
17376
17377 #[test]
17378 fn dep_validate_reads_requirement_through_accessor() {
17379 // Composition pin: the [`Dep::validate`]
17380 // [`crate::render::require_valid_versao_requirement`] cascade
17381 // consumes the requirement string through the lifted accessor —
17382 // both the requirement-gate input and the
17383 // [`DepError::VersaoInvalid`] error-body carrier route through
17384 // `self.versao_requirement()`. A valid requirement passes
17385 // (positive control); a malformed-but-non-empty requirement fails
17386 // and the diagnostic quotes the offending byte-string verbatim
17387 // (same shape the accessor projects), so a future regression that
17388 // detoured the requirement carrier through a different byte-
17389 // string (say the parsed `VersionReq`'s `Display`, or a
17390 // normalized rewrite) would surface here at build time. The
17391 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
17392 // ahead of the parse arm, pinning the empty-first cascade the
17393 // accessor's `""` sentinel round-trip acknowledges.
17394 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17395 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
17396 assert!(
17397 matches!(
17398 &err,
17399 DepError::VersaoInvalid {
17400 nome,
17401 versao,
17402 ..
17403 } if nome == "caixa-teia" && versao == "v0.1",
17404 ),
17405 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
17406 );
17407 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
17408 assert!(
17409 matches!(
17410 &err,
17411 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
17412 ),
17413 "expected VersaoEmpty from the empty-first arm, got {err:?}",
17414 );
17415 }
17416
17417 // ── Dep::fonte accessor pins ──────────────────────────────────────
17418 //
17419 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
17420 // equal projection over the plain-shorthand (`:fonte None`) /
17421 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
17422 // docstring lists (so the accessor's accept-set is exercised across
17423 // every author-surface `:fonte` shape and both `DepSource` variants);
17424 // pointer identity so the borrowed reference points into the field's
17425 // own `Option<DepSource>` storage (not a cloned side-buffer); and
17426 // validate-composition through the [`Dep::validate`] gate reading
17427 // its per-`:fonte` [`DepSource::validate`] delegation through the
17428 // lifted accessor rather than the raw `if let Some(ref fonte) =
17429 // self.fonte` bracket.
17430
17431 #[test]
17432 fn dep_fonte_returns_declared_source_across_shapes() {
17433 // Plain-shorthand form — `:fonte` omitted, accessor projects
17434 // the `None` partition the resolver-side default-fill treats
17435 // as "resolve through `github:<default-org>/<nome>`".
17436 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
17437 // Explicit git-source form with a tag pin — same accessor path.
17438 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17439 match git.fonte() {
17440 Some(DepSource::Git {
17441 repo,
17442 tag,
17443 rev,
17444 branch,
17445 }) => {
17446 assert_eq!(repo, "github:pleme-io/caixa-teia");
17447 assert_eq!(tag.as_deref(), Some("v0.1.0"));
17448 assert!(rev.is_none());
17449 assert!(branch.is_none());
17450 }
17451 other => panic!("expected explicit git :fonte, got {other:?}"),
17452 }
17453 // Explicit path-source form — the dev-only local-filesystem
17454 // arm the [`Dep`] docstring's third fixture carries.
17455 let path = Dep {
17456 nome: "caixa-teia".to_string(),
17457 versao: "0.1.0".to_string(),
17458 fonte: Some(DepSource::Path {
17459 caminho: "../caixa-teia".to_string(),
17460 }),
17461 opcional: false,
17462 caracteristicas: Vec::new(),
17463 };
17464 match path.fonte() {
17465 Some(DepSource::Path { caminho }) => {
17466 assert_eq!(caminho, "../caixa-teia");
17467 }
17468 other => panic!("expected explicit path :fonte, got {other:?}"),
17469 }
17470 }
17471
17472 #[test]
17473 fn dep_fonte_is_by_borrow_pointer_identity() {
17474 // Zero-copy pin: the accessor must borrow into the field's own
17475 // `Option<DepSource>` storage, not clone into a side buffer. If
17476 // a future rewrite regresses to `self.fonte.clone()` or an
17477 // owned-buffer shape, the two pointers diverge and this pin
17478 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17479 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17480 // identity pins — same by-borrow discipline extended onto the
17481 // outer-`Dep` `Option<&Composite>` composite-reference axis.
17482 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17483 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17484 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17485 assert!(std::ptr::eq(accessed, raw));
17486 }
17487
17488 #[test]
17489 fn dep_validate_reads_fonte_through_accessor() {
17490 // Composition pin: [`Dep::validate`]'s per-`:fonte`
17491 // [`DepSource::validate`] delegation consumes the typed slot
17492 // through the lifted accessor — an author-omitted `:fonte`
17493 // still passes the outer gate (positive control), an explicit
17494 // well-formed git source with exactly one pin passes, and a
17495 // malformed git source (empty `:repo`) surfaces the
17496 // [`DepError::FonteRepoEmpty`] variant quoting the offending
17497 // dep's `:nome` verbatim so a future regression that detoured
17498 // the `:fonte` delegation through a different path (say a
17499 // per-scope override projector) would surface here at build
17500 // time. Peer of the sibling
17501 // `dep_validate_reads_requirement_through_accessor` composition
17502 // pin on the `:versao` axis.
17503 // Positive control 1: no `:fonte` at all.
17504 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17505 // Positive control 2: well-formed git source.
17506 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17507 .validate()
17508 .unwrap();
17509 // Negative control: empty `:repo` — the accessor still returns
17510 // `Some(&DepSource::Git { repo: "", … })` and the delegated
17511 // `DepSource::validate` gate raises the typed carrier.
17512 let bad = Dep {
17513 nome: "caixa-teia".to_string(),
17514 versao: "^0.1".to_string(),
17515 fonte: Some(DepSource::Git {
17516 repo: String::new(),
17517 tag: Some("v0.1.0".to_string()),
17518 rev: None,
17519 branch: None,
17520 }),
17521 opcional: false,
17522 caracteristicas: Vec::new(),
17523 };
17524 let err = bad.validate().unwrap_err();
17525 assert!(
17526 matches!(
17527 &err,
17528 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17529 ),
17530 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17531 );
17532 }
17533
17534 #[test]
17535 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17536 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17537 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17538 // own `:nome` through the lifted accessor rather than the raw
17539 // field. Fails-before-passes-after: with the accessor lifted the
17540 // gate reads its equality check through `dep.nome() ==
17541 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17542 // the diagnostic still names the offending list tag as expected.
17543 let deps = vec![Dep::simple("orquestra", "^0.1")];
17544 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17545 assert!(matches!(
17546 err,
17547 DepError::DepIsSelf {
17548 ref nome,
17549 list,
17550 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17551 ));
17552 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17553 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17554 assert!(matches!(
17555 err,
17556 DepError::DepIsSelf {
17557 ref nome,
17558 list,
17559 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17560 ));
17561 // A non-matching `:nome` passes through the accessor gate.
17562 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17563 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17564 }
17565
17566 // ── Dep::caracteristicas accessor pins ────────────────────────────
17567 //
17568 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17569 // byte-equal projection over the default-empty / single-entry /
17570 // multi-entry fixture triad (so the accessor's accept-set is
17571 // exercised across every author-surface `:caracteristicas` shape,
17572 // matching the peer sibling family's fixture-triad discipline); by-
17573 // borrow pointer identity so the projection stays zero-copy at every
17574 // consumer site; and validate-composition through the
17575 // [`Dep::validate_caracteristicas`] gate reading its per-entry
17576 // linear walk through the lifted accessor rather than the raw
17577 // `for c in &self.caracteristicas` bracket.
17578
17579 #[test]
17580 fn dep_caracteristicas_returns_declared_features_across_shapes() {
17581 // Default-empty form — the [`Dep::simple`] constructor's
17582 // `Vec::new()` fill; the accessor projects the empty slice
17583 // verbatim (no `None` collapse).
17584 assert!(
17585 Dep::simple("caixa-teia", "^0.1")
17586 .caracteristicas()
17587 .is_empty(),
17588 );
17589 // Single-entry form — the canonical Cargo-shaped one-feature
17590 // enable ([`crate::render::is_cargo_feature_name`] accepts the
17591 // `"http"` byte-string as a valid feature name).
17592 let one = Dep {
17593 nome: "caixa-teia".to_string(),
17594 versao: "^0.1".to_string(),
17595 fonte: None,
17596 opcional: false,
17597 caracteristicas: vec!["http".to_string()],
17598 };
17599 assert_eq!(one.caracteristicas(), &["http".to_string()]);
17600 // Multi-entry form — the substrate's set-shaped multi-feature
17601 // enable, exercising the accessor over a length-two slice with
17602 // no duplicate collapse.
17603 let two = Dep {
17604 nome: "caixa-teia".to_string(),
17605 versao: "^0.1".to_string(),
17606 fonte: None,
17607 opcional: false,
17608 caracteristicas: vec!["http".to_string(), "json".to_string()],
17609 };
17610 assert_eq!(
17611 two.caracteristicas(),
17612 &["http".to_string(), "json".to_string()],
17613 );
17614 }
17615
17616 #[test]
17617 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17618 // Zero-copy pin: the accessor must borrow into the field's own
17619 // `Vec<String>` storage, not clone into a side buffer. If a
17620 // future rewrite regresses to `self.caracteristicas.clone()` or
17621 // an owned-buffer shape, the two pointers diverge and this pin
17622 // fails at build time. Peer of the sibling per-`Dep`
17623 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17624 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17625 // borrow discipline extended onto the outer-`Dep` `&[String]`
17626 // slice-projection axis.
17627 let d = Dep {
17628 nome: "caixa-teia".to_string(),
17629 versao: "^0.1".to_string(),
17630 fonte: None,
17631 opcional: false,
17632 caracteristicas: vec!["http".to_string(), "json".to_string()],
17633 };
17634 assert!(std::ptr::eq(
17635 d.caracteristicas().as_ptr(),
17636 d.caracteristicas.as_ptr(),
17637 ));
17638 }
17639
17640 #[test]
17641 fn dep_validate_reads_caracteristicas_through_accessor() {
17642 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17643 // linear walk consumes the feature-toggle list through the
17644 // lifted accessor — a well-formed `:caracteristicas` set passes
17645 // (positive control), an empty-string entry surfaces the
17646 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17647 // `Dep::nome`, and a within-list duplicate surfaces the
17648 // [`DepError::CaracteristicaDuplicate`] variant so a future
17649 // regression that detoured the walk through a different byte-
17650 // string list (say a per-scope override projector) would surface
17651 // here at build time. Peer of the sibling
17652 // `dep_validate_reads_fonte_through_accessor` /
17653 // `dep_validate_reads_requirement_through_accessor` composition
17654 // pins on the `:fonte` / `:versao` axes.
17655 // Positive control: two distinct well-formed feature names pass.
17656 Dep {
17657 nome: "caixa-teia".to_string(),
17658 versao: "^0.1".to_string(),
17659 fonte: None,
17660 opcional: false,
17661 caracteristicas: vec!["http".to_string(), "json".to_string()],
17662 }
17663 .validate()
17664 .unwrap();
17665 // Negative control 1: empty-string feature-name entry — the
17666 // accessor still returns `&[""]` and the walk raises the typed
17667 // empty-first carrier.
17668 let err = Dep {
17669 nome: "caixa-teia".to_string(),
17670 versao: "^0.1".to_string(),
17671 fonte: None,
17672 opcional: false,
17673 caracteristicas: vec![String::new()],
17674 }
17675 .validate()
17676 .unwrap_err();
17677 assert!(
17678 matches!(
17679 &err,
17680 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17681 ),
17682 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17683 );
17684 // Negative control 2: within-list duplicate — the accessor's
17685 // slice view carries both entries, and the walk's dedup arm
17686 // raises the typed duplicate carrier quoting the offending
17687 // feature name verbatim.
17688 let err = Dep {
17689 nome: "caixa-teia".to_string(),
17690 versao: "^0.1".to_string(),
17691 fonte: None,
17692 opcional: false,
17693 caracteristicas: vec!["http".to_string(), "http".to_string()],
17694 }
17695 .validate()
17696 .unwrap_err();
17697 assert!(
17698 matches!(
17699 &err,
17700 DepError::CaracteristicaDuplicate {
17701 nome,
17702 caracteristica,
17703 } if nome == "caixa-teia" && caracteristica == "http",
17704 ),
17705 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17706 );
17707 }
17708
17709 // ── Dep::opcional accessor pins ───────────────────────────────────
17710 //
17711 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17712 // equal projection over the default-`false` / explicit-`true`
17713 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17714 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17715 // exercising the accessor's accept-set over every author-surface
17716 // `:fonte` shape × every author-surface `:opcional` shape; and by-
17717 // `Copy` idempotency so the projection stays value-return (no
17718 // silent detour to a fresh `&bool` borrow that would introduce a
17719 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17720 // shape elides). No composition pin — `:opcional` does not
17721 // participate in [`Dep::validate`] (an opcional dep with any bool
17722 // value is validate-accepted; the missing-source arm is a resolver-
17723 // side runtime dispatch, not a build-time refusal), so the axis
17724 // reduces to the value-shape + `Copy` pin pair the peer
17725 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17726 // outer-`Option<Copy>` accessor pins already carry.
17727
17728 #[test]
17729 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17730 // Default-`false` form via the [`Dep::simple`] constructor —
17731 // the accessor projects the `false` bit the default-fill sets.
17732 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17733 // Default-`false` form via the [`Dep::git`] constructor — same
17734 // default fill; the accessor projects `false` regardless of the
17735 // `:fonte` arm.
17736 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17737 // Explicit-`true` form × plain-shorthand `:fonte` — the
17738 // canonical author-surface "this dep may be missing" shape.
17739 let plain_true = Dep {
17740 nome: "caixa-teia".to_string(),
17741 versao: "^0.1".to_string(),
17742 fonte: None,
17743 opcional: true,
17744 caracteristicas: Vec::new(),
17745 };
17746 assert!(plain_true.opcional());
17747 // Explicit-`true` form × explicit git-source — the accessor
17748 // projects the bit verbatim regardless of the `:fonte` arm.
17749 let git_true = Dep {
17750 nome: "caixa-teia".to_string(),
17751 versao: "^0.1".to_string(),
17752 fonte: Some(DepSource::Git {
17753 repo: "github:pleme-io/caixa-teia".to_string(),
17754 tag: Some("v0.1.0".to_string()),
17755 rev: None,
17756 branch: None,
17757 }),
17758 opcional: true,
17759 caracteristicas: Vec::new(),
17760 };
17761 assert!(git_true.opcional());
17762 // Explicit-`true` form × explicit path-source — the dev-only
17763 // local-filesystem arm the [`Dep`] docstring's third fixture
17764 // carries.
17765 let path_true = Dep {
17766 nome: "caixa-teia".to_string(),
17767 versao: "0.1.0".to_string(),
17768 fonte: Some(DepSource::Path {
17769 caminho: "../caixa-teia".to_string(),
17770 }),
17771 opcional: true,
17772 caracteristicas: Vec::new(),
17773 };
17774 assert!(path_true.opcional());
17775 }
17776
17777 #[test]
17778 fn dep_opcional_projects_bool_by_copy() {
17779 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17780 // (`bool: Copy`) — the accessor does not borrow `&self` past
17781 // the call (no lifetime on the return type), and calling the
17782 // accessor twice on the same [`Dep`] must yield discriminant-
17783 // equal values (idempotent, no side effects on `&self`). Peer
17784 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17785 // `max_restarts_projects_option_by_copy` (eba5211) /
17786 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17787 // outer-`Caixa` altitude — extended here to the outer-`Dep`
17788 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17789 // replaces the pointer-equality claim the sibling per-`Dep`
17790 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17791 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17792 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17793 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17794 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17795 // the same discriminant, so the axis reduces to discriminant
17796 // equality).
17797 //
17798 // Pins against a future silent detour that returned a fresh
17799 // `&bool` reference (which would type-check but silently
17800 // introduce a borrow of `&self` past the call, collapsing the
17801 // load-bearing "no lifetime on the return type" `Copy`
17802 // projection the plain-`Copy`-scalar axis's `bool` shape
17803 // carries) or a stale-read side effect that flipped the outer
17804 // discriminant on successive calls.
17805 for opcional in [false, true] {
17806 let d = Dep {
17807 nome: "caixa-teia".to_string(),
17808 versao: "^0.1".to_string(),
17809 fonte: None,
17810 opcional,
17811 caracteristicas: Vec::new(),
17812 };
17813 let first = d.opcional();
17814 let second = d.opcional();
17815 assert_eq!(
17816 first, second,
17817 "Dep::opcional must be idempotent — two successive calls \
17818 on the same &self must return the same bool",
17819 );
17820 assert_eq!(
17821 first, opcional,
17822 "Dep::opcional must return :opcional verbatim by Copy — \
17823 got {first}, expected {opcional}",
17824 );
17825 assert_eq!(
17826 d.opcional(),
17827 d.opcional,
17828 "Dep::opcional accessor and self.opcional field access \
17829 must byte-equal — a bit-flip drift would silently split \
17830 the paired resolver-side drop-vs-error dispatch from \
17831 the storage-side default-fill the [`Dep::simple`] / \
17832 [`Dep::git`] constructor pair carries",
17833 );
17834 }
17835 }
17836
17837 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17838
17839 #[test]
17840 fn sole_pin_returns_none_for_path_source() {
17841 // A path source carries no git-ref, so `sole_pin()` returns
17842 // `None` structurally — the sibling arm every git-fetching
17843 // consumer partitions off before reaching for a git-ref. Pins
17844 // the Path-arm branch of the accessor against a future silent
17845 // detour that treats a `Self::Path` as an unpinned-git source
17846 // and returns the wrong "no pin" signal (e.g. the empty string,
17847 // or a hard-coded `Some("HEAD")` matching the caixa-crd
17848 // path-arm `git_ref` fill).
17849 let s = DepSource::Path {
17850 caminho: "../local-caixa".to_string(),
17851 };
17852 assert_eq!(s.sole_pin(), None);
17853 }
17854
17855 #[test]
17856 fn sole_pin_returns_none_for_unpinned_git_source() {
17857 // The [`DepSource::default_github`] shorthand shape carries no
17858 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17859 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17860 // materializes when the author omits `:fonte` entirely, then
17861 // hands to `fetch_git` which raises `ResolveError::MissingPin`
17862 // on the `None` arm — the accessor's return matches the arm
17863 // the resolver's diagnostic keys off.
17864 let s = DepSource::default_github("pleme-io", "caixa-teia");
17865 assert_eq!(s.sole_pin(), None);
17866 }
17867
17868 #[test]
17869 fn sole_pin_returns_rev_when_only_rev_is_set() {
17870 let s = DepSource::Git {
17871 repo: "github:o/x".into(),
17872 tag: None,
17873 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17874 branch: None,
17875 };
17876 assert_eq!(
17877 s.sole_pin(),
17878 Some("deadbeefcafebabe1234567890abcdef12345678")
17879 );
17880 }
17881
17882 #[test]
17883 fn sole_pin_returns_tag_when_only_tag_is_set() {
17884 let s = DepSource::Git {
17885 repo: "github:o/x".into(),
17886 tag: Some("v0.1.0".into()),
17887 rev: None,
17888 branch: None,
17889 };
17890 assert_eq!(s.sole_pin(), Some("v0.1.0"));
17891 }
17892
17893 #[test]
17894 fn sole_pin_returns_branch_when_only_branch_is_set() {
17895 let s = DepSource::Git {
17896 repo: "github:o/x".into(),
17897 tag: None,
17898 rev: None,
17899 branch: Some("main".into()),
17900 };
17901 assert_eq!(s.sole_pin(), Some("main"));
17902 }
17903
17904 #[test]
17905 fn sole_pin_precedence_rev_beats_tag_and_branch() {
17906 // Precedence: rev > tag > branch. Validate() rejects
17907 // multiple-pin shapes, but the accessor's precedence is defined
17908 // for pre-validate consumers (the resolver's `MissingPin`
17909 // diagnostic path, the caixa-crd round-trip's default `"main"`
17910 // fallback) and as defense-in-depth if the gate is ever
17911 // bypassed. Pins the same precedence caixa-resolver's
17912 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17913 // inline.
17914 let s = DepSource::Git {
17915 repo: "github:o/x".into(),
17916 tag: Some("v1".into()),
17917 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17918 branch: Some("main".into()),
17919 };
17920 assert_eq!(
17921 s.sole_pin(),
17922 Some("deadbeefcafebabe1234567890abcdef12345678")
17923 );
17924 }
17925
17926 #[test]
17927 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17928 let s = DepSource::Git {
17929 repo: "github:o/x".into(),
17930 tag: Some("v1".into()),
17931 rev: None,
17932 branch: Some("main".into()),
17933 };
17934 assert_eq!(s.sole_pin(), Some("v1"));
17935 }
17936
17937 #[test]
17938 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17939 // Fail-before-pass-after byte-parity pin: the substrate accessor
17940 // must return byte-identical to the inline
17941 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17942 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17943 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17944 // time if the accessor's precedence silently drifts from the
17945 // consumer-side cascade — the exact drift this lift converges
17946 // to one substrate primitive to close structurally.
17947 //
17948 // Iterates through the 2^3 = 8 combinations of (tag, rev,
17949 // branch) each-either-`None`-or-`Some`, so every arm of the
17950 // precedence cascade lands under the pin. `validate()` refuses
17951 // the 4 multi-pin combinations, but the accessor's return is
17952 // defined on all 8.
17953 let vals = [Some("R".to_string()), None];
17954 for tag in &vals {
17955 for rev in &vals {
17956 for branch in &vals {
17957 let s = DepSource::Git {
17958 repo: "github:o/x".into(),
17959 tag: tag.clone(),
17960 rev: rev.clone(),
17961 branch: branch.clone(),
17962 };
17963 // The exact inline cascade the two pre-lift
17964 // consumer sites hand-rolled, byte-for-byte.
17965 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17966 assert_eq!(
17967 s.sole_pin(),
17968 expected,
17969 "sole_pin() must byte-equal \
17970 rev.or(tag).or(branch) for \
17971 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17972 a drift would silently split caixa-resolver's \
17973 fetch_git checkout target from caixa-crd's \
17974 dep_into_ref git_ref fill",
17975 );
17976 }
17977 }
17978 }
17979 }
17980
17981 // Fail-before-pass-after pins on the eleven
17982 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17983 // constructors folded from the [`DepSource::validate_caminho`]
17984 // wire-up sites. Each pins the generated ctor's output to the
17985 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17986 // any wrapper-side lowercase / trim / re-order / silent-field-swap
17987 // regression on the two-field `{ nome: nome.to_string(), caminho:
17988 // caminho.to_string() }` construction surfaces here rather than at
17989 // a downstream diagnostic-shape mismatch. Peer of the sibling
17990 // `empty_child_version_ctor_matches_struct_literal_wrap` /
17991 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17992 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17993 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17994 // pins on the peer `SupervisorError` / `AplicacaoError` /
17995 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17996
17997 #[test]
17998 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17999 assert_eq!(
18000 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
18001 DepError::FonteCaminhoAbsolute {
18002 nome: "caixa-teia".to_string(),
18003 caminho: "/home/me/work/caixa-teia".to_string(),
18004 },
18005 "generated fonte_caminho_absolute ctor must produce byte-equal \
18006 DepError to the open-coded struct-literal wrap on the same \
18007 (&str, &str) fixture",
18008 );
18009 }
18010
18011 #[test]
18012 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
18013 assert_eq!(
18014 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
18015 DepError::FonteCaminhoTildeExpansion {
18016 nome: "caixa-teia".to_string(),
18017 caminho: "~/work/caixa-teia".to_string(),
18018 },
18019 );
18020 }
18021
18022 #[test]
18023 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
18024 assert_eq!(
18025 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
18026 DepError::FonteCaminhoVarExpansion {
18027 nome: "caixa-teia".to_string(),
18028 caminho: "$HOME/work/caixa-teia".to_string(),
18029 },
18030 );
18031 }
18032
18033 #[test]
18034 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
18035 assert_eq!(
18036 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
18037 DepError::FonteCaminhoLeadingWhitespace {
18038 nome: "caixa-teia".to_string(),
18039 caminho: " ../caixa-teia".to_string(),
18040 },
18041 );
18042 }
18043
18044 #[test]
18045 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
18046 assert_eq!(
18047 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
18048 DepError::FonteCaminhoLeadingHyphen {
18049 nome: "caixa-teia".to_string(),
18050 caminho: "-rf".to_string(),
18051 },
18052 );
18053 }
18054
18055 #[test]
18056 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
18057 assert_eq!(
18058 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
18059 DepError::FonteCaminhoBackslash {
18060 nome: "caixa-teia".to_string(),
18061 caminho: "..\\caixa-teia".to_string(),
18062 },
18063 );
18064 }
18065
18066 #[test]
18067 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
18068 assert_eq!(
18069 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
18070 DepError::FonteCaminhoShellPipe {
18071 nome: "caixa-teia".to_string(),
18072 caminho: "../caixa-teia|evil".to_string(),
18073 },
18074 );
18075 }
18076
18077 #[test]
18078 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
18079 assert_eq!(
18080 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
18081 DepError::FonteCaminhoShellSemicolon {
18082 nome: "caixa-teia".to_string(),
18083 caminho: "../caixa-teia;evil".to_string(),
18084 },
18085 );
18086 }
18087
18088 #[test]
18089 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
18090 assert_eq!(
18091 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
18092 DepError::FonteCaminhoShellBackground {
18093 nome: "caixa-teia".to_string(),
18094 caminho: "../caixa-teia&".to_string(),
18095 },
18096 );
18097 }
18098
18099 #[test]
18100 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
18101 assert_eq!(
18102 DepError::fonte_caminho_shell_command_substitution(
18103 "caixa-teia",
18104 "../caixa-teia`whoami`",
18105 ),
18106 DepError::FonteCaminhoShellCommandSubstitution {
18107 nome: "caixa-teia".to_string(),
18108 caminho: "../caixa-teia`whoami`".to_string(),
18109 },
18110 );
18111 }
18112
18113 #[test]
18114 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
18115 assert_eq!(
18116 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
18117 DepError::FonteCaminhoTrailingSlash {
18118 nome: "caixa-teia".to_string(),
18119 caminho: "../caixa-teia/".to_string(),
18120 },
18121 );
18122 }
18123
18124 #[test]
18125 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
18126 // Cross-axis pin: sweep the two constructor input axes
18127 // (`nome: &str`, `caminho: &str`) through a non-default fixture
18128 // pair against every generated arm in the
18129 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
18130 // / trim / truncate / re-order on the two-field
18131 // `{ nome, caminho }` construction — or a silent field swap
18132 // between the two axes at codegen time — surfaces here rather
18133 // than at a downstream diagnostic-shape mismatch. Peer of the
18134 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
18135 // to_string` cross-axis routing pin on the peer
18136 // `SupervisorError` envelope, extended here onto the
18137 // `DepError` `{ nome: String, caminho: String }` envelope so
18138 // every substrate-primitive ctor family in caixa-core
18139 // guarantees each `&str`-field construction routes the
18140 // caller's `&str` verbatim through `.to_string()`.
18141 let nome = "sibling-teia";
18142 let caminho = "../workspace/sibling";
18143 let cases: [(DepError, DepError); 11] = [
18144 (
18145 DepError::fonte_caminho_absolute(nome, caminho),
18146 DepError::FonteCaminhoAbsolute {
18147 nome: nome.to_string(),
18148 caminho: caminho.to_string(),
18149 },
18150 ),
18151 (
18152 DepError::fonte_caminho_tilde_expansion(nome, caminho),
18153 DepError::FonteCaminhoTildeExpansion {
18154 nome: nome.to_string(),
18155 caminho: caminho.to_string(),
18156 },
18157 ),
18158 (
18159 DepError::fonte_caminho_var_expansion(nome, caminho),
18160 DepError::FonteCaminhoVarExpansion {
18161 nome: nome.to_string(),
18162 caminho: caminho.to_string(),
18163 },
18164 ),
18165 (
18166 DepError::fonte_caminho_leading_whitespace(nome, caminho),
18167 DepError::FonteCaminhoLeadingWhitespace {
18168 nome: nome.to_string(),
18169 caminho: caminho.to_string(),
18170 },
18171 ),
18172 (
18173 DepError::fonte_caminho_leading_hyphen(nome, caminho),
18174 DepError::FonteCaminhoLeadingHyphen {
18175 nome: nome.to_string(),
18176 caminho: caminho.to_string(),
18177 },
18178 ),
18179 (
18180 DepError::fonte_caminho_backslash(nome, caminho),
18181 DepError::FonteCaminhoBackslash {
18182 nome: nome.to_string(),
18183 caminho: caminho.to_string(),
18184 },
18185 ),
18186 (
18187 DepError::fonte_caminho_shell_pipe(nome, caminho),
18188 DepError::FonteCaminhoShellPipe {
18189 nome: nome.to_string(),
18190 caminho: caminho.to_string(),
18191 },
18192 ),
18193 (
18194 DepError::fonte_caminho_shell_semicolon(nome, caminho),
18195 DepError::FonteCaminhoShellSemicolon {
18196 nome: nome.to_string(),
18197 caminho: caminho.to_string(),
18198 },
18199 ),
18200 (
18201 DepError::fonte_caminho_shell_background(nome, caminho),
18202 DepError::FonteCaminhoShellBackground {
18203 nome: nome.to_string(),
18204 caminho: caminho.to_string(),
18205 },
18206 ),
18207 (
18208 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
18209 DepError::FonteCaminhoShellCommandSubstitution {
18210 nome: nome.to_string(),
18211 caminho: caminho.to_string(),
18212 },
18213 ),
18214 (
18215 DepError::fonte_caminho_trailing_slash(nome, caminho),
18216 DepError::FonteCaminhoTrailingSlash {
18217 nome: nome.to_string(),
18218 caminho: caminho.to_string(),
18219 },
18220 ),
18221 ];
18222 for (via_ctor, via_struct_literal) in cases {
18223 assert_eq!(
18224 via_ctor, via_struct_literal,
18225 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
18226 through `.to_string()` in declared field order — a field-swap or \
18227 silent-conversion regression surfaces here rather than at a \
18228 downstream diagnostic-shape mismatch",
18229 );
18230 }
18231 }
18232
18233 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
18234 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
18235 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
18236 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
18237 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
18238
18239 #[test]
18240 fn versao_empty_ctor_matches_struct_literal_wrap() {
18241 assert_eq!(
18242 DepError::versao_empty("caixa-teia"),
18243 DepError::VersaoEmpty {
18244 nome: "caixa-teia".to_string(),
18245 },
18246 );
18247 }
18248
18249 #[test]
18250 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
18251 assert_eq!(
18252 DepError::fonte_repo_empty("caixa-teia"),
18253 DepError::FonteRepoEmpty {
18254 nome: "caixa-teia".to_string(),
18255 },
18256 );
18257 }
18258
18259 #[test]
18260 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
18261 assert_eq!(
18262 DepError::fonte_pin_missing("caixa-teia"),
18263 DepError::FontePinMissing {
18264 nome: "caixa-teia".to_string(),
18265 },
18266 );
18267 }
18268
18269 #[test]
18270 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
18271 assert_eq!(
18272 DepError::fonte_caminho_empty("caixa-teia"),
18273 DepError::FonteCaminhoEmpty {
18274 nome: "caixa-teia".to_string(),
18275 },
18276 );
18277 }
18278
18279 #[test]
18280 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
18281 assert_eq!(
18282 DepError::caracteristica_empty("caixa-teia"),
18283 DepError::CaracteristicaEmpty {
18284 nome: "caixa-teia".to_string(),
18285 },
18286 );
18287 }
18288
18289 #[test]
18290 fn dep_nome_only_ctors_route_nome_through_to_string() {
18291 // Cross-axis routing pin: sweep the single constructor input
18292 // axis (`nome: &str`) through a non-default fixture against
18293 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
18294 // any wrapper-side lowercase / trim / truncate at codegen time
18295 // — or a silent field re-name away from the canonical `nome`
18296 // axis on any one variant — surfaces here rather than at a
18297 // downstream diagnostic-shape mismatch. Peer of the sibling
18298 // `fonte_caminho_ctors_route_nome_and_caminho_through_
18299 // to_string` cross-axis routing pin on the same envelope's
18300 // two-slot family (f85f145) and of the peer
18301 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
18302 // pin on the `SupervisorError` single-slot family (db09650).
18303 let nome = "sibling-teia";
18304 let cases: [(DepError, DepError); 5] = [
18305 (
18306 DepError::versao_empty(nome),
18307 DepError::VersaoEmpty {
18308 nome: nome.to_string(),
18309 },
18310 ),
18311 (
18312 DepError::fonte_repo_empty(nome),
18313 DepError::FonteRepoEmpty {
18314 nome: nome.to_string(),
18315 },
18316 ),
18317 (
18318 DepError::fonte_pin_missing(nome),
18319 DepError::FontePinMissing {
18320 nome: nome.to_string(),
18321 },
18322 ),
18323 (
18324 DepError::fonte_caminho_empty(nome),
18325 DepError::FonteCaminhoEmpty {
18326 nome: nome.to_string(),
18327 },
18328 ),
18329 (
18330 DepError::caracteristica_empty(nome),
18331 DepError::CaracteristicaEmpty {
18332 nome: nome.to_string(),
18333 },
18334 ),
18335 ];
18336 for (via_ctor, via_struct_literal) in cases {
18337 assert_eq!(
18338 via_ctor, via_struct_literal,
18339 "dep_nome_only_ctors!-generated ctor must route `nome` \
18340 through `.to_string()` onto the canonical `nome` field \
18341 — a field-rename or silent-conversion regression surfaces \
18342 here rather than at a downstream diagnostic-shape mismatch",
18343 );
18344 }
18345 }
18346
18347 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
18348 // &'static str }` two-slot envelope on `DepError`, strict
18349 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
18350 // same envelope's `{ nome: String }` one-slot shape and of the
18351 // peer `supervisor_caixa_only_ctors!` (db09650) on the
18352 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
18353
18354 #[test]
18355 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
18356 assert_eq!(
18357 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
18358 DepError::DuplicateNome {
18359 nome: "caixa-teia".to_string(),
18360 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18361 },
18362 "generated duplicate_nome ctor must produce byte-equal \
18363 `DepError::DuplicateNome` to the pre-lift struct-literal \
18364 wrap on the same scalar fixtures",
18365 );
18366 }
18367
18368 #[test]
18369 fn dep_is_self_ctor_matches_struct_literal_wrap() {
18370 assert_eq!(
18371 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18372 DepError::DepIsSelf {
18373 nome: "orquestra".to_string(),
18374 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18375 },
18376 "generated dep_is_self ctor must produce byte-equal \
18377 `DepError::DepIsSelf` to the pre-lift struct-literal \
18378 wrap on the same scalar fixtures",
18379 );
18380 }
18381
18382 #[test]
18383 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
18384 // Cross-axis routing pin: sweep the two constructor input axes
18385 // (`nome: &str`, `list: &'static str`) through non-default
18386 // fixtures against every generated arm in the
18387 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
18388 // lowercase / trim / truncate at codegen time — or a silent
18389 // field re-name away from the canonical `nome` / `list` axes
18390 // on any one variant, or a `list` axis silently rerouted
18391 // through `.to_string()` instead of passed as `&'static str`
18392 // verbatim — surfaces here rather than at a downstream
18393 // diagnostic-shape mismatch. Peer of the sibling
18394 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18395 // (792aa92) on the same envelope's one-slot family, and of the
18396 // peer
18397 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
18398 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
18399 // two-slot `{ caixa: String, reason: String }` shape.
18400 let nome = "sibling-teia";
18401 let cases: [(DepError, DepError); 4] = [
18402 (
18403 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18404 DepError::DuplicateNome {
18405 nome: nome.to_string(),
18406 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18407 },
18408 ),
18409 (
18410 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18411 DepError::DuplicateNome {
18412 nome: nome.to_string(),
18413 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18414 },
18415 ),
18416 (
18417 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18418 DepError::DepIsSelf {
18419 nome: nome.to_string(),
18420 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18421 },
18422 ),
18423 (
18424 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18425 DepError::DepIsSelf {
18426 nome: nome.to_string(),
18427 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18428 },
18429 ),
18430 ];
18431 for (via_ctor, via_struct_literal) in cases {
18432 assert_eq!(
18433 via_ctor, via_struct_literal,
18434 "dep_nome_list_ctors!-generated ctor must route `nome` \
18435 through `.to_string()` onto the canonical `nome` field \
18436 and pass `list` verbatim onto the canonical `&'static str` \
18437 `list` field — a field-rename, silent-conversion, or \
18438 axis-swap regression surfaces here rather than at a \
18439 downstream diagnostic-shape mismatch",
18440 );
18441 }
18442 }
18443
18444 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18445 // value: String, reason: String }` four-slot envelope on
18446 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18447 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18448 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18449 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
18450 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
18451 // envelope. Single-variant lift closing the last open-coded ctor
18452 // site on the `:fonte (:tipo git …)` value-shape trajectory.
18453
18454 #[test]
18455 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18456 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18457 // ctor: sweep both wire-up-shape arms (the refname-pin arm
18458 // routing `":tag"` / `":branch"` value through
18459 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18460 // routing `":rev"` through [`crate::render::is_git_oid`]) and
18461 // assert byte-equal `PartialEq` against the pre-lift
18462 // struct-literal, so any wrapper-side field-rename /
18463 // silent-conversion regression surfaces here rather than at a
18464 // downstream diagnostic-shape mismatch. Peer of the sibling
18465 // per-envelope byte-equal ctor pins
18466 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18467 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18468 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18469 assert_eq!(
18470 DepError::fonte_pin_shape(
18471 "caixa-teia",
18472 ":tag",
18473 "v0.1.0 ",
18474 "trailing whitespace".to_string(),
18475 ),
18476 DepError::FontePinShape {
18477 nome: "caixa-teia".to_string(),
18478 pin: ":tag".to_string(),
18479 value: "v0.1.0 ".to_string(),
18480 reason: "trailing whitespace".to_string(),
18481 },
18482 "fonte_pin_shape ctor must produce byte-equal \
18483 `DepError::FontePinShape` to the pre-lift struct-literal \
18484 wrap on a refname-pin (`:tag` / `:branch`) fixture",
18485 );
18486 assert_eq!(
18487 DepError::fonte_pin_shape(
18488 "caixa-teia",
18489 ":rev",
18490 "DEADBEEF",
18491 "abbreviated OID rejected".to_string(),
18492 ),
18493 DepError::FontePinShape {
18494 nome: "caixa-teia".to_string(),
18495 pin: ":rev".to_string(),
18496 value: "DEADBEEF".to_string(),
18497 reason: "abbreviated OID rejected".to_string(),
18498 },
18499 "fonte_pin_shape ctor must produce byte-equal \
18500 `DepError::FontePinShape` to the pre-lift struct-literal \
18501 wrap on a hex-OID-pin (`:rev`) fixture",
18502 );
18503 }
18504
18505 #[test]
18506 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18507 // Cross-axis routing pin: sweep every one of the four
18508 // constructor input axes (`nome: &str`, `pin: &str`,
18509 // `value: &str`, `reason: String`) through non-default
18510 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18511 // any wrapper-side lowercase / trim / truncate at codegen time
18512 // — or a silent field re-name / axis-swap on any one of the
18513 // four fields, or a `reason` axis silently routed through
18514 // `.to_string()` instead of forwarded owned — surfaces here
18515 // rather than at a downstream diagnostic-shape mismatch. Peer
18516 // of the sibling
18517 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18518 // (792aa92) and
18519 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18520 // pin (6f5e0cd) on the same envelope's one- and two-slot
18521 // families. Distinct-per-axis fixtures rule out any two-axis
18522 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18523 // etc.) that would still pass a same-fixture-per-axis pin.
18524 let nome = "sibling-teia";
18525 let pin = ":branch";
18526 let value = "feature/bar";
18527 let reason = "embedded space".to_string();
18528 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18529 let via_struct_literal = DepError::FontePinShape {
18530 nome: nome.to_string(),
18531 pin: pin.to_string(),
18532 value: value.to_string(),
18533 reason: reason.clone(),
18534 };
18535 assert_eq!(
18536 via_ctor, via_struct_literal,
18537 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18538 through `.to_string()` onto their canonical fields and \
18539 forward `reason` owned onto the canonical `reason` field \
18540 — a field-rename, silent-conversion, or axis-swap \
18541 regression surfaces here rather than at a downstream \
18542 diagnostic-shape mismatch",
18543 );
18544 let DepError::FontePinShape {
18545 nome: n,
18546 pin: p,
18547 value: v,
18548 reason: r,
18549 } = via_ctor
18550 else {
18551 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18552 };
18553 assert_eq!(n, nome);
18554 assert_eq!(p, pin);
18555 assert_eq!(v, value);
18556 assert_eq!(r, reason);
18557 }
18558
18559 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18560 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18561 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18562 // the same envelope's `{ nome: String, caminho: String }` two-slot
18563 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18564 // same envelope's `{ nome: String }` one-slot shape.
18565
18566 #[test]
18567 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18568 assert_eq!(
18569 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18570 DepError::FonteCaminhoControlChar {
18571 nome: "caixa-teia".to_string(),
18572 caminho: "../caixa-teia\x00foo".to_string(),
18573 byte: 0x00,
18574 },
18575 );
18576 }
18577
18578 #[test]
18579 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18580 assert_eq!(
18581 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18582 DepError::FonteCaminhoShellRedirection {
18583 nome: "caixa-teia".to_string(),
18584 caminho: "../caixa-teia>log".to_string(),
18585 byte: b'>',
18586 },
18587 );
18588 }
18589
18590 #[test]
18591 #[allow(
18592 clippy::too_many_lines,
18593 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18594 byte-classification arm on the {nome,caminho,byte} envelope; \
18595 the linear per-variant repetition is exactly what the sweep \
18596 is pinning — a helper macro would hide the shape the fold is \
18597 keying on"
18598 )]
18599 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18600 // Cross-axis routing pin: sweep the three constructor input axes
18601 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18602 // non-default fixture triple against every generated arm in the
18603 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18604 // lowercase / trim / truncate on the two `&str` axes — a silent
18605 // field swap between `nome` and `caminho`, or a silent
18606 // re-classification of the offending byte — surfaces here rather
18607 // than at a downstream diagnostic-shape mismatch. Peer of the
18608 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18609 // to_string` cross-axis routing pin on the same envelope's
18610 // two-slot family (f85f145) and of the sibling
18611 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18612 // same envelope's one-slot family (792aa92), extended here onto
18613 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18614 // envelope so every substrate-primitive ctor family in
18615 // caixa-core's `DepError` envelope guarantees each field routes
18616 // the caller's value verbatim through `.to_string()` (or byte-
18617 // identity for `byte: u8`) in declared field order.
18618 let nome = "sibling-teia";
18619 let caminho = "../workspace/sibling";
18620 let byte = 0x2A_u8;
18621 let cases: [(DepError, DepError); 12] = [
18622 (
18623 DepError::fonte_caminho_control_char(nome, caminho, byte),
18624 DepError::FonteCaminhoControlChar {
18625 nome: nome.to_string(),
18626 caminho: caminho.to_string(),
18627 byte,
18628 },
18629 ),
18630 (
18631 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18632 DepError::FonteCaminhoShellRedirection {
18633 nome: nome.to_string(),
18634 caminho: caminho.to_string(),
18635 byte,
18636 },
18637 ),
18638 (
18639 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18640 DepError::FonteCaminhoShellGlob {
18641 nome: nome.to_string(),
18642 caminho: caminho.to_string(),
18643 byte,
18644 },
18645 ),
18646 (
18647 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18648 DepError::FonteCaminhoShellSubshellGrouping {
18649 nome: nome.to_string(),
18650 caminho: caminho.to_string(),
18651 byte,
18652 },
18653 ),
18654 (
18655 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18656 DepError::FonteCaminhoShellBraceExpansion {
18657 nome: nome.to_string(),
18658 caminho: caminho.to_string(),
18659 byte,
18660 },
18661 ),
18662 (
18663 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18664 DepError::FonteCaminhoShellBracketExpansion {
18665 nome: nome.to_string(),
18666 caminho: caminho.to_string(),
18667 byte,
18668 },
18669 ),
18670 (
18671 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18672 DepError::FonteCaminhoShellQuoteGrouping {
18673 nome: nome.to_string(),
18674 caminho: caminho.to_string(),
18675 byte,
18676 },
18677 ),
18678 (
18679 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18680 DepError::FonteCaminhoShellComment {
18681 nome: nome.to_string(),
18682 caminho: caminho.to_string(),
18683 byte,
18684 },
18685 ),
18686 (
18687 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18688 DepError::FonteCaminhoUrlPercentEncoding {
18689 nome: nome.to_string(),
18690 caminho: caminho.to_string(),
18691 byte,
18692 },
18693 ),
18694 (
18695 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18696 DepError::FonteCaminhoShellVariableExpansion {
18697 nome: nome.to_string(),
18698 caminho: caminho.to_string(),
18699 byte,
18700 },
18701 ),
18702 (
18703 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18704 DepError::FonteCaminhoShellHistoryExpansion {
18705 nome: nome.to_string(),
18706 caminho: caminho.to_string(),
18707 byte,
18708 },
18709 ),
18710 (
18711 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18712 DepError::FonteCaminhoShellHistorySubstitution {
18713 nome: nome.to_string(),
18714 caminho: caminho.to_string(),
18715 byte,
18716 },
18717 ),
18718 ];
18719 for (via_ctor, via_struct_literal) in cases {
18720 assert_eq!(
18721 via_ctor, via_struct_literal,
18722 "fonte_caminho_byte_ctors!-generated ctor must route \
18723 (nome, caminho, byte) through `.to_string()` / byte-\
18724 identity in declared field order — a field-swap or \
18725 silent-conversion regression surfaces here rather than \
18726 at a downstream diagnostic-shape mismatch",
18727 );
18728 }
18729 }
18730
18731 #[test]
18732 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18733 // Fail-before-pass-after byte-parity pin on the lifted
18734 // `impl AsRef<str> for DepList` — asserts the standard-
18735 // library trait impl and the substrate-primitive
18736 // [`super::DepList::as_str`] `pub const fn` accessor resolve
18737 // to the same `&str` per instance across the two-arm closed
18738 // set, so any future silent detour that routes the impl
18739 // through a divergent projection (a per-arm inline
18740 // `match self { DepList::Prod => ":deps", … }` re-inlining
18741 // that opens a compile-time link to the un-lifted arm-literal,
18742 // a swap onto a second projection axis) trips at caixa-core
18743 // test time under `PartialEq` rather than at a downstream
18744 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18745 // every one of the two arms [`super::DepList::ALL`] carries
18746 // so no arm's projection is covered only by the sibling
18747 // `Display` path. Peer of the sibling
18748 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18749 // (1723611) on the top-level dialect-classification closed-
18750 // set typed enum, and the peer
18751 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18752 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18753 // typed enum — the pins together close the substrate
18754 // primitive's `AsRef<str>` projection axis onto the seventh
18755 // (and last unlifted) closed-set typed enum on the caixa
18756 // surface.
18757 for &list in super::DepList::ALL {
18758 assert_eq!(
18759 <super::DepList as AsRef<str>>::as_ref(&list),
18760 list.as_str(),
18761 "AsRef<str> impl on DepList::{list:?} must byte-equal \
18762 DepList::as_str on the same instance — divergence \
18763 signals a silent detour off the substrate-primitive \
18764 accessor"
18765 );
18766 }
18767 }
18768
18769 #[test]
18770 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18771 // Fail-before-pass-after byte-parity pin on the three-path
18772 // convergence discipline the [`super::DepList`] two-list
18773 // dep-graph closed-set typed enum now carries on the `&str`-
18774 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18775 // newly lifted impl), `format!("{v}")` (the pre-existing
18776 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18777 // primitive `pub const fn` accessor both trait impls delegate
18778 // through) must resolve to the same byte-string on every
18779 // instance across the two-arm closed set. Refuses any future
18780 // divergence between the two trait impls (a stray
18781 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18782 // rather than delegating through the shared accessor; a
18783 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18784 // literal cascade) that would silently split the two
18785 // projection paths of the same closed-set typed enum. Mirrors
18786 // the sibling three-path-convergence discipline the peer
18787 // [`crate::CaixaDialeto`] typed enum carries
18788 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18789 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18790 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18791 // d8136db), the peer [`crate::CaixaKind`] triple
18792 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18793 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18794 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18795 // 16d5c7e).
18796 for &list in super::DepList::ALL {
18797 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18798 let via_display: String = format!("{list}");
18799 let via_accessor: &str = list.as_str();
18800 assert_eq!(via_as_ref, via_accessor);
18801 assert_eq!(via_display, via_accessor);
18802 assert_eq!(via_as_ref, via_display.as_str());
18803 }
18804 }
18805
18806 #[test]
18807 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18808 // Fail-before-pass-after byte-parity pin on the newly lifted
18809 // `impl TryFrom<&str> for DepList` — asserts the standard-
18810 // library trait impl and the substrate-primitive
18811 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18812 // to the same two-arm accept-set across every arm the
18813 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18814 // the sibling
18815 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18816 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18817 // and the 12 other substrate-wide trait-idiomatic reverse-
18818 // projection routes-through pins — closes the campaign's
18819 // completeness gap on the two-list dep-graph closed-set enum.
18820 for &list in super::DepList::ALL {
18821 let wire = list.as_str();
18822 assert_eq!(
18823 <super::DepList as TryFrom<&str>>::try_from(wire),
18824 Ok(list),
18825 "TryFrom<&str> impl on DepList must round-trip \
18826 DepList::{list:?}.as_str() = {wire:?} back to \
18827 Ok(DepList::{list:?}) — divergence from \
18828 DepList::from_wire signals a silent detour off the \
18829 substrate-primitive accessor"
18830 );
18831 assert_eq!(
18832 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18833 super::DepList::from_wire(wire),
18834 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18835 DepList::from_wire on the same input"
18836 );
18837 }
18838 }
18839
18840 #[test]
18841 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18842 // Rejection witness on the `impl TryFrom<&str> for DepList` —
18843 // sweeps candidate byte-strings outside the two-arm accept-set
18844 // the sibling [`super::DepList::as_str`] emits (`:deps` /
18845 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18846 // future accidental widening of the trait impl's accept-set (a
18847 // stray case-fold path, a silent inclusion of a rebrand alias
18848 // like `":packages"`, an English rebrand `":dev-deps"` in
18849 // reverse arm-order that would silently swap the two arms) trips
18850 // at caixa-core test time. Peer of the sibling
18851 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18852 // (5b828ed) rejection witness.
18853 let rejected: &[&str] = &[
18854 "",
18855 " ",
18856 "\t",
18857 "\n",
18858 ":deps ",
18859 " :deps",
18860 ":DEPS",
18861 ":Deps",
18862 ":Deps-Dev",
18863 ":deps_dev",
18864 ":deps-development",
18865 ":dev-deps",
18866 ":packages",
18867 ":packages-dev",
18868 "deps",
18869 "deps-dev",
18870 "Prod",
18871 "Dev",
18872 "prod",
18873 "dev",
18874 "\":deps\"",
18875 "\":deps-dev\"",
18876 ":deps\n",
18877 ":deps-dev\n",
18878 ];
18879 for &input in rejected {
18880 assert_eq!(
18881 <super::DepList as TryFrom<&str>>::try_from(input),
18882 Err(()),
18883 "TryFrom<&str> impl on DepList must reject unknown \
18884 byte-string {input:?} — divergence from \
18885 DepList::from_wire on the same input signals a silent \
18886 accept-set widening past the two lifted \
18887 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18888 );
18889 assert_eq!(
18890 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18891 super::DepList::from_wire(input),
18892 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18893 DepList::from_wire on the same input — divergence signals \
18894 the two reverse-projection paths have drifted onto \
18895 different accept-sets"
18896 );
18897 }
18898 }
18899
18900 #[test]
18901 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18902 // Fail-before-pass-after byte-parity pin on the newly lifted
18903 // `impl From<DepList> for &'static str` — asserts the standard-
18904 // library trait impl and the substrate-primitive
18905 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18906 // the same two-arm emit-set across every arm the exhaustive
18907 // [`super::DepList::ALL`] slice enumerates. Materializes the
18908 // `<&'static str as From<DepList>>::from` output in a
18909 // `const`-shape binding to make the `'static` lifetime promise
18910 // a build-time invariant — a future accidental downgrade of
18911 // either arm to a non-`&'static str` (a `String::leak()`-
18912 // produced return, a `Box::leak`-cast) trips at caixa-core
18913 // build time rather than at a downstream `'static`-bound
18914 // consumer. Peer of the sibling
18915 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18916 // (523157d) and the 13 other substrate-wide forward-projection
18917 // routes-through pins.
18918 const PROD: &str = super::DepList::Prod.as_str();
18919 const DEV: &str = super::DepList::Dev.as_str();
18920 for &list in super::DepList::ALL {
18921 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18922 let via_method: &'static str = list.as_str();
18923 assert_eq!(
18924 via_trait, via_method,
18925 "From<DepList> for &'static str impl must round-trip \
18926 DepList::{list:?} to the same lifted \
18927 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18928 DepList::as_str returns — divergence signals a silent \
18929 detour off the substrate-primitive accessor"
18930 );
18931 let via_into: &'static str = list.into();
18932 assert_eq!(
18933 via_into, via_method,
18934 "Into<&'static str>::into on DepList::{list:?} must \
18935 byte-equal DepList::as_str on the same input — the \
18936 blanket-derived Into shape must resolve to the same \
18937 as_str dispatch as the explicit From impl"
18938 );
18939 }
18940 assert_eq!(
18941 [PROD, DEV],
18942 [
18943 crate::render::DEP_AUTHOR_KEY_DEPS,
18944 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18945 ],
18946 "const-context DepList::as_str must resolve to the two lifted \
18947 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18948 of either arm to a non-const or non-static byte-string breaks \
18949 the `&'static str`-lifetime promise the paired \
18950 From<DepList> for &'static str impl carries by construction"
18951 );
18952 }
18953
18954 #[test]
18955 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18956 // Cross-axis partition pin: the paired trait-idiomatic
18957 // `From<DepList> for &'static str` forward projection and the
18958 // method-named [`super::DepList::as_str`] forward projection
18959 // must resolve identically on every arm, locking the two paths
18960 // together so any future detour trips at caixa-core test time.
18961 // Then a round-trip witness: every arm's forward `From` output
18962 // re-parses through the paired trait-idiomatic reverse
18963 // `TryFrom<&str>` back to the original variant, closing the
18964 // two-way `DepList ↔ &'static str` round-trip on the trait-
18965 // idiomatic axis pair, mirroring the pre-existing method-named
18966 // `as_str` + `from_wire` round-trip. Peer of the sibling
18967 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18968 // (523157d).
18969 for &list in super::DepList::ALL {
18970 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18971 let via_method: &'static str = list.as_str();
18972 assert_eq!(
18973 via_trait, via_method,
18974 "From<DepList> for &'static str and DepList::as_str must \
18975 resolve identically on DepList::{list:?} — divergence \
18976 signals the two forward-projection paths have drifted \
18977 onto different emit-sets"
18978 );
18979 }
18980 for &list in super::DepList::ALL {
18981 let emitted: &'static str = list.into();
18982 let re_parsed: Result<super::DepList, ()> =
18983 <super::DepList as TryFrom<&str>>::try_from(emitted);
18984 assert_eq!(
18985 re_parsed,
18986 Ok(list),
18987 "trait-idiomatic axis pair must round-trip \
18988 DepList::{list:?} through `.into::<&'static str>()` and \
18989 back through `TryFrom<&str>` — a break signals the \
18990 forward-emit and reverse-parse axes have drifted onto \
18991 different vocabularies"
18992 );
18993 }
18994 }
18995
18996 #[test]
18997 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18998 // Fail-before-pass-after byte-parity pin on the newly lifted
18999 // `impl From<&DepList> for &'static str` — asserts the borrowed-
19000 // input standard-library trait impl and the substrate-primitive
19001 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19002 // the same two-arm emit-set across every arm the exhaustive
19003 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
19004 // does not auto-derive the borrowed-input sibling from a paired
19005 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
19006 // U: From<T>` blanket in `core`), so the borrowed-input axis is
19007 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
19008 // shape over [`super::DepList::ALL`] (whose iterator yields
19009 // `&DepList`, not `DepList`) reaches through this impl and no
19010 // other — the paired owned-input [`From<DepList>`] impl requires
19011 // an explicit `.copied()` / dereference before the trait fires.
19012 // Materializes the `<&'static str as From<&DepList>>::from`
19013 // output in a `const`-shape binding to make the `'static`
19014 // lifetime promise a build-time invariant.
19015 const PROD: &str = super::DepList::Prod.as_str();
19016 const DEV: &str = super::DepList::Dev.as_str();
19017 for list in super::DepList::ALL {
19018 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
19019 let via_method: &'static str = list.as_str();
19020 assert_eq!(
19021 via_trait, via_method,
19022 "From<&DepList> for &'static str impl must round-trip \
19023 &DepList::{list:?} to the same lifted \
19024 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19025 DepList::as_str returns — divergence signals a silent \
19026 detour off the substrate-primitive accessor"
19027 );
19028 let via_into: &'static str = list.into();
19029 assert_eq!(
19030 via_into, via_method,
19031 "Into<&'static str>::into on &DepList::{list:?} must \
19032 byte-equal DepList::as_str on the same input — the \
19033 blanket-derived Into shape must resolve to the same \
19034 as_str dispatch as the explicit From impl"
19035 );
19036 }
19037 assert_eq!(
19038 [PROD, DEV],
19039 [
19040 crate::render::DEP_AUTHOR_KEY_DEPS,
19041 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19042 ],
19043 "const-context DepList::as_str must resolve to the two lifted \
19044 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
19045 From<&DepList> for &'static str impl inherits its `'static` \
19046 lifetime promise from the same accessor the owned-input \
19047 sibling routes through"
19048 );
19049 }
19050
19051 #[test]
19052 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
19053 // Cross-axis partition pin: the paired trait-idiomatic
19054 // owned-input `From<DepList> for &'static str` (523157d
19055 // campaign-shape) and borrowed-input `From<&DepList> for
19056 // &'static str` (this lift) forward projections must resolve
19057 // identically on every arm, locking the two input-shape paths
19058 // together so any future detour trips at caixa-core test time.
19059 // Then a witness that a `.iter().map(Into::into)` pipe over
19060 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
19061 // materializes the two-arm accept-set through the borrowed-
19062 // input axis alone — the exact shape a future M4 admission-
19063 // webhook rejection body composer, a future substrate-wide
19064 // per-arm diagnostic column, or a
19065 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
19066 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
19067 // through — closing the two-way owned/borrowed input-shape
19068 // symmetry on the forward-projection trait-idiomatic axis.
19069 for &list in super::DepList::ALL {
19070 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
19071 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
19072 assert_eq!(
19073 owned, borrowed,
19074 "From<DepList> and From<&DepList> for &'static str must \
19075 resolve identically on DepList::{list:?} — divergence \
19076 signals the owned-input and borrowed-input forward-\
19077 projection paths have drifted onto different emit-sets"
19078 );
19079 }
19080 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
19081 let via_method: Vec<&'static str> =
19082 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19083 assert_eq!(
19084 via_iter, via_method,
19085 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
19086 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
19087 input `From<&DepList> for &'static str` axis is what makes \
19088 the `.iter().map(Into::into)` shape route through the \
19089 substrate-primitive `DepList::as_str` accessor rather than \
19090 through a per-call-site `.copied()` / dereference detour"
19091 );
19092 }
19093
19094 #[test]
19095 fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
19096 // Fail-before-pass-after byte-parity pin on the newly lifted
19097 // `impl From<DepList> for String` — asserts the owned-`String`
19098 // -returning standard-library trait impl and the substrate-
19099 // primitive [`super::DepList::as_str`] `pub const fn` accessor
19100 // resolve to the same two-arm emit-set across every arm the
19101 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19102 // standard library does not carry a blanket
19103 // `impl<T: AsRef<str>> From<T> for String` (nor an
19104 // `impl<T: fmt::Display> From<T> for String`), so the
19105 // owned-`String` forward-projection axis is a distinct trait-
19106 // idiomatic surface that a `let key: String = list.into();`-
19107 // shaped call site reaches through this impl and no other — the
19108 // paired sibling `From<DepList> for &'static str` impl forces
19109 // every owned-`String` call site through an explicit
19110 // `.to_owned()` / `String::from` restatement. Peer of the
19111 // first-mover
19112 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
19113 // (7baa18a), the second-peer
19114 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
19115 // (7851725), the third-peer
19116 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
19117 // (231a18c), and the fourth-peer
19118 // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
19119 // (88942cd) — extends the trait-idiomatic owned-`String`
19120 // forward-projection axis onto the fifth closed-set fieldless
19121 // typed enum on the caixa surface (the two-list dep-graph axis).
19122 for &variant in super::DepList::ALL {
19123 let via_trait: String = <String as From<super::DepList>>::from(variant);
19124 let via_method: &'static str = variant.as_str();
19125 assert_eq!(
19126 via_trait.as_str(),
19127 via_method,
19128 "From<DepList> for String impl must round-trip \
19129 DepList::{variant:?} to the same lifted \
19130 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19131 DepList::as_str returns — divergence signals a silent \
19132 detour off the substrate-primitive accessor"
19133 );
19134 let via_into: String = variant.into();
19135 assert_eq!(
19136 via_into.as_str(),
19137 via_method,
19138 "Into<String>::into on DepList::{variant:?} must \
19139 byte-equal DepList::as_str on the same input — the \
19140 blanket-derived Into shape must resolve to the same \
19141 as_str dispatch as the explicit From impl"
19142 );
19143 }
19144 }
19145
19146 #[test]
19147 fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
19148 // Cross-axis partition pin: the paired trait-idiomatic
19149 // owned-`String` `From<DepList> for String` (this lift) and
19150 // owned-`&'static str` `From<DepList> for &'static str`
19151 // (523157d campaign-shape) forward projections must resolve
19152 // identically on every arm, locking the two return-type-shape
19153 // paths together so any future detour trips at caixa-core test
19154 // time. Also byte-parity witness against the sibling
19155 // [`ToString::to_string`] surface routed through
19156 // [`std::fmt::Display`] — the three owned-heap-string paths
19157 // (`.into::<String>()`, `String::from`, `.to_string()`) must
19158 // resolve identically on every arm so a future consumer that
19159 // picks any of the three lands on the same two-arm lifted
19160 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19161 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
19162 // Then a `.iter().copied().map(String::from)` pipe witness
19163 // over [`super::DepList::ALL`] that materializes the two-arm
19164 // accept-set through the owned-`String` axis alone — the exact
19165 // shape a future M4 admission-webhook rejection body composer
19166 // or a
19167 // `HashMap::<String, DepList>::from_iter(
19168 // DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
19169 // style owned-key per-list lookup reaches through — closing the
19170 // owned-`String` forward-projection axis's iterator-pipe shape.
19171 // Then a direct round-trip witness through the paired
19172 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
19173 // owned-`String`'s [`String::as_str`] borrow that closes the
19174 // two-way `Self → String → Self` round-trip on the trait-
19175 // idiomatic owned-`String` forward + reverse axis pair.
19176 //
19177 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19178 // `From` emit lands on the lowercase Portuguese `as_str`
19179 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19180 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19181 // forcing the round-trip through an intermediate
19182 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19183 // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
19184 // parse resolve through the same lifted
19185 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19186 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19187 // construction (there is no wire/diagnostic axis split on this
19188 // enum), so the owned-`String` forward axis and the reverse
19189 // axis compose directly — matching the peer
19190 // [`crate::supervisor::RestartStrategy`] /
19191 // [`crate::supervisor::RestartPolicy`] /
19192 // [`crate::CaixaDialeto`] owned-`String` axis pairs.
19193 for &list in super::DepList::ALL {
19194 let owned_string: String = <String as From<super::DepList>>::from(list);
19195 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19196 assert_eq!(
19197 owned_string.as_str(),
19198 owned_static,
19199 "From<DepList> for String and From<DepList> for \
19200 &'static str must resolve identically on \
19201 DepList::{list:?} — divergence signals the owned-\
19202 `String` and owned-`&'static str` forward-projection \
19203 return-type-shape paths have drifted onto different \
19204 emit-sets"
19205 );
19206 let via_to_string: String = list.to_string();
19207 assert_eq!(
19208 owned_string, via_to_string,
19209 "From<DepList> for String must byte-equal \
19210 DepList::to_string on DepList::{list:?} — divergence \
19211 signals the trait-idiomatic owned-`String` forward-\
19212 projection axis and the ToString-through-Display axis \
19213 have drifted onto different emit-sets"
19214 );
19215 }
19216 let via_iter: Vec<String> = super::DepList::ALL
19217 .iter()
19218 .copied()
19219 .map(String::from)
19220 .collect();
19221 let via_method: Vec<String> = super::DepList::ALL
19222 .iter()
19223 .map(|l| l.as_str().to_owned())
19224 .collect();
19225 assert_eq!(
19226 via_iter, via_method,
19227 "`.iter().copied().map(String::from)` over DepList::ALL must \
19228 byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
19229 every arm — the owned-`String` `From<DepList> for String` \
19230 axis is what makes the `String::from` composition route \
19231 through the substrate-primitive `DepList::as_str` accessor \
19232 rather than through a per-call-site `.to_owned()` / \
19233 `String::from(list.as_str())` detour"
19234 );
19235 for &variant in super::DepList::ALL {
19236 let emitted: String = variant.into();
19237 let re_parsed: Result<super::DepList, ()> =
19238 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19239 assert_eq!(
19240 re_parsed,
19241 Ok(variant),
19242 "trait-idiomatic owned-`String` forward-projection + \
19243 reverse-projection axis pair must round-trip \
19244 DepList::{variant:?} through `.into::<String>()` and \
19245 back through `TryFrom<&str>` on the owned-`String`'s \
19246 String::as_str borrow — a break signals the owned-\
19247 `String` forward-emit and reverse-parse axes have \
19248 drifted onto different vocabularies (unlike the peer \
19249 CaixaKind axis pair, DepList's forward emit and \
19250 reverse parse share the same lifted \
19251 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
19252 round-trip composes directly)"
19253 );
19254 }
19255 }
19256
19257 #[test]
19258 fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
19259 // Fail-before-pass-after byte-parity pin on the newly lifted
19260 // `impl From<&DepList> for String` — asserts the borrowed-input
19261 // owned-`String`-returning standard-library trait impl and the
19262 // substrate-primitive [`super::DepList::as_str`] `pub const fn`
19263 // accessor resolve to the same two-arm emit-set across every
19264 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
19265 // Rust's standard library does not carry a blanket
19266 // `impl<T: AsRef<str>> From<&T> for String` (nor an
19267 // `impl<T: fmt::Display> From<&T> for String`), so the
19268 // borrowed-input owned-`String` forward-projection axis is a
19269 // distinct trait-idiomatic surface that a
19270 // `let key: String = (&list).into();`-shaped call site reaches
19271 // through this impl and no other — the paired sibling
19272 // `From<DepList> for String` impl forces every borrowed-input
19273 // call site through an explicit `Copy` deref
19274 // (`String::from(*list)`) or an `.as_str().to_owned()` /
19275 // `.to_string()` detour. Peer of the first-mover
19276 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19277 // (579385f) and the second-peer
19278 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19279 // (8465740) — extends the trait-idiomatic borrowed-input owned-
19280 // `String` forward-projection axis off the M2 OTP-shape sibling
19281 // axis pair onto the first non-M2 closed-set fieldless typed
19282 // enum peer (the two-list dep-graph axis).
19283 for &variant in super::DepList::ALL {
19284 let via_trait: String = <String as From<&super::DepList>>::from(&variant);
19285 let via_method: &'static str = variant.as_str();
19286 assert_eq!(
19287 via_trait.as_str(),
19288 via_method,
19289 "From<&DepList> for String impl must round-trip \
19290 &DepList::{variant:?} to the same lifted \
19291 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19292 DepList::as_str returns — divergence signals a silent \
19293 detour off the substrate-primitive accessor"
19294 );
19295 let via_into: String = (&variant).into();
19296 assert_eq!(
19297 via_into.as_str(),
19298 via_method,
19299 "Into<String>::into on &DepList::{variant:?} must \
19300 byte-equal DepList::as_str on the same input — the \
19301 blanket-derived Into shape must resolve to the same \
19302 as_str dispatch as the explicit From impl"
19303 );
19304 }
19305 }
19306
19307 #[test]
19308 fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
19309 // Cross-axis partition pin: the newly lifted trait-idiomatic
19310 // borrowed-input owned-`String` `From<&DepList> for String`
19311 // (this lift), the paired owned-input owned-`String`
19312 // `From<DepList> for String` (32b0ee8), the paired borrowed-
19313 // input owned-`&'static str` `From<&DepList> for &'static str`
19314 // (64aa742), and the paired owned-input owned-`&'static str`
19315 // `From<DepList> for &'static str` (3455cbf) — every corner of
19316 // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
19317 // idiomatic projection family — must resolve identically on
19318 // every arm, locking the four return-shape × input-shape paths
19319 // together so any future detour trips at caixa-core test time.
19320 // Also byte-parity witness against the sibling
19321 // [`ToString::to_string`] surface routed through
19322 // [`std::fmt::Display`] and a direct round-trip witness through
19323 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
19324 // the owned-`String`'s [`String::as_str`] borrow that closes
19325 // the two-way `&Self → String → Self` round-trip on the trait-
19326 // idiomatic borrowed-input owned-`String` forward + reverse
19327 // axis pair. Peer of the first-mover
19328 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19329 // (579385f) and the second-peer
19330 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19331 // (8465740) — closes the whole `{Self, &Self} × {&'static str,
19332 // String}` 2×2 projection corner on the third substrate-wide
19333 // closed-set fieldless typed enum peer (the two-list dep-graph
19334 // axis, first outside the M2 OTP-shape sibling pair).
19335 //
19336 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19337 // `From` emit lands on the lowercase Portuguese `as_str`
19338 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19339 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19340 // forcing the round-trip through an intermediate
19341 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19342 // [`super::DepList::as_str`] emit and
19343 // [`super::DepList::from_wire`] parse resolve through the same
19344 // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19345 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19346 // construction (there is no wire/diagnostic axis split on this
19347 // enum), so the borrowed-input owned-`String` forward axis and
19348 // the reverse axis compose directly — matching the peer
19349 // [`crate::supervisor::RestartStrategy`] /
19350 // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
19351 // `String` axis pairs.
19352 for &list in super::DepList::ALL {
19353 let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
19354 let owned_string: String = <String as From<super::DepList>>::from(list);
19355 let borrowed_static: &'static str =
19356 <&'static str as From<&super::DepList>>::from(&list);
19357 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19358 assert_eq!(
19359 borrowed_string, owned_string,
19360 "From<&DepList> for String and From<DepList> for String \
19361 must resolve identically on DepList::{list:?} — \
19362 divergence signals the borrowed-input and owned-input \
19363 owned-`String` forward-projection input-shape paths \
19364 have drifted onto different emit-sets"
19365 );
19366 assert_eq!(
19367 borrowed_string.as_str(),
19368 borrowed_static,
19369 "From<&DepList> for String and From<&DepList> for \
19370 &'static str must resolve identically on \
19371 DepList::{list:?} — divergence signals the borrowed-\
19372 input `&'static str` and owned-`String` return-shape \
19373 paths have drifted onto different emit-sets"
19374 );
19375 assert_eq!(
19376 borrowed_string.as_str(),
19377 owned_static,
19378 "From<&DepList> for String and From<DepList> for \
19379 &'static str must resolve identically on \
19380 DepList::{list:?} — divergence signals a break in the \
19381 diagonal corner of the {{Self, &Self}} × {{&'static \
19382 str, String}} 2×2 trait-idiomatic projection family"
19383 );
19384 let via_to_string: String = list.to_string();
19385 assert_eq!(
19386 borrowed_string, via_to_string,
19387 "From<&DepList> for String must byte-equal \
19388 DepList::to_string on DepList::{list:?} — divergence \
19389 signals the trait-idiomatic borrowed-input owned-\
19390 `String` forward-projection axis and the ToString-\
19391 through-Display axis have drifted onto different \
19392 emit-sets"
19393 );
19394 }
19395 let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
19396 let via_method: Vec<String> = super::DepList::ALL
19397 .iter()
19398 .map(|l| l.as_str().to_owned())
19399 .collect();
19400 assert_eq!(
19401 via_iter, via_method,
19402 "`.iter().map(String::from)` over DepList::ALL — a call \
19403 site whose iteration axis holds `&DepList` by construction \
19404 — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
19405 on every arm — the borrowed-input owned-`String` \
19406 `From<&DepList> for String` axis is what makes the \
19407 `String::from` composition route through the substrate-\
19408 primitive `DepList::as_str` accessor without a spurious \
19409 `Copy` deref (which would only be reachable through the \
19410 owned-input `From<DepList> for String` axis by first \
19411 calling `.copied()` on the iterator)"
19412 );
19413 for &variant in super::DepList::ALL {
19414 let emitted: String = (&variant).into();
19415 let re_parsed: Result<super::DepList, ()> =
19416 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19417 assert_eq!(
19418 re_parsed,
19419 Ok(variant),
19420 "trait-idiomatic borrowed-input owned-`String` \
19421 forward-projection + reverse-projection axis pair must \
19422 round-trip &DepList::{variant:?} through \
19423 `.into::<String>()` on the borrowed-input surface and \
19424 back through `TryFrom<&str>` on the owned-`String`'s \
19425 String::as_str borrow — a break signals the \
19426 borrowed-input owned-`String` forward-emit and \
19427 reverse-parse axes have drifted onto different \
19428 vocabularies (unlike the peer CaixaKind axis pair, \
19429 DepList's forward emit and reverse parse share the \
19430 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
19431 construction, so the round-trip composes directly)"
19432 );
19433 }
19434 }
19435
19436 #[test]
19437 fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
19438 // Fail-before-pass-after byte-parity pin on the newly lifted
19439 // `impl From<DepList> for std::borrow::Cow<'static, str>` —
19440 // asserts the standard-library trait impl and the substrate-
19441 // primitive [`super::DepList::as_str`] `pub const fn`
19442 // accessor resolve to the same two-arm emit-set across every
19443 // arm the exhaustive [`super::DepList::ALL`] slice
19444 // enumerates. Rust's standard library does not carry a
19445 // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19446 // (nor an `impl<T: fmt::Display> From<T> for
19447 // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19448 // projection axis is a distinct trait-idiomatic surface that
19449 // a `let key: Cow<'static, str> = list.into();`-shaped call
19450 // site reaches through this impl and no other — the paired
19451 // sibling `From<DepList> for &'static str` and
19452 // `From<DepList> for String` impls force every
19453 // `Cow<'static, str>`-parameterized call site through a
19454 // `Cow::Borrowed(list.as_str())` /
19455 // `Cow::Owned(list.to_string())` composition whose type
19456 // bounds have no compile-time link back to the substrate
19457 // primitive.
19458 //
19459 // Also asserts the projection lands on the zero-alloc
19460 // [`std::borrow::Cow::Borrowed`] arm (not the
19461 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19462 // [`super::DepList::as_str`] accessor's `&'static str`
19463 // return lifetime by construction (each match arm resolves
19464 // to one of the two lifted
19465 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19466 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19467 // &str` values) makes the borrowed arm the type-correct
19468 // projection with no runtime allocation. Any future silent
19469 // detour that routes the impl through the owned arm trips
19470 // at caixa-core test time under the
19471 // [`std::borrow::Cow::Borrowed`] discriminator witness
19472 // rather than at a downstream `Cow<'static, str>`-bound
19473 // consumer's silent allocation.
19474 //
19475 // First-mover on the outside-M3 substrate-wide tier of the
19476 // substrate-wide trait-idiomatic
19477 // [`std::borrow::Cow<'static, str>`] forward-projection
19478 // campaign — extends the axis off the paired
19479 // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19480 // the paired M2 OTP-shape
19481 // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19482 // and [`crate::supervisor::RestartPolicy`] (0612398 +
19483 // ee577fd), and the paired M3-mesh-shape
19484 // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19485 // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19486 // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19487 // peers onto the first outside-M3 caixa-core peer (the two-
19488 // list dep-graph axis), opening the outside-M3 caixa-core
19489 // tier of the substrate-wide Cow<'static, str> forward-
19490 // projection campaign's owned-input corner.
19491 for &variant in super::DepList::ALL {
19492 let via_trait: std::borrow::Cow<'static, str> =
19493 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19494 let via_method: &'static str = variant.as_str();
19495 assert_eq!(
19496 via_trait.as_ref(),
19497 via_method,
19498 "From<DepList> for Cow<'static, str> impl must \
19499 round-trip DepList::{variant:?} to the same lifted \
19500 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19501 DepList::as_str returns — divergence signals a \
19502 silent detour off the substrate-primitive accessor"
19503 );
19504 assert!(
19505 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19506 "From<DepList> for Cow<'static, str> impl must land \
19507 on the zero-alloc Cow::Borrowed arm on \
19508 DepList::{variant:?} — a Cow::Owned outcome signals \
19509 the projection has silently allocated where the \
19510 substrate-primitive DepList::as_str `&'static str` \
19511 return makes the borrowed arm the type-correct \
19512 projection"
19513 );
19514 let via_into: std::borrow::Cow<'static, str> = variant.into();
19515 assert_eq!(
19516 via_into.as_ref(),
19517 via_method,
19518 "Into<Cow<'static, str>>::into on DepList::\
19519 {variant:?} must byte-equal DepList::as_str on the \
19520 same input — the blanket-derived Into shape must \
19521 resolve to the same as_str dispatch as the explicit \
19522 From impl"
19523 );
19524 assert!(
19525 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19526 "Into<Cow<'static, str>>::into on DepList::\
19527 {variant:?} must land on the zero-alloc \
19528 Cow::Borrowed arm — the blanket-derived Into shape \
19529 must resolve to the same Cow::Borrowed dispatch as \
19530 the explicit From impl"
19531 );
19532 }
19533 }
19534
19535 #[test]
19536 fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19537 // Cross-axis partition pin: the newly lifted trait-idiomatic
19538 // `From<DepList> for std::borrow::Cow<'static, str>` (this
19539 // lift), the paired owned-input `From<DepList> for
19540 // &'static str` (3455cbf), and the paired owned-input
19541 // `From<DepList> for String` (32b0ee8) forward projections
19542 // must resolve identically on every arm, locking the three
19543 // return-shape paths together by construction so any future
19544 // detour trips at caixa-core test time. Also byte-parity
19545 // witness against the sibling [`ToString::to_string`]
19546 // surface routed through [`std::fmt::Display`] — every
19547 // owned-heap-string path (the `Cow::Owned` promotion of
19548 // this axis's `.into_owned()`, `From<DepList> for String`,
19549 // and `.to_string()`) resolves to the same two-arm lifted
19550 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19551 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19552 // arm.
19553 //
19554 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19555 // witness over [`super::DepList::ALL`] that materializes the
19556 // two-arm accept-set through the
19557 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19558 // shape a future M4 admission-webhook rejection body's
19559 // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19560 // future substrate-wide per-arm diagnostic surface whose
19561 // typing rules out the sibling [`AsRef<str>`] borrowed
19562 // return, or a future per-arm dep-list emitter that binds
19563 // through a [`std::borrow::Cow<'static, str>`] boundary
19564 // reaches through — opening the composable-projection axis
19565 // on the first outside-M3 caixa-core closed-set fieldless
19566 // typed enum peer on the caixa surface. The pipe witness
19567 // also pins the zero-alloc discipline: every element in the
19568 // collected vector satisfies the
19569 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19570 // accidental silent-allocation regression on the pipe's
19571 // iteration axis is a caixa-core-test-time failure.
19572 for &variant in super::DepList::ALL {
19573 let via_cow: std::borrow::Cow<'static, str> =
19574 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19575 let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19576 let via_string: String = <String as From<super::DepList>>::from(variant);
19577 assert_eq!(
19578 via_cow.as_ref(),
19579 via_static,
19580 "From<DepList> for Cow<'static, str> and \
19581 From<DepList> for &'static str must resolve \
19582 identically on DepList::{variant:?} — divergence \
19583 signals the Cow<'static, str> and &'static str \
19584 return-shape paths have drifted onto different \
19585 emit-sets"
19586 );
19587 assert_eq!(
19588 via_cow.as_ref(),
19589 via_string.as_str(),
19590 "From<DepList> for Cow<'static, str> and \
19591 From<DepList> for String must resolve identically \
19592 on DepList::{variant:?} — divergence signals the \
19593 Cow<'static, str> and String return-shape paths \
19594 have drifted onto different emit-sets"
19595 );
19596 let via_to_string: String = variant.to_string();
19597 assert_eq!(
19598 via_cow.as_ref(),
19599 via_to_string.as_str(),
19600 "From<DepList> for Cow<'static, str> must byte-equal \
19601 DepList::to_string on DepList::{variant:?} — \
19602 divergence signals the trait-idiomatic \
19603 Cow<'static, str> forward-projection axis and the \
19604 ToString-through-Display axis have drifted onto \
19605 different emit-sets"
19606 );
19607 }
19608 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19609 .iter()
19610 .copied()
19611 .map(std::borrow::Cow::from)
19612 .collect();
19613 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19614 .iter()
19615 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19616 .collect();
19617 assert_eq!(
19618 via_iter, via_method,
19619 "`.iter().copied().map(Cow::from)` over DepList::ALL \
19620 must byte-equal `.iter().map(|l| \
19621 Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19622 idiomatic `From<DepList> for Cow<'static, str>` axis is \
19623 what makes the `Cow::from` composition route through \
19624 the substrate-primitive `DepList::as_str` accessor with \
19625 the zero-alloc Cow::Borrowed arm by construction, \
19626 rather than a per-call-site `Cow::Owned(list.to_string())` \
19627 allocation"
19628 );
19629 for cow in &via_iter {
19630 assert!(
19631 matches!(cow, std::borrow::Cow::Borrowed(_)),
19632 "every element of the .iter().copied().map(Cow::from) \
19633 pipe over DepList::ALL must land on the zero-alloc \
19634 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19635 signals the pipe's iteration axis has silently \
19636 allocated where the substrate-primitive \
19637 DepList::as_str `&'static str` return makes the \
19638 borrowed arm the type-correct projection"
19639 );
19640 }
19641 }
19642
19643 #[test]
19644 fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19645 // Fail-before-pass-after byte-parity pin on the newly lifted
19646 // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19647 // asserts the borrowed-input standard-library trait impl and
19648 // the substrate-primitive [`super::DepList::as_str`] `pub const
19649 // fn` accessor resolve to the same two-arm emit-set across
19650 // every arm the exhaustive [`super::DepList::ALL`] slice
19651 // enumerates. Rust's standard library does not carry a blanket
19652 // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19653 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19654 // the borrowed-input `Cow<'static, str>` forward-projection
19655 // axis is a distinct trait-idiomatic surface that a
19656 // `let key: Cow<'static, str> = (&list).into();`-shaped call
19657 // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19658 // reaches through this impl and no other — the paired owned-
19659 // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19660 // forces every borrowed-input call site through an explicit
19661 // `Copy` deref (`Cow::from(*list)`) or a
19662 // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19663 // have no compile-time link back to the substrate primitive.
19664 //
19665 // Also asserts the projection lands on the zero-alloc
19666 // [`std::borrow::Cow::Borrowed`] arm (not the
19667 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19668 // [`super::DepList::as_str`] accessor's `&'static str` return
19669 // lifetime by construction (each match arm resolves to one of
19670 // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19671 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19672 // values) makes the borrowed arm the type-correct projection
19673 // with no runtime allocation on the borrowed-input surface
19674 // just as on the paired owned-input surface.
19675 //
19676 // Closes the `{Self, &Self}` input-shape corner on the outside-
19677 // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19678 // on the first outside-M3 caixa-core closed-set fieldless typed
19679 // enum peer on the caixa surface, exactly as afdf0f4 closed it
19680 // on the second M3-mesh-primitive peer
19681 // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19682 // the owning half (eee504d) landed, as 25690ef closed it on
19683 // the first M3-mesh-primitive peer
19684 // ([`crate::aplicacao::WitShape`]) one commit after the owning
19685 // half (8634dec) landed, as d45c409 closed it on the top-level
19686 // [`crate::CaixaKind`] one commit after the owning half
19687 // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19688 // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19689 // [`crate::supervisor::RestartPolicy`] sibling peers one
19690 // commit after (7dd28b3 / 0612398) landed.
19691 for &variant in super::DepList::ALL {
19692 let via_trait: std::borrow::Cow<'static, str> =
19693 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19694 let via_method: &'static str = variant.as_str();
19695 assert_eq!(
19696 via_trait.as_ref(),
19697 via_method,
19698 "From<&DepList> for Cow<'static, str> impl must \
19699 round-trip &DepList::{variant:?} to the same lifted \
19700 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19701 DepList::as_str returns — divergence signals a silent \
19702 detour off the substrate-primitive accessor"
19703 );
19704 assert!(
19705 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19706 "From<&DepList> for Cow<'static, str> impl must land \
19707 on the zero-alloc Cow::Borrowed arm on \
19708 &DepList::{variant:?} — a Cow::Owned outcome signals \
19709 the projection has silently allocated where the \
19710 substrate-primitive DepList::as_str `&'static str` \
19711 return makes the borrowed arm the type-correct \
19712 projection"
19713 );
19714 let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19715 assert_eq!(
19716 via_into.as_ref(),
19717 via_method,
19718 "Into<Cow<'static, str>>::into on &DepList::\
19719 {variant:?} must byte-equal DepList::as_str on the \
19720 same input — the blanket-derived Into shape must \
19721 resolve to the same as_str dispatch as the explicit \
19722 From impl"
19723 );
19724 assert!(
19725 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19726 "Into<Cow<'static, str>>::into on &DepList::\
19727 {variant:?} must land on the zero-alloc \
19728 Cow::Borrowed arm — the blanket-derived Into shape \
19729 must resolve to the same Cow::Borrowed dispatch as \
19730 the explicit From impl"
19731 );
19732 }
19733 }
19734
19735 #[test]
19736 fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19737 // Cross-axis partition pin: the newly lifted trait-idiomatic
19738 // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19739 // str>` (this lift), the paired owned-input `From<DepList> for
19740 // std::borrow::Cow<'static, str>` (6858bac), the paired
19741 // borrowed-input owned-`&'static str` `From<&DepList> for
19742 // &'static str` (3455cbf), and the paired borrowed-input
19743 // owned-`String` `From<&DepList> for String` must resolve
19744 // identically on every arm, locking the four return-shape ×
19745 // input-shape paths together by construction so any future
19746 // detour trips at caixa-core test time. Also byte-parity
19747 // witness against the sibling [`ToString::to_string`] surface
19748 // routed through [`std::fmt::Display`] — every owned-heap-
19749 // string path (this axis's `.into_owned()` promotion, the
19750 // paired [`From<&DepList> for String`], and `.to_string()`)
19751 // resolves to the same two-arm lifted
19752 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19753 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19754 // arm.
19755 //
19756 // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19757 // over [`super::DepList::ALL`] — whose iterator yields
19758 // `&DepList` by construction, so the borrowed-input
19759 // [`Cow<'static, str>`] axis is what routes the pipe through
19760 // the substrate-primitive [`super::DepList::as_str`] accessor
19761 // without a spurious [`Copy`] deref (which would only be
19762 // reachable through the owned-input [`From<DepList> for
19763 // Cow<'static, str>`] axis by first calling `.copied()` on the
19764 // iterator). The pipe witness also pins the zero-alloc
19765 // discipline: every element in the collected vector satisfies
19766 // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19767 // future accidental silent-allocation regression on the pipe's
19768 // iteration axis is a caixa-core-test-time failure. Peer of
19769 // the sibling
19770 // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19771 // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19772 // axis — extends the whole borrowed-input `Cow<'static, str>`
19773 // + paired `{&'static str, String}` cross-axis-parity corner
19774 // onto the first outside-M3 caixa-core closed-set fieldless
19775 // typed enum peer on the caixa surface.
19776 for &variant in super::DepList::ALL {
19777 let borrowed_cow: std::borrow::Cow<'static, str> =
19778 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19779 let owned_cow: std::borrow::Cow<'static, str> =
19780 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19781 let borrowed_static: &'static str =
19782 <&'static str as From<&super::DepList>>::from(&variant);
19783 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19784 assert_eq!(
19785 borrowed_cow, owned_cow,
19786 "From<&DepList> for Cow<'static, str> and \
19787 From<DepList> for Cow<'static, str> must resolve \
19788 identically on DepList::{variant:?} — divergence \
19789 signals the borrowed-input and owned-input \
19790 Cow<'static, str> forward-projection input-shape \
19791 paths have drifted onto different emit-sets"
19792 );
19793 assert_eq!(
19794 borrowed_cow.as_ref(),
19795 borrowed_static,
19796 "From<&DepList> for Cow<'static, str> and \
19797 From<&DepList> for &'static str must resolve \
19798 identically on DepList::{variant:?} — divergence \
19799 signals the borrowed-input Cow<'static, str> and \
19800 &'static str return-shape paths have drifted onto \
19801 different emit-sets"
19802 );
19803 assert_eq!(
19804 borrowed_cow.as_ref(),
19805 borrowed_string.as_str(),
19806 "From<&DepList> for Cow<'static, str> and \
19807 From<&DepList> for String must resolve identically \
19808 on DepList::{variant:?} — divergence signals the \
19809 borrowed-input Cow<'static, str> and owned-`String` \
19810 return-shape paths have drifted onto different \
19811 emit-sets"
19812 );
19813 let via_to_string: String = variant.to_string();
19814 assert_eq!(
19815 borrowed_cow.as_ref(),
19816 via_to_string.as_str(),
19817 "From<&DepList> for Cow<'static, str> must byte-equal \
19818 DepList::to_string on DepList::{variant:?} — \
19819 divergence signals the trait-idiomatic borrowed-input \
19820 Cow<'static, str> forward-projection axis and the \
19821 ToString-through-Display axis have drifted onto \
19822 different emit-sets"
19823 );
19824 }
19825 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19826 .iter()
19827 .map(std::borrow::Cow::from)
19828 .collect();
19829 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19830 .iter()
19831 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19832 .collect();
19833 assert_eq!(
19834 via_iter, via_method,
19835 "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19836 whose iteration axis holds &DepList by construction — \
19837 must byte-equal `.iter().map(|l| \
19838 Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19839 input Cow<'static, str> `From<&DepList> for Cow<'static, \
19840 str>` axis is what makes the `Cow::from` composition \
19841 route through the substrate-primitive `DepList::as_str` \
19842 accessor with the zero-alloc Cow::Borrowed arm by \
19843 construction and without a spurious `Copy` deref (which \
19844 would only be reachable through the owned-input \
19845 `From<DepList> for Cow<'static, str>` axis by first \
19846 calling `.copied()` on the iterator)"
19847 );
19848 for cow in &via_iter {
19849 assert!(
19850 matches!(cow, std::borrow::Cow::Borrowed(_)),
19851 "every element of the .iter().map(Cow::from) pipe \
19852 over DepList::ALL must land on the zero-alloc \
19853 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19854 signals the pipe's iteration axis has silently \
19855 allocated where the substrate-primitive \
19856 DepList::as_str `&'static str` return makes the \
19857 borrowed arm the type-correct projection"
19858 );
19859 }
19860 }
19861
19862 #[test]
19863 fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19864 // Fail-before-pass-after byte-parity pin on the newly lifted
19865 // `impl From<DepList> for Box<str>` — asserts the owned-input
19866 // standard-library trait impl and the substrate-primitive
19867 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19868 // the same two-arm emit-set (the paired
19869 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19870 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19871 // byte-strings) across every arm the exhaustive
19872 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19873 // core-internal tier of the substrate-wide [`Box<str>`] forward-
19874 // projection campaign onto the second caixa-core-internal peer,
19875 // after the render-side path-shape-diagnostic
19876 // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19877 // both corners in one axis) opened the tier. Rust's standard
19878 // library carries `impl From<&str> for Box<str>` and
19879 // `impl From<String> for Box<str>` but no blanket
19880 // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19881 // distinct trait-idiomatic surface that a
19882 // `let key: Box<str> = list.into();`-shaped call site reaches
19883 // through this impl and no other — a paired
19884 // `Box::from(list.as_str())` open-code has no compile-time link
19885 // back to the substrate primitive.
19886 for &variant in super::DepList::ALL {
19887 let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19888 let via_method: &'static str = variant.as_str();
19889 assert_eq!(
19890 via_trait.as_ref(),
19891 via_method,
19892 "From<DepList> for Box<str> impl must round-trip \
19893 DepList::{variant:?} to the same lifted \
19894 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19895 DepList::as_str returns — divergence signals a silent \
19896 detour off the substrate-primitive accessor"
19897 );
19898 let via_into: Box<str> = variant.into();
19899 assert_eq!(
19900 via_into.as_ref(),
19901 via_method,
19902 "Into<Box<str>>::into on DepList::{variant:?} must \
19903 byte-equal DepList::as_str on the same input — the \
19904 blanket-derived Into shape must resolve to the same \
19905 as_str dispatch as the explicit From impl"
19906 );
19907 }
19908 }
19909
19910 #[test]
19911 fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
19912 // Fail-before-pass-after byte-parity pin on the newly lifted
19913 // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
19914 // standard-library trait impl and the substrate-primitive
19915 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19916 // the same two-arm emit-set (the paired
19917 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19918 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19919 // byte-strings) across every arm the exhaustive
19920 // [`super::DepList::ALL`] slice enumerates. Rust's standard
19921 // library carries `impl From<&str> for Box<str>` and
19922 // `impl From<String> for Box<str>` but no blanket
19923 // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
19924 // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
19925 // input [`Box<str>`] forward-projection axis is a distinct
19926 // trait-idiomatic surface that a
19927 // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
19928 // iterator over `&'static [DepList]` yields `&DepList` by
19929 // construction) or a `let key: Box<str> = (&list).into();`-shaped
19930 // call site reaches through this impl and no other — the paired
19931 // owned-input `From<DepList> for Box<str>` impl alone would force
19932 // every borrowed-input call site through an explicit `Copy` deref
19933 // (`Box::<str>::from(*list)`) or a
19934 // `Box::<str>::from(list.as_str())` open-code whose type bounds
19935 // have no compile-time link back to the substrate primitive.
19936 //
19937 // Closes the `{Self, &Self}` input-shape corner on the second
19938 // caixa-core-internal closed-set fieldless typed enum peer of
19939 // the substrate-wide [`Box<str>`] forward-projection campaign —
19940 // one commit after the paired render-side path-shape-diagnostic
19941 // [`super::super::render::PathShapeViolation`] pair (0d87a72)
19942 // opened the caixa-core-internal tier — matching the trajectory
19943 // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
19944 // in one axis), the caixa-provedor `FerriteRuntime` pair
19945 // (14886a8, both corners in one axis), and the render-side
19946 // `PathShapeViolation` pair (0d87a72, both corners in one axis)
19947 // walked before it.
19948 for &variant in super::DepList::ALL {
19949 let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19950 let via_method: &'static str = variant.as_str();
19951 assert_eq!(
19952 via_trait.as_ref(),
19953 via_method,
19954 "From<&DepList> for Box<str> impl must round-trip \
19955 &DepList::{variant:?} to the same lifted \
19956 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19957 DepList::as_str returns — divergence signals a silent \
19958 detour off the substrate-primitive accessor"
19959 );
19960 let via_into: Box<str> = (&variant).into();
19961 assert_eq!(
19962 via_into.as_ref(),
19963 via_method,
19964 "Into<Box<str>>::into on &DepList::{variant:?} must \
19965 byte-equal DepList::as_str on the same input — the \
19966 blanket-derived Into shape on the borrowed-input \
19967 surface must resolve to the same as_str dispatch as \
19968 the explicit From impl"
19969 );
19970 }
19971
19972 // Pipe witness — the distinguishing shape that forces the
19973 // borrowed-input axis to be independent of the owned-input
19974 // peer. `DepList::ALL.iter()` yields `&DepList` by
19975 // construction, so `.map(Box::<str>::from)` resolves through
19976 // the borrowed-input `From<&DepList> for Box<str>` impl and
19977 // no other — without this axis, the same pipe would force an
19978 // explicit `.copied()` restatement whose type bounds bypass
19979 // the substrate primitive.
19980 let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
19981 let via_accessor: Vec<&'static str> =
19982 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19983 assert_eq!(
19984 via_pipe.len(),
19985 via_accessor.len(),
19986 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19987 preserve arity against the paired DepList::as_str \
19988 accessor — a length divergence signals the borrowed-input \
19989 axis has silently rejected an arm"
19990 );
19991 for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
19992 assert_eq!(
19993 pipe_arm.as_ref(),
19994 *accessor_arm,
19995 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19996 byte-equal the paired \
19997 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
19998 arm — divergence signals the borrowed-input \
19999 `From<&DepList> for Box<str>` axis has silently \
20000 detoured off the substrate-primitive accessor"
20001 );
20002 }
20003 }
20004
20005 #[test]
20006 fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
20007 // Fail-before-pass-after byte-parity pin on the newly lifted
20008 // `impl From<DepList> for std::sync::Arc<str>` — asserts the
20009 // owned-input standard-library trait impl and the substrate-
20010 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20011 // resolve to the same two-arm emit-set (the paired
20012 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20013 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20014 // byte-strings) across every arm the exhaustive
20015 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20016 // core-internal tier of the substrate-wide
20017 // [`std::sync::Arc<str>`] forward-projection campaign onto the
20018 // second caixa-core-internal peer, after the top-level
20019 // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
20020 // opened the tier. Rust's standard library carries
20021 // `impl From<&str> for std::sync::Arc<str>` and
20022 // `impl From<String> for std::sync::Arc<str>` but no blanket
20023 // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
20024 // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
20025 // this axis is a distinct trait-idiomatic surface that a
20026 // `let key: std::sync::Arc<str> = list.into();`-shaped call site
20027 // reaches through this impl and no other — a paired
20028 // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
20029 // compile-time link back to the substrate primitive, and a two-
20030 // step `std::sync::Arc::<str>::from(String::from(list))`
20031 // composition through the owned-`String` axis allocates twice
20032 // (once into the intermediate `String`, once into the
20033 // [`std::sync::Arc<str>`] on the `From<String>` conversion)
20034 // where the single-step trait impl allocates once.
20035 //
20036 // Cross-axis byte-parity witness against the sibling owned-input
20037 // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
20038 // shape axes — locking the five return-shape paths on the owned-
20039 // input surface together by construction so any future detour
20040 // off the substrate-primitive [`super::DepList::as_str`] accessor
20041 // trips at caixa-core test time.
20042 for &variant in super::DepList::ALL {
20043 let via_trait: std::sync::Arc<str> =
20044 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20045 let via_method: &'static str = variant.as_str();
20046 assert_eq!(
20047 via_trait.as_ref(),
20048 via_method,
20049 "From<DepList> for std::sync::Arc<str> impl must round-\
20050 trip DepList::{variant:?} to the same lifted \
20051 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20052 DepList::as_str returns — divergence signals a silent \
20053 detour off the substrate-primitive accessor"
20054 );
20055 let via_into: std::sync::Arc<str> = variant.into();
20056 assert_eq!(
20057 via_into.as_ref(),
20058 via_method,
20059 "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
20060 must byte-equal DepList::as_str on the same input — \
20061 the blanket-derived Into shape must resolve to the same \
20062 as_str dispatch as the explicit From impl"
20063 );
20064 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20065 assert_eq!(
20066 via_trait.as_ref(),
20067 owned_static,
20068 "From<DepList> for std::sync::Arc<str> and \
20069 From<DepList> for &'static str must resolve identically \
20070 on DepList::{variant:?} — divergence signals the owned-\
20071 input std::sync::Arc<str> and &'static str return-shape \
20072 paths have drifted onto different emit-sets"
20073 );
20074 let owned_string: String = <String as From<super::DepList>>::from(variant);
20075 assert_eq!(
20076 via_trait.as_ref(),
20077 owned_string.as_str(),
20078 "From<DepList> for std::sync::Arc<str> and \
20079 From<DepList> for String must resolve identically on \
20080 DepList::{variant:?} — divergence signals the owned-\
20081 input std::sync::Arc<str> and owned-`String` return-shape \
20082 paths have drifted onto different emit-sets"
20083 );
20084 let owned_cow: std::borrow::Cow<'static, str> =
20085 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20086 assert_eq!(
20087 via_trait.as_ref(),
20088 owned_cow.as_ref(),
20089 "From<DepList> for std::sync::Arc<str> and \
20090 From<DepList> for Cow<'static, str> must resolve \
20091 identically on DepList::{variant:?} — divergence signals \
20092 the owned-input std::sync::Arc<str> and \
20093 Cow<'static, str> return-shape paths have drifted onto \
20094 different emit-sets"
20095 );
20096 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20097 assert_eq!(
20098 via_trait.as_ref(),
20099 owned_box.as_ref(),
20100 "From<DepList> for std::sync::Arc<str> and \
20101 From<DepList> for Box<str> must resolve identically on \
20102 DepList::{variant:?} — divergence signals the owned-\
20103 input std::sync::Arc<str> and Box<str> return-shape \
20104 paths have drifted onto different emit-sets"
20105 );
20106 }
20107 }
20108
20109 #[test]
20110 #[allow(
20111 clippy::too_many_lines,
20112 reason = "cross-axis partition pin folds four borrowed-input \
20113 return-shape paths (&'static str, String, Cow<'static, \
20114 str>, Box<str>) plus the paired owned-input Arc<str> \
20115 witness and the .iter().map(std::sync::Arc::<str>::from) \
20116 pipe witness into one exhaustive round-trip over \
20117 DepList::ALL — the accepted line-count cost of keying \
20118 the whole borrowed-input Arc<str> corner to the \
20119 substrate-primitive as_str accessor at the same test-site"
20120 )]
20121 fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
20122 // Fail-before-pass-after byte-parity pin on the newly lifted
20123 // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
20124 // borrowed-input standard-library trait impl and the substrate-
20125 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20126 // resolve to the same two-arm emit-set across every arm the
20127 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20128 // standard library does not carry a blanket
20129 // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
20130 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20131 // the borrowed-input `std::sync::Arc<str>` forward-projection
20132 // axis is a distinct trait-idiomatic surface that a
20133 // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
20134 // site or a
20135 // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
20136 // pipe reaches through this impl and no other — the paired
20137 // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
20138 // forces every borrowed-input call site through a spurious
20139 // `Copy` deref
20140 // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
20141 // `.copied()` restatement whose type bounds have no compile-time
20142 // link back to the substrate primitive.
20143 //
20144 // Closes the `{Self, &Self}` input-shape corner on the second
20145 // caixa-core-internal closed-set fieldless typed enum peer of
20146 // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
20147 // forward-projection campaign — one commit after the paired
20148 // top-level [`crate::CaixaKind`] pair (c17be64) opened the
20149 // caixa-core-internal tier — matching the
20150 // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
20151 // Box<str>}` 2×4 forward-projection matrix the peer projection
20152 // surfaces already close on this same enum.
20153 //
20154 // Cross-axis partition pin against the paired owned-input
20155 // [`From<DepList> for std::sync::Arc<str>`] and the sibling
20156 // borrowed-input `{&'static str, String, Cow<'static, str>,
20157 // Box<str>}` return-shape axes — locking the five return-shape
20158 // × input-shape paths on the borrowed-input surface together by
20159 // construction so any future detour off the substrate-primitive
20160 // accessor trips at caixa-core test time. Then a
20161 // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
20162 // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
20163 // construction, so the borrowed-input
20164 // [`std::sync::Arc<str>`] axis is what routes the pipe through
20165 // the substrate-primitive [`super::DepList::as_str`] accessor
20166 // without a spurious [`Copy`] deref (which would only be
20167 // reachable through the owned-input
20168 // [`From<DepList> for std::sync::Arc<str>`] axis by first
20169 // calling `.copied()` on the iterator).
20170 for &variant in super::DepList::ALL {
20171 let via_trait: std::sync::Arc<str> =
20172 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20173 let via_method: &'static str = variant.as_str();
20174 assert_eq!(
20175 via_trait.as_ref(),
20176 via_method,
20177 "From<&DepList> for std::sync::Arc<str> impl must round-\
20178 trip &DepList::{variant:?} to the same lifted \
20179 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20180 DepList::as_str returns — divergence signals a silent \
20181 detour off the substrate-primitive accessor"
20182 );
20183 let via_into: std::sync::Arc<str> = (&variant).into();
20184 assert_eq!(
20185 via_into.as_ref(),
20186 via_method,
20187 "Into<std::sync::Arc<str>>::into on &DepList::\
20188 {variant:?} must byte-equal DepList::as_str on the \
20189 same input — the blanket-derived Into shape on the \
20190 borrowed-input surface must resolve to the same as_str \
20191 dispatch as the explicit From impl"
20192 );
20193 let owned_arc: std::sync::Arc<str> =
20194 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20195 assert_eq!(
20196 via_trait, owned_arc,
20197 "From<&DepList> for std::sync::Arc<str> and \
20198 From<DepList> for std::sync::Arc<str> must resolve \
20199 identically on DepList::{variant:?} — divergence \
20200 signals the borrowed-input and owned-input \
20201 std::sync::Arc<str> forward-projection input-shape \
20202 paths have drifted onto different emit-sets"
20203 );
20204 let borrowed_static: &'static str =
20205 <&'static str as From<&super::DepList>>::from(&variant);
20206 assert_eq!(
20207 via_trait.as_ref(),
20208 borrowed_static,
20209 "From<&DepList> for std::sync::Arc<str> and \
20210 From<&DepList> for &'static str must resolve \
20211 identically on DepList::{variant:?} — divergence \
20212 signals the borrowed-input std::sync::Arc<str> and \
20213 &'static str return-shape paths have drifted onto \
20214 different emit-sets"
20215 );
20216 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20217 assert_eq!(
20218 via_trait.as_ref(),
20219 borrowed_string.as_str(),
20220 "From<&DepList> for std::sync::Arc<str> and \
20221 From<&DepList> for String must resolve identically on \
20222 DepList::{variant:?} — divergence signals the \
20223 borrowed-input std::sync::Arc<str> and owned-`String` \
20224 return-shape paths have drifted onto different emit-\
20225 sets"
20226 );
20227 let borrowed_cow: std::borrow::Cow<'static, str> =
20228 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20229 assert_eq!(
20230 via_trait.as_ref(),
20231 borrowed_cow.as_ref(),
20232 "From<&DepList> for std::sync::Arc<str> and \
20233 From<&DepList> for Cow<'static, str> must resolve \
20234 identically on DepList::{variant:?} — divergence \
20235 signals the borrowed-input std::sync::Arc<str> and \
20236 Cow<'static, str> return-shape paths have drifted onto \
20237 different emit-sets"
20238 );
20239 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20240 assert_eq!(
20241 via_trait.as_ref(),
20242 borrowed_box.as_ref(),
20243 "From<&DepList> for std::sync::Arc<str> and \
20244 From<&DepList> for Box<str> must resolve identically \
20245 on DepList::{variant:?} — divergence signals the \
20246 borrowed-input std::sync::Arc<str> and Box<str> \
20247 return-shape paths have drifted onto different emit-sets"
20248 );
20249 }
20250 let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
20251 .iter()
20252 .map(std::sync::Arc::<str>::from)
20253 .collect();
20254 let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
20255 .iter()
20256 .map(|l| std::sync::Arc::<str>::from(l.as_str()))
20257 .collect();
20258 assert_eq!(
20259 via_iter, via_method,
20260 "`.iter().map(std::sync::Arc::<str>::from)` over \
20261 DepList::ALL — a call site whose iteration axis holds \
20262 `&DepList` by construction — must byte-equal \
20263 `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
20264 on every arm — the borrowed-input std::sync::Arc<str> \
20265 `From<&DepList> for std::sync::Arc<str>` axis is what \
20266 makes the `std::sync::Arc::<str>::from` composition route \
20267 through the substrate-primitive `DepList::as_str` \
20268 accessor without a spurious `Copy` deref (which would \
20269 only be reachable through the owned-input \
20270 `From<DepList> for std::sync::Arc<str>` axis by first \
20271 calling `.copied()` on the iterator)"
20272 );
20273 }
20274
20275 #[test]
20276 fn dep_list_from_into_rc_str_routes_through_as_str_accessor() {
20277 // Fail-before-pass-after byte-parity pin on the newly lifted
20278 // `impl From<DepList> for std::rc::Rc<str>` — asserts the
20279 // owned-input standard-library trait impl and the substrate-
20280 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20281 // resolve to the same two-arm emit-set (the paired
20282 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20283 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20284 // byte-strings) across every arm the exhaustive
20285 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20286 // core-internal tier of the substrate-wide
20287 // [`std::rc::Rc<str>`] forward-projection campaign onto the
20288 // third caixa-core-internal peer, after the top-level
20289 // [`crate::CaixaKind`] (e04aff0), the second-peer
20290 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and the render-
20291 // side [`crate::render::PathShapeViolation`] (31fc43e) pairs
20292 // opened the tier. Rust's standard library carries
20293 // `impl From<&str> for std::rc::Rc<str>` and
20294 // `impl From<String> for std::rc::Rc<str>` but no blanket
20295 // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and the
20296 // [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait
20297 // tables are disjoint, so this axis is a distinct trait-
20298 // idiomatic surface that a
20299 // `let key: std::rc::Rc<str> = list.into();`-shaped call site
20300 // reaches through this impl and no other — a paired
20301 // `std::rc::Rc::<str>::from(list.as_str())` open-code has no
20302 // compile-time link back to the substrate primitive, and a
20303 // two-step `std::rc::Rc::<str>::from(String::from(list))`
20304 // composition through the owned-`String` axis allocates twice
20305 // (once into the intermediate `String`, once into the
20306 // [`std::rc::Rc<str>`] on the `From<String>` conversion) where
20307 // the single-step trait impl allocates once.
20308 //
20309 // Cross-axis byte-parity witness against the sibling owned-
20310 // input `{&'static str, String, Cow<'static, str>, Box<str>,
20311 // std::sync::Arc<str>}` return-shape axes — locking the six
20312 // return-shape paths on the owned-input surface together by
20313 // construction so any future detour off the substrate-
20314 // primitive [`super::DepList::as_str`] accessor trips at
20315 // caixa-core test time.
20316 for &variant in super::DepList::ALL {
20317 let via_trait: std::rc::Rc<str> =
20318 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20319 let via_method: &'static str = variant.as_str();
20320 assert_eq!(
20321 via_trait.as_ref(),
20322 via_method,
20323 "From<DepList> for std::rc::Rc<str> impl must round-\
20324 trip DepList::{variant:?} to the same lifted \
20325 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20326 DepList::as_str returns — divergence signals a silent \
20327 detour off the substrate-primitive accessor"
20328 );
20329 let via_into: std::rc::Rc<str> = variant.into();
20330 assert_eq!(
20331 via_into.as_ref(),
20332 via_method,
20333 "Into<std::rc::Rc<str>>::into on DepList::{variant:?} \
20334 must byte-equal DepList::as_str on the same input — \
20335 the blanket-derived Into shape must resolve to the \
20336 same as_str dispatch as the explicit From impl"
20337 );
20338 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20339 assert_eq!(
20340 via_trait.as_ref(),
20341 owned_static,
20342 "From<DepList> for std::rc::Rc<str> and \
20343 From<DepList> for &'static str must resolve identically \
20344 on DepList::{variant:?} — divergence signals the owned-\
20345 input std::rc::Rc<str> and &'static str return-shape \
20346 paths have drifted onto different emit-sets"
20347 );
20348 let owned_string: String = <String as From<super::DepList>>::from(variant);
20349 assert_eq!(
20350 via_trait.as_ref(),
20351 owned_string.as_str(),
20352 "From<DepList> for std::rc::Rc<str> and \
20353 From<DepList> for String must resolve identically on \
20354 DepList::{variant:?} — divergence signals the owned-\
20355 input std::rc::Rc<str> and owned-`String` return-shape \
20356 paths have drifted onto different emit-sets"
20357 );
20358 let owned_cow: std::borrow::Cow<'static, str> =
20359 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20360 assert_eq!(
20361 via_trait.as_ref(),
20362 owned_cow.as_ref(),
20363 "From<DepList> for std::rc::Rc<str> and \
20364 From<DepList> for Cow<'static, str> must resolve \
20365 identically on DepList::{variant:?} — divergence signals \
20366 the owned-input std::rc::Rc<str> and Cow<'static, str> \
20367 return-shape paths have drifted onto different emit-sets"
20368 );
20369 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20370 assert_eq!(
20371 via_trait.as_ref(),
20372 owned_box.as_ref(),
20373 "From<DepList> for std::rc::Rc<str> and \
20374 From<DepList> for Box<str> must resolve identically on \
20375 DepList::{variant:?} — divergence signals the owned-\
20376 input std::rc::Rc<str> and Box<str> return-shape paths \
20377 have drifted onto different emit-sets"
20378 );
20379 let owned_arc: std::sync::Arc<str> =
20380 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20381 assert_eq!(
20382 via_trait.as_ref(),
20383 owned_arc.as_ref(),
20384 "From<DepList> for std::rc::Rc<str> and \
20385 From<DepList> for std::sync::Arc<str> must resolve \
20386 identically on DepList::{variant:?} — divergence signals \
20387 the owned-input std::rc::Rc<str> and std::sync::Arc<str> \
20388 return-shape paths have drifted onto different emit-sets \
20389 (the two disjoint reference-counted trait tables have \
20390 desynchronized on the caixa-core two-list dep-graph axis)"
20391 );
20392 }
20393 }
20394
20395 #[test]
20396 #[allow(
20397 clippy::too_many_lines,
20398 reason = "cross-axis partition pin folds five borrowed-input \
20399 return-shape paths (&'static str, String, Cow<'static, \
20400 str>, Box<str>, std::sync::Arc<str>) plus the paired \
20401 owned-input Rc<str> witness and the \
20402 .iter().map(std::rc::Rc::<str>::from) pipe witness into \
20403 one exhaustive round-trip over DepList::ALL — the \
20404 accepted line-count cost of keying the whole borrowed-\
20405 input Rc<str> corner to the substrate-primitive as_str \
20406 accessor at the same test-site"
20407 )]
20408 fn dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
20409 // Fail-before-pass-after byte-parity pin on the newly lifted
20410 // `impl From<&DepList> for std::rc::Rc<str>` — asserts the
20411 // borrowed-input standard-library trait impl and the substrate-
20412 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20413 // resolve to the same two-arm emit-set across every arm the
20414 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20415 // standard library does not carry a blanket
20416 // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
20417 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20418 // the borrowed-input `std::rc::Rc<str>` forward-projection axis
20419 // is a distinct trait-idiomatic surface that a
20420 // `let key: std::rc::Rc<str> = (&list).into();`-shaped call
20421 // site or a
20422 // `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
20423 // pipe reaches through this impl and no other — the paired
20424 // owned-input `From<DepList> for std::rc::Rc<str>` impl alone
20425 // would force every borrowed-input call site through a spurious
20426 // `Copy` deref
20427 // (`std::rc::Rc::<str>::from((*list).as_str())`) or a
20428 // `.copied()` restatement whose type bounds have no compile-
20429 // time link back to the substrate primitive.
20430 //
20431 // Closes the `{Self, &Self}` input-shape corner on the third
20432 // caixa-core-internal closed-set fieldless typed enum peer of
20433 // the substrate-wide trait-idiomatic [`std::rc::Rc<str>`]
20434 // forward-projection campaign, matching the trajectory the
20435 // paired [`crate::CaixaKind`] (e04aff0),
20436 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and
20437 // [`crate::render::PathShapeViolation`] (31fc43e) pairs walked
20438 // before it on the same tier of the same axis.
20439 //
20440 // Cross-axis partition pin against the paired owned-input
20441 // [`From<DepList> for std::rc::Rc<str>`] and the sibling
20442 // borrowed-input `{&'static str, String, Cow<'static, str>,
20443 // Box<str>, std::sync::Arc<str>}` return-shape axes — locking
20444 // the six return-shape × input-shape paths on the borrowed-
20445 // input surface together by construction so any future detour
20446 // off the substrate-primitive accessor trips at caixa-core
20447 // test time. Then a `.iter().map(std::rc::Rc::<str>::from)`
20448 // pipe witness over [`super::DepList::ALL`] — whose iterator
20449 // yields `&DepList` by construction, so the borrowed-input
20450 // [`std::rc::Rc<str>`] axis is what routes the pipe through
20451 // the substrate-primitive [`super::DepList::as_str`] accessor
20452 // without a spurious [`Copy`] deref (which would only be
20453 // reachable through the owned-input
20454 // [`From<DepList> for std::rc::Rc<str>`] axis by first calling
20455 // `.copied()` on the iterator).
20456 for &variant in super::DepList::ALL {
20457 let via_trait: std::rc::Rc<str> =
20458 <std::rc::Rc<str> as From<&super::DepList>>::from(&variant);
20459 let via_method: &'static str = variant.as_str();
20460 assert_eq!(
20461 via_trait.as_ref(),
20462 via_method,
20463 "From<&DepList> for std::rc::Rc<str> impl must round-\
20464 trip &DepList::{variant:?} to the same lifted \
20465 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20466 DepList::as_str returns — divergence signals a silent \
20467 detour off the substrate-primitive accessor"
20468 );
20469 let via_into: std::rc::Rc<str> = (&variant).into();
20470 assert_eq!(
20471 via_into.as_ref(),
20472 via_method,
20473 "Into<std::rc::Rc<str>>::into on &DepList::\
20474 {variant:?} must byte-equal DepList::as_str on the \
20475 same input — the blanket-derived Into shape on the \
20476 borrowed-input surface must resolve to the same \
20477 as_str dispatch as the explicit From impl"
20478 );
20479 let owned_rc: std::rc::Rc<str> =
20480 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20481 assert_eq!(
20482 via_trait, owned_rc,
20483 "From<&DepList> for std::rc::Rc<str> and \
20484 From<DepList> for std::rc::Rc<str> must resolve \
20485 identically on DepList::{variant:?} — divergence \
20486 signals the borrowed-input and owned-input \
20487 std::rc::Rc<str> forward-projection input-shape \
20488 paths have drifted onto different emit-sets"
20489 );
20490 let borrowed_static: &'static str =
20491 <&'static str as From<&super::DepList>>::from(&variant);
20492 assert_eq!(
20493 via_trait.as_ref(),
20494 borrowed_static,
20495 "From<&DepList> for std::rc::Rc<str> and \
20496 From<&DepList> for &'static str must resolve \
20497 identically on DepList::{variant:?} — divergence \
20498 signals the borrowed-input std::rc::Rc<str> and \
20499 &'static str return-shape paths have drifted onto \
20500 different emit-sets"
20501 );
20502 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20503 assert_eq!(
20504 via_trait.as_ref(),
20505 borrowed_string.as_str(),
20506 "From<&DepList> for std::rc::Rc<str> and \
20507 From<&DepList> for String must resolve identically on \
20508 DepList::{variant:?} — divergence signals the \
20509 borrowed-input std::rc::Rc<str> and owned-`String` \
20510 return-shape paths have drifted onto different emit-\
20511 sets"
20512 );
20513 let borrowed_cow: std::borrow::Cow<'static, str> =
20514 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20515 assert_eq!(
20516 via_trait.as_ref(),
20517 borrowed_cow.as_ref(),
20518 "From<&DepList> for std::rc::Rc<str> and \
20519 From<&DepList> for Cow<'static, str> must resolve \
20520 identically on DepList::{variant:?} — divergence \
20521 signals the borrowed-input std::rc::Rc<str> and \
20522 Cow<'static, str> return-shape paths have drifted onto \
20523 different emit-sets"
20524 );
20525 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20526 assert_eq!(
20527 via_trait.as_ref(),
20528 borrowed_box.as_ref(),
20529 "From<&DepList> for std::rc::Rc<str> and \
20530 From<&DepList> for Box<str> must resolve identically \
20531 on DepList::{variant:?} — divergence signals the \
20532 borrowed-input std::rc::Rc<str> and Box<str> \
20533 return-shape paths have drifted onto different emit-sets"
20534 );
20535 let borrowed_arc: std::sync::Arc<str> =
20536 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20537 assert_eq!(
20538 via_trait.as_ref(),
20539 borrowed_arc.as_ref(),
20540 "From<&DepList> for std::rc::Rc<str> and \
20541 From<&DepList> for std::sync::Arc<str> must resolve \
20542 identically on DepList::{variant:?} — divergence \
20543 signals the borrowed-input std::rc::Rc<str> and \
20544 std::sync::Arc<str> return-shape paths have drifted \
20545 onto different emit-sets (the two disjoint reference-\
20546 counted trait tables have desynchronized on the \
20547 caixa-core two-list dep-graph axis)"
20548 );
20549 }
20550 let via_iter: Vec<std::rc::Rc<str>> = super::DepList::ALL
20551 .iter()
20552 .map(std::rc::Rc::<str>::from)
20553 .collect();
20554 let via_method: Vec<std::rc::Rc<str>> = super::DepList::ALL
20555 .iter()
20556 .map(|l| std::rc::Rc::<str>::from(l.as_str()))
20557 .collect();
20558 assert_eq!(
20559 via_iter, via_method,
20560 "`.iter().map(std::rc::Rc::<str>::from)` over \
20561 DepList::ALL — a call site whose iteration axis holds \
20562 `&DepList` by construction — must byte-equal \
20563 `.iter().map(|l| std::rc::Rc::<str>::from(l.as_str()))` \
20564 on every arm — the borrowed-input std::rc::Rc<str> \
20565 `From<&DepList> for std::rc::Rc<str>` axis is what makes \
20566 the `std::rc::Rc::<str>::from` composition route through \
20567 the substrate-primitive `DepList::as_str` accessor \
20568 without a spurious `Copy` deref (which would only be \
20569 reachable through the owned-input \
20570 `From<DepList> for std::rc::Rc<str>` axis by first \
20571 calling `.copied()` on the iterator)"
20572 );
20573 }
20574
20575 #[test]
20576 fn dep_list_author_keys_covers_every_arm() {
20577 // Load-bearing pin on the substrate-canonical
20578 // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
20579 // on the `:`-prefixed kebab-case tatara-lisp author-surface
20580 // key axis: every variant of the sibling
20581 // [`super::DepList::ALL`] exhaustive-iteration surface must
20582 // project through [`super::DepList::as_str`] onto an entry the
20583 // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
20584 // roster's length must byte-equal `super::DepList::ALL.len()`
20585 // so a silent skew between the [`super::DepList::as_str`]
20586 // match's arm-set and the roster's arm-set trips here at
20587 // caixa-core test time rather than at a downstream M4
20588 // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
20589 // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
20590 // a `feira dep --list …` "did you mean" hint drift / a
20591 // downstream [`super::DepError`] widening's typed `list:
20592 // DepList` carry that fans on the enum through a stale
20593 // accepted-set. A future arm addition (a `:build-dep` or
20594 // `:tool-dep` third list once the substrate grows Cargo-style
20595 // split-graphs — both trajectory items the sibling
20596 // [`super::DepList::from_wire`] doc block already names)
20597 // extends [`super::DepList::ALL`] as a single edit and this
20598 // pin sweeps the new arm by iteration; the paired
20599 // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
20600 // or this assertion trips. Every entry is further pinned to
20601 // open with the ASCII `:` byte (the tatara-lisp author-surface
20602 // keyword marker) so a silent collapse of the author-key axis
20603 // with any hypothetical peer un-prefixed wire-form axis (an
20604 // entry byte-identical to a sibling `deps` / `deps-dev`
20605 // bare-kebab byte-string that would let an author-key-axis
20606 // consumer accept the un-prefixed vocabulary) trips here
20607 // rather than at a downstream consumer's
20608 // vocabulary-collision miss.
20609 //
20610 // Peer of the sibling
20611 // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
20612 // (bd708bd) /
20613 // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
20614 // (427fe75) /
20615 // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
20616 // (3033f45) /
20617 // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
20618 // (ce9412b) /
20619 // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
20620 // (3e5b194) /
20621 // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
20622 // (9d9f585) /
20623 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20624 // (b553ec9) /
20625 // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
20626 // (1898d77) /
20627 // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
20628 // (cc42c0e) pins — the same closed-set exhaustive-roster
20629 // coverage discipline extended here onto the two-list dep-graph
20630 // closed-set typed enum, the ninth substrate-side closed-set
20631 // typed enum on the roster axis and the last unlifted
20632 // `&'static str`-carrying closed-set typed enum on the top-
20633 // level manifest surface to converge onto the discipline.
20634 //
20635 // Fail-before-pass-after locally verified by mutating one arm
20636 // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
20637 // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
20638 // `":deps-dev"` to `":deps_dev"`) — the length pin still
20639 // passes but the `contains` check fires on the mutated arm;
20640 // and by shortening the roster to one entry — the length pin
20641 // fires first.
20642 assert_eq!(
20643 super::DepList::AUTHOR_KEYS.len(),
20644 super::DepList::ALL.len(),
20645 "DepList::AUTHOR_KEYS.len() must byte-equal \
20646 DepList::ALL.len() — a mismatch means the roster and \
20647 the enum's arm-set have drifted; downstream consumers \
20648 that fan through both will silently disagree on the \
20649 accepted arm-set"
20650 );
20651 for &variant in super::DepList::ALL {
20652 let key = variant.as_str();
20653 assert!(
20654 super::DepList::AUTHOR_KEYS.contains(&key),
20655 "DepList::{variant:?}.as_str() = {key:?} must be a \
20656 member of DepList::AUTHOR_KEYS — the emitter and the \
20657 roster have drifted out of lockstep"
20658 );
20659 }
20660 for tag in super::DepList::AUTHOR_KEYS {
20661 let first = tag.chars().next().unwrap_or_else(|| {
20662 panic!(
20663 "DepList::AUTHOR_KEYS entry {tag:?} must be a \
20664 non-empty `:`-prefixed kebab-case tatara-lisp \
20665 author-surface key byte-string"
20666 )
20667 });
20668 assert_eq!(
20669 first, ':',
20670 "DepList::AUTHOR_KEYS entry {tag:?} must open with \
20671 the ASCII `:` byte (tatara-lisp author-surface \
20672 keyword marker) — an un-prefixed entry would \
20673 collide the roster with any hypothetical peer bare-\
20674 kebab wire-form axis a downstream consumer might \
20675 disambiguate against"
20676 );
20677 }
20678 // Pin the exact two-arm roster in declaration order so a
20679 // future arm-swap on either the roster or the paired
20680 // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
20681 // arm-key mapping that leaves both the length pin and the
20682 // membership pin passing on their own) trips at caixa-core
20683 // test time under `assert_eq!`. Order matches variant
20684 // declaration order verbatim (`Prod` → `Dev`) so the roster
20685 // is the canonical ordering every listing / rendering
20686 // consumer defers to. Same declaration-order pin the sibling
20687 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20688 // (b553ec9) closes on the M3 `:politicas :rate-limit`
20689 // canonical-suffix axis.
20690 assert_eq!(
20691 super::DepList::AUTHOR_KEYS,
20692 &[
20693 crate::render::DEP_AUTHOR_KEY_DEPS,
20694 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
20695 ],
20696 "DepList::AUTHOR_KEYS must enumerate every arm's \
20697 author-surface key exactly once, in variant declaration \
20698 order (Prod → Dev)"
20699 );
20700 }
20701
20702 #[test]
20703 fn dep_list_from_str_routes_through_try_from_str_impl() {
20704 // Fail-before-pass-after byte-parity pin on the newly lifted
20705 // `impl std::str::FromStr for DepList` — asserts the standard-
20706 // library `.parse()` parse-axis entry point and the paired
20707 // [`super::DepList::try_from`] `TryFrom<&str>` impl (which in
20708 // turn routes through the substrate-primitive
20709 // [`super::DepList::from_wire`] `Option<Self>` accessor)
20710 // resolve to the same two-arm accept-set across every arm the
20711 // exhaustive [`super::DepList::ALL`] slice enumerates. First-
20712 // mover on the substrate-wide `FromStr` parse-axis campaign —
20713 // the peer method-named `from_wire` accessor and the paired
20714 // `TryFrom<&str>` trait impl fix the two-arm accept set; this
20715 // pin locks the `FromStr::from_str` trait entry point onto the
20716 // same set so any future divergence (a stray per-arm `match s`
20717 // re-inlining that opens a compile-time link to an un-lifted
20718 // arm-literal, a swap onto a hand-rolled parser that widens
20719 // the accept-set past the two wire-format consts) trips at
20720 // caixa-core test time.
20721 use std::str::FromStr;
20722 for &list in super::DepList::ALL {
20723 let wire = list.as_str();
20724 assert_eq!(
20725 <super::DepList as FromStr>::from_str(wire),
20726 Ok(list),
20727 "FromStr impl on DepList must round-trip \
20728 DepList::{list:?}.as_str() = {wire:?} back to \
20729 Ok(DepList::{list:?}) — divergence from \
20730 DepList::try_from signals a silent detour off the \
20731 paired reverse-projection trait impl"
20732 );
20733 assert_eq!(
20734 <super::DepList as FromStr>::from_str(wire).ok(),
20735 super::DepList::from_wire(wire),
20736 "FromStr ok()-projection on {wire:?} must byte-equal \
20737 DepList::from_wire on the same input — divergence \
20738 signals the two reverse-projection trait paths have \
20739 drifted off the substrate-primitive accessor"
20740 );
20741 // `.parse::<DepList>()` short-form witness — the stdlib
20742 // consumer surface that reaches the enum through the
20743 // `T: FromStr` bound, not through `TryFrom<&str>`.
20744 let via_parse: Result<super::DepList, ()> = wire.parse();
20745 assert_eq!(
20746 via_parse,
20747 Ok(list),
20748 "`{wire:?}`.parse::<DepList>() must resolve to \
20749 Ok(DepList::{list:?}) — divergence signals the \
20750 stdlib `.parse()` short-form has drifted from the \
20751 lifted `FromStr::from_str` impl"
20752 );
20753 }
20754 }
20755
20756 #[test]
20757 fn dep_list_from_str_rejects_unknown_byte_strings() {
20758 // Rejection witness on the `impl FromStr for DepList` —
20759 // sweeps candidate byte-strings outside the two-arm accept-set
20760 // the sibling [`super::DepList::as_str`] emits (`:deps` /
20761 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
20762 // future accidental widening of the trait impl's accept-set (a
20763 // stray case-fold path, a silent inclusion of a rebrand alias
20764 // like `":packages"`, an English rebrand `":dev-deps"` in
20765 // reverse arm-order that would silently swap the two arms) trips
20766 // at caixa-core test time. Peer of the sibling
20767 // `dep_list_try_from_str_rejects_unknown_byte_strings` rejection
20768 // witness — the two pins together bracket both reverse-projection
20769 // trait impls against the same rejected set.
20770 use std::str::FromStr;
20771 let rejected: &[&str] = &[
20772 "",
20773 " ",
20774 "\t",
20775 "\n",
20776 ":deps ",
20777 " :deps",
20778 ":DEPS",
20779 ":Deps",
20780 ":Deps-Dev",
20781 ":deps_dev",
20782 ":deps-development",
20783 ":dev-deps",
20784 ":packages",
20785 ":packages-dev",
20786 "deps",
20787 "deps-dev",
20788 "Prod",
20789 "Dev",
20790 "prod",
20791 "dev",
20792 "\":deps\"",
20793 "\":deps-dev\"",
20794 ":deps\n",
20795 ":deps-dev\n",
20796 ];
20797 for &input in rejected {
20798 assert_eq!(
20799 <super::DepList as FromStr>::from_str(input),
20800 Err(()),
20801 "FromStr impl on DepList must reject unknown \
20802 byte-string {input:?} — divergence from \
20803 DepList::from_wire on the same input signals a silent \
20804 accept-set widening past the two lifted \
20805 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
20806 );
20807 assert_eq!(
20808 <super::DepList as FromStr>::from_str(input).ok(),
20809 super::DepList::from_wire(input),
20810 "FromStr ok()-projection on {input:?} must byte-equal \
20811 DepList::from_wire on the same input — divergence \
20812 signals the FromStr trait path has drifted off the \
20813 substrate-primitive accessor"
20814 );
20815 let via_parse: Result<super::DepList, ()> = input.parse();
20816 assert_eq!(
20817 via_parse,
20818 Err(()),
20819 "`{input:?}`.parse::<DepList>() must reject the \
20820 unknown byte-string — divergence signals the stdlib \
20821 `.parse()` short-form has drifted from the lifted \
20822 `FromStr::from_str` impl"
20823 );
20824 }
20825 }
20826
20827 #[test]
20828 #[allow(
20829 clippy::too_many_lines,
20830 reason = "cross-axis partition pin folds the substrate-primitive \
20831 as_str accessor's `.as_bytes()` byte-tail plus the \
20832 paired str-view (AsRef<str>, Display, as_str) and \
20833 reverse-projection ({&'static str, String, \
20834 Cow<'static, str>, Box<str>, std::sync::Arc<str>, \
20835 std::rc::Rc<str>}) return-shape axes' `.as_bytes()` \
20836 byte-tails plus a <T: AsRef<[u8]>>-bound-consumer \
20837 witness plus a blake3::Hasher::update-shape byte-\
20838 input surface witness into one exhaustive round-trip \
20839 over DepList::ALL — the accepted line-count cost of \
20840 opening the byte-view axis keyed to the substrate-\
20841 primitive as_str accessor at the same test-site"
20842 )]
20843 #[allow(
20844 clippy::needless_borrows_for_generic_args,
20845 reason = "the borrowed-input surface (&variant) is exercised \
20846 deliberately: the `<T: AsRef<[u8]>>`-bound consumer \
20847 and the `blake3::Hasher::update`-shape byte-input \
20848 surface both accept either owned or borrowed input \
20849 through the standard-library blanket \
20850 `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`, \
20851 and this pin round-trips both input shapes to lock \
20852 the borrowed-input path load-bearing against a \
20853 future silent regression"
20854 )]
20855 fn dep_list_as_ref_bytes_routes_through_as_str_accessor() {
20856 // `<T: AsRef<[u8]>>`-bound-consumer witness helper: a generic
20857 // byte-input function accepts a [`super::DepList`] directly
20858 // through the trait bound, without the caller open-coding the
20859 // two-hop `list.as_str().as_bytes()` composition. Lifted to
20860 // the top of the function per `clippy::items_after_statements`.
20861 fn generic_bytes_sink<T: AsRef<[u8]>>(t: T) -> Vec<u8> {
20862 t.as_ref().to_vec()
20863 }
20864 // `blake3::Hasher::update`-shape byte-input surface mock:
20865 // mirrors `blake3::Hasher::update` / `ring::digest::Context::
20866 // update` / `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound
20867 // `update` signature so a per-caixa BLAKE3 content-address
20868 // closure that composes `hasher.update(list)` on the
20869 // [`crate::Lacre`] closure builder reaches the substrate-
20870 // primitive `as_str` accessor through the [`super::DepList`]
20871 // `AsRef<[u8]>` axis and no other. Lifted to the top of the
20872 // function per `clippy::items_after_statements`.
20873 struct MockHasher(Vec<u8>);
20874 impl MockHasher {
20875 fn new() -> Self {
20876 Self(Vec::new())
20877 }
20878 fn update(&mut self, bytes: impl AsRef<[u8]>) -> &mut Self {
20879 self.0.extend_from_slice(bytes.as_ref());
20880 self
20881 }
20882 fn finalize(self) -> Vec<u8> {
20883 self.0
20884 }
20885 }
20886
20887 // Fail-before-pass-after byte-parity pin on the newly lifted
20888 // `impl AsRef<[u8]> for DepList` — asserts the trait-idiomatic
20889 // byte-view standard-library impl and the substrate-primitive
20890 // [`super::DepList::as_str`] `pub const fn` accessor's
20891 // `.as_bytes()` byte-tail resolve to the same two-arm
20892 // `:`-prefixed kebab-case byte-string emit-set across every
20893 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
20894 // Extends the substrate-wide trait-idiomatic byte-view axis
20895 // onto the third closed-set fieldless typed enum on the
20896 // caixa-core-internal tier — matching the trajectory the
20897 // sibling [`super::CaixaKind`] first-mover [`AsRef<[u8]>`]
20898 // impl (69d8d86) and [`super::CaixaDialeto`] second-mover
20899 // impl (8151347) walked before it.
20900 for &variant in super::DepList::ALL {
20901 let via_trait: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
20902 let via_method_bytes: &[u8] = variant.as_str().as_bytes();
20903 assert_eq!(
20904 via_trait, via_method_bytes,
20905 "AsRef<[u8]> for DepList impl must byte-equal \
20906 DepList::as_str().as_bytes() on DepList::\
20907 {variant:?} — divergence signals a silent detour off \
20908 the substrate-primitive accessor"
20909 );
20910 // Cross-axis witness against the paired str-view axes'
20911 // `.as_bytes()` byte-tails: [`AsRef<str>`] /
20912 // [`std::fmt::Display`] / [`super::DepList::as_str`] all
20913 // resolve to the same lifted `render::DEP_AUTHOR_KEY_*`
20914 // const roster, and the byte-view axis must byte-equal
20915 // each of their `.as_bytes()` byte-tails by construction
20916 // — locking the str-view and byte-view axes together at
20917 // the substrate-primitive accessor.
20918 let str_view_ref: &str = <super::DepList as AsRef<str>>::as_ref(&variant);
20919 assert_eq!(
20920 via_trait,
20921 str_view_ref.as_bytes(),
20922 "AsRef<[u8]> for DepList and AsRef<str> for DepList \
20923 must resolve to byte-equal byte-tails on DepList::\
20924 {variant:?} — divergence signals the byte-view and \
20925 str-view axes have drifted off the same substrate-\
20926 primitive as_str accessor"
20927 );
20928 let display_bytes = variant.to_string();
20929 assert_eq!(
20930 via_trait,
20931 display_bytes.as_bytes(),
20932 "AsRef<[u8]> for DepList and \
20933 <DepList as std::fmt::Display>::to_string must \
20934 resolve to byte-equal byte-tails on DepList::\
20935 {variant:?} — divergence signals the byte-view axis \
20936 and the Display formatter axis have drifted off the \
20937 same substrate-primitive as_str accessor"
20938 );
20939 // Cross-axis witness against the paired reverse-
20940 // projection axes' `.as_bytes()` byte-tails: every one of
20941 // `{&'static str, String, Cow<'static, str>, Box<str>,
20942 // std::sync::Arc<str>, std::rc::Rc<str>}` allocates (or
20943 // borrows) the same `:`-prefixed kebab byte-string the
20944 // substrate-primitive accessor emits, so the byte-view
20945 // axis must byte-equal each of their `.as_bytes()` byte-
20946 // tails by construction.
20947 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20948 assert_eq!(
20949 via_trait,
20950 owned_static.as_bytes(),
20951 "AsRef<[u8]> for DepList and From<DepList> for \
20952 &'static str must resolve to byte-equal byte-tails on \
20953 DepList::{variant:?}"
20954 );
20955 let owned_string: String = <String as From<super::DepList>>::from(variant);
20956 assert_eq!(
20957 via_trait,
20958 owned_string.as_bytes(),
20959 "AsRef<[u8]> for DepList and From<DepList> for \
20960 String must resolve to byte-equal byte-tails on \
20961 DepList::{variant:?}"
20962 );
20963 let owned_cow: std::borrow::Cow<'static, str> =
20964 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20965 assert_eq!(
20966 via_trait,
20967 owned_cow.as_bytes(),
20968 "AsRef<[u8]> for DepList and From<DepList> for \
20969 Cow<'static, str> must resolve to byte-equal byte-\
20970 tails on DepList::{variant:?}"
20971 );
20972 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20973 assert_eq!(
20974 via_trait,
20975 owned_box.as_bytes(),
20976 "AsRef<[u8]> for DepList and From<DepList> for \
20977 Box<str> must resolve to byte-equal byte-tails on \
20978 DepList::{variant:?}"
20979 );
20980 let owned_arc: std::sync::Arc<str> =
20981 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20982 assert_eq!(
20983 via_trait,
20984 owned_arc.as_bytes(),
20985 "AsRef<[u8]> for DepList and From<DepList> for \
20986 std::sync::Arc<str> must resolve to byte-equal byte-\
20987 tails on DepList::{variant:?}"
20988 );
20989 let owned_rc_str: std::rc::Rc<str> =
20990 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20991 assert_eq!(
20992 via_trait,
20993 owned_rc_str.as_bytes(),
20994 "AsRef<[u8]> for DepList and From<DepList> for \
20995 std::rc::Rc<str> must resolve to byte-equal byte-\
20996 tails on DepList::{variant:?}"
20997 );
20998 }
20999 // `<T: AsRef<[u8]>>`-bound-consumer witness: the generic byte-
21000 // input function `generic_bytes_sink` (lifted above per
21001 // `clippy::items_after_statements`) accepts a [`super::DepList`]
21002 // directly through the trait bound, without the caller open-
21003 // coding the two-hop `list.as_str().as_bytes()` composition.
21004 // This is the shape that reaches the caixa-lacre BLAKE3
21005 // content-address closure's
21006 // `blake3::Hasher::update(impl AsRef<[u8]>)` byte-input surface
21007 // through this impl and no other. Exercised on both owned and
21008 // borrowed input surfaces via the standard-library blanket
21009 // `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`.
21010 for &variant in super::DepList::ALL {
21011 let via_generic = generic_bytes_sink(variant);
21012 let via_borrowed_generic = generic_bytes_sink(&variant);
21013 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21014 assert_eq!(
21015 via_generic, via_method_bytes,
21016 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21017 DepList::{variant:?} must yield the same byte-tail \
21018 DepList::as_str().as_bytes() returns — divergence \
21019 signals the byte-view axis fails to bridge a generic \
21020 byte-input trait bound to the substrate-primitive \
21021 accessor"
21022 );
21023 assert_eq!(
21024 via_borrowed_generic, via_method_bytes,
21025 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21026 &DepList::{variant:?} must yield the same byte-tail \
21027 DepList::as_str().as_bytes() returns — the borrowed-\
21028 input surface must resolve to the same as_str dispatch"
21029 );
21030 }
21031 // `blake3::Hasher::update`-shape byte-input surface witness
21032 // on the caixa-lacre compounding target: the `MockHasher`
21033 // (lifted above per `clippy::items_after_statements`) mirrors
21034 // `blake3::Hasher::update` / `ring::digest::Context::update` /
21035 // `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound update
21036 // signature and accepts a [`super::DepList`] directly, routing
21037 // its byte-tail through the substrate-primitive `as_str`
21038 // accessor — the shape a future per-caixa BLAKE3 content-
21039 // address closure composes to fold a dep-list discriminator
21040 // byte-tag into the [`crate::Lacre`] closure body so a
21041 // downstream `Lacre` consumer can partition the runtime-
21042 // closure `:deps` from the dev-only-closure `:deps-dev` at
21043 // content-address time.
21044 for &variant in super::DepList::ALL {
21045 let mut owned_hasher = MockHasher::new();
21046 owned_hasher.update(variant);
21047 let owned_folded = owned_hasher.finalize();
21048 assert_eq!(
21049 owned_folded,
21050 variant.as_str().as_bytes(),
21051 "`hasher.update(list)`-shape composition on DepList::\
21052 {variant:?} must fold the same byte-tail DepList::\
21053 as_str().as_bytes() returns — the shape a future \
21054 per-caixa BLAKE3 content-address closure composes to \
21055 fold a dep-list discriminator byte-tag into the Lacre \
21056 closure body"
21057 );
21058 let mut borrowed_hasher = MockHasher::new();
21059 borrowed_hasher.update(&variant);
21060 let borrowed_folded = borrowed_hasher.finalize();
21061 assert_eq!(
21062 borrowed_folded,
21063 variant.as_str().as_bytes(),
21064 "`hasher.update(&list)`-shape composition on \
21065 &DepList::{variant:?} must fold the same byte-tail \
21066 DepList::as_str().as_bytes() returns — the borrowed-\
21067 input surface must resolve to the same as_str dispatch"
21068 );
21069 }
21070 }
21071
21072 #[test]
21073 #[expect(
21074 clippy::too_many_lines,
21075 reason = "the byte-owned reverse-projection axis is extended \
21076 onto DepList here as the third peer on the substrate-\
21077 wide byte-owned Vec<u8>-output projection family \
21078 (after the sibling first-mover CaixaKind, b245fd6, \
21079 and second-mover CaixaDialeto, 4cceaf5), so the pin \
21080 binds the new impl against every paired byte-view \
21081 and str-view axis on the same enum plus a generic \
21082 <T: Into<Vec<u8>>>-bound consumer witness and a \
21083 std::io::Write::write_all-shape owned-byte-sink \
21084 surface witness on both owned and borrowed input \
21085 shapes to lock the whole family against a future \
21086 silent regression"
21087 )]
21088 fn dep_list_from_into_owned_vec_bytes_routes_through_as_str_accessor() {
21089 // `<T: Into<Vec<u8>>>`-bound-consumer witness helper: a generic
21090 // owned-byte-input function accepts a [`super::DepList`]
21091 // directly through the trait bound, without the caller open-
21092 // coding the three-hop `list.as_str().as_bytes().to_vec()`
21093 // composition. Lifted to the top of the function per
21094 // `clippy::items_after_statements`.
21095 fn generic_owned_bytes_sink<T: Into<Vec<u8>>>(t: T) -> Vec<u8> {
21096 t.into()
21097 }
21098 // `std::io::Write::write_all`-shape owned-byte-sink surface
21099 // mock: mirrors `std::io::Write::write_all` /
21100 // `bytes::BytesMut::extend_from_slice` / any per-arm audit-log
21101 // byte-sink that consumes a `Vec<u8>` payload via
21102 // `Into<Vec<u8>>`, so a future per-caixa per-`:deps`/`:deps-dev`
21103 // audit-log emit reaches the substrate-primitive `as_str`
21104 // accessor through the byte-owned reverse-projection axis and
21105 // no other. Lifted to the top of the function per
21106 // `clippy::items_after_statements`.
21107 struct MockOwnedByteSink(Vec<u8>);
21108 impl MockOwnedByteSink {
21109 fn new() -> Self {
21110 Self(Vec::new())
21111 }
21112 fn write_all(&mut self, bytes: impl Into<Vec<u8>>) -> &mut Self {
21113 self.0.extend_from_slice(&bytes.into());
21114 self
21115 }
21116 fn finalize(self) -> Vec<u8> {
21117 self.0
21118 }
21119 }
21120
21121 // Fail-before-pass-after byte-parity pin on the newly lifted
21122 // `impl From<DepList> for Vec<u8>` and
21123 // `impl From<&DepList> for Vec<u8>` — asserts the trait-
21124 // idiomatic byte-owned reverse-projection standard-library
21125 // impls and the substrate-primitive
21126 // [`super::DepList::as_str`] `pub const fn` accessor's
21127 // `.as_bytes().to_vec()` byte-tail resolve to the same two-arm
21128 // `:`-prefixed kebab-case byte-string emit-set across every
21129 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
21130 // Extends the substrate-wide trait-idiomatic byte-owned
21131 // reverse-projection axis onto the third closed-set fieldless
21132 // typed enum on the caixa-core-internal tier — matching the
21133 // trajectory the sibling first-mover [`super::CaixaKind`]
21134 // `From<{Self, &Self}> for Vec<u8>` impls (b245fd6) and the
21135 // second-mover [`crate::dialeto::CaixaDialeto`] impls (4cceaf5)
21136 // walked before it on the caixa-core tier of the byte-owned
21137 // axis.
21138 for &variant in super::DepList::ALL {
21139 let via_owned_from: Vec<u8> = <Vec<u8> as From<super::DepList>>::from(variant);
21140 let via_borrowed_from: Vec<u8> = <Vec<u8> as From<&super::DepList>>::from(&variant);
21141 let via_method_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
21142 assert_eq!(
21143 via_owned_from, via_method_bytes,
21144 "From<DepList> for Vec<u8> impl must byte-equal \
21145 DepList::as_str().as_bytes().to_vec() on DepList::\
21146 {variant:?} — divergence signals a silent detour off \
21147 the substrate-primitive accessor"
21148 );
21149 assert_eq!(
21150 via_borrowed_from, via_method_bytes,
21151 "From<&DepList> for Vec<u8> impl must byte-equal \
21152 DepList::as_str().as_bytes().to_vec() on DepList::\
21153 {variant:?} — divergence signals a silent detour off \
21154 the substrate-primitive accessor"
21155 );
21156 assert_eq!(
21157 via_owned_from, via_borrowed_from,
21158 "From<DepList> for Vec<u8> and From<&DepList> for \
21159 Vec<u8> must byte-equal each other on DepList::\
21160 {variant:?} — divergence signals the owned-input and \
21161 borrowed-input paths have drifted off the same \
21162 substrate-primitive as_str accessor"
21163 );
21164 // Cross-axis witness against the paired [`AsRef<[u8]>`]
21165 // borrowed byte-view axis: the byte-owned reverse-
21166 // projection axis must byte-equal the paired borrowed
21167 // byte-view axis by construction — locking the byte-view
21168 // and byte-owned axes together at the substrate-primitive
21169 // accessor.
21170 let borrowed_bytes: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21171 assert_eq!(
21172 via_owned_from,
21173 borrowed_bytes.to_vec(),
21174 "From<DepList> for Vec<u8> and AsRef<[u8]> for DepList \
21175 must resolve to byte-equal byte-tails on DepList::\
21176 {variant:?} — divergence signals the byte-owned and \
21177 byte-view axes have drifted off the same substrate-\
21178 primitive as_str accessor"
21179 );
21180 // Cross-axis witness against the str-owned reverse-
21181 // projection family's `.into_bytes()` / `.as_bytes().to_vec()`
21182 // byte-tails: every one of `{String, Cow<'static, str>,
21183 // Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
21184 // allocates (or borrows) the same `:`-prefixed kebab byte-
21185 // string the substrate-primitive accessor emits, so the
21186 // byte-owned axis must byte-equal each of their owned
21187 // byte-tails by construction.
21188 let owned_string: String = <String as From<super::DepList>>::from(variant);
21189 assert_eq!(
21190 via_owned_from,
21191 owned_string.into_bytes(),
21192 "From<DepList> for Vec<u8> and \
21193 String::from(list).into_bytes() must resolve to byte-\
21194 equal byte-tails on DepList::{variant:?}"
21195 );
21196 let owned_cow: std::borrow::Cow<'static, str> =
21197 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
21198 assert_eq!(
21199 via_owned_from,
21200 owned_cow.as_bytes().to_vec(),
21201 "From<DepList> for Vec<u8> and From<DepList> for \
21202 Cow<'static, str> must resolve to byte-equal byte-\
21203 tails on DepList::{variant:?}"
21204 );
21205 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
21206 assert_eq!(
21207 via_owned_from,
21208 owned_box.as_bytes().to_vec(),
21209 "From<DepList> for Vec<u8> and From<DepList> for \
21210 Box<str> must resolve to byte-equal byte-tails on \
21211 DepList::{variant:?}"
21212 );
21213 let owned_arc: std::sync::Arc<str> =
21214 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
21215 assert_eq!(
21216 via_owned_from,
21217 owned_arc.as_bytes().to_vec(),
21218 "From<DepList> for Vec<u8> and From<DepList> for \
21219 std::sync::Arc<str> must resolve to byte-equal byte-\
21220 tails on DepList::{variant:?}"
21221 );
21222 let owned_rc_str: std::rc::Rc<str> =
21223 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
21224 assert_eq!(
21225 via_owned_from,
21226 owned_rc_str.as_bytes().to_vec(),
21227 "From<DepList> for Vec<u8> and From<DepList> for \
21228 std::rc::Rc<str> must resolve to byte-equal byte-\
21229 tails on DepList::{variant:?}"
21230 );
21231 }
21232 // `<T: Into<Vec<u8>>>`-bound-consumer witness on both owned
21233 // and borrowed input shapes: the generic owned-byte-input
21234 // function `generic_owned_bytes_sink` (lifted above per
21235 // `clippy::items_after_statements`) accepts a
21236 // [`super::DepList`] and a `&DepList` directly through the
21237 // trait bound, without the caller open-coding the three-hop
21238 // `list.as_str().as_bytes().to_vec()` composition.
21239 for &variant in super::DepList::ALL {
21240 let via_generic_owned = generic_owned_bytes_sink(variant);
21241 // Bind the borrowed-input path through an explicit
21242 // `&DepList` local so the generic-consumer witness routes
21243 // through `From<&DepList> for Vec<u8>` (T binds to
21244 // `&DepList`) rather than clippy-collapsing the borrow
21245 // onto the owned-input `From<DepList> for Vec<u8>` peer.
21246 let variant_ref: &super::DepList = &variant;
21247 let via_generic_borrowed = generic_owned_bytes_sink(variant_ref);
21248 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21249 assert_eq!(
21250 via_generic_owned, via_method_bytes,
21251 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21252 DepList::{variant:?} must yield the same byte-tail \
21253 DepList::as_str().as_bytes().to_vec() returns — \
21254 divergence signals the byte-owned axis fails to \
21255 bridge a generic owned-byte-input trait bound to the \
21256 substrate-primitive accessor"
21257 );
21258 assert_eq!(
21259 via_generic_borrowed, via_method_bytes,
21260 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21261 &DepList::{variant:?} must yield the same byte-tail \
21262 DepList::as_str().as_bytes().to_vec() returns — the \
21263 borrowed-input surface must resolve to the same \
21264 as_str dispatch"
21265 );
21266 }
21267 // `std::io::Write::write_all`-shape owned-byte-sink surface
21268 // witness: the `MockOwnedByteSink` (lifted above per
21269 // `clippy::items_after_statements`) mirrors
21270 // `std::io::Write::write_all` /
21271 // `bytes::BytesMut::extend_from_slice`'s `impl Into<Vec<u8>>`-
21272 // bound owned-byte input signature and accepts a
21273 // [`super::DepList`] directly on both owned and borrowed input
21274 // shapes, routing its byte-tail through the substrate-
21275 // primitive `as_str` accessor — the shape a future per-caixa
21276 // per-`:deps`/`:deps-dev` audit-log emit composes to fold a
21277 // dep-list discriminator byte-tag into a downstream owned-
21278 // byte-sink surface so a partition of the runtime-closure
21279 // `:deps` from the dev-only-closure `:deps-dev` reaches the
21280 // sink through this axis and no other.
21281 for &variant in super::DepList::ALL {
21282 let mut owned_sink = MockOwnedByteSink::new();
21283 owned_sink.write_all(variant);
21284 let owned_folded = owned_sink.finalize();
21285 assert_eq!(
21286 owned_folded,
21287 variant.as_str().as_bytes(),
21288 "`sink.write_all(list)`-shape composition on DepList::\
21289 {variant:?} must fold the same byte-tail DepList::\
21290 as_str().as_bytes() returns"
21291 );
21292 let mut borrowed_sink = MockOwnedByteSink::new();
21293 // Same explicit `&DepList` binding as the generic-consumer
21294 // witness above: routes the owned-byte-sink surface
21295 // through `From<&DepList> for Vec<u8>` (T binds to
21296 // `&DepList`) rather than clippy-collapsing the borrow
21297 // onto the owned-input peer.
21298 let variant_ref: &super::DepList = &variant;
21299 borrowed_sink.write_all(variant_ref);
21300 let borrowed_folded = borrowed_sink.finalize();
21301 assert_eq!(
21302 borrowed_folded,
21303 variant.as_str().as_bytes(),
21304 "`sink.write_all(&list)`-shape composition on \
21305 &DepList::{variant:?} must fold the same byte-tail \
21306 DepList::as_str().as_bytes() returns — the borrowed-\
21307 input surface must resolve to the same as_str dispatch"
21308 );
21309 }
21310 }
21311}
21312
21313#[cfg(test)]
21314mod dep_source_is_variant_tests {
21315 use super::*;
21316
21317 fn all_variants() -> Vec<(DepSource, &'static str)> {
21318 vec![
21319 (
21320 DepSource::Git {
21321 repo: "github:pleme-io/caixa-teia".into(),
21322 tag: Some("v0.1.0".into()),
21323 rev: None,
21324 branch: None,
21325 },
21326 "Git",
21327 ),
21328 (
21329 DepSource::Path {
21330 caminho: "../caixa-teia".into(),
21331 },
21332 "Path",
21333 ),
21334 ]
21335 }
21336
21337 fn predicate_row(s: &DepSource) -> [bool; 2] {
21338 [s.is_git(), s.is_path()]
21339 }
21340
21341 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
21342 // derive-generated per-arm predicate partition — for every variant
21343 // in `all_variants()`, the observed 2-slot predicate row must equal
21344 // a one-hot row with the `true` at exactly the same index as the
21345 // variant's declaration order. Expected rows are generated live
21346 // from the enumeration rather than transcribed by hand, so a
21347 // copy-paste flip that reroutes one arm through the wrong predicate
21348 // lane trips at the identity-diagonal assertion the way every peer
21349 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
21350 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
21351 // / [`crate::upgrade::UpgradeInstruction`] /
21352 // [`crate::aplicacao::PlacementStrategy`] /
21353 // [`crate::aplicacao::RateLimitUnit`] /
21354 // [`crate::aplicacao::WitTarget`] /
21355 // [`crate::render::PathShapeViolation`] partition pin already does.
21356 #[test]
21357 fn dep_source_is_variant_predicates_partition_the_arm_set() {
21358 let variants = all_variants();
21359 for (idx, (variant, name)) in variants.iter().enumerate() {
21360 let observed = predicate_row(variant);
21361 let mut expected = [false; 2];
21362 expected[idx] = true;
21363 assert_eq!(
21364 observed, expected,
21365 "DepSource::{name} at declaration-order slot {idx} must \
21366 satisfy exactly one is_* predicate (its own); observed \
21367 row must equal the one-hot expected row — a drift \
21368 would silently reroute one `:fonte`-arm consumer \
21369 through the wrong predicate lane"
21370 );
21371 }
21372 }
21373
21374 // Byte-parity pin on the two field-agnostic `matches!` shapes the
21375 // per-arm arm-discriminator predicates replace at any future
21376 // consumer site (a `:fonte`-shape-only lint rule that flags path
21377 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
21378 // a future admission-webhook that rejects `:fonte` shapes outside
21379 // the `is_git()` accept-set, a caixa-lacre indexing pass that
21380 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
21381 // Refuses a future accidental split between the derived predicate
21382 // and its `matches!` shape — a hand-rolled shadow impl that
21383 // overrides one path, an accidental rebrand that leaves one
21384 // consumer on the raw `matches!` form — on the two load-bearing
21385 // `:fonte`-arm-discriminator axes every downstream substrate
21386 // consumer of the dep-source axis keys off.
21387 #[test]
21388 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
21389 for (variant, name) in all_variants() {
21390 let via_matches_git = matches!(variant, DepSource::Git { .. });
21391 let via_predicate_git = variant.is_git();
21392 assert_eq!(
21393 via_predicate_git, via_matches_git,
21394 "DepSource::{name}.is_git() must byte-equal \
21395 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
21396 future converged consumer site would silently \
21397 disagree with its pre-lift shape"
21398 );
21399 let via_matches_path = matches!(variant, DepSource::Path { .. });
21400 let via_predicate_path = variant.is_path();
21401 assert_eq!(
21402 via_predicate_path, via_matches_path,
21403 "DepSource::{name}.is_path() must byte-equal \
21404 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
21405 future converged consumer site would silently \
21406 disagree with its pre-lift shape"
21407 );
21408 }
21409 }
21410
21411 // Cross-pin against every constructor path that materializes a
21412 // [`DepSource`] shape today (the [`DepSource::default_github`]
21413 // resolver-side fallback that materializes an unpinned
21414 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
21415 // surface constructor that materializes a pinned `:tag`-carrying
21416 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
21417 // fixture family builds inline). Every constructor's return must
21418 // satisfy the arm-discriminator predicate the constructor's
21419 // variant name matches — a future constructor addition (an
21420 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
21421 // enclosing docstring already names as a trajectory item) surfaces
21422 // as a build-time failure that names the offending drift when its
21423 // return arm doesn't route through the paired predicate.
21424 #[test]
21425 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
21426 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
21427 assert!(
21428 via_default_github.is_git(),
21429 "DepSource::default_github must materialize a Git-arm shape — \
21430 a future constructor that routed through a non-Git arm \
21431 (a registry-fetch pin, a `DepSource::Feira` promotion) \
21432 would silently split the resolver's unpinned-shorthand \
21433 materializer from the sole_pin() precedence cascade"
21434 );
21435 assert!(
21436 !via_default_github.is_path(),
21437 "DepSource::default_github must NOT materialize a Path-arm \
21438 shape — the paired negation pin"
21439 );
21440
21441 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
21442 .fonte
21443 .expect("Dep::git materializes a Some(fonte)");
21444 assert!(
21445 via_dep_git.is_git(),
21446 "Dep::git's `:fonte` materialization must land on the Git \
21447 arm — the author-surface pinned-git constructor's return \
21448 must route through the paired predicate"
21449 );
21450 assert!(!via_dep_git.is_path(), "paired negation pin");
21451
21452 let via_path = DepSource::Path {
21453 caminho: "../caixa-teia".into(),
21454 };
21455 assert!(
21456 via_path.is_path(),
21457 "the dev-mode Path-arm materialization must satisfy is_path()"
21458 );
21459 assert!(!via_path.is_git(), "paired negation pin");
21460 }
21461
21462 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
21463 // String, reason: String }` three-slot envelope on `DepError`,
21464 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
21465 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
21466 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
21467 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
21468 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
21469 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
21470
21471 #[test]
21472 fn versao_invalid_ctor_matches_struct_literal_wrap() {
21473 assert_eq!(
21474 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
21475 DepError::VersaoInvalid {
21476 nome: "caixa-teia".to_string(),
21477 versao: "^0..1".to_string(),
21478 reason: "invalid comparator".to_string(),
21479 },
21480 "versao_invalid ctor must produce byte-equal \
21481 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
21482 );
21483 }
21484
21485 #[test]
21486 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
21487 assert_eq!(
21488 DepError::fonte_repo_shape(
21489 "caixa-teia",
21490 "-upload-pack=evil",
21491 "leading dash rejected".to_string(),
21492 ),
21493 DepError::FonteRepoShape {
21494 nome: "caixa-teia".to_string(),
21495 repo: "-upload-pack=evil".to_string(),
21496 reason: "leading dash rejected".to_string(),
21497 },
21498 "fonte_repo_shape ctor must produce byte-equal \
21499 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
21500 );
21501 }
21502
21503 #[test]
21504 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
21505 assert_eq!(
21506 DepError::caracteristica_invalid(
21507 "caixa-teia",
21508 "bad feature!",
21509 "embedded space rejected".to_string(),
21510 ),
21511 DepError::CaracteristicaInvalid {
21512 nome: "caixa-teia".to_string(),
21513 caracteristica: "bad feature!".to_string(),
21514 reason: "embedded space rejected".to_string(),
21515 },
21516 "caracteristica_invalid ctor must produce byte-equal \
21517 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
21518 );
21519 }
21520
21521 #[test]
21522 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
21523 // Cross-axis routing pin: sweep the three constructor input axes
21524 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
21525 // distinct-per-axis fixtures against every generated arm in the
21526 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
21527 // lowercase / trim / truncate on the two `&str` axes — a silent
21528 // field swap between `nome`, the middle `<axis>` field, and
21529 // `reason`, or a `reason` axis silently rerouted through
21530 // `.to_string()` instead of forwarded owned — surfaces here rather
21531 // than at a downstream diagnostic-shape mismatch. Peer of the
21532 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
21533 // through_to_string` (0e35793) cross-axis routing pin on the same
21534 // envelope's `{ nome, caminho, byte }` three-slot family and of
21535 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
21536 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
21537 // — extended here onto the `{ nome, <axis>: String, reason:
21538 // String }` three-slot envelope so every substrate-primitive ctor
21539 // family in caixa-core's `DepError` envelope guarantees each field
21540 // routes the caller's value verbatim through `.to_string()` (or
21541 // owned-forward for `reason: String`) in declared field order.
21542 // Distinct-per-axis fixtures rule out any two-axis swap
21543 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
21544 // same-fixture-per-axis pin.
21545 let nome = "sibling-teia";
21546 let axis = "distinct-axis-value";
21547 let reason = "distinct rejection sentence".to_string();
21548 assert_eq!(
21549 DepError::versao_invalid(nome, axis, reason.clone()),
21550 DepError::VersaoInvalid {
21551 nome: nome.to_string(),
21552 versao: axis.to_string(),
21553 reason: reason.clone(),
21554 },
21555 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
21556 `reason` → `reason` in declared field order",
21557 );
21558 assert_eq!(
21559 DepError::fonte_repo_shape(nome, axis, reason.clone()),
21560 DepError::FonteRepoShape {
21561 nome: nome.to_string(),
21562 repo: axis.to_string(),
21563 reason: reason.clone(),
21564 },
21565 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
21566 `reason` → `reason` in declared field order",
21567 );
21568 assert_eq!(
21569 DepError::caracteristica_invalid(nome, axis, reason.clone()),
21570 DepError::CaracteristicaInvalid {
21571 nome: nome.to_string(),
21572 caracteristica: axis.to_string(),
21573 reason: reason.clone(),
21574 },
21575 "caracteristica_invalid must route `nome` → `nome`, \
21576 `axis` → `caracteristica`, `reason` → `reason` in declared \
21577 field order",
21578 );
21579 }
21580
21581 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
21582 // two-slot envelope on `DepError`, missing rung between
21583 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
21584 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
21585 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
21586 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
21587 // two-slot `{ nome, list: &'static str }` envelope (same slot
21588 // count, `&'static str` axis instead of owned `String` axis).
21589
21590 #[test]
21591 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
21592 assert_eq!(
21593 DepError::fonte_pin_empty("caixa-teia", ":tag"),
21594 DepError::FontePinEmpty {
21595 nome: "caixa-teia".to_string(),
21596 pin: ":tag".to_string(),
21597 },
21598 "fonte_pin_empty ctor must produce byte-equal \
21599 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
21600 on the same `(&str, &str)` fixture",
21601 );
21602 }
21603
21604 #[test]
21605 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
21606 assert_eq!(
21607 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
21608 DepError::FontePinAmbiguous {
21609 nome: "caixa-teia".to_string(),
21610 pins: ":tag, :rev".to_string(),
21611 },
21612 "fonte_pin_ambiguous ctor must produce byte-equal \
21613 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
21614 wrap on the same `(&str, &str)` fixture",
21615 );
21616 }
21617
21618 #[test]
21619 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
21620 assert_eq!(
21621 DepError::caracteristica_duplicate("caixa-teia", "http"),
21622 DepError::CaracteristicaDuplicate {
21623 nome: "caixa-teia".to_string(),
21624 caracteristica: "http".to_string(),
21625 },
21626 "caracteristica_duplicate ctor must produce byte-equal \
21627 `DepError::CaracteristicaDuplicate` to the pre-lift \
21628 struct-literal wrap on the same `(&str, &str)` fixture",
21629 );
21630 }
21631
21632 #[test]
21633 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
21634 // Owned-`String` routing pin: thread the real
21635 // `set.join(", ")` `String` carrier through the ctor's
21636 // `&str`-parameter Deref coercion, so the ambiguity-arm
21637 // wire-up site's actual `&set.join(", ")` shape stays
21638 // byte-equal to a direct `":tag, :rev"` literal. A future
21639 // parameter-shape change silently dropping the Deref
21640 // coercion route (e.g., a switch to `impl Into<String>`)
21641 // surfaces here rather than at the wire-up's compile
21642 // error far from the ctor definition.
21643 let set: Vec<&'static str> = vec![":tag", ":rev"];
21644 let joined: String = set.join(", ");
21645 assert_eq!(
21646 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
21647 DepError::FontePinAmbiguous {
21648 nome: "caixa-teia".to_string(),
21649 pins: ":tag, :rev".to_string(),
21650 },
21651 "fonte_pin_ambiguous ctor must accept an owned-`String` \
21652 `&set.join(\", \")` carrier via Deref coercion — the exact \
21653 shape the ambiguity-arm wire-up site passes into it",
21654 );
21655 }
21656
21657 #[test]
21658 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
21659 // Cross-axis routing pin: sweep the two constructor input axes
21660 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
21661 // fixtures against every generated arm in the
21662 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
21663 // trim / truncate at codegen time — a silent field swap between
21664 // `nome` and the middle `<axis>` field, or a `<axis>` axis
21665 // silently rerouted through the wrong field on any one variant
21666 // — surfaces here rather than at a downstream diagnostic-shape
21667 // mismatch. Peer of the sibling
21668 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
21669 // (6f5e0cd) pin on the same envelope's peer two-slot family
21670 // (`{ nome, list: &'static str }`) and of the sibling
21671 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
21672 // (5621f8a) pin on the same envelope's three-slot `{ nome,
21673 // <axis>: String, reason: String }` family — extended here onto
21674 // the `{ nome, <axis>: String }` two-slot envelope so the last
21675 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
21676 // ladder guarantees each field routes the caller's value
21677 // verbatim through `.to_string()` in declared field order.
21678 // Distinct-per-axis fixtures rule out any two-axis swap
21679 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
21680 // per-axis pin.
21681 let nome = "sibling-teia";
21682 let axis = "distinct-axis-value";
21683 assert_eq!(
21684 DepError::fonte_pin_empty(nome, axis),
21685 DepError::FontePinEmpty {
21686 nome: nome.to_string(),
21687 pin: axis.to_string(),
21688 },
21689 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
21690 in declared field order",
21691 );
21692 assert_eq!(
21693 DepError::fonte_pin_ambiguous(nome, axis),
21694 DepError::FontePinAmbiguous {
21695 nome: nome.to_string(),
21696 pins: axis.to_string(),
21697 },
21698 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
21699 in declared field order",
21700 );
21701 assert_eq!(
21702 DepError::caracteristica_duplicate(nome, axis),
21703 DepError::CaracteristicaDuplicate {
21704 nome: nome.to_string(),
21705 caracteristica: axis.to_string(),
21706 },
21707 "caracteristica_duplicate must route `nome` → `nome`, \
21708 `axis` → `caracteristica` in declared field order",
21709 );
21710 }
21711
21712 #[test]
21713 fn nome_invalid_ctor_matches_struct_literal_wrap() {
21714 // Equivalence pin: the ctor produces byte-equal
21715 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
21716 // literal that cloned the offending `:deps :nome` verbatim and
21717 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
21718 // owned `reason` payload at the caller site inside
21719 // [`Dep::validate`]. Guards any future field-addition /
21720 // reordering / accessor-return tweak on the variant. Sibling of
21721 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
21722 // (below) and the sibling three-slot
21723 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
21724 // pin on the same envelope's three-slot `{ nome, <axis>: String,
21725 // reason: String }` family.
21726 let nome = "Caixa-Teia";
21727 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
21728 let via_ctor = DepError::nome_invalid(nome, reason.clone());
21729 let via_literal = DepError::NomeInvalid {
21730 nome: nome.to_string(),
21731 reason,
21732 };
21733 assert_eq!(
21734 via_ctor, via_literal,
21735 "nome_invalid(nome, reason) must byte-equal the open-coded \
21736 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
21737 );
21738 assert_eq!(
21739 via_ctor.to_string(),
21740 via_literal.to_string(),
21741 "Display byte-string must byte-equal the open-coded struct-literal"
21742 );
21743 }
21744
21745 #[test]
21746 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
21747 // Boundary-sweep pin on the ctor's two-slot projection: sweep
21748 // the two ctor input axes (`nome: &str`, `reason: String`)
21749 // through distinct-per-axis fixtures against a representative
21750 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
21751 // wrapper-side silent lowercase / trim / truncate at codegen
21752 // time — a silent field swap between `nome` and `reason`, an
21753 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
21754 // divergence on the `reason` axis — surfaces at caixa-core
21755 // build time rather than at a downstream diagnostic consumer
21756 // that reads `err.nome` / `err.reason` back and gets a different
21757 // value than the one it stored. Peer of the sibling
21758 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
21759 // (7f7c950) pin on the same envelope's peer two-slot family
21760 // (`{ nome, <axis>: String }`) — extended here onto the
21761 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
21762 // variant carries. Distinct-per-axis fixtures rule out any
21763 // two-axis swap (`nome` ↔ `reason`) that would still pass a
21764 // same-fixture-per-axis pin. The sweep list carries a mixed
21765 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
21766 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
21767 // over-63-byte) so a future silent per-input normalization
21768 // surfaces on the arm that diverges.
21769 for nome in [
21770 "Caixa-Teia",
21771 "caixa_teia",
21772 "caixa.teia",
21773 "-caixa-teia",
21774 "caixa-teia-",
21775 "caixa/teia",
21776 &"a".repeat(64),
21777 ] {
21778 let reason = crate::render::is_dns_1123_label(nome)
21779 .expect_err("fixture must be a DNS-1123-refused label");
21780 let via_ctor = DepError::nome_invalid(nome, reason.clone());
21781 let DepError::NomeInvalid {
21782 nome: stored_nome,
21783 reason: stored_reason,
21784 } = via_ctor
21785 else {
21786 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
21787 };
21788 assert_eq!(
21789 stored_nome, nome,
21790 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
21791 );
21792 assert_eq!(
21793 stored_reason, reason,
21794 "reason slot must forward the owned `String` verbatim for {nome:?}"
21795 );
21796 }
21797 }
21798
21799 #[test]
21800 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
21801 // End-to-end pin: the sole in-crate wire-up site
21802 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
21803 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
21804 // the ctor's output on the same DNS-1123-refused `:deps :nome`
21805 // fixture, with identical `Display` rendering. A future silent
21806 // de-lift of the wire-up back to the open-coded struct-literal
21807 // trips this test at caixa-core build time rather than at a
21808 // downstream diagnostic consumer far from the wire-up commit.
21809 // Sibling of the peer
21810 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
21811 // pin on the same wire-up — extended here from a `matches!`
21812 // shape check to a byte-identity + Display parity route through
21813 // the ctor.
21814 let d = Dep::simple("Caixa_Teia", "^0.1");
21815 let observed = d.validate().unwrap_err();
21816 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
21817 .expect_err("fixture must be DNS-1123-refused");
21818 let expected = DepError::nome_invalid("Caixa_Teia", reason);
21819 assert_eq!(
21820 observed, expected,
21821 "Dep::validate's DNS-1123 refusal arm must byte-equal \
21822 nome_invalid(nome, reason)"
21823 );
21824 assert_eq!(
21825 observed.to_string(),
21826 expected.to_string(),
21827 "Display byte-string parity"
21828 );
21829 }
21830}