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/// Trait-idiomatic *borrowed byte-slice input* reverse projection on the
4754/// third caixa-core-internal closed-set fieldless typed enum peer
4755/// ([`DepList`]) — the byte-view mirror of the str-view reverse-projection
4756/// axis carried by the paired [`TryFrom<&str> for DepList`] impl (which
4757/// routes through the substrate-primitive [`DepList::from_wire`]
4758/// `Option<Self>` accessor on the two-arm `:`-prefixed kebab-case accept-
4759/// set the sibling [`DepList::as_str`] emitter returns —
4760/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4761/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`]). Routes byte-for-byte
4762/// through the standard-library [`std::str::from_utf8`] UTF-8 validator
4763/// and then through [`DepList::from_wire`] so every consumer that holds a
4764/// borrowed [`&[u8]`] and needs to project it back into a typed
4765/// [`DepList`] — a future `bytes::Bytes::as_ref()`-fed reader that parses
4766/// a per-caixa `:deps` / `:deps-dev` classification tag from an already-
4767/// borrowed framing byte-tail (a `tracing::field::valuable::Value::Bytes`
4768/// recorder on the caixa-lacre `:deps` / `:deps-dev` partitioning
4769/// pipeline, a future audit-report re-loader binding a prior
4770/// [`DepList::as_str`] output from an mmap'd byte-slice back through the
4771/// typed enum for cross-run comparison), a future admission-webhook
4772/// rejection body that reads a `spec.dep_list` field off a raw HTTP body
4773/// byte-slice before UTF-8 validation commits allocation, a future
4774/// generic `<T: for<'a> TryFrom<&'a [u8]>>`-bound loader over any of the
4775/// substrate's closed-set typed enums — reaches the same two-arm
4776/// `:`-prefixed kebab-case wire accept-set the sibling method-named
4777/// [`DepList::from_wire`] resolver and the paired trait-idiomatic
4778/// [`TryFrom<&str>`] axis already resolve against, rather than an open-
4779/// coded per-call-site
4780/// `std::str::from_utf8(bytes).ok().and_then(DepList::from_wire)`
4781/// composition or a
4782/// `<DepList as TryFrom<&str>>::try_from(std::str::from_utf8(bytes)?)`
4783/// two-hop shape whose type bounds have no compile-time link to the
4784/// substrate primitive.
4785///
4786/// Extends the substrate-wide trait-idiomatic *byte-view reverse-
4787/// projection* family — opened on the structurally most fundamental
4788/// closed-set fieldless typed enum peer ([`crate::CaixaKind`], commit
4789/// 18d1940) and extended onto [`crate::dialeto::CaixaDialeto`] (d102cb8
4790/// second-mover) — onto the third caixa-core-internal closed-set
4791/// fieldless typed enum peer, tracking the "route through `from_wire` via
4792/// `std::str::from_utf8`" discipline the first-mover established. Rust's
4793/// standard library carries no blanket
4794/// `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so a two-hop
4795/// composition through [`std::str::from_utf8`] + the paired
4796/// [`TryFrom<&str>`] axis is reachable at every call site but has no
4797/// compile-time link back to the byte-view reverse-projection axis. Every
4798/// future closed-set fieldless typed enum peer on the substrate
4799/// ([`crate::supervisor::RestartStrategy`],
4800/// [`crate::supervisor::RestartPolicy`],
4801/// [`crate::aplicacao::PlacementStrategy`],
4802/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitShape`],
4803/// and the outside-`caixa-core` peers `PathShapeViolation`,
4804/// `InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`,
4805/// `FerriteRuntime`) is a future target of the campaign, mirroring the
4806/// trajectory the closed byte-owned reverse-projection family walked
4807/// arm-by-arm onto each peer.
4808///
4809/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
4810/// `Option<Self>` return-shape's deliberate deferral of error typing and
4811/// the paired trait-idiomatic [`TryFrom<&str>`] axis's unit-error shape —
4812/// the caller picks the diagnostic form appropriate for its use site (a
4813/// future `feira dep --list <deps|deps-dev>` arg-parse composes its own
4814/// per-verb "unknown list: <arg> — accepted: {…}" message enumerating
4815/// [`DepList::ALL`]; the M4 admission-webhook rejection body wraps
4816/// `Err(())` with the accepted-set enumeration for operator diagnostics;
4817/// a `Result::map_err` at the call site lifts the unit-error to a per-
4818/// verb error type). Two rejection paths route through the single unit-
4819/// error: an invalid UTF-8 byte-sequence ([`std::str::from_utf8`] returns
4820/// `Err`) and a valid UTF-8 byte-string that falls outside the two-arm
4821/// `:`-prefixed kebab-case accept-set ([`DepList::from_wire`] returns
4822/// `None`) — both collapse onto `Err(())` so the trait signature stays
4823/// consistent with the sibling str-view reverse axis, and a caller that
4824/// needs to distinguish the two failure modes composes
4825/// [`std::str::from_utf8`] + [`DepList::from_wire`] explicitly.
4826///
4827/// Pinned load-bearing by
4828/// [`tests::dep_list_try_from_bytes_routes_through_from_wire_accessor`]
4829/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
4830/// [`DepList::ALL`] accept-set on the borrowed byte-slice surface, plus a
4831/// cross-axis witness that the byte-view reverse projection agrees with
4832/// the paired [`TryFrom<&str>`] str-view reverse axis on every accepted
4833/// arm) and
4834/// [`tests::dep_list_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
4835/// (rejection witness against silent accept-set widening on both the
4836/// non-UTF-8 byte-sequence rejection path and the unknown-wire-vocabulary
4837/// rejection path).
4838impl TryFrom<&[u8]> for DepList {
4839 type Error = ();
4840
4841 fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
4842 std::str::from_utf8(bytes)
4843 .ok()
4844 .and_then(Self::from_wire)
4845 .ok_or(())
4846 }
4847}
4848
4849/// Trait-idiomatic *owned byte-vec input* reverse projection on the
4850/// third caixa-core-internal closed-set fieldless typed enum peer
4851/// ([`DepList`]) — the owned-input peer of
4852/// [`TryFrom<&[u8]> for DepList`], mirroring the closed
4853/// [`From<DepList> for Vec<u8>`] + [`From<&DepList> for Vec<u8>`]
4854/// byte-owned *forward*-projection pair on this same enum onto the
4855/// byte-owned *reverse*-projection axis. Routes byte-for-byte through
4856/// [`<Self as TryFrom<&[u8]>>::try_from`] on the [`Vec<u8>::as_slice`]
4857/// borrow, so the owned-input surface reaches the same
4858/// [`std::str::from_utf8`] + [`DepList::from_wire`] resolution chain
4859/// the borrowed-input peer already carries — one substrate-primitive
4860/// accessor, one trait dispatch, no per-consumer detour.
4861///
4862/// Rust's standard library carries no blanket
4863/// `impl<T: for<'a> TryFrom<&'a [u8]>> TryFrom<Vec<u8>> for T`, so a
4864/// consumer that holds an owned [`Vec<u8>`] and needs a typed
4865/// [`DepList`] otherwise picks between (a) an open-coded
4866/// `<DepList as TryFrom<&[u8]>>::try_from(bytes.as_slice())` at every
4867/// call site (whose type bounds have no compile-time link to the byte-
4868/// owned reverse-projection axis), (b) a two-hop
4869/// `String::from_utf8(bytes)` + [`DepList::from_wire`] composition
4870/// whose error surface leaks the standard-library [`std::string::FromUtf8Error`]
4871/// (widening the sibling [`TryFrom<&[u8]>`] axis's unit-error) and
4872/// silently allocates a [`String`] on inputs that will never make it
4873/// past the wire vocabulary, or (c) an intermediate
4874/// `<DepList as TryFrom<&str>>::try_from(std::str::from_utf8(&bytes)?)`
4875/// three-hop shape. This impl closes the owned-byte-vec reverse-
4876/// projection axis at the substrate-primitive
4877/// [`DepList::from_wire`] accessor so every future
4878/// `<T: TryFrom<Vec<u8>>>`-bound owned-byte-vec consumer — a future
4879/// admission-webhook body reader that hands raw request bytes off as
4880/// a [`Vec<u8>`] before UTF-8 validation commits, a future
4881/// `std::io::Read::read_to_end`-shape audit-log source whose framing
4882/// yields an owned byte-vec per frame, a future protobuf/CBOR/msgpack
4883/// per-field decoder whose bytes arm surfaces an owned [`Vec<u8>`]
4884/// before dispatch, a `bytes::Bytes::to_vec()`-shape wire-body
4885/// composer walking a prior audit's payload back to the typed enum,
4886/// an `<T: TryFrom<Vec<u8>>>`-bound generic loader over any of the
4887/// substrate's closed-set typed enums — reaches the same two-arm
4888/// `:`-prefixed kebab-case wire accept-set through one trait dispatch.
4889///
4890/// Extends the substrate-wide trait-idiomatic *byte-owned reverse-
4891/// projection* family onto the third caixa-core-internal closed-set
4892/// fieldless typed enum peer, tracking the trajectory the sibling
4893/// first-mover [`TryFrom<Vec<u8>> for crate::CaixaKind`] (99c2849)
4894/// opened on the structurally most fundamental enum and the sibling
4895/// second-mover [`TryFrom<Vec<u8>> for crate::CaixaDialeto`] (83a1526)
4896/// continued through. Peer of the sibling closed byte-view reverse-
4897/// projection family (`TryFrom<&[u8]>`; extended onto this enum
4898/// b8f25d5) and of the closed byte-owned forward-projection family
4899/// (`From<{Self, &Self}> for Vec<u8>`; extended onto this enum on the
4900/// same commit as its `TryFrom<&[u8]>` peer) on this same enum — the
4901/// {owned-input, borrowed-input} × {owned-output byte-vec, borrowed-
4902/// output byte-slice} byte-view reverse-projection square now closes
4903/// on [`DepList`].
4904///
4905/// `type Error = ()` matches the sibling [`TryFrom<&[u8]> for DepList`]
4906/// unit-error shape, preserving the trait-family consistency across
4907/// the borrowed-and-owned byte-view reverse-projection pair. Both
4908/// rejection paths (invalid UTF-8, valid-UTF-8-but-unknown-wire)
4909/// collapse onto `Err(())` through the delegated borrowed axis.
4910/// The owned [`Vec<u8>`] input is dropped on the error path (the
4911/// standard-library `String::from_utf8` convention of returning the
4912/// input in the error deliberately declined — a caller that needs
4913/// the bytes back holds a clone before the call, and the closed-set-
4914/// enum use site rarely wants the raw bytes back past a "did you
4915/// mean" diagnostic that operates on the wire vocabulary rather than
4916/// the input).
4917///
4918/// Like the peer [`TryFrom<Vec<u8>> for crate::CaixaDialeto`] and
4919/// unlike [`TryFrom<Vec<u8>> for crate::CaixaKind`] (which carries a
4920/// wire-vs-diagnostic two-axis split — lowercase Portuguese
4921/// `as_str` vs `PascalCase` `wire_name`), [`DepList`] has no such
4922/// split: [`Self::as_str`] and [`Self::from_wire`] operate on the
4923/// same two-arm `:`-prefixed kebab-case byte-vocabulary
4924/// (`":deps"`, `":deps-dev"`). So on this enum the byte-owned reverse-
4925/// projection axis *can* round-trip against the paired byte-owned
4926/// forward-projection pair ([`From<DepList> for Vec<u8>`],
4927/// [`From<&DepList> for Vec<u8>`]) — a four-corner witness the pinned
4928/// load-bearing test makes explicit, and a witness the sibling
4929/// [`TryFrom<Vec<u8>> for crate::CaixaKind`] axis deliberately
4930/// declines.
4931///
4932/// Pinned load-bearing by
4933/// [`tests::dep_list_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
4934/// (byte-parity pin against the paired borrowed [`TryFrom<&[u8]>`]
4935/// axis across the two-arm [`DepList::ALL`] accept-set on the owned
4936/// byte-vec surface, plus a cross-axis witness that the byte-owned
4937/// reverse projection agrees with the paired str-view reverse-
4938/// projection axis ([`TryFrom<&str>`]) on every accepted arm through
4939/// the shared substrate-primitive [`DepList::from_wire`] accessor,
4940/// plus a four-corner {owned-input, borrowed-input} × {owned-output
4941/// byte-vec, borrowed-output byte-slice} round-trip witness against
4942/// the paired [`From<{Self, &Self}> for Vec<u8>`] byte-owned forward-
4943/// projection pair) and
4944/// [`tests::dep_list_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
4945/// (rejection witness against silent accept-set widening on both the
4946/// non-UTF-8 byte-sequence rejection path and the unknown-wire-
4947/// vocabulary rejection path, plus a cross-axis witness that the
4948/// owned byte-vec reverse-projection axis agrees with the borrowed
4949/// byte-slice reverse-projection axis on every rejected input).
4950impl TryFrom<Vec<u8>> for DepList {
4951 type Error = ();
4952
4953 fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error> {
4954 <Self as TryFrom<&[u8]>>::try_from(bytes.as_slice())
4955 }
4956}
4957
4958/// Errors raised by [`Dep::validate`].
4959///
4960/// Mirrors the per-axis error families the other `:versao`-carrying
4961/// typed surfaces expose
4962/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4963/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4964/// [`crate::SupervisorError::EmptyChildVersion`] /
4965/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4966/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4967#[derive(Debug, Error, PartialEq, Eq)]
4968pub enum DepError {
4969 #[error(
4970 ":deps entry has empty :nome (every dep must name a target caixa; \
4971 omit the entry instead of carrying an empty name)"
4972 )]
4973 NomeEmpty,
4974 #[error(
4975 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4976 (the value flows verbatim as the target caixa's `:nome`, the rendered \
4977 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4978 value, and the resolver's checkout-directory leaf — each apiserver-side \
4979 schema rejects non-DNS-1123 names at admission time; use a lowercase \
4980 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4981 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4982 )]
4983 NomeInvalid { nome: String, reason: String },
4984 #[error(
4985 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4986 constraint that resolves through the lacre pipeline)"
4987 )]
4988 VersaoEmpty { nome: String },
4989 #[error(
4990 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4991 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4992 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4993 and `:children :versao` carry; the lacre pipeline resolves all three \
4994 through the same parser)"
4995 )]
4996 VersaoInvalid {
4997 nome: String,
4998 versao: String,
4999 reason: String,
5000 },
5001 #[error(
5002 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
5003 (every git source must name a repo — use a `github:org/repo` \
5004 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
5005 entire :fonte block to fall back to the default-host resolver \
5006 convention)"
5007 )]
5008 FonteRepoEmpty { nome: String },
5009 #[error(
5010 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
5011 invalid value-shape: {reason} (the value flows verbatim into the \
5012 caixa-resolver's `git clone <repo>` subprocess invocation; every \
5013 documented form carries a `:` separator and no whitespace / \
5014 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
5015 an `https://host/path` / `ssh://[user@]host/path` / \
5016 `git://host/path` / `file:///path` URL, or the `git@host:path` \
5017 scp-style SSH form)"
5018 )]
5019 FonteRepoShape {
5020 nome: String,
5021 repo: String,
5022 reason: String,
5023 },
5024 #[error(
5025 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
5026 (set exactly one of :tag, :rev, or :branch so the resolver \
5027 can pick a reproducible commit; omit the entire :fonte block \
5028 to fall back to the default-host resolver convention, which \
5029 resolves the latest tag matching :versao)"
5030 )]
5031 FontePinMissing { nome: String },
5032 #[error(
5033 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
5034 set ({pins}); exactly one of :tag, :rev, or :branch must be \
5035 set so the resolver's checkout target is unambiguous (the \
5036 resolver's silent precedence is :rev > :tag > :branch — if \
5037 you intended one specifically, drop the others)"
5038 )]
5039 FontePinAmbiguous { nome: String, pins: String },
5040 #[error(
5041 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
5042 (a set pin must name a non-empty git ref; drop the {pin} key \
5043 entirely to fall through to another pin axis)"
5044 )]
5045 FontePinEmpty { nome: String, pin: String },
5046 #[error(
5047 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
5048 value-shape: {reason} (the git porcelain enforces the same shape at \
5049 `git fetch` / `git checkout` time on every pin; use a leaf refname \
5050 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
5051 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
5052 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
5053 prepends at clone time, and avoid abbreviated SHAs which are \
5054 ambiguous across repository history)"
5055 )]
5056 FontePinShape {
5057 nome: String,
5058 pin: String,
5059 value: String,
5060 reason: String,
5061 },
5062 #[error(
5063 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
5064 (every path source must name a non-empty filesystem path; \
5065 omit the entire :fonte block to fall back to the default-host \
5066 resolver convention)"
5067 )]
5068 FonteCaminhoEmpty { nome: String },
5069 #[error(
5070 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
5071 absolute (the lacre pipeline embeds the value verbatim in its \
5072 per-dep content-address `path:{caminho}` at \
5073 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
5074 BLAKE3 closure differ across machines — defeating the \
5075 reproducibility contract that's load-bearing for CSE; express \
5076 the path relative to the caixa.lisp location, e.g. \
5077 \"../caixa-teia\" for a sibling workspace dep)"
5078 )]
5079 FonteCaminhoAbsolute { nome: String, caminho: String },
5080 #[error(
5081 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5082 with `~` (the leading-tilde is a shell-expansion convention, not a \
5083 POSIX path component — `Path::is_absolute` returns false on it, so \
5084 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
5085 pipeline embeds the value verbatim in its per-dep content-address \
5086 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
5087 caixa-resolver folds it through `Path::join` without `~`-expansion, \
5088 so the build looks for a literal `./{caminho}` subdirectory and \
5089 fails at resolve time far from the source caixa.lisp; even worse, a \
5090 future caixa-resolver pass that *does* expand `~` would silently \
5091 re-open the host-layout-leak the b94fd83 absolute gate closes — \
5092 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
5093 runners with different `$HOME` layouts resolve to two distinct paths \
5094 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
5095 determinism contract; express the path relative to the caixa.lisp \
5096 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
5097 spell out the full relative path explicitly if a workstation-rooted \
5098 dep is genuinely intended)"
5099 )]
5100 FonteCaminhoTildeExpansion { nome: String, caminho: String },
5101 #[error(
5102 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5103 with `$` (the leading-`$` is a shell-variable-expansion convention, \
5104 not a POSIX path component — `Path::is_absolute` returns false on it \
5105 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
5106 embeds the value verbatim in its per-dep content-address \
5107 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
5108 caixa-resolver folds it through `Path::join` without `$`-expansion, \
5109 so the build looks for a literal `./{caminho}` subdirectory and \
5110 fails at resolve time far from the source caixa.lisp; even worse, a \
5111 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
5112 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
5113 invites) would silently re-open the host-layout-leak the b94fd83 \
5114 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
5115 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
5116 layouts resolve to two distinct paths for the byte-identical caixa, \
5117 defeating the THEORY.md §V.2 render-determinism contract; express \
5118 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
5119 for a sibling workspace dep, or spell out the full relative path \
5120 explicitly if a workstation-rooted dep is genuinely intended)"
5121 )]
5122 FonteCaminhoVarExpansion { nome: String, caminho: String },
5123 #[error(
5124 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5125 with a space (the leading ASCII space `0x20` is the orthogonal \
5126 paste-from-aligned-doc footgun that silently passes \
5127 `Path::is_absolute` and every prior leading-byte arm — \
5128 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
5129 `./ ../caixa-teia` subdirectory the resolver fails to find at \
5130 resolve time with a non-self-locating `No such file or directory` \
5131 error far from the source caixa.lisp; the lacre pipeline embeds \
5132 the value verbatim in its per-dep content-address `path:{caminho}` \
5133 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
5134 semantic-identical caixa values (` ../caixa-teia` vs \
5135 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
5136 workstations whose authors differ only in paste-from-aligned- \
5137 caixa.lisp-doc whitespace habits — the most insidious failure \
5138 mode the typed slot can carry (no error surfaces; the divergence \
5139 is invisible until two machines compare lacres), defeating the \
5140 THEORY.md §V.2 render-determinism contract. The canonical \
5141 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
5142 a multi-entry `:deps` block sits at the same column — an author \
5143 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
5144 the rendered alignment into a fresh entry preserves the leading \
5145 whitespace verbatim); peer `:fonte :repo` axis already rejects \
5146 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
5147 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
5148 `is_chart_description_shape`, `:licenca` via \
5149 `is_spdx_expression_shape`. Drop the leading space; express the \
5150 path as a bare relative single-token like \"../caixa-teia\")"
5151 )]
5152 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
5153 #[error(
5154 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5155 with `-` (the canonical CLI-argument-injection footgun on the \
5156 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
5157 its per-dep content-address `path:{caminho}` at \
5158 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
5159 through `Path::join` looking for a literal `./{caminho}` \
5160 subdirectory. Every downstream subprocess that consumes the resolved \
5161 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
5162 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
5163 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
5164 value as a CLI flag rather than a positional path when the invocation \
5165 does not carry a `--` argument-list terminator between the flag block \
5166 and the path (the common case at every porcelain entry point). The \
5167 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
5168 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
5169 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
5170 CLI-arg-injection vector at every git porcelain entry point that \
5171 consumes a path or URL argument, peer with is_git_repo_url's \
5172 leading-`-` arm on the sibling `:fonte :repo` axis), \
5173 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
5174 POSIX `std::path::Path` treats a leading `-` as a literal filename \
5175 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
5176 for a literal `./-rf` subdirectory that fails at resolve time with a \
5177 non-self-locating `No such file or directory` error far from the \
5178 source caixa.lisp — but on any downstream shell-out without `--` the \
5179 reinterpretation is silent and the failure mode is arbitrary-\
5180 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
5181 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
5182 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
5183 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
5184 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
5185 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
5186 `:children :caixa`, `:deps :nome`, cluster names); \
5187 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
5188 the feira `init` / `add <nome>` positional gate (868c191) rejects \
5189 leading `-` on the CLI positional itself. Express the path as a bare \
5190 relative single-token like \"../caixa-teia\" — the sibling-workspace \
5191 directory name carries no leading-hyphen semantic, and `./` / `../` \
5192 prefixes structurally partition the leading-byte set to safe values.)"
5193 )]
5194 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
5195 #[error(
5196 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
5197 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
5198 every `std::fs` syscall routes the path through `CString::new` which \
5199 fails with `NulError` at resolve time; the lacre pipeline embeds the \
5200 value verbatim in its per-dep content-address `path:{caminho}` at \
5201 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
5202 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
5203 determinism contract — the canonical paste-from-multiline-doc \
5204 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
5205 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
5206 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
5207 already gates against. Express the path as a relative single-line ASCII \
5208 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
5209 )]
5210 FonteCaminhoControlChar {
5211 nome: String,
5212 caminho: String,
5213 byte: u8,
5214 },
5215 #[error(
5216 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
5217 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
5218 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
5219 not the parent's sibling — and the caixa-resolver folds the value through \
5220 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
5221 resolve time with a non-self-locating `No such file or directory` error far \
5222 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
5223 primary path separator equal to `/`, so byte-identical caixa.lisp values \
5224 resolve to two distinct directories across runner OSes — the lacre pipeline \
5225 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5226 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
5227 determinism contract via the cross-host-OS-separator divergence vector. The \
5228 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
5229 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
5230 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
5231 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
5232 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
5233 \"../caixa-teia\" for a sibling workspace dep)"
5234 )]
5235 FonteCaminhoBackslash { nome: String, caminho: String },
5236 #[error(
5237 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5238 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
5239 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
5240 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
5241 paste-from-shell-pipeline footgun where an author copies a `command > log` \
5242 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
5243 as literal path-component bytes, so the resolver folds the value through \
5244 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5245 subdirectory and fails at resolve time with a non-self-locating `No such \
5246 file or directory` error far from the source caixa.lisp. The lacre pipeline \
5247 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5248 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
5249 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5250 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5251 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
5252 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
5253 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
5254 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
5255 RFC-3986-reserved set. Express the path as a bare relative single-token like \
5256 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5257 redirection semantic.",
5258 ch = *byte as char
5259 )]
5260 FonteCaminhoShellRedirection {
5261 nome: String,
5262 caminho: String,
5263 byte: u8,
5264 },
5265 #[error(
5266 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
5267 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
5268 `|` as the pipe operator that wires one command's stdout to the next command's \
5269 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
5270 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
5271 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
5272 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
5273 treats `|` as a literal path-component byte, so the resolver folds the value \
5274 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5275 subdirectory and fails at resolve time with a non-self-locating `No such file or \
5276 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
5277 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
5278 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
5279 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
5280 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
5281 subprocess-argument / shell-metachar injection surface every peer single-token-\
5282 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
5283 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5284 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5285 workspace directory name carries no shell-pipe semantic."
5286 )]
5287 FonteCaminhoShellPipe { nome: String, caminho: String },
5288 #[error(
5289 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5290 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
5291 / nushell — lexes `;` as the sequential-command terminator that fires the next \
5292 command regardless of the prior command's exit status, so `:caminho \
5293 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
5294 footgun where an author copies a `cd path; do-thing` chain without trimming \
5295 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
5296 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
5297 literal path-component byte, so the resolver folds the value through \
5298 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5299 subdirectory and fails at resolve time with a non-self-locating `No such file \
5300 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5301 the value verbatim in its per-dep content-address `path:{caminho}` at \
5302 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5303 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5304 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5305 canonical shell-metachar injection surface every peer single-token-shaped \
5306 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
5307 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5308 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5309 workspace directory name carries no shell-command-separator semantic."
5310 )]
5311 FonteCaminhoShellSemicolon { nome: String, caminho: String },
5312 #[error(
5313 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5314 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
5315 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
5316 terminator detaching the prior command and returning control immediately to \
5317 the prompt, double `&&` as the logical-AND list operator firing the next \
5318 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
5319 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
5320 sleep 1` background-launch one-liner or a `cd path && make install` build-\
5321 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
5322 05c358e closed the sequential-command-separator vector, this arm closes the \
5323 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
5324 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
5325 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5326 byte lands in the BLAKE3 closure and rides into every shell-spawned \
5327 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5328 future operator-side `nix` spawn) as the canonical shell-metachar injection \
5329 surface every peer single-token-shaped typed slot already closes. The peer \
5330 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
5331 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
5332 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
5333 shell-background / logical-AND semantic."
5334 )]
5335 FonteCaminhoShellBackground { nome: String, caminho: String },
5336 #[error(
5337 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5338 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
5339 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
5340 wrapper that runs the enclosed command and substitutes its standard-output \
5341 verbatim into the surrounding word, so a backticked `whoami` expands to the \
5342 current user's name and a backticked `cat /etc/passwd` expands to the file's \
5343 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
5344 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
5345 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
5346 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
5347 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
5348 background / logical-AND vector, this arm closes the orthogonal command-\
5349 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
5350 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
5351 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
5352 value verbatim in its per-dep content-address `path:{caminho}` at \
5353 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5354 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
5355 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5356 shell-metachar injection surface every peer single-token-shaped typed slot \
5357 already closes. The peer `:entrada :paths` axis rejects the byte via \
5358 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
5359 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5360 directory name carries no shell-command-substitution semantic."
5361 )]
5362 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
5363 #[error(
5364 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5365 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
5366 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
5367 expansion wildcards: `*` matches any sequence of characters in a path component \
5368 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
5369 canonical paste-from-shell-listing footgun where an author copies a \
5370 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
5371 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
5372 `std::path::Path` treats both bytes as literal path-component bytes, so the \
5373 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
5374 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
5375 locating `No such file or directory` error far from the source caixa.lisp. The \
5376 lacre pipeline embeds the value verbatim in its per-dep content-address \
5377 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
5378 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
5379 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
5380 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
5381 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
5382 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
5383 reserved set. Express the path as a bare relative single-token like \
5384 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
5385 / pathname-expansion semantic.",
5386 ch = *byte as char
5387 )]
5388 FonteCaminhoShellGlob {
5389 nome: String,
5390 caminho: String,
5391 byte: u8,
5392 },
5393 #[error(
5394 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5395 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
5396 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
5397 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
5398 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
5399 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
5400 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
5401 arm closes the leading byte of — together the two arms now structurally exclude the \
5402 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
5403 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5404 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
5405 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
5406 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
5407 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
5408 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
5409 self-locating `No such file or directory` error far from the source caixa.lisp. The \
5410 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
5411 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
5412 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5413 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5414 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
5415 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
5416 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
5417 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
5418 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
5419 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5420 subshell-grouping semantic.",
5421 ch = *byte as char
5422 )]
5423 FonteCaminhoShellSubshellGrouping {
5424 nome: String,
5425 caminho: String,
5426 byte: u8,
5427 },
5428 #[error(
5429 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5430 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
5431 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
5432 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
5433 comma-separated members and `{{1..10}}` expands to the integer range — the \
5434 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
5435 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
5436 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
5437 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
5438 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
5439 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
5440 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
5441 `std::path::Path` treats the byte as a literal path-component byte, so a \
5442 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
5443 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
5444 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
5445 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
5446 silently passes every prior arm and the resolver folds the value through \
5447 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5448 resolve time with a non-self-locating `No such file or directory` error far from \
5449 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
5450 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5451 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5452 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5453 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
5454 expansion / URI-Template-placeholder surface every peer single-token-shaped \
5455 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
5456 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
5457 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
5458 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5459 directory name carries no shell-brace-expansion / URI-Template-placeholder \
5460 semantic; if two siblings actually need pinning, author two separate `:deps` \
5461 entries rather than one brace-expanded `:caminho` value.",
5462 ch = *byte as char
5463 )]
5464 FonteCaminhoShellBraceExpansion {
5465 nome: String,
5466 caminho: String,
5467 byte: u8,
5468 },
5469 #[error(
5470 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5471 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
5472 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
5473 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
5474 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
5475 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
5476 glob every shell-history block carries; the bracket pair additionally carries the \
5477 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
5478 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
5479 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
5480 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
5481 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
5482 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
5483 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5484 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
5485 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
5486 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
5487 leak) silently passes every prior arm and the resolver folds the value through \
5488 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5489 resolve time with a non-self-locating `No such file or directory` error far from \
5490 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5491 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5492 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5493 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5494 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
5495 surface every peer single-token-shaped typed slot already closes. Express the path \
5496 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5497 directory name carries no shell-bracket-expansion / glob-character-class / array-\
5498 literal semantic; if a family of sibling caixas actually needs pinning, author \
5499 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
5500 ch = *byte as char
5501 )]
5502 FonteCaminhoShellBracketExpansion {
5503 nome: String,
5504 caminho: String,
5505 byte: u8,
5506 },
5507 #[error(
5508 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5509 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
5510 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5511 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
5512 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
5513 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
5514 every path-with-embedded-whitespace paste block carries and the symmetric \
5515 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
5516 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
5517 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
5518 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
5519 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
5520 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
5521 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
5522 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
5523 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
5524 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
5525 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
5526 production. POSIX `std::path::Path` treats the byte as a literal path-component \
5527 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
5528 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
5529 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
5530 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
5531 shape) silently passes every prior arm and the resolver folds the value through \
5532 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5533 resolve time with a non-self-locating `No such file or directory` error far from \
5534 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5535 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5536 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5537 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5538 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
5539 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5540 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
5541 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
5542 `is_git_repo_url`). Express the path as a bare relative single-token like \
5543 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
5544 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
5545 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
5546 quoting on the outer syntactic layer, so an inner quote pair would nest and \
5547 desugar to a broken layer).",
5548 ch = *byte as char
5549 )]
5550 FonteCaminhoShellQuoteGrouping {
5551 nome: String,
5552 caminho: String,
5553 byte: u8,
5554 },
5555 #[error(
5556 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5557 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
5558 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5559 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
5560 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
5561 discarding the byte and everything after it to the end of the physical line \
5562 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
5563 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
5564 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
5565 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
5566 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
5567 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
5568 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
5569 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
5570 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
5571 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
5572 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
5573 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
5574 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
5575 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
5576 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
5577 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
5578 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
5579 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
5580 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
5581 fails at resolve time with a non-self-locating `No such file or directory` \
5582 error far from the source caixa.lisp — while every downstream shell / YAML / \
5583 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
5584 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
5585 scalar disagree with the resolver on which directory the value names. The \
5586 lacre pipeline embeds the value verbatim in its per-dep content-address \
5587 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
5588 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5589 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
5590 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
5591 fragment-delimiter surface every peer single-token-shaped typed slot already \
5592 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
5593 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
5594 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5595 workspace directory name carries no shell-comment / URL-fragment / YAML-\
5596 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
5597 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
5598 and drop any `#fragment` tail entirely (fragment identifiers select \
5599 renderings, not directories, and `:caminho` names a directory).",
5600 ch = *byte as char
5601 )]
5602 FonteCaminhoShellComment {
5603 nome: String,
5604 caminho: String,
5605 byte: u8,
5606 },
5607 #[error(
5608 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
5609 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
5610 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
5611 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
5612 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
5613 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
5614 literally inside a URL value. The canonical paste-from-browser-address-bar \
5615 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
5616 encoded README hyperlink / browser address bar / percent-encoded permalink \
5617 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
5618 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
5619 what the author intended as the byte-identical sibling-workspace dep. POSIX \
5620 `std::path::Path` treats the byte as a literal path-component byte, so \
5621 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
5622 resolve time with a non-self-locating `No such file or directory` error far \
5623 from the source caixa.lisp — while every downstream URL parser / shell printf \
5624 builtin / YAML directive parser silently reinterprets the byte to a different \
5625 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
5626 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
5627 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
5628 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
5629 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
5630 recent job whose command started with `foo`\" — a future `kill %1` invocation \
5631 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
5632 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
5633 directive block cross-idiom leak); and the Windows-shell env-var-reference \
5634 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
5635 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
5636 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5637 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
5638 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5639 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
5640 printf-format-specifier / job-control-specifier surface every peer single-\
5641 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
5642 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
5643 `is_git_repo_url`). Express the path as a bare relative single-token like \
5644 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
5645 percent-encoding-escape / format-specifier / job-control semantic; substitute \
5646 any `%20` percent-encoded-space with a literal space then reject the whole \
5647 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5648 directory name never carries an embedded space in practice); drop any \
5649 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5650 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5651 ch = *byte as char
5652 )]
5653 FonteCaminhoUrlPercentEncoding {
5654 nome: String,
5655 caminho: String,
5656 byte: u8,
5657 },
5658 #[error(
5659 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5660 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5661 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5662 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5663 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5664 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5665 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5666 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5667 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5668 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5669 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5670 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5671 the byte is a first-class parser byte in nearly every config / templating / \
5672 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5673 `std::path::Path` treats the byte as a literal path-component byte, so the \
5674 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5675 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5676 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5677 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5678 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5679 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5680 subdirectory that fails at resolve time with a non-self-locating `No such file \
5681 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5682 the value verbatim in its per-dep content-address `path:{caminho}` at \
5683 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5684 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5685 time lock to two distinct BLAKE3 closures across two workstations whose \
5686 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5687 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5688 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5689 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5690 is the canonical CWE-78 shell-command-injection surface every peer single-\
5691 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5692 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5693 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5694 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5695 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5696 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5697 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5698 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5699 so every position — leading and embedded — is structurally rejected. Substitute \
5700 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5701 time, or express the path as a bare relative single-token like \
5702 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5703 variable-expansion / command-substitution / arithmetic-expansion semantic.",
5704 ch = *byte as char
5705 )]
5706 FonteCaminhoShellVariableExpansion {
5707 nome: String,
5708 caminho: String,
5709 byte: u8,
5710 },
5711 #[error(
5712 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5713 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5714 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5715 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5716 reference §9.3: `!command` re-runs the most recent history entry beginning with \
5717 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5718 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5719 and the substitution fires at every history-expansion-enabled shell context — \
5720 `set -o histexpand` is bash's default for interactive sessions and the layer \
5721 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5722 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5723 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5724 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5725 encodes it inside a query component via the 'special-query percent-encode set' \
5726 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5727 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5728 prefix — the paste-from-source-code idiom where an author copies \
5729 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5730 the string-literal boundary); the canonical English-typography emphasis / \
5731 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5732 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5733 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5734 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5735 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5736 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5737 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5738 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5739 repeat-prior-command paste idiom), the English-typography `:caminho \
5740 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5741 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5742 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5743 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5744 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5745 subdirectory that fails at resolve time with a non-self-locating `No such file \
5746 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5747 the value verbatim in its per-dep content-address `path:{caminho}` at \
5748 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5749 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5750 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5751 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5752 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5753 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5754 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5755 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5756 name carries no shell-history-expansion / bang-operator semantic; drop any \
5757 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5758 idiom; and drop any trailing English-typography exclamation mark that pasted \
5759 from prose.",
5760 ch = *byte as char
5761 )]
5762 FonteCaminhoShellHistoryExpansion {
5763 nome: String,
5764 caminho: String,
5765 byte: u8,
5766 },
5767 #[error(
5768 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5769 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5770 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5771 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5772 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5773 substitution' history operator that rewrites the prior command's `old` string to \
5774 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5775 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5776 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5777 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5778 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5779 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5780 literal value diverges from every downstream `feira tofu` curl-invocation / \
5781 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5782 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5783 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5784 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5785 `std::path::Path` treats `^` as a literal path-component byte, so \
5786 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5787 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5788 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5789 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5790 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5791 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5792 that fails at resolve time with a non-self-locating `No such file or directory` \
5793 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5794 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5795 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5796 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5797 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5798 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5799 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5800 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5801 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5802 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5803 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5804 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5805 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5806 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5807 drop any trailing `^` history-substitution-open fragment.",
5808 ch = *byte as char
5809 )]
5810 FonteCaminhoShellHistorySubstitution {
5811 nome: String,
5812 caminho: String,
5813 byte: u8,
5814 },
5815 #[error(
5816 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5817 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5818 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5819 value verbatim in its per-dep content-address `path:{caminho}` at \
5820 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5821 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5822 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5823 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5824 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5825 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5826 trailing `/`; every `:caminho` value names a sibling-workspace directory \
5827 already, so the trailing separator carries no information. Use \
5828 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5829 )]
5830 FonteCaminhoTrailingSlash { nome: String, caminho: String },
5831 #[error(
5832 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5833 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5834 apply the same set-not-multiset discipline; one package per table), and \
5835 two entries naming the same caixa carry two version constraints / source \
5836 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5837 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5838 silently overwrites the first at the resolver-side `concrete_versao` step, \
5839 and the dropped entry's pin / features never reach the closure — far from \
5840 the source caixa.lisp, with no field naming which `:deps` entry was the \
5841 silent loser. If two version constraints are genuinely needed (the rare \
5842 multi-version closure case the lacre pipeline doesn't yet support), the \
5843 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5844 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5845 )]
5846 DuplicateNome { nome: String, list: &'static str },
5847 #[error(
5848 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5849 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5850 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5851 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5852 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5853 with the canonical kebab-case feature name the target caixa declares."
5854 )]
5855 CaracteristicaEmpty { nome: String },
5856 #[error(
5857 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5858 feature name: {reason} (the value flows verbatim into Cargo's \
5859 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5860 parser enforces the same shape at `cargo metadata` time; use a single-token \
5861 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5862 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5863 an ASCII alphanumeric or `_`)"
5864 )]
5865 CaracteristicaInvalid {
5866 nome: String,
5867 caracteristica: String,
5868 reason: String,
5869 },
5870 #[error(
5871 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5872 every feature-flag list keys its entries by name (Cargo's \
5873 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5874 per feature per dep), and two entries naming the same feature are a redundant \
5875 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5876 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5877 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5878 feature once regardless of declaration count, so the duplicate's pin / position never \
5879 reaches the closure with no field naming the silent loser. One entry per feature per \
5880 dep; if two distinct features are intended, name each verbatim."
5881 )]
5882 CaracteristicaDuplicate {
5883 nome: String,
5884 caracteristica: String,
5885 },
5886 #[error(
5887 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5888 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5889 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5890 rejects mid-traversal far from the source caixa.lisp or recurses on until \
5891 it exhausts its stack). Every :nome is globally-unique substrate identity, \
5892 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5893 *is* the parent itself, not a coincidentally-named peer. Drop the \
5894 self-referential dep entry — to reference code from this caixa, use \
5895 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5896 referencing the caixa's own code surface) instead."
5897 )]
5898 DepIsSelf { nome: String, list: &'static str },
5899}
5900
5901// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5902// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5903// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5904// variant — the paired `{ nome: String, caminho: String }` two-slot family
5905// on [`DepError`], sibling of the peer
5906// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5907// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5908// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5909// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5910// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5911// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5912// `{ de, para, wit, expected }`), and
5913// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5914// variants on `{ de, para, <field>: String, reason: String }`) on the
5915// `AplicacaoError` envelopes, the peer
5916// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5917// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5918// (0419438, 4 variants on `{ caixa, kind, slots }`),
5919// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5920// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5921// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5922// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5923// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5924// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5925// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5926// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5927//
5928// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5929// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5930// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5931// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5932// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5933// CommandSubstitution}` on the four single-byte shell operators; and the
5934// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5935// opened the identical `DepError::FonteCaminho<Variant> { nome:
5936// nome.to_string(), caminho: caminho.to_string() }` four-line
5937// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5938// — the exact "same block re-inlined at every consumer" shape the PRIME
5939// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5940// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5941// families each closed on their sibling envelopes. The eleven variants
5942// share one `{ nome: String, caminho: String }` shape, so the fold routes
5943// each wire-up site through one dispatch per typed variant.
5944//
5945// The macro below generates one `#[must_use]` inherent constructor per
5946// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5947// wire-up site collapses onto one dispatch:
5948// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5949// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5950// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5951// once — inside the macro — rather than at every wire-up site.
5952//
5953// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5954// shapes at the per-byte-classification arms — the
5955// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5956// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5957// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5958// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5959// cluster — carry an additional `byte: u8` naming the offending byte and
5960// so would break the uniform-two-field routing this macro promises. They
5961// instead fold onto the sibling three-field envelope through
5962// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5963// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5964// two-slot family is the `byte: u8` classification the arms carry. The
5965// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5966// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5967// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5968// envelope.
5969//
5970// Every future consumer that wants to construct one of these eleven
5971// variants outside the current in-crate [`DepSource::validate_caminho`]
5972// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5973// at lacre-resolve time re-checking the same value-shape axes the resolver
5974// consumes, a future `feira validate --deps` per-caixa admission verb
5975// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5976// rejecting a `:caminho` value against a cluster-local snapshot) now
5977// reaches each variant through one call rather than re-inlining the
5978// four-line struct-literal in lockstep with the eleven in-crate wire-up
5979// sites.
5980macro_rules! fonte_caminho_ctors {
5981 ($($ctor:ident => $variant:ident),* $(,)?) => {
5982 impl DepError {
5983 $(
5984 #[doc = concat!(
5985 "Construct a [`DepError::",
5986 stringify!($variant),
5987 "`] naming the offending `:deps :nome` + `:fonte ",
5988 "(:tipo path …) :caminho` pair. Folds the uniform ",
5989 "`Self::",
5990 stringify!($variant),
5991 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5992 "two-slot struct-literal onto one substrate primitive so ",
5993 "every [`DepSource::validate_caminho`] wire-up on this ",
5994 "variant reads through one dispatch rather than the ",
5995 "pre-lift four-line open-coded block."
5996 )]
5997 #[must_use]
5998 pub fn $ctor(nome: &str, caminho: &str) -> Self {
5999 Self::$variant {
6000 nome: nome.to_string(),
6001 caminho: caminho.to_string(),
6002 }
6003 }
6004 )*
6005 }
6006 };
6007}
6008
6009fonte_caminho_ctors! {
6010 fonte_caminho_absolute => FonteCaminhoAbsolute,
6011 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
6012 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
6013 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
6014 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
6015 fonte_caminho_backslash => FonteCaminhoBackslash,
6016 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
6017 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
6018 fonte_caminho_shell_background => FonteCaminhoShellBackground,
6019 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
6020 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
6021}
6022
6023// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
6024// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
6025// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
6026// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
6027// three-slot family on [`DepError`], strict sibling of the peer
6028// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
6029// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
6030// that fold onto the `byte`-classifying arms whose additional `byte: u8`
6031// axis broke its uniform-two-field routing — the exact "future compounding
6032// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
6033// here. Third fold family on this `DepError` envelope, sibling of the peer
6034// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
6035// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
6036// same enum.
6037//
6038// Each of the twelve wire-up sites on this shape (the control-byte arm
6039// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
6040// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
6041// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
6042// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
6043// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
6044// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
6045// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
6046// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
6047// `FonteCaminhoShellHistoryExpansion` on `!`, and
6048// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
6049// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
6050// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
6051// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
6052// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
6053// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
6054// closed on the sibling two-field envelope of this same enum. The twelve
6055// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
6056// the fold routes each wire-up site through one dispatch per typed variant.
6057//
6058// The macro below generates one `#[must_use]` inherent constructor per
6059// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
6060// so every wire-up site collapses onto one dispatch:
6061// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
6062// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
6063// three-field construction (`nome.to_string()` / `caminho.to_string()` /
6064// `byte`) is spelled once — inside the macro — rather than at every wire-up
6065// site.
6066//
6067// Every future consumer that wants to construct one of these twelve
6068// variants outside the current in-crate [`DepSource::validate_caminho`]
6069// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
6070// at lacre-resolve time re-checking the same value-shape axes the resolver
6071// consumes, a future `feira validate --deps` per-caixa admission verb
6072// re-checking the `:fonte :caminho` axis against the shell-metachar
6073// classification bytes this cluster catches, a per-lacre overlay resolver
6074// rejecting a `:caminho` value against a cluster-local snapshot) now
6075// reaches each variant through one call rather than re-inlining the
6076// five-line struct-literal in lockstep with the twelve in-crate wire-up
6077// sites.
6078macro_rules! fonte_caminho_byte_ctors {
6079 ($($ctor:ident => $variant:ident),* $(,)?) => {
6080 impl DepError {
6081 $(
6082 #[doc = concat!(
6083 "Construct a [`DepError::",
6084 stringify!($variant),
6085 "`] naming the offending `:deps :nome` + `:fonte ",
6086 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
6087 "classification. Folds the uniform `Self::",
6088 stringify!($variant),
6089 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
6090 "byte }` three-slot struct-literal onto one substrate ",
6091 "primitive so every [`DepSource::validate_caminho`] wire-up ",
6092 "on this variant reads through one dispatch rather than ",
6093 "the pre-lift five-line open-coded block."
6094 )]
6095 #[must_use]
6096 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
6097 Self::$variant {
6098 nome: nome.to_string(),
6099 caminho: caminho.to_string(),
6100 byte,
6101 }
6102 }
6103 )*
6104 }
6105 };
6106}
6107
6108fonte_caminho_byte_ctors! {
6109 fonte_caminho_control_char => FonteCaminhoControlChar,
6110 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
6111 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
6112 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
6113 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
6114 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
6115 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
6116 fonte_caminho_shell_comment => FonteCaminhoShellComment,
6117 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
6118 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
6119 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
6120 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
6121}
6122
6123// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
6124// single-slot struct-variant wire-up sites scattered across
6125// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
6126// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
6127// substrate primitive per typed variant — the paired `{ nome: String }`
6128// single-slot family on [`DepError`], sibling of the peer
6129// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
6130// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
6131// the same enum, and of the peer
6132// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
6133// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
6134// axis. Second fold family on this `DepError` envelope, and the first on
6135// the single-`{ nome }` shape.
6136//
6137// The five wire-up sites this fold closes each opened the identical
6138// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
6139// struct-literal against the same `nome: &str` (or `self.nome: &String`)
6140// local — the exact "same block re-inlined at every consumer" shape the
6141// PRIME DIRECTIVE names as a bug. The five variants share one
6142// `{ nome: String }` shape, so the fold routes each wire-up site through
6143// one dispatch per typed variant.
6144//
6145// The macro below generates one `#[must_use]` inherent constructor per
6146// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
6147// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
6148// pre-lift struct-literal on the same `&str` fixture. The uniform
6149// one-field construction (`nome.to_string()`) is spelled once — inside
6150// the macro — rather than at every wire-up site. Callers that hold a
6151// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
6152// and lets the macro-owned `.to_string()` produce the fresh owning copy
6153// the enum variant needs; the semantics collapse onto the same
6154// `.clone()`-equivalent one this fold replaces at every site.
6155//
6156// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
6157// on the same envelope stays on its pre-lift open-coded wire-up shape —
6158// it carries no `nome` field (the offending `:nome` value *is* the empty
6159// string this variant catches) so the uniform `fn(nome: &str) -> Self`
6160// signature this macro promises does not apply. Every future consumer
6161// that wants to construct one of these five variants outside the current
6162// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
6163// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
6164// re-validator at lacre-resolve time, a future `feira validate --deps`
6165// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
6166// these empty-value shapes against a cluster-local snapshot) now reaches
6167// each variant through one call rather than re-inlining the three-line
6168// struct-literal in lockstep with the five in-crate wire-up sites.
6169macro_rules! dep_nome_only_ctors {
6170 ($($ctor:ident => $variant:ident),* $(,)?) => {
6171 impl DepError {
6172 $(
6173 #[doc = concat!(
6174 "Construct a [`DepError::",
6175 stringify!($variant),
6176 "`] naming the offending `:deps :nome`. Folds the ",
6177 "uniform `Self::",
6178 stringify!($variant),
6179 " { nome: nome.to_string() }` one-field ",
6180 "struct-literal onto one substrate primitive so every ",
6181 "in-crate wire-up on this variant reads through one ",
6182 "dispatch rather than the pre-lift three-line ",
6183 "open-coded block."
6184 )]
6185 #[must_use]
6186 pub fn $ctor(nome: &str) -> Self {
6187 Self::$variant { nome: nome.to_string() }
6188 }
6189 )*
6190 }
6191 };
6192}
6193
6194dep_nome_only_ctors! {
6195 versao_empty => VersaoEmpty,
6196 fonte_repo_empty => FonteRepoEmpty,
6197 fonte_pin_missing => FontePinMissing,
6198 fonte_caminho_empty => FonteCaminhoEmpty,
6199 caracteristica_empty => CaracteristicaEmpty,
6200}
6201
6202// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
6203// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
6204// [`crate::manifest::Caixa::validate_deps`] +
6205// [`validate_no_self_dep`] onto one substrate-primitive family per
6206// typed variant — the `DepError`-side siblings of the peer
6207// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
6208// on the `SupervisorError { caixa: String }` one-slot envelope and of
6209// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
6210// `DepError { nome: String }` one-slot envelope. The two variants
6211// carry the same `{ nome: String, list: &'static str }` two-slot
6212// shape: the `nome` field names the offending dep the diagnostic
6213// points the author back at, and the `list` field carries the
6214// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
6215// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
6216// [`validate_deps`] arms, and via the paired
6217// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
6218// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
6219// canonicals on the [`validate_no_self_dep`] arm) so the author can
6220// grep their caixa.lisp for the offending list block in one edit.
6221//
6222// Each of the four wire-up sites opened the same struct-literal
6223// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
6224// two-line block — the exact "same block re-inlined at every
6225// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
6226// altitude the peer `DepError` / `SupervisorError` /
6227// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
6228// already closed on their sibling envelopes. The two `#[must_use]`
6229// inherent constructors below fold each wire-up onto one dispatch:
6230// `DepError::duplicate_nome(<nome>, <list>)` and
6231// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
6232// pre-lift struct-literal on the same scalar fixtures. The `list:
6233// &'static str` parameter (not `impl Into<String>`) preserves the
6234// exact wire tag every consumer already passes verbatim — no
6235// downstream diagnostic reshaping at the lift, matching the peer
6236// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
6237// contract each wire-up site already keys off.
6238macro_rules! dep_nome_list_ctors {
6239 ($($ctor:ident => $variant:ident),* $(,)?) => {
6240 impl DepError {
6241 $(
6242 #[doc = concat!(
6243 "Construct a [`DepError::",
6244 stringify!($variant),
6245 "`] naming the offending `:deps :nome` and the ",
6246 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
6247 "the diagnostic points the author back at. Folds ",
6248 "the uniform `Self::",
6249 stringify!($variant),
6250 " { nome: nome.to_string(), list }` two-field ",
6251 "struct-literal onto one substrate primitive so ",
6252 "every in-crate wire-up on this variant reads ",
6253 "through one dispatch rather than the pre-lift ",
6254 "open-coded struct-literal block."
6255 )]
6256 #[must_use]
6257 pub fn $ctor(nome: &str, list: &'static str) -> Self {
6258 Self::$variant { nome: nome.to_string(), list }
6259 }
6260 )*
6261 }
6262 };
6263}
6264
6265dep_nome_list_ctors! {
6266 duplicate_nome => DuplicateNome,
6267 dep_is_self => DepIsSelf,
6268}
6269
6270// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
6271// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
6272// <value>.to_string(), reason }` struct-variant wire-up sites at
6273// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
6274// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
6275// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
6276// primitive family per typed variant — the `DepError`-side siblings of the
6277// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
6278// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
6279// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
6280// the two-slot `{ nome, caminho }` envelope, and
6281// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
6282// caminho, byte }` envelope. The three variants share the same
6283// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
6284// the `nome` field names the offending dep the diagnostic points the
6285// author back at, the middle `<axis>: String` field carries the offending
6286// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
6287// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
6288// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
6289// field carries the parser-shaped rejection sentence the paired
6290// [`crate::render::require_valid_versao_requirement`] /
6291// [`crate::render::is_git_repo_url`] /
6292// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
6293// axis-field name differs across variants (`versao` / `repo` /
6294// `caracteristica`) so the ctor family below takes the axis field name as
6295// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
6296// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
6297// -> Self` inherent constructor per typed variant that spells the uniform
6298// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
6299// `reason` forwarded owned) exactly once. Peer of the sibling
6300// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
6301// family on the `AplicacaoError` envelope's mirror-symmetric
6302// `{ <field>: String, reason: String }` two-slot shape — same
6303// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
6304// one `nome`-axis added at the per-dep-owned altitude the `DepError`
6305// envelope keys off (every `DepError` variant carries the offending
6306// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
6307// offending block in one edit).
6308//
6309// The three wire-up sites this fold closes are:
6310// - [`DepSource::validate`]'s `:repo` value-shape arm
6311// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
6312// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
6313// rejects the offending URL);
6314// - [`Dep::validate`]'s `:versao` requirement-shape arm
6315// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
6316// self.versao_requirement().to_string(), reason }` inside the
6317// [`crate::render::require_valid_versao_requirement`] callback pair);
6318// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
6319// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
6320// caracteristica: c.clone(), reason })` after
6321// [`crate::render::is_cargo_feature_name`] rejects the offending
6322// feature-name).
6323//
6324// Each opened the identical five-line struct-literal against the same
6325// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
6326// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6327// same altitude the peer four already-lifted `DepError` ctor families
6328// closed on their sibling shape-envelopes. The three variant / axis-field
6329// discriminators are the only things that vary between them; the rest of
6330// the struct-literal is a byte-for-byte re-inline.
6331//
6332// Every future consumer wanting to raise one of these three diagnostics
6333// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
6334// time re-checking each declared dep against the same requirement +
6335// git-URL + feature-name value-shape cascade, a future `feira validate
6336// --deps` per-caixa admission verb re-running the shape gates on demand,
6337// a per-lacre overlay resolver rejecting an author-supplied dep against a
6338// cluster-local snapshot) now reaches one dispatch rather than re-inlining
6339// the five-line struct-literal in lockstep with the three in-crate
6340// wire-up sites.
6341macro_rules! dep_nome_axis_reason_ctors {
6342 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6343 impl DepError {
6344 $(
6345 #[doc = concat!(
6346 "Construct a [`DepError::",
6347 stringify!($variant),
6348 "`] naming the offending `:deps :nome`, the offending ",
6349 "`:", stringify!($axis), "` axis value, and the ",
6350 "parser-shaped rejection `reason`. Folds the uniform ",
6351 "`Self::",
6352 stringify!($variant),
6353 " { nome: nome.to_string(), ",
6354 stringify!($axis),
6355 ": ",
6356 stringify!($axis),
6357 ".to_string(), reason }` three-field struct-literal ",
6358 "onto one substrate primitive so every in-crate ",
6359 "wire-up on this variant reads through one dispatch ",
6360 "rather than the pre-lift five-line open-coded block. ",
6361 "The `nome: &str` and `",
6362 stringify!($axis),
6363 ": &str` parameters accept `&str` literals and ",
6364 "`&String` (via Deref coercion) so every existing ",
6365 "wire-up threads through the ctor without a ",
6366 "pre-conversion; the `reason: String` parameter takes ",
6367 "an owned `String` (not `impl Into<String>`) matching ",
6368 "the paired `crate::render::*` predicate's ",
6369 "`Result<(), String>` return shape every wire-up ",
6370 "already holds owned at the call site."
6371 )]
6372 #[must_use]
6373 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
6374 Self::$variant {
6375 nome: nome.to_string(),
6376 $axis: $axis.to_string(),
6377 reason,
6378 }
6379 }
6380 )*
6381 }
6382 };
6383}
6384
6385dep_nome_axis_reason_ctors! {
6386 versao_invalid => VersaoInvalid { versao },
6387 fonte_repo_shape => FonteRepoShape { repo },
6388 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
6389}
6390
6391// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
6392// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
6393// <value>.to_string() }` struct-variant wire-up sites at
6394// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
6395// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
6396// per-entry set-not-multiset dedup closure onto one substrate-primitive
6397// family per typed variant — the missing two-slot rung on the
6398// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
6399// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
6400// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
6401// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
6402// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
6403// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
6404// symmetric sibling of the peer
6405// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
6406// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
6407// envelope — same `<axis>: <value>.to_string()` owned-forward payload
6408// shape, `reason` axis removed and `nome`-axis added at the per-dep-
6409// owned altitude the `DepError` envelope keys off (every `DepError`
6410// variant carries the offending `:deps :nome` verbatim so the author
6411// can grep their caixa.lisp for the offending block in one edit). The
6412// three variants share the same `{ nome: String, <axis>: String }`
6413// two-slot shape: the `nome` field names the offending dep the
6414// diagnostic points the author back at, and the middle `<axis>:
6415// String` field carries the offending per-envelope axis value verbatim
6416// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
6417// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
6418// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
6419// The middle axis-field name differs across variants (`pin` / `pins` /
6420// `caracteristica`) so the ctor family below takes the axis field name
6421// as a macro parameter (`$axis:ident`) alongside the ctor + variant
6422// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
6423// Self` inherent constructor per typed variant that spells the
6424// uniform two-field construction (`nome.to_string()` /
6425// `<axis>.to_string()`) exactly once.
6426//
6427// The three wire-up sites this fold closes are:
6428// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
6429// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
6430// pin.to_string() });` inside the `set.len() == 1` branch after the
6431// `is_some_and(String::is_empty)` iterator);
6432// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
6433// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
6434// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
6435// - [`Dep::validate_caracteristicas`]'s per-entry
6436// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
6437// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
6438// [`crate::render::insert_first_seen`]).
6439//
6440// Each opened the identical four-line struct-literal against the same
6441// `(nome, <axis>)` local pair — the exact "same block re-inlined at
6442// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6443// same altitude the peer four already-lifted `DepError` ctor families
6444// closed on their sibling shape-envelopes. The three variant / axis-
6445// field discriminators are the only things that vary between them;
6446// the rest of the struct-literal is a byte-for-byte re-inline.
6447//
6448// Every future consumer wanting to raise one of these three
6449// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
6450// at lacre-resolve time re-checking each declared dep against the
6451// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
6452// set-not-multiset cascade, a future `feira validate --deps` per-
6453// caixa admission verb re-running the shape gates on demand, a
6454// per-lacre overlay resolver rejecting an author-supplied dep against
6455// a cluster-local snapshot the M4 CR materializer projects) now
6456// reaches one dispatch rather than re-inlining the four-line struct-
6457// literal in lockstep with the three in-crate wire-up sites.
6458macro_rules! dep_nome_axis_ctors {
6459 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6460 impl DepError {
6461 $(
6462 #[doc = concat!(
6463 "Construct a [`DepError::",
6464 stringify!($variant),
6465 "`] naming the offending `:deps :nome` and the ",
6466 "offending `:", stringify!($axis), "` axis value. ",
6467 "Folds the uniform `Self::",
6468 stringify!($variant),
6469 " { nome: nome.to_string(), ",
6470 stringify!($axis),
6471 ": ",
6472 stringify!($axis),
6473 ".to_string() }` two-field struct-literal onto one ",
6474 "substrate primitive so every in-crate wire-up on ",
6475 "this variant reads through one dispatch rather than ",
6476 "the pre-lift four-line open-coded block. Both `nome: ",
6477 "&str` and `",
6478 stringify!($axis),
6479 ": &str` parameters accept `&str` literals and ",
6480 "`&String` (via Deref coercion) so every existing ",
6481 "wire-up threads through the ctor without a pre-",
6482 "conversion."
6483 )]
6484 #[must_use]
6485 pub fn $ctor(nome: &str, $axis: &str) -> Self {
6486 Self::$variant {
6487 nome: nome.to_string(),
6488 $axis: $axis.to_string(),
6489 }
6490 }
6491 )*
6492 }
6493 };
6494}
6495
6496dep_nome_axis_ctors! {
6497 fonte_pin_empty => FontePinEmpty { pin },
6498 fonte_pin_ambiguous => FontePinAmbiguous { pins },
6499 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
6500}
6501
6502// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
6503// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
6504// struct-variant wire-up sites at [`DepSource::validate`]'s
6505// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
6506// the `DepError` envelope — the last open-coded ctor site remaining on
6507// the `:fonte (:tipo git …)` value-shape trajectory this envelope
6508// carries, and the single-variant sibling of the peer four already-
6509// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
6510// on the two-slot `{ nome, caminho }` envelope,
6511// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
6512// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
6513// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
6514// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
6515// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
6516// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
6517// `{ …, value: String, reason: String }` payload shape, one axis
6518// removed at the `nome`-only-owner altitude the `DepError` envelope
6519// keys off (no `edge_pair()` de/para pair).
6520//
6521// The two wire-up sites this fold closes are the paired refname-pin
6522// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
6523// pin: pin.to_string(), value: v.clone(), reason }` inside the
6524// `[(":tag", tag), (":branch", branch)]` iterator against
6525// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
6526// (`|| DepError::FontePinShape { nome: nome.to_string(),
6527// pin: ":rev".to_string(), value: v.clone(), reason }` against
6528// [`crate::render::is_git_oid`]) — each opened the identical
6529// `DepError::FontePinShape { … }` six-line struct-literal against the
6530// same `(nome: &str, pin: &str, v: &String, reason: String)` local
6531// tuple, the exact "same block re-inlined at every consumer" shape
6532// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
6533// the only thing that varies between them (`":tag"`/`":branch"` on
6534// the refname arm, `":rev"` on the hex-OID arm); the rest of the
6535// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
6536// route through the same ctor because their `pin` field carries the
6537// author-surface tag verbatim (matching the `FontePinEmpty` /
6538// `FontePinAmbiguous` sibling variants' `pin: String` axis
6539// convention), so the offending author can grep their caixa.lisp for
6540// the offending `:tag "<value>"` / `:branch "<value>"` /
6541// `:rev "<value>"` literal in one edit.
6542//
6543// The single ctor below folds each wire-up onto one dispatch:
6544// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
6545// the pre-lift struct-literal on the same `(&str, &str, &str,
6546// String)` fixture. The uniform four-field construction
6547// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
6548// `reason` forwarded owned) is spelled once here rather than at every
6549// wire-up site. The `reason: String` field takes an owned `String`
6550// (not `impl Into<String>`) matching the two call sites' pre-existing
6551// `let Err(reason) = crate::render::is_git_ref_name(v)` /
6552// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
6553// predicates return `Result<(), String>`, so the caller always holds
6554// an owned `String` at the wire-up site and threading it through the
6555// ctor without a `.into()` shim keeps the routing shape byte-equal to
6556// the pre-lift block. The `value: &str` parameter accepts both `&str`
6557// literals (unused today) and `&String` (from the caller-held
6558// `v: &String` on each arm, via Deref coercion), so every existing
6559// wire-up threads through the ctor without a pre-conversion.
6560//
6561// Every future consumer that wants to construct this variant outside
6562// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
6563// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
6564// re-checking the same value-shape axes the resolver consumes, a
6565// future `feira validate --deps` per-caixa admission verb re-checking
6566// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
6567// resolver rejecting a git-pin value against a cluster-local
6568// snapshot) now reaches this variant through one call rather than
6569// re-inlining the six-line struct-literal in lockstep with the two
6570// in-crate wire-up sites.
6571impl DepError {
6572 /// Construct a [`DepError::FontePinShape`] naming the offending
6573 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
6574 /// axis tag, the offending value, and the parser-shaped `reason`.
6575 /// Folds the uniform
6576 /// `Self::FontePinShape { nome: nome.to_string(),
6577 /// pin: pin.to_string(), value: value.to_string(), reason }`
6578 /// four-field struct-literal onto one substrate primitive so
6579 /// every [`DepSource::validate`] wire-up on this variant reads
6580 /// through one dispatch rather than the pre-lift six-line
6581 /// open-coded block. The `nome` string threads verbatim from
6582 /// [`Dep::nome`] at the call site; the `pin` string carries the
6583 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
6584 /// `value` string carries the offending refname / hex-OID
6585 /// verbatim; and `reason` forwards the owned `String` returned
6586 /// by [`crate::render::is_git_ref_name`] /
6587 /// [`crate::render::is_git_oid`] without a `.into()` shim.
6588 #[must_use]
6589 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
6590 Self::FontePinShape {
6591 nome: nome.to_string(),
6592 pin: pin.to_string(),
6593 value: value.to_string(),
6594 reason,
6595 }
6596 }
6597
6598 /// Construct a [`DepError::NomeInvalid`] naming the offending
6599 /// `:deps :nome` byte-string and the parser-shaped rejection
6600 /// `reason` returned by [`crate::render::is_dns_1123_label`].
6601 ///
6602 /// Folds the uniform
6603 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
6604 /// struct-literal onto one substrate primitive so every wire-up on
6605 /// this variant reads through one dispatch rather than the pre-lift
6606 /// four-line open-coded `DepError::NomeInvalid { nome:
6607 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
6608 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
6609 /// ctor-family ladder (`{ nome }` one-slot →
6610 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
6611 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
6612 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
6613 /// `{ nome, <axis>: String, reason: String }` three-slot →
6614 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
6615 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
6616 /// — the sole variant on the envelope carrying the
6617 /// `{ nome: String, reason: String }` two-slot shape without a
6618 /// middle axis, matching the peer
6619 /// [`crate::manifest::ManifestError::NomeInvalid`] +
6620 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
6621 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
6622 /// four-axis DNS-1123 caixa-identifier diagnostic family the
6623 /// existing `nome_invalid_diagnostic_carries_offending_name` test
6624 /// pins on this envelope.
6625 ///
6626 /// The `nome: &str` parameter accepts `&str` literals and `&String`
6627 /// (via Deref coercion) so the sole in-crate wire-up threads through
6628 /// the ctor without a pre-conversion; the `reason: String`
6629 /// parameter takes an owned `String` (not `impl Into<String>`)
6630 /// matching the [`crate::render::is_dns_1123_label`] predicate's
6631 /// `Result<(), String>` return shape the sole wire-up site already
6632 /// holds owned at the call site, keeping the routing byte-equal to
6633 /// the pre-lift block. Same owned-`String`-forward `reason` payload
6634 /// discipline as the sibling three-slot family
6635 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
6636 /// and the four-slot [`DepError::fonte_pin_shape`] on
6637 /// `{ nome, pin, value, reason }`.
6638 ///
6639 /// Every future consumer that raises the same diagnostic outside
6640 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
6641 /// re-validator at lacre-resolve time re-checking each declared
6642 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
6643 /// side schema uses (the `:nome` value flows verbatim as the target
6644 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
6645 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
6646 /// checkout-directory leaf), a future `feira validate --deps`
6647 /// per-caixa admission verb re-running the shape gate on demand, a
6648 /// per-lacre overlay resolver rejecting an author-supplied dep's
6649 /// `:nome` against a cluster-local snapshot the M4 CR materializer
6650 /// projects, a future authoring-surface widening the field into a
6651 /// `(String, Vec<Suggestion>)` pair carrying a
6652 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6653 /// variant through one call rather than re-inlining the four-line
6654 /// struct-literal in lockstep with the one in-crate wire-up site.
6655 #[must_use]
6656 pub fn nome_invalid(nome: &str, reason: String) -> Self {
6657 Self::NomeInvalid {
6658 nome: nome.to_string(),
6659 reason,
6660 }
6661 }
6662}
6663
6664#[allow(clippy::trivially_copy_pass_by_ref)]
6665fn is_false(b: &bool) -> bool {
6666 !*b
6667}
6668
6669#[cfg(test)]
6670mod tests {
6671 use super::*;
6672
6673 #[test]
6674 fn registry_dep_is_minimal() {
6675 let d = Dep::simple("caixa-teia", "^0.1");
6676 assert_eq!(d.nome, "caixa-teia");
6677 assert_eq!(d.versao, "^0.1");
6678 assert!(d.fonte.is_none());
6679 assert!(!d.opcional());
6680 assert!(d.caracteristicas().is_empty());
6681 }
6682
6683 #[test]
6684 fn dep_string_scalar_accessor_pair_is_const_fn() {
6685 // Fail-before-pass-after pin on [`Dep::nome`] +
6686 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6687 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6688 // entry's [`String`] storage through the `pub const fn`
6689 // [`String::as_str`] (const-stable since Rust 1.87, well
6690 // within the workspace MSRV) — any future accidental
6691 // downgrade to non-`const` fails the corresponding
6692 // `<name>_via_const_fn` wrapper at caixa-core build time with
6693 // E0015 (`cannot call non-const method`), strictly stronger
6694 // than a runtime `assert!`. Sibling of the peer
6695 // per-M2/M3/universal-axis `String → &str` scalar-accessor
6696 // family pins on the sibling `const`-eval-surface passes
6697 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6698 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6699 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6700 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6701 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6702 // [`crate::aplicacao::Entrada::destination`] at the M3
6703 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6704 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6705 // M2 supervisor-tree axis,
6706 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6707 // M2 upgrade axis, and the per-`:contratos`
6708 // [`crate::aplicacao::WitContract::source`] /
6709 // [`crate::aplicacao::WitContract::destination`] /
6710 // [`crate::aplicacao::WitContract::world_ref`] trio the
6711 // sibling pin at 279823b already anchors).
6712 const fn nome_via_const_fn(d: &Dep) -> &str {
6713 d.nome()
6714 }
6715 const fn versao_via_const_fn(d: &Dep) -> &str {
6716 d.versao_requirement()
6717 }
6718 for (nome, versao) in [
6719 ("caixa-teia", "^0.1"),
6720 ("caixa-mesh", "~0.2.3"),
6721 ("caixa-helm", "*"),
6722 ] {
6723 let d = Dep::simple(nome, versao);
6724 assert_eq!(nome_via_const_fn(&d), d.nome());
6725 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6726 assert_eq!(d.nome(), nome);
6727 assert_eq!(d.versao_requirement(), versao);
6728 }
6729 }
6730
6731 #[test]
6732 fn dep_outer_accessor_family_is_const_fn() {
6733 // Fail-before-pass-after pin on [`Dep::fonte`] +
6734 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6735 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6736 // entry's composite / list storage through a `pub const fn`
6737 // stdlib method (`Option::<DepSource>::as_ref` /
6738 // `Vec::<String>::as_slice`, both const-stable since Rust
6739 // 1.83, well within the workspace MSRV). Any future
6740 // accidental downgrade to non-`const` fails the corresponding
6741 // `<name>_via_const_fn` wrapper at caixa-core build time with
6742 // E0015 (`cannot call non-const method`), strictly stronger
6743 // than a runtime `assert!` and side-stepping the destructor-
6744 // in-const restriction the `Dep` fixture's `String` /
6745 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6746 // direct-`const _: () = assert!(...)` residence.
6747 //
6748 // Peer of the sibling per-`Dep` scalar-accessor pair pin
6749 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6750 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6751 // the `const`-eval-surface discipline onto the composite-
6752 // reference and slice-return arms of the outer-`Dep` accessor
6753 // family, closing the four-slot outer surface (`:nome` +
6754 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6755 // posture. The `:opcional` `bool` arm already carries the
6756 // posture through [`Dep::opcional`]'s prior `pub const fn`
6757 // declaration, so this pin lands the last two unlifted
6758 // outer-`Dep` accessors and closes the family.
6759 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6760 d.fonte()
6761 }
6762 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6763 d.caracteristicas()
6764 }
6765 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6766 let empty = Dep::simple("caixa-teia", "^0.1");
6767 assert!(fonte_via_const_fn(&empty).is_none());
6768 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6769 assert!(caracteristicas_via_const_fn(&empty).is_empty());
6770 assert_eq!(
6771 caracteristicas_via_const_fn(&empty),
6772 empty.caracteristicas()
6773 );
6774 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6775 // still empty.
6776 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6777 assert!(fonte_via_const_fn(&git).is_some());
6778 assert_eq!(fonte_via_const_fn(&git), git.fonte());
6779 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6780 // Populated `:caracteristicas` — exercise the non-empty
6781 // slice-view arm to pin the accessor's borrow shape against
6782 // both a `Vec::new()` empty backing buffer and a populated one.
6783 let mut with_features = Dep::simple("caixa-teia", "^0.1");
6784 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6785 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6786 assert_eq!(
6787 caracteristicas_via_const_fn(&with_features),
6788 with_features.caracteristicas()
6789 );
6790 }
6791
6792 #[test]
6793 fn git_dep_carries_tag() {
6794 let d = Dep::git("t", "*", "github:o/r", "v1");
6795 match d.fonte {
6796 Some(DepSource::Git {
6797 ref repo, ref tag, ..
6798 }) => {
6799 assert_eq!(repo, "github:o/r");
6800 assert_eq!(tag.as_deref(), Some("v1"));
6801 }
6802 _ => panic!("expected Git source"),
6803 }
6804 }
6805
6806 #[test]
6807 fn validate_accepts_simple_dep() {
6808 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6809 }
6810
6811 #[test]
6812 fn validate_rejects_empty_nome() {
6813 // The fail-before-pass-after pin for `:nome ""`: the empty-name
6814 // arm fires first so the per-entry parse-side diagnostic doesn't
6815 // emit a useless `nome: ""` reference.
6816 let mut d = Dep::simple("placeholder", "^0.1");
6817 d.nome = String::new();
6818 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6819 }
6820
6821 #[test]
6822 fn validate_rejects_empty_versao() {
6823 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6824 // semver crate accepts the empty string as a wildcard match),
6825 // so the empty-`:versao` arm is structurally necessary even
6826 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6827 // `EmptyChildVersion` ordering on the other two `:versao` axes.
6828 let mut d = Dep::simple("caixa-teia", "ignored");
6829 d.versao = String::new();
6830 let err = d.validate().unwrap_err();
6831 assert!(
6832 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6833 "got {err:?}"
6834 );
6835 }
6836
6837 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6838
6839 #[test]
6840 fn validate_rejects_nome_with_uppercase() {
6841 // The fail-before-pass-after pin: a non-empty but uppercase
6842 // `:nome` silently passed `validate()` on every pre-gate
6843 // codebase because the prior shape only refused the empty
6844 // string. The DNS-1123 violation surfaced far downstream at
6845 // lacre-resolve time when the *target* caixa's `:nome` failed
6846 // its own gate — far from the `:deps` entry, with a diagnostic
6847 // naming the target rather than the dep entry that referenced
6848 // it. Same fail-before-pass-after fixture pinned for
6849 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6850 // and Caixa `:nome` (6c992f8).
6851 let d = Dep::simple("Caixa-Teia", "^0.1");
6852 let err = d.validate().unwrap_err();
6853 assert!(
6854 matches!(
6855 err,
6856 DepError::NomeInvalid { ref nome, ref reason }
6857 if nome == "Caixa-Teia" && reason.contains("uppercase")
6858 ),
6859 "got {err:?}"
6860 );
6861 }
6862
6863 #[test]
6864 fn validate_rejects_nome_with_underscore() {
6865 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6866 // "I'm thinking of Go module names / Python identifiers" leak.
6867 // Same fixture pinned for the peer caixa-identifier axes.
6868 let d = Dep::simple("caixa_teia", "^0.1");
6869 let err = d.validate().unwrap_err();
6870 assert!(
6871 matches!(
6872 err,
6873 DepError::NomeInvalid { ref nome, ref reason }
6874 if nome == "caixa_teia" && reason.contains('_')
6875 ),
6876 "got {err:?}"
6877 );
6878 }
6879
6880 #[test]
6881 fn validate_rejects_nome_with_dot() {
6882 // A `:deps :nome` is a single DNS-1123 *label*, not a
6883 // subdomain — dots are rejected. The `"caixa.teia"` shape is
6884 // the canonical "I confused the dep name with the FQDN /
6885 // namespace" footgun, distinct from the legitimate
6886 // `:fonte :repo "github:org/caixa-teia"` axis.
6887 let d = Dep::simple("caixa.teia", "^0.1");
6888 let err = d.validate().unwrap_err();
6889 assert!(
6890 matches!(
6891 err,
6892 DepError::NomeInvalid { ref nome, ref reason }
6893 if nome == "caixa.teia" && reason.contains('.')
6894 ),
6895 "got {err:?}"
6896 );
6897 }
6898
6899 #[test]
6900 fn validate_rejects_nome_with_leading_hyphen() {
6901 // RFC 1123 requires alphanumeric at both label boundaries.
6902 // Pinned in parity with the peer DNS-1123 fixtures.
6903 let d = Dep::simple("-caixa-teia", "^0.1");
6904 let err = d.validate().unwrap_err();
6905 assert!(
6906 matches!(
6907 err,
6908 DepError::NomeInvalid { ref nome, ref reason }
6909 if nome == "-caixa-teia" && reason.contains("alphanumeric")
6910 ),
6911 "got {err:?}"
6912 );
6913 }
6914
6915 #[test]
6916 fn validate_rejects_nome_with_trailing_hyphen() {
6917 let d = Dep::simple("caixa-teia-", "^0.1");
6918 let err = d.validate().unwrap_err();
6919 assert!(
6920 matches!(
6921 err,
6922 DepError::NomeInvalid { ref nome, ref reason }
6923 if nome == "caixa-teia-" && reason.contains("alphanumeric")
6924 ),
6925 "got {err:?}"
6926 );
6927 }
6928
6929 #[test]
6930 fn validate_rejects_nome_with_slash() {
6931 // The canonical "I copied the GitHub repo path into `:nome`
6932 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6933 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6934 // the local-name slot. Same fixture pinned for `:membros
6935 // :caixa` (3f9d7a0).
6936 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6937 let err = d.validate().unwrap_err();
6938 assert!(
6939 matches!(
6940 err,
6941 DepError::NomeInvalid { ref nome, ref reason }
6942 if nome == "pleme-io/caixa-teia" && reason.contains('/')
6943 ),
6944 "got {err:?}"
6945 );
6946 }
6947
6948 #[test]
6949 fn validate_rejects_nome_too_long() {
6950 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6951 // Built from a valid character set so the length-bound
6952 // diagnostic surfaces before any per-character check (the
6953 // order pin parallel to the per-character predicates inside
6954 // [`crate::render::is_dns_1123_label`]).
6955 let long = "a".repeat(64);
6956 let d = Dep::simple(&long, "^0.1");
6957 let err = d.validate().unwrap_err();
6958 assert!(
6959 matches!(
6960 err,
6961 DepError::NomeInvalid { ref nome, ref reason }
6962 if nome.len() == 64 && reason.contains("max length of 63")
6963 ),
6964 "got {err:?}"
6965 );
6966 }
6967
6968 #[test]
6969 fn validate_accepts_canonical_nome_labels() {
6970 // Positive-control sweep — every form the K8s apiserver
6971 // accepts as a DNS-1123 label must round-trip through
6972 // validate. Covers a hyphen-bearing label, a numeric-suffix
6973 // label, a leading-digit label, a single-character label, and
6974 // a 63-byte (exactly the cap) label — the same fixture set
6975 // the peer `:membros :caixa` / `:children :caixa` positive
6976 // controls pin.
6977 for nome in [
6978 "caixa-teia",
6979 "caixa-resolver2",
6980 "2nd-tier-cache",
6981 "x",
6982 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6983 ] {
6984 Dep::simple(nome, "^0.1")
6985 .validate()
6986 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6987 }
6988 }
6989
6990 #[test]
6991 fn nome_empty_takes_precedence_over_nome_invalid() {
6992 // Ordering pin: `NomeEmpty` is the more self-locating
6993 // diagnostic on `""` and must lead — `is_dns_1123_label` is
6994 // only reached after the empty-check fires at the call site.
6995 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6996 // (3f9d7a0) on the peer caixa-identifier axis.
6997 let mut d = Dep::simple("placeholder", "^0.1");
6998 d.nome = String::new();
6999 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
7000 }
7001
7002 #[test]
7003 fn nome_invalid_fires_before_versao_empty() {
7004 // Ordering pin: a malformed `:nome` fires before any `:versao`
7005 // axis check on the *same* entry — the per-entry shape gates
7006 // run top-to-bottom (nome empty → nome shape → versao empty →
7007 // versao parse → fonte shape), so a one-entry caixa.lisp with
7008 // both wrong sees the name-side diagnostic first (the name is
7009 // the self-locating axis — without a valid name, the parse
7010 // diagnostic can't quote `:nome "<bad>"`). Same ordering
7011 // discipline as `membro_caixa_invalid_fires_before_versao_check`
7012 // (3f9d7a0).
7013 let mut d = Dep::simple("Caixa-Teia", "^0.1");
7014 d.versao = String::new();
7015 let err = d.validate().unwrap_err();
7016 assert!(
7017 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
7018 "got {err:?}"
7019 );
7020 }
7021
7022 #[test]
7023 fn nome_invalid_fires_before_versao_invalid() {
7024 // Ordering pin: a malformed `:nome` fires before the `:versao`
7025 // parse-side check on the *same* entry. Pin separately from
7026 // the empty-versao ordering so a future re-ordering surfaces
7027 // here, parallel to the b0c8389 / c4213a4 trajectory.
7028 let d = Dep::simple("Caixa-Teia", "^^0.1");
7029 let err = d.validate().unwrap_err();
7030 assert!(
7031 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
7032 "got {err:?}"
7033 );
7034 }
7035
7036 #[test]
7037 fn nome_invalid_fires_before_fonte_invalid() {
7038 // Ordering pin: a malformed `:nome` fires before the `:fonte`
7039 // shape check on the *same* entry. The `:fonte` diagnostic
7040 // names the offending dep's `:nome` verbatim (via
7041 // `DepSource::validate(&self.nome)`), so a non-self-locating
7042 // name would taint the downstream diagnostic too — the gate
7043 // ordering keeps both diagnostics individually self-locating.
7044 let mut d = Dep::simple("Caixa-Teia", "^0.1");
7045 d.fonte = Some(DepSource::Git {
7046 repo: String::new(),
7047 tag: None,
7048 rev: None,
7049 branch: None,
7050 });
7051 let err = d.validate().unwrap_err();
7052 assert!(
7053 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
7054 "got {err:?}"
7055 );
7056 }
7057
7058 #[test]
7059 fn nome_invalid_diagnostic_carries_offending_name() {
7060 // The diagnostic-shape pin: the error names the offending
7061 // `:nome` value verbatim so the author can grep their
7062 // caixa.lisp without re-running the build, and carries a
7063 // non-empty `reason` from `is_dns_1123_label` so the
7064 // predicate's own wording flows through to the diagnostic.
7065 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
7066 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
7067 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
7068 // share a structurally-equivalent diagnostic family.
7069 let d = Dep::simple("Caixa_Teia", "^0.1");
7070 let err = d.validate().unwrap_err();
7071 let DepError::NomeInvalid { nome, reason } = err else {
7072 panic!("expected NomeInvalid, got other variant");
7073 };
7074 assert_eq!(nome, "Caixa_Teia");
7075 assert!(
7076 !reason.is_empty(),
7077 "NomeInvalid `reason` must carry the predicate's wording verbatim"
7078 );
7079 }
7080
7081 #[test]
7082 fn validate_rejects_invalid_versao_requirement() {
7083 // The fail-before-pass-after pin: a non-empty but malformed
7084 // requirement (`"^bad-version"`) silently passed every pre-gate
7085 // codebase because `:deps :versao` wasn't validated. The parse
7086 // failure surfaced far downstream at lacre-resolve time with a
7087 // `semver::Error` that didn't name which `:deps` entry carried
7088 // the typo. The new gate moves the check to caixa-build time
7089 // at the source caixa.lisp.
7090 let d = Dep::simple("caixa-teia", "^bad-version");
7091 let err = d.validate().unwrap_err();
7092 assert!(
7093 matches!(
7094 err,
7095 DepError::VersaoInvalid { ref nome, ref versao, .. }
7096 if nome == "caixa-teia" && versao == "^bad-version"
7097 ),
7098 "got {err:?}"
7099 );
7100 }
7101
7102 #[test]
7103 fn validate_rejects_versao_with_double_caret_typo() {
7104 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
7105 // Cargo-shaped requirement on first glance but fails the parser
7106 // because semver doesn't accept stacked operators. Pin this
7107 // adjacent-shape footgun explicitly so a future relaxation that
7108 // accepts "looks-canonical-but-isn't" forms surfaces here, in
7109 // parity with the `:membros` / `:children` fixtures.
7110 let d = Dep::simple("caixa-teia", "^^0.1");
7111 let err = d.validate().unwrap_err();
7112 assert!(
7113 matches!(
7114 err,
7115 DepError::VersaoInvalid { ref nome, ref versao, .. }
7116 if nome == "caixa-teia" && versao == "^^0.1"
7117 ),
7118 "got {err:?}"
7119 );
7120 }
7121
7122 #[test]
7123 fn validate_rejects_versao_with_v_prefixed_tag() {
7124 // `"v0.1"` is the canonical "git-tag-shape leaking into the
7125 // semver requirement slot" typo — an author copies the
7126 // publish-side git-tag string verbatim into `:versao`, but
7127 // Cargo's semver parser rejects the leading `v`. Same fixture
7128 // pinned for `:membros :versao` (9888b13) and `:children
7129 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
7130 // are *accepted* by the semver crate as an `*` wildcard on the
7131 // patch axis — they're a Cargo-side valid shape, not a typo.)
7132 let d = Dep::simple("caixa-teia", "v0.1");
7133 let err = d.validate().unwrap_err();
7134 assert!(
7135 matches!(
7136 err,
7137 DepError::VersaoInvalid { ref nome, ref versao, .. }
7138 if nome == "caixa-teia" && versao == "v0.1"
7139 ),
7140 "got {err:?}"
7141 );
7142 }
7143
7144 #[test]
7145 fn validate_accepts_canonical_versao_forms() {
7146 // The five Cargo-shaped requirement forms `:membros :versao`
7147 // and `:children :versao` already accept via
7148 // `crate::parse_requirement` must pass the deps gate without
7149 // re-validating at the resolver layer. Pin every leg so a
7150 // future tightening of the canonical set surfaces here as a
7151 // test failure.
7152 for form in [
7153 "^0.1", // caret — minor-range pin (the most common shape)
7154 "~0.1.2", // tilde — patch-range pin
7155 "0.1.0", // exact — single-version pin
7156 "*", // wildcard — explicitly any-version
7157 ">=0.1, <2", // multi-range — comma-separated comparators
7158 ] {
7159 Dep::simple("caixa-teia", form)
7160 .validate()
7161 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
7162 }
7163 }
7164
7165 #[test]
7166 fn versao_empty_takes_precedence_over_invalid() {
7167 // Order pin: the existing `VersaoEmpty` diagnostic (which
7168 // doesn't try to parse) fires before the new `VersaoInvalid`
7169 // parse-side diagnostic, so an empty `:versao` keeps its
7170 // narrower error message — `parse_requirement("")` would
7171 // otherwise return `Ok(STAR)` and silently pass, but the empty
7172 // arm catches it first.
7173 let mut d = Dep::simple("caixa-teia", "ignored");
7174 d.versao = String::new();
7175 let err = d.validate().unwrap_err();
7176 assert!(
7177 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
7178 "got {err:?}"
7179 );
7180 }
7181
7182 #[test]
7183 fn nome_empty_takes_precedence_over_versao_invalid() {
7184 // Order pin: even when `:versao` is malformed and would raise
7185 // its own diagnostic, `:nome ""` fires first because the
7186 // per-entry parse diagnostic needs a non-empty name to be
7187 // self-locating. Mirrors the
7188 // `membros_validation_runs_before_contratos_membership_check`
7189 // ordering on the typed-graph layer.
7190 let mut d = Dep::simple("placeholder", "^bad");
7191 d.nome = String::new();
7192 let err = d.validate().unwrap_err();
7193 assert_eq!(err, DepError::NomeEmpty);
7194 }
7195
7196 #[test]
7197 fn versao_invalid_diagnostic_carries_offending_versao() {
7198 // The diagnostic-shape pin: the error names the offending
7199 // `:versao` value verbatim so the author can grep their
7200 // caixa.lisp without re-running the build, and carries a
7201 // non-empty `reason` from `semver::VersionReq::parse` so the
7202 // parser's own wording flows through to the diagnostic.
7203 let d = Dep::simple("caixa-teia", "not-a-req");
7204 let err = d.validate().unwrap_err();
7205 let DepError::VersaoInvalid {
7206 nome,
7207 versao,
7208 reason,
7209 } = err
7210 else {
7211 panic!("expected VersaoInvalid, got other variant");
7212 };
7213 assert_eq!(nome, "caixa-teia");
7214 assert_eq!(versao, "not-a-req");
7215 assert!(
7216 !reason.is_empty(),
7217 "VersaoInvalid `reason` must carry the parser's wording verbatim"
7218 );
7219 }
7220
7221 // -- :fonte value-shape gate ------------------------------------------
7222
7223 fn dep_with_fonte(fonte: DepSource) -> Dep {
7224 let mut d = Dep::simple("caixa-teia", "^0.1");
7225 d.fonte = Some(fonte);
7226 d
7227 }
7228
7229 #[test]
7230 fn validate_accepts_git_fonte_with_tag() {
7231 // The positive-control pin on the canonical git source — exactly
7232 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
7233 // shape every existing caixa-resolver integration test uses.
7234 let d = dep_with_fonte(DepSource::Git {
7235 repo: "github:pleme-io/caixa-teia".into(),
7236 tag: Some("v0.1.0".into()),
7237 rev: None,
7238 branch: None,
7239 });
7240 d.validate().unwrap();
7241 }
7242
7243 #[test]
7244 fn validate_accepts_git_fonte_with_rev() {
7245 // Each of the three pin axes is independently a valid single-pin
7246 // shape; pin the :rev arm so a future relaxation that only
7247 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
7248 // OID — the canonical `git rev-parse HEAD` emission shape the
7249 // `crate::render::is_git_oid` value-shape gate now requires;
7250 // abbreviated OIDs are ambiguous across repo history and
7251 // rejected at this gate (pinned separately by
7252 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
7253 let d = dep_with_fonte(DepSource::Git {
7254 repo: "github:pleme-io/caixa-teia".into(),
7255 tag: None,
7256 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
7257 branch: None,
7258 });
7259 d.validate().unwrap();
7260 }
7261
7262 #[test]
7263 fn validate_accepts_git_fonte_with_branch() {
7264 // The :branch arm is the third valid single-pin shape — pinned
7265 // separately so the gate-accepts-all-three-pin-axes contract is
7266 // a build-error to relax.
7267 let d = dep_with_fonte(DepSource::Git {
7268 repo: "github:pleme-io/caixa-teia".into(),
7269 tag: None,
7270 rev: None,
7271 branch: Some("main".into()),
7272 });
7273 d.validate().unwrap();
7274 }
7275
7276 #[test]
7277 fn validate_accepts_path_fonte() {
7278 // The positive-control pin on the path source — non-empty
7279 // :caminho, no pin axes (paths have no commit identity). Pinned
7280 // so a future "paths must also pin a rev" tightening surfaces
7281 // here as a structural decision, not a silent break.
7282 let d = dep_with_fonte(DepSource::Path {
7283 caminho: "../caixa-teia".into(),
7284 });
7285 d.validate().unwrap();
7286 }
7287
7288 #[test]
7289 fn validate_rejects_git_fonte_with_empty_repo() {
7290 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
7291 // "v1")`: the empty-repo shape silently passed every pre-gate
7292 // codebase because `:fonte` wasn't validated. The git-clone
7293 // failure surfaced far downstream at lacre-resolve time with no
7294 // field naming which `:deps` entry carried the typo. The new
7295 // gate moves the check to caixa-build time at the source
7296 // caixa.lisp.
7297 let d = dep_with_fonte(DepSource::Git {
7298 repo: String::new(),
7299 tag: Some("v0.1.0".into()),
7300 rev: None,
7301 branch: None,
7302 });
7303 let err = d.validate().unwrap_err();
7304 assert!(
7305 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
7306 "got {err:?}"
7307 );
7308 }
7309
7310 // -- :repo value-shape gate -------------------------------------------
7311 //
7312 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
7313 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
7314 // codebase admitted any non-empty string; the new
7315 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
7316 // URL intersection-floor at validate time, peer with the three pin
7317 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
7318 // `is_git_oid`). Every test in this section is a fail-before /
7319 // pass-after pin on a specific authoring footgun.
7320
7321 #[test]
7322 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
7323 // The canonical paste-from-doc footgun on `:repo` — an author
7324 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
7325 // a doc paragraph. Until this gate landed the empty-repo arm
7326 // passed (the string isn't empty), the resolver issued
7327 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
7328 // surfaced at clone time with a quoting-confused error far from
7329 // the source caixa.lisp. Same paste-from-doc footgun the
7330 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
7331 // axis — now closed on the `:repo` URL axis too.
7332 let d = dep_with_fonte(DepSource::Git {
7333 repo: "github:pleme-io/caixa-teia ".into(),
7334 tag: Some("v0.1.0".into()),
7335 rev: None,
7336 branch: None,
7337 });
7338 let err = d.validate().unwrap_err();
7339 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7340 panic!("expected FonteRepoShape, got other variant");
7341 };
7342 assert_eq!(nome, "caixa-teia");
7343 assert_eq!(repo, "github:pleme-io/caixa-teia ");
7344 assert!(
7345 reason.contains("whitespace"),
7346 "reason must surface the whitespace arm, got {reason:?}"
7347 );
7348 }
7349
7350 #[test]
7351 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
7352 // The canonical CLI-argument-injection footgun at the `git clone`
7353 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
7354 // argv parser read the value as a CLI flag, escaping the
7355 // subprocess argument boundary. The `--` separator workaround
7356 // does not fix the typed slot's accepted set; the gate rejects
7357 // the shape upstream at validate time so the resolver never
7358 // invokes a `git clone -…` subprocess.
7359 let d = dep_with_fonte(DepSource::Git {
7360 repo: "-upload-pack=evil".into(),
7361 tag: Some("v0.1.0".into()),
7362 rev: None,
7363 branch: None,
7364 });
7365 let err = d.validate().unwrap_err();
7366 let DepError::FonteRepoShape { repo, reason, .. } = err else {
7367 panic!("expected FonteRepoShape, got other variant");
7368 };
7369 assert_eq!(repo, "-upload-pack=evil");
7370 assert!(
7371 reason.contains("must not start with `-`"),
7372 "reason must surface the leading-`-` arm, got {reason:?}"
7373 );
7374 }
7375
7376 #[test]
7377 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
7378 // The canonical paste-from-multiline-doc footgun — a `:repo`
7379 // string with an embedded `\n` silently breaks git's URL parser
7380 // and is a class of CRLF-injection at the subprocess-argument
7381 // boundary. Caught by the control-char arm (0x0A < 0x20).
7382 let d = dep_with_fonte(DepSource::Git {
7383 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
7384 tag: Some("v0.1.0".into()),
7385 rev: None,
7386 branch: None,
7387 });
7388 let err = d.validate().unwrap_err();
7389 let DepError::FonteRepoShape { reason, .. } = err else {
7390 panic!("expected FonteRepoShape, got other variant");
7391 };
7392 assert!(
7393 reason.contains("control character"),
7394 "reason must surface the control-char arm, got {reason:?}"
7395 );
7396 }
7397
7398 #[test]
7399 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
7400 // Tab is the sibling whitespace footgun (the canonical
7401 // copy-from-aligned-table paste); pinned separately from the
7402 // space arm so a future relaxation that only catches one
7403 // surfaces here.
7404 let d = dep_with_fonte(DepSource::Git {
7405 repo: "github:pleme-io/caixa-teia\t".into(),
7406 tag: Some("v0.1.0".into()),
7407 rev: None,
7408 branch: None,
7409 });
7410 let err = d.validate().unwrap_err();
7411 assert!(
7412 matches!(
7413 err,
7414 DepError::FonteRepoShape { ref reason, .. }
7415 if reason.contains("whitespace")
7416 ),
7417 "got {err:?}"
7418 );
7419 }
7420
7421 #[test]
7422 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
7423 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
7424 // non-ASCII silently breaks at git's URL parser and round-trips
7425 // inconsistently across NFC/NFD normalization on APFS /
7426 // case-folding filesystems. Same intersection-floor
7427 // [`is_git_ref_name`] enforces on the refname axes.
7428 let d = dep_with_fonte(DepSource::Git {
7429 repo: "https://github.com/pleme-io/café".into(),
7430 tag: Some("v0.1.0".into()),
7431 rev: None,
7432 branch: None,
7433 });
7434 let err = d.validate().unwrap_err();
7435 assert!(
7436 matches!(
7437 err,
7438 DepError::FonteRepoShape { ref reason, .. }
7439 if reason.contains("non-ASCII")
7440 ),
7441 "got {err:?}"
7442 );
7443 }
7444
7445 #[test]
7446 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
7447 // The fail-before-pass-after pin for the canonical paste-from-
7448 // browser-address-bar footgun on `:repo`: an author copies a
7449 // GitHub permalink to a README anchor / line-permalink and
7450 // forgets to trim the `#fragment` tail. Until this arm landed
7451 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
7452 // silently passed every prior arm (no whitespace, no control
7453 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
7454 // or `:`), libcurl's URL parser stripped the `#readme` tail
7455 // before opening the HTTPS transport, and the lacre embedded
7456 // the value verbatim in its per-dep BLAKE3 closure — two
7457 // authors whose values differ only in their fragment anchor
7458 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
7459 // `git clone` but lock to two distinct lacres, defeating the
7460 // THEORY.md §V.2 render-determinism contract. Same value-shape
7461 // axis-floor every peer typed surface enforces; peer `:fonte
7462 // :tag` / `:fonte :branch` already reject the byte-class through
7463 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
7464 // URL grammar admitted) and `:entrada :paths` rejects `#` as
7465 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
7466 let d = dep_with_fonte(DepSource::Git {
7467 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
7468 tag: Some("v0.1.0".into()),
7469 rev: None,
7470 branch: None,
7471 });
7472 let err = d.validate().unwrap_err();
7473 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7474 panic!("expected FonteRepoShape, got other variant");
7475 };
7476 assert_eq!(nome, "caixa-teia");
7477 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
7478 assert!(
7479 reason.contains("must not contain `#`"),
7480 "reason must surface the fragment-`#` arm, got {reason:?}"
7481 );
7482 assert!(
7483 reason.contains("fragment"),
7484 "reason must name the URL fragment grammar, got {reason:?}"
7485 );
7486 }
7487
7488 #[test]
7489 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
7490 // The symmetric paste-from-Nix-flake-ref footgun — an author
7491 // confuses the Nix flake-reference idiom (`github:foo/
7492 // bar#packageName`, where `#packageName` selects a flake
7493 // output) with the bare git `:repo` shape. The pleme-io
7494 // substrate authors compose flakes downstream of caixa
7495 // (caixa-flake renders a flake.nix), so the cross-idiom leak
7496 // is the canonical near-miss: the author writes the
7497 // flake-ref shape into a git `:repo` slot. Pinned separately
7498 // from the HTTPS-anchor arm so a future relaxation that
7499 // narrows to one URL scheme surfaces here.
7500 let d = dep_with_fonte(DepSource::Git {
7501 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
7502 tag: Some("v0.1.0".into()),
7503 rev: None,
7504 branch: None,
7505 });
7506 let err = d.validate().unwrap_err();
7507 let DepError::FonteRepoShape { reason, .. } = err else {
7508 panic!("expected FonteRepoShape, got other variant");
7509 };
7510 assert!(
7511 reason.contains("must not contain `#`"),
7512 "reason must surface the fragment-`#` arm, got {reason:?}"
7513 );
7514 assert!(
7515 reason.contains("Nix flake"),
7516 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
7517 );
7518 }
7519
7520 #[test]
7521 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
7522 // The fail-before-pass-after pin for the canonical paste-from-
7523 // browser-address-bar footgun on `:repo` (peer with the
7524 // a68f818 fragment-`#` arm on the same axis). An author
7525 // copies a GitHub tab deep-link out of the address bar and
7526 // forgets to trim the `?tab=…` query tail. Until this arm
7527 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
7528 // silently passed every prior arm (no whitespace, no control
7529 // chars, no non-ASCII, no `#` fragment, contains a `:`,
7530 // doesn't start with `-` or `:`); GitHub silently ignored
7531 // the `?query` tail and served the same repo regardless;
7532 // the lacre embedded the value verbatim in its per-dep
7533 // BLAKE3 closure — two authors whose values differ only in
7534 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
7535 // `?utm_source=twitter`) resolve to the byte-identical
7536 // upstream `git clone` but lock to two distinct lacres,
7537 // defeating the THEORY.md §V.2 render-determinism contract
7538 // on the same axis the `#` fragment arm closes. Same value-
7539 // shape axis-floor every peer typed surface enforces; peer
7540 // `:fonte :tag` / `:fonte :branch` already reject the byte-
7541 // class through `is_git_ref_name`'s alphabet (refspec glob
7542 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
7543 // :paths` rejects `?` as the query separator in
7544 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
7545 let d = dep_with_fonte(DepSource::Git {
7546 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
7547 tag: Some("v0.1.0".into()),
7548 rev: None,
7549 branch: None,
7550 });
7551 let err = d.validate().unwrap_err();
7552 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7553 panic!("expected FonteRepoShape, got other variant");
7554 };
7555 assert_eq!(nome, "caixa-teia");
7556 assert_eq!(
7557 repo,
7558 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
7559 );
7560 assert!(
7561 reason.contains("must not contain `?`"),
7562 "reason must surface the query-`?` arm, got {reason:?}"
7563 );
7564 assert!(
7565 reason.contains("query"),
7566 "reason must name the URL query grammar, got {reason:?}"
7567 );
7568 }
7569
7570 #[test]
7571 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
7572 // The symmetric paste-from-social-share footgun — an author
7573 // copies a repo URL out of a Slack unfurl / Twitter share /
7574 // newsletter link / Discord embed and forgets to trim the
7575 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
7576 // campaign-tracker tail. Every major social-share / unfurl /
7577 // newsletter platform appends these UTM parameters; the
7578 // canonical near-miss on the `:repo` axis. Pinned separately
7579 // from the GitHub-tab-deep-link arm so a future relaxation
7580 // that narrows to one query-parameter class surfaces here.
7581 let d = dep_with_fonte(DepSource::Git {
7582 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
7583 .into(),
7584 tag: Some("v0.1.0".into()),
7585 rev: None,
7586 branch: None,
7587 });
7588 let err = d.validate().unwrap_err();
7589 let DepError::FonteRepoShape { reason, .. } = err else {
7590 panic!("expected FonteRepoShape, got other variant");
7591 };
7592 assert!(
7593 reason.contains("must not contain `?`"),
7594 "reason must surface the query-`?` arm, got {reason:?}"
7595 );
7596 assert!(
7597 reason.contains("campaign-tracker"),
7598 "reason must name the campaign-tracker paste footgun, got {reason:?}"
7599 );
7600 }
7601
7602 #[test]
7603 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
7604 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
7605 // both per-byte arms inside the same `for &b in s.as_bytes()`
7606 // loop, so the byte that appears first in the value's byte
7607 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
7608 // (fragment before query — unusual URL-grammar but value-
7609 // disjoint at byte level) carries both `#` and `?`; the `#`
7610 // byte appears first, so the fragment-`#` arm fires, surfacing
7611 // the more self-locating diagnostic on the byte the author
7612 // pasted earliest in the URL. Mirrors the peer cascade
7613 // discipline `fonte_repo_control_char_fires_before_fragment`
7614 // pins on the prior `:repo` byte-class arm.
7615 let d = dep_with_fonte(DepSource::Git {
7616 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
7617 tag: Some("v0.1.0".into()),
7618 rev: None,
7619 branch: None,
7620 });
7621 let err = d.validate().unwrap_err();
7622 let DepError::FonteRepoShape { reason, .. } = err else {
7623 panic!("expected FonteRepoShape, got other variant");
7624 };
7625 assert!(
7626 reason.contains("must not contain `#`"),
7627 "reason must surface the fragment-`#` arm (fires before query-`?` when \
7628 `#` byte appears first in value), got {reason:?}"
7629 );
7630 }
7631
7632 #[test]
7633 fn fonte_repo_control_char_fires_before_fragment() {
7634 // Cascade pin: the control-char arm structurally precedes the
7635 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
7636 // positive on both arms (contains LF and `#`), but the narrower
7637 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
7638 // (`control character`) wins so the author sees the more
7639 // self-locating arm first. Mirrors the peer cascade discipline
7640 // every prior `:repo` byte-class arm establishes.
7641 let d = dep_with_fonte(DepSource::Git {
7642 repo: "github:pleme-io/caixa-teia\n#readme".into(),
7643 tag: Some("v0.1.0".into()),
7644 rev: None,
7645 branch: None,
7646 });
7647 let err = d.validate().unwrap_err();
7648 let DepError::FonteRepoShape { reason, .. } = err else {
7649 panic!("expected FonteRepoShape, got other variant");
7650 };
7651 assert!(
7652 reason.contains("control character"),
7653 "reason must surface the control-char arm, got {reason:?}"
7654 );
7655 }
7656
7657 #[test]
7658 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7659 // The fail-before-pass-after pin for the canonical Windows-
7660 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7661 // backslash arm on the sibling `:caminho` path-fonte axis).
7662 // An author pastes a Windows Explorer address-bar / PowerShell
7663 // `Get-Location` output into a `file://` URL slot, producing
7664 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7665 // value silently passed every prior arm (no whitespace, no
7666 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7667 // with `-` or `:`); libcurl's URL parser silently translates
7668 // `\` → `/` on some platforms and refuses it on others, so
7669 // the byte rides verbatim into the lacre's per-dep content-
7670 // address but is silently rewritten / rejected at the wire —
7671 // two authors whose `:repo` values differ only in backslash-
7672 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7673 // resolve to the byte-identical local clone but lock to two
7674 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7675 // render-determinism contract on the same axis the `#`
7676 // fragment and `?` query arms close. Same value-shape axis-
7677 // floor every peer typed surface enforces; the `:caminho`
7678 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7679 let d = dep_with_fonte(DepSource::Git {
7680 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7681 tag: Some("v0.1.0".into()),
7682 rev: None,
7683 branch: None,
7684 });
7685 let err = d.validate().unwrap_err();
7686 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7687 panic!("expected FonteRepoShape, got other variant");
7688 };
7689 assert_eq!(nome, "caixa-teia");
7690 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7691 assert!(
7692 reason.contains("must not contain `\\`"),
7693 "reason must surface the backslash-`\\` arm, got {reason:?}"
7694 );
7695 assert!(
7696 reason.contains("Windows"),
7697 "reason must name the Windows-path-confusion footgun, got {reason:?}"
7698 );
7699 }
7700
7701 #[test]
7702 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7703 // The symmetric Win32-shell-mangled-slashes footgun — an author
7704 // copies `https://github.com/foo/bar` into a Win32 shell that
7705 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7706 // separator-coercion bug), pastes the result into a `:repo`
7707 // slot, and produces `https:\\github.com\foo\bar`. Pinned
7708 // separately from the `file://` Explorer-paste arm so a future
7709 // relaxation that narrows to one URL scheme surfaces here.
7710 let d = dep_with_fonte(DepSource::Git {
7711 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7712 tag: Some("v0.1.0".into()),
7713 rev: None,
7714 branch: None,
7715 });
7716 let err = d.validate().unwrap_err();
7717 let DepError::FonteRepoShape { reason, .. } = err else {
7718 panic!("expected FonteRepoShape, got other variant");
7719 };
7720 assert!(
7721 reason.contains("must not contain `\\`"),
7722 "reason must surface the backslash-`\\` arm, got {reason:?}"
7723 );
7724 assert!(
7725 reason.contains("path separator") || reason.contains("path-segment separator"),
7726 "reason must name the URL path-segment separator grammar, got {reason:?}"
7727 );
7728 }
7729
7730 #[test]
7731 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7732 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7733 // are both per-byte arms inside the same `for &b in s.as_bytes()`
7734 // loop, so the byte that appears first in the value's byte order
7735 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7736 // both `#` and `\`; the `#` byte appears first, so the fragment-
7737 // `#` arm fires, surfacing the more self-locating diagnostic on
7738 // the byte the author pasted earliest in the URL. Mirrors the
7739 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7740 // pins on the prior `:repo` byte-class arm.
7741 let d = dep_with_fonte(DepSource::Git {
7742 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7743 tag: Some("v0.1.0".into()),
7744 rev: None,
7745 branch: None,
7746 });
7747 let err = d.validate().unwrap_err();
7748 let DepError::FonteRepoShape { reason, .. } = err else {
7749 panic!("expected FonteRepoShape, got other variant");
7750 };
7751 assert!(
7752 reason.contains("must not contain `#`"),
7753 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7754 `#` byte appears first in value), got {reason:?}"
7755 );
7756 }
7757
7758 #[test]
7759 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7760 // The fail-before-pass-after pin for the canonical URI Template
7761 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7762 // README quick-start snippet / OpenAPI `servers:` URL / Helm
7763 // chart `home:` template that carries unresolved
7764 // `{org}` / `{repo}` placeholders and pastes the raw template
7765 // into the `:repo` slot, expecting the substrate to resolve the
7766 // placeholder downstream. Until this arm landed the value
7767 // silently passed every prior arm (no whitespace, no control
7768 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7769 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7770 // / `%7D` on the wire, so the byte rides verbatim into the
7771 // lacre's per-dep content-address but round-trips inconsistently
7772 // between the lacre's per-dep content-address and the
7773 // resolver's `git clone <repo>` invocation, defeating the
7774 // THEORY.md §V.2 render-determinism contract on the same axis
7775 // the `#` fragment, `?` query, and `\` backslash arms close;
7776 // every git porcelain entry-point additionally fetches a
7777 // nonexistent literal-`{placeholder}`-named path far from the
7778 // source caixa.lisp.
7779 let d = dep_with_fonte(DepSource::Git {
7780 repo: "https://github.com/{org}/caixa-teia".into(),
7781 tag: Some("v0.1.0".into()),
7782 rev: None,
7783 branch: None,
7784 });
7785 let err = d.validate().unwrap_err();
7786 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7787 panic!("expected FonteRepoShape, got other variant");
7788 };
7789 assert_eq!(nome, "caixa-teia");
7790 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7791 assert!(
7792 reason.contains("must not contain `{`"),
7793 "reason must surface the open-brace `{{` arm, got {reason:?}"
7794 );
7795 assert!(
7796 reason.contains("URI Template") || reason.contains("RFC 6570"),
7797 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7798 );
7799 }
7800
7801 #[test]
7802 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7803 // The symmetric Mustache / Handlebars doubled-brace
7804 // substitution-form footgun every CI / IaC templating engine
7805 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7806 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7807 // chart README quick-start snippet emits. Pinned separately
7808 // from the single-`{` `{org}` arm so a future relaxation that
7809 // narrows to one substitution-form surfaces here.
7810 let d = dep_with_fonte(DepSource::Git {
7811 repo: "https://github.com/{{org}}/caixa-teia".into(),
7812 tag: Some("v0.1.0".into()),
7813 rev: None,
7814 branch: None,
7815 });
7816 let err = d.validate().unwrap_err();
7817 let DepError::FonteRepoShape { reason, .. } = err else {
7818 panic!("expected FonteRepoShape, got other variant");
7819 };
7820 assert!(
7821 reason.contains("must not contain `{`"),
7822 "reason must surface the open-brace `{{` arm, got {reason:?}"
7823 );
7824 }
7825
7826 #[test]
7827 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7828 // Asymmetric `}`-only shape — covers the closing-brace-by-
7829 // itself footgun (an author truncated `{org}/{repo}` mid-edit
7830 // and left a trailing `}` from the prior template fragment,
7831 // or pasted a value that included a closing brace from a
7832 // surrounding shell context). Pinned to ensure the predicate
7833 // refuses each brace independently rather than only when both
7834 // appear — a future regression that ANDs the two byte tests
7835 // surfaces here.
7836 let d = dep_with_fonte(DepSource::Git {
7837 repo: "https://github.com/pleme-io/caixa-teia}".into(),
7838 tag: Some("v0.1.0".into()),
7839 rev: None,
7840 branch: None,
7841 });
7842 let err = d.validate().unwrap_err();
7843 let DepError::FonteRepoShape { reason, .. } = err else {
7844 panic!("expected FonteRepoShape, got other variant");
7845 };
7846 assert!(
7847 reason.contains("must not contain `}`"),
7848 "reason must surface the close-brace `}}` arm, got {reason:?}"
7849 );
7850 }
7851
7852 #[test]
7853 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7854 // Cascade pin: the fragment-`#` arm and the template-`{` /
7855 // `}` arm are both per-byte arms inside the same
7856 // `for &b in s.as_bytes()` loop, so the byte that appears
7857 // first in the value's byte order wins. A `:repo
7858 // "https://github.com/p/x#readme{org}"` carries both `#` and
7859 // `{`; the `#` byte appears first, so the fragment-`#` arm
7860 // fires, surfacing the more self-locating diagnostic on the
7861 // byte the author pasted earliest in the URL. Mirrors the
7862 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7863 // pins on the prior `:repo` byte-class arm.
7864 let d = dep_with_fonte(DepSource::Git {
7865 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7866 tag: Some("v0.1.0".into()),
7867 rev: None,
7868 branch: None,
7869 });
7870 let err = d.validate().unwrap_err();
7871 let DepError::FonteRepoShape { reason, .. } = err else {
7872 panic!("expected FonteRepoShape, got other variant");
7873 };
7874 assert!(
7875 reason.contains("must not contain `#`"),
7876 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7877 `#` byte appears first in value), got {reason:?}"
7878 );
7879 }
7880
7881 #[test]
7882 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7883 // The fail-before-pass-after pin for the canonical
7884 // shell-output-redirection footgun on `:repo`: an author
7885 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7886 // / `… >output.txt`) into the `:repo` slot without trimming
7887 // the redirect. Until this arm landed the value silently
7888 // passed every prior arm (no whitespace, no control chars,
7889 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7890 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7891 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7892 // percent-encode set maps `>` → `%3E` on the wire, so the
7893 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7894 // but is silently rewritten or rejected at libcurl's URL-
7895 // parser layer — two authors whose values differ only in
7896 // their redirect tail (`>build.log` vs nothing) resolve to
7897 // the byte-identical upstream `git clone` but lock to two
7898 // distinct lacres, defeating the THEORY.md §V.2 render-
7899 // determinism contract. Peer with the `:caminho` axis's
7900 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7901 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7902 // byte RFC-3986-reserved set on `:entrada :paths`.
7903 let d = dep_with_fonte(DepSource::Git {
7904 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7905 tag: Some("v0.1.0".into()),
7906 rev: None,
7907 branch: None,
7908 });
7909 let err = d.validate().unwrap_err();
7910 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7911 panic!("expected FonteRepoShape, got other variant");
7912 };
7913 assert_eq!(nome, "caixa-teia");
7914 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7915 assert!(
7916 reason.contains("must not contain `>`"),
7917 "reason must surface the output-redirection `>` arm, got {reason:?}"
7918 );
7919 assert!(
7920 reason.contains("redirection") || reason.contains("'delims'"),
7921 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7922 );
7923 }
7924
7925 #[test]
7926 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7927 // The symmetric shell-input-redirection footgun — an author
7928 // pastes a shell-pipeline head (`git clone <input.url` /
7929 // `cat <README.md`) into the `:repo` slot. Pinned separately
7930 // from the `>`-output arm so a future relaxation that only
7931 // catches one of the two redirect bytes surfaces here. Peer
7932 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7933 // arm which closes both `<` and `>` under the same banner.
7934 let d = dep_with_fonte(DepSource::Git {
7935 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7936 tag: Some("v0.1.0".into()),
7937 rev: None,
7938 branch: None,
7939 });
7940 let err = d.validate().unwrap_err();
7941 let DepError::FonteRepoShape { reason, .. } = err else {
7942 panic!("expected FonteRepoShape, got other variant");
7943 };
7944 assert!(
7945 reason.contains("must not contain `<`"),
7946 "reason must surface the input-redirection `<` arm, got {reason:?}"
7947 );
7948 assert!(
7949 reason.contains("RFC 3986") || reason.contains("'unwise'"),
7950 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7951 );
7952 }
7953
7954 #[test]
7955 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7956 // The fail-before-pass-after pin for the canonical
7957 // paste-from-shell-prompt-with-backticked-substitution footgun
7958 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7959 // `:caminho` path-fonte axis). An author pastes a URL whose
7960 // segment carries a backticked command-substitution wrapper
7961 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7962 // from a doc / README quick-start snippet that expected the
7963 // substrate to substitute the value downstream. Until this arm
7964 // landed the value silently passed every prior arm (no
7965 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7966 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7967 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7968 // 'unwise' set and the WHATWG URL spec's fragment percent-
7969 // encode set maps `` ` `` → `%60` on the wire, so the byte
7970 // rides verbatim into the lacre's per-dep BLAKE3 closure but
7971 // is silently rewritten or rejected at libcurl's URL-parser
7972 // layer — two authors whose values differ only in their
7973 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7974 // byte-identical upstream `git clone` but lock to two distinct
7975 // lacres, defeating the THEORY.md §V.2 render-determinism
7976 // contract. Peer with the `:caminho` axis's
7977 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7978 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7979 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7980 let d = dep_with_fonte(DepSource::Git {
7981 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7982 tag: Some("v0.1.0".into()),
7983 rev: None,
7984 branch: None,
7985 });
7986 let err = d.validate().unwrap_err();
7987 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7988 panic!("expected FonteRepoShape, got other variant");
7989 };
7990 assert_eq!(nome, "caixa-teia");
7991 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7992 assert!(
7993 reason.contains("must not contain `` ` ``"),
7994 "reason must surface the backtick command-substitution arm, got {reason:?}"
7995 );
7996 assert!(
7997 reason.contains("command-substitution") || reason.contains("'unwise'"),
7998 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7999 got {reason:?}"
8000 );
8001 }
8002
8003 #[test]
8004 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
8005 // Cascade pin: the fragment-`#` arm and the backtick command-
8006 // substitution arm are both per-byte arms inside the same
8007 // `for &b in s.as_bytes()` loop, so the byte that appears first
8008 // in the value's byte order wins. A `:repo
8009 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
8010 // and backtick; the `#` byte appears first, so the fragment-
8011 // `#` arm fires, surfacing the more self-locating diagnostic
8012 // on the byte the author pasted earliest in the URL. Mirrors
8013 // the peer cascade discipline
8014 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
8015 // pins on the prior `:repo` byte-class arm.
8016 let d = dep_with_fonte(DepSource::Git {
8017 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
8018 tag: Some("v0.1.0".into()),
8019 rev: None,
8020 branch: None,
8021 });
8022 let err = d.validate().unwrap_err();
8023 let DepError::FonteRepoShape { reason, .. } = err else {
8024 panic!("expected FonteRepoShape, got other variant");
8025 };
8026 assert!(
8027 reason.contains("must not contain `#`"),
8028 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
8029 appears first in value), got {reason:?}"
8030 );
8031 }
8032
8033 #[test]
8034 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
8035 // Cascade pin: the shell-redirection `<` / `>` arm and the
8036 // backtick command-substitution arm are both per-byte arms
8037 // inside the same `for &b in s.as_bytes()` loop, so the byte
8038 // that appears first in the value's byte order wins. A `:repo
8039 // "https://github.com/p/x>build.log/`whoami`"` carries both
8040 // `>` and backtick; the `>` byte appears first, so the
8041 // shell-redirection arm fires, surfacing the more self-
8042 // locating diagnostic on the byte the author pasted earliest
8043 // in the URL. Pins the natural-order cascade so a future
8044 // reorder of the per-byte arms surfaces here.
8045 let d = dep_with_fonte(DepSource::Git {
8046 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
8047 tag: Some("v0.1.0".into()),
8048 rev: None,
8049 branch: None,
8050 });
8051 let err = d.validate().unwrap_err();
8052 let DepError::FonteRepoShape { reason, .. } = err else {
8053 panic!("expected FonteRepoShape, got other variant");
8054 };
8055 assert!(
8056 reason.contains("must not contain `>`"),
8057 "reason must surface the shell-redirection `>` arm (fires before backtick when \
8058 `>` byte appears first in value), got {reason:?}"
8059 );
8060 }
8061
8062 #[test]
8063 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
8064 // Cascade pin: the fragment-`#` arm and the shell-redirection
8065 // `<` / `>` arm are both per-byte arms inside the same
8066 // `for &b in s.as_bytes()` loop, so the byte that appears
8067 // first in the value's byte order wins. A `:repo
8068 // "https://github.com/p/x#readme>build.log"` carries both
8069 // `#` and `>`; the `#` byte appears first, so the fragment-
8070 // `#` arm fires, surfacing the more self-locating diagnostic
8071 // on the byte the author pasted earliest in the URL. Mirrors
8072 // the peer cascade discipline
8073 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
8074 // pins on the prior `:repo` byte-class arm.
8075 let d = dep_with_fonte(DepSource::Git {
8076 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
8077 tag: Some("v0.1.0".into()),
8078 rev: None,
8079 branch: None,
8080 });
8081 let err = d.validate().unwrap_err();
8082 let DepError::FonteRepoShape { reason, .. } = err else {
8083 panic!("expected FonteRepoShape, got other variant");
8084 };
8085 assert!(
8086 reason.contains("must not contain `#`"),
8087 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
8088 `#` byte appears first in value), got {reason:?}"
8089 );
8090 }
8091
8092 #[test]
8093 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
8094 // The fail-before-pass-after pin for the canonical
8095 // paste-from-shell-prompt-with-piped-pipeline footgun on
8096 // `:repo` (peer with the 124106f pipe arm on the sibling
8097 // `:caminho` path-fonte axis). An author pastes a shell
8098 // pipeline (`git clone <url> | tee build.log`,
8099 // `git ls-remote <url> | head`) into the `:repo` slot,
8100 // forgetting to trim the `| <consumer>` tail. Until this arm
8101 // landed the value silently passed every prior arm (no
8102 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8103 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
8104 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
8105 // 'unwise' set and the WHATWG URL spec's fragment percent-
8106 // encode set maps `|` → `%7C` on the wire, so the byte rides
8107 // verbatim into the lacre's per-dep BLAKE3 closure but is
8108 // silently rewritten or rejected at libcurl's URL-parser
8109 // layer — two authors whose values differ only in their pipe
8110 // tail (`|tee build.log` vs nothing) resolve to the byte-
8111 // identical upstream `git clone` but lock to two distinct
8112 // lacres, defeating the THEORY.md §V.2 render-determinism
8113 // contract. Peer with the `:caminho` axis's
8114 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
8115 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
8116 // RFC-3986-reserved set on `:entrada :paths`.
8117 let d = dep_with_fonte(DepSource::Git {
8118 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
8119 tag: Some("v0.1.0".into()),
8120 rev: None,
8121 branch: None,
8122 });
8123 let err = d.validate().unwrap_err();
8124 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8125 panic!("expected FonteRepoShape, got other variant");
8126 };
8127 assert_eq!(nome, "caixa-teia");
8128 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
8129 assert!(
8130 reason.contains("must not contain `|`"),
8131 "reason must surface the shell-pipe arm, got {reason:?}"
8132 );
8133 assert!(
8134 reason.contains("pipe") || reason.contains("'unwise'"),
8135 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
8136 );
8137 }
8138
8139 #[test]
8140 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
8141 // Cascade pin: the fragment-`#` arm and the pipe arm are both
8142 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8143 // so the byte that appears first in the value's byte order
8144 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
8145 // both `#` and `|`; the `#` byte appears first, so the
8146 // fragment-`#` arm fires, surfacing the more self-locating
8147 // diagnostic on the byte the author pasted earliest in the
8148 // URL. Mirrors the peer cascade discipline
8149 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
8150 // pins on the prior `:repo` byte-class arm.
8151 let d = dep_with_fonte(DepSource::Git {
8152 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
8153 tag: Some("v0.1.0".into()),
8154 rev: None,
8155 branch: None,
8156 });
8157 let err = d.validate().unwrap_err();
8158 let DepError::FonteRepoShape { reason, .. } = err else {
8159 panic!("expected FonteRepoShape, got other variant");
8160 };
8161 assert!(
8162 reason.contains("must not contain `#`"),
8163 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
8164 appears first in value), got {reason:?}"
8165 );
8166 }
8167
8168 #[test]
8169 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
8170 // Cascade pin: the backtick arm and the pipe arm are both per-
8171 // byte arms inside the same `for &b in s.as_bytes()` loop, so
8172 // the byte that appears first in the value's byte order wins.
8173 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
8174 // `` ` `` and `|`; the backtick byte appears first, so the
8175 // backtick arm fires, surfacing the more self-locating
8176 // diagnostic on the byte the author pasted earliest in the
8177 // URL. Pins the natural-order cascade so a future reorder of
8178 // the per-byte arms surfaces here.
8179 let d = dep_with_fonte(DepSource::Git {
8180 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
8181 tag: Some("v0.1.0".into()),
8182 rev: None,
8183 branch: None,
8184 });
8185 let err = d.validate().unwrap_err();
8186 let DepError::FonteRepoShape { reason, .. } = err else {
8187 panic!("expected FonteRepoShape, got other variant");
8188 };
8189 assert!(
8190 reason.contains("must not contain `` ` ``"),
8191 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
8192 appears first in value), got {reason:?}"
8193 );
8194 }
8195
8196 #[test]
8197 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
8198 // The fail-before-pass-after pin for the canonical
8199 // paste-from-shell-prompt-with-sequential-command-tail footgun
8200 // on `:repo` (peer with the 05c358e `;` arm on the sibling
8201 // `:caminho` path-fonte axis). An author pastes a shell
8202 // one-liner that chained a cleanup tail after the URL
8203 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
8204 // echo done`) into the `:repo` slot, forgetting to trim the
8205 // `; <cmd>` tail. Until this arm landed the value silently
8206 // passed every prior `is_git_repo_url` arm (no whitespace, no
8207 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
8208 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
8209 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
8210 // reserved set and the WHATWG URL spec's fragment percent-
8211 // encode set maps `;` → `%3B` on the wire, so the byte rides
8212 // verbatim into the lacre's per-dep BLAKE3 closure but is
8213 // silently rewritten at libcurl's URL-parser layer — two
8214 // authors whose values differ only in their sequential-command
8215 // tail (`; rm -rf build` vs nothing) resolve to the byte-
8216 // identical upstream `git clone` but lock to two distinct
8217 // lacres, defeating the THEORY.md §V.2 render-determinism
8218 // contract. Peer with the `:caminho` axis's
8219 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
8220 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8221 // byte RFC-3986-reserved set on `:entrada :paths`.
8222 let d = dep_with_fonte(DepSource::Git {
8223 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
8224 tag: Some("v0.1.0".into()),
8225 rev: None,
8226 branch: None,
8227 });
8228 let err = d.validate().unwrap_err();
8229 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8230 panic!("expected FonteRepoShape, got other variant");
8231 };
8232 assert_eq!(nome, "caixa-teia");
8233 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
8234 assert!(
8235 reason.contains("must not contain `;`"),
8236 "reason must surface the shell-command-separator arm, got {reason:?}"
8237 );
8238 assert!(
8239 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
8240 "reason must name the shell-command-separator / RFC-3986-sub-delims \
8241 rationale, got {reason:?}"
8242 );
8243 }
8244
8245 #[test]
8246 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
8247 // Cascade pin: the fragment-`#` arm and the semicolon arm are
8248 // both per-byte arms inside the same `for &b in s.as_bytes()`
8249 // loop, so the byte that appears first in the value's byte
8250 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
8251 // carries both `#` and `;`; the `#` byte appears first, so the
8252 // fragment-`#` arm fires, surfacing the more self-locating
8253 // diagnostic on the byte the author pasted earliest in the URL.
8254 // Mirrors the peer cascade discipline
8255 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
8256 // pins on the prior `:repo` byte-class arm.
8257 let d = dep_with_fonte(DepSource::Git {
8258 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
8259 tag: Some("v0.1.0".into()),
8260 rev: None,
8261 branch: None,
8262 });
8263 let err = d.validate().unwrap_err();
8264 let DepError::FonteRepoShape { reason, .. } = err else {
8265 panic!("expected FonteRepoShape, got other variant");
8266 };
8267 assert!(
8268 reason.contains("must not contain `#`"),
8269 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
8270 byte appears first in value), got {reason:?}"
8271 );
8272 }
8273
8274 #[test]
8275 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
8276 // Cascade pin: the pipe arm and the semicolon arm are both
8277 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8278 // so the byte that appears first in the value's byte order
8279 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
8280 // both `|` and `;`; the `|` byte appears first, so the
8281 // pipe arm fires, surfacing the more self-locating diagnostic
8282 // on the byte the author pasted earliest in the URL. Pins the
8283 // natural-order cascade so a future reorder of the per-byte
8284 // arms surfaces here.
8285 let d = dep_with_fonte(DepSource::Git {
8286 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
8287 tag: Some("v0.1.0".into()),
8288 rev: None,
8289 branch: None,
8290 });
8291 let err = d.validate().unwrap_err();
8292 let DepError::FonteRepoShape { reason, .. } = err else {
8293 panic!("expected FonteRepoShape, got other variant");
8294 };
8295 assert!(
8296 reason.contains("must not contain `|`"),
8297 "reason must surface the pipe arm (fires before semicolon when `|` byte \
8298 appears first in value), got {reason:?}"
8299 );
8300 }
8301
8302 #[test]
8303 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
8304 // The fail-before-pass-after pin for the canonical
8305 // paste-from-shell-prompt-with-background-launch-tail footgun
8306 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
8307 // `:caminho` path-fonte axis). An author pastes a shell one-
8308 // liner that detached the clone into the background
8309 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
8310 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
8311 // `&& <cmd>` tail. Until this arm landed the value silently
8312 // passed every prior `is_git_repo_url` arm (no whitespace,
8313 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
8314 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8315 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
8316 // the 'sub-delims' / reserved set and the WHATWG URL spec's
8317 // fragment percent-encode set maps `&` → `%26` on the wire,
8318 // so the byte rides verbatim into the lacre's per-dep
8319 // BLAKE3 closure but is silently rewritten at libcurl's
8320 // URL-parser layer — two authors whose values differ only
8321 // in their background-launch tail (`& sleep 1` vs nothing)
8322 // resolve to the byte-identical upstream `git clone` but
8323 // lock to two distinct lacres, defeating the THEORY.md
8324 // §V.2 render-determinism contract. Peer with the
8325 // `:caminho` axis's `FonteCaminhoShellBackground` arm
8326 // (e12e4f3) on the sibling path-fonte axis, and
8327 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
8328 // reserved set on `:entrada :paths`.
8329 let d = dep_with_fonte(DepSource::Git {
8330 repo: "https://github.com/pleme-io/caixa-teia&sleep".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 { nome, repo, reason } = err else {
8337 panic!("expected FonteRepoShape, got other variant");
8338 };
8339 assert_eq!(nome, "caixa-teia");
8340 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
8341 assert!(
8342 reason.contains("must not contain `&`"),
8343 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
8344 );
8345 assert!(
8346 reason.contains("background-task") || reason.contains("'sub-delims'"),
8347 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
8348 got {reason:?}"
8349 );
8350 }
8351
8352 #[test]
8353 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
8354 // The fail-before-pass-after pin for the symmetric `&&`
8355 // logical-AND build-chain paste footgun: an author pastes
8356 // a `git clone <url> && cd <repo>` build-chain one-liner
8357 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
8358 // is the same `&` byte twice in a row; the per-byte arm
8359 // fires on the first `&` it sees. Pinned separately from
8360 // the single-`&` background-launch shape so a future
8361 // diagnostic-surface change that special-cased the
8362 // doubled-byte form surfaces here.
8363 let d = dep_with_fonte(DepSource::Git {
8364 repo: "github:pleme-io/caixa-teia&&echo".into(),
8365 tag: Some("v0.1.0".into()),
8366 rev: None,
8367 branch: None,
8368 });
8369 let err = d.validate().unwrap_err();
8370 let DepError::FonteRepoShape { reason, .. } = err else {
8371 panic!("expected FonteRepoShape, got other variant");
8372 };
8373 assert!(
8374 reason.contains("must not contain `&`"),
8375 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
8376 shape too, got {reason:?}"
8377 );
8378 }
8379
8380 #[test]
8381 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
8382 // Cascade pin: the fragment-`#` arm and the background-`&`
8383 // arm are both per-byte arms inside the same `for &b in
8384 // s.as_bytes()` loop, so the byte that appears first in the
8385 // value's byte order wins. A `:repo
8386 // "https://github.com/p/x#readme & sleep"` carries both `#`
8387 // and `&`; the `#` byte appears first, so the fragment-`#`
8388 // arm fires, surfacing the more self-locating diagnostic on
8389 // the byte the author pasted earliest in the URL. Mirrors
8390 // the peer cascade discipline
8391 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
8392 // on the prior `:repo` byte-class arm.
8393 let d = dep_with_fonte(DepSource::Git {
8394 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
8395 tag: Some("v0.1.0".into()),
8396 rev: None,
8397 branch: None,
8398 });
8399 let err = d.validate().unwrap_err();
8400 let DepError::FonteRepoShape { reason, .. } = err else {
8401 panic!("expected FonteRepoShape, got other variant");
8402 };
8403 assert!(
8404 reason.contains("must not contain `#`"),
8405 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
8406 byte appears first in value), got {reason:?}"
8407 );
8408 }
8409
8410 #[test]
8411 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
8412 // Cascade pin: the semicolon arm and the background-`&` arm
8413 // are both per-byte arms inside the same `for &b in
8414 // s.as_bytes()` loop, so the byte that appears first in the
8415 // value's byte order wins. A `:repo
8416 // "https://github.com/p/x; rm & sleep"` carries both `;` and
8417 // `&`; the `;` byte appears first, so the semicolon arm
8418 // fires, surfacing the more self-locating diagnostic on the
8419 // byte the author pasted earliest in the URL. Pins the
8420 // natural-order cascade so a future reorder of the per-byte
8421 // arms surfaces here.
8422 let d = dep_with_fonte(DepSource::Git {
8423 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
8424 tag: Some("v0.1.0".into()),
8425 rev: None,
8426 branch: None,
8427 });
8428 let err = d.validate().unwrap_err();
8429 let DepError::FonteRepoShape { reason, .. } = err else {
8430 panic!("expected FonteRepoShape, got other variant");
8431 };
8432 assert!(
8433 reason.contains("must not contain `;`"),
8434 "reason must surface the semicolon arm (fires before background-`&` when `;` \
8435 byte appears first in value), got {reason:?}"
8436 );
8437 }
8438
8439 #[test]
8440 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
8441 // The fail-before-pass-after pin for the canonical
8442 // paste-from-shell-prompt-with-unsubstituted-variable footgun
8443 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
8444 // `:caminho` path-fonte axis). An author pastes a shell one-
8445 // liner that referenced an environment variable
8446 // (`git clone https://github.com/$ORG/x`, `git clone
8447 // github:$USER/repo`) into the `:repo` slot, forgetting to
8448 // substitute the literal value at author time. Until this arm
8449 // landed the value silently passed every prior
8450 // `is_git_repo_url` arm (no whitespace, no control chars, no
8451 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8452 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
8453 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
8454 // reserved set and the WHATWG URL spec's fragment percent-
8455 // encode set maps `$` → `%24` on the wire, so the byte rides
8456 // verbatim into the lacre's per-dep BLAKE3 closure but is
8457 // silently rewritten at libcurl's URL-parser layer — two
8458 // authors whose values differ only in their `$VAR` /
8459 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
8460 // identical upstream `git clone` but lock to two distinct
8461 // lacres, defeating the THEORY.md §V.2 render-determinism
8462 // contract. Beyond determinism, the value is a structural
8463 // host-layout leak: two authors with the same `:repo` slot
8464 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
8465 // different upstreams. Peer with the `:caminho` axis's
8466 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
8467 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8468 // byte RFC-3986-reserved set on `:entrada :paths`.
8469 let d = dep_with_fonte(DepSource::Git {
8470 repo: "https://github.com/$ORG/caixa-teia".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 { nome, repo, reason } = err else {
8477 panic!("expected FonteRepoShape, got other variant");
8478 };
8479 assert_eq!(nome, "caixa-teia");
8480 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
8481 assert!(
8482 reason.contains("must not contain `$`"),
8483 "reason must surface the shell-variable-expansion arm, got {reason:?}"
8484 );
8485 assert!(
8486 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
8487 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
8488 rationale, got {reason:?}"
8489 );
8490 }
8491
8492 #[test]
8493 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
8494 // The fail-before-pass-after pin for the symmetric POSIX-
8495 // shell braced `${VAR}` expansion paste footgun: an author
8496 // pastes a CI-manifest line `git clone
8497 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
8498 // Actions / GitLab CI / Drone shape) and forgets to
8499 // substitute the literal value. The `${...}` shape is the
8500 // same `$` byte at the leading position of the expansion;
8501 // the per-byte arm fires on the `$`. Pinned separately from
8502 // the bare-`$VAR` shape so a future diagnostic-surface
8503 // change that special-cased the braced form surfaces here.
8504 let d = dep_with_fonte(DepSource::Git {
8505 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
8506 tag: Some("v0.1.0".into()),
8507 rev: None,
8508 branch: None,
8509 });
8510 let err = d.validate().unwrap_err();
8511 let DepError::FonteRepoShape { reason, .. } = err else {
8512 panic!("expected FonteRepoShape, got other variant");
8513 };
8514 assert!(
8515 reason.contains("must not contain `$`"),
8516 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
8517 shape too, got {reason:?}"
8518 );
8519 }
8520
8521 #[test]
8522 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
8523 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
8524 // arm are both per-byte arms inside the same `for &b in
8525 // s.as_bytes()` loop, so the byte that appears first in the
8526 // value's byte order wins. A `:repo
8527 // "https://github.com/p/x#readme$HOME"` carries both `#` and
8528 // `$`; the `#` byte appears first, so the fragment-`#` arm
8529 // fires, surfacing the more self-locating diagnostic on the
8530 // byte the author pasted earliest in the URL. Mirrors the
8531 // peer cascade discipline
8532 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
8533 // on the prior `:repo` byte-class arm.
8534 let d = dep_with_fonte(DepSource::Git {
8535 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
8536 tag: Some("v0.1.0".into()),
8537 rev: None,
8538 branch: None,
8539 });
8540 let err = d.validate().unwrap_err();
8541 let DepError::FonteRepoShape { reason, .. } = err else {
8542 panic!("expected FonteRepoShape, got other variant");
8543 };
8544 assert!(
8545 reason.contains("must not contain `#`"),
8546 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
8547 `#` byte appears first in value), got {reason:?}"
8548 );
8549 }
8550
8551 #[test]
8552 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
8553 // Cascade pin: the background-`&` arm and the
8554 // var-expansion-`$` arm are both per-byte arms inside the
8555 // same `for &b in s.as_bytes()` loop, so the byte that
8556 // appears first in the value's byte order wins. A `:repo
8557 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
8558 // `$`; the `&` byte appears first, so the background arm
8559 // fires, surfacing the more self-locating diagnostic on the
8560 // byte the author pasted earliest in the URL. Pins the
8561 // natural-order cascade so a future reorder of the per-byte
8562 // arms surfaces here — `$` is the most recent byte-class arm,
8563 // so the cascade-pin sweep extends to cover every immediately
8564 // prior byte arm (`#`, `&`) firing first when ordered ahead
8565 // of `$` in the value.
8566 let d = dep_with_fonte(DepSource::Git {
8567 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
8568 tag: Some("v0.1.0".into()),
8569 rev: None,
8570 branch: None,
8571 });
8572 let err = d.validate().unwrap_err();
8573 let DepError::FonteRepoShape { reason, .. } = err else {
8574 panic!("expected FonteRepoShape, got other variant");
8575 };
8576 assert!(
8577 reason.contains("must not contain `&`"),
8578 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
8579 `&` byte appears first in value), got {reason:?}"
8580 );
8581 }
8582
8583 #[test]
8584 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
8585 // The fail-before-pass-after pin for the canonical
8586 // paste-from-shell-prompt glob footgun on `:repo` (peer with
8587 // the cf9034b `*` / `?` arm on the sibling `:caminho`
8588 // path-fonte axis). An author pastes a shell one-liner that
8589 // referenced a glob expansion (`ls
8590 // github.com/pleme-io/caixa-*`, `git clone
8591 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
8592 // to substitute the literal repo name. Until this arm landed
8593 // the `*` byte silently passed every prior `is_git_repo_url`
8594 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
8595 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
8596 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
8597 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
8598 // the WHATWG URL spec's special-query percent-encode set maps
8599 // `*` → `%2A` on the wire, so the byte rides verbatim into
8600 // the lacre's per-dep BLAKE3 closure but is silently
8601 // rewritten at libcurl's URL-parser layer — two authors
8602 // whose values differ only in their asterisk presence
8603 // resolve to the byte-identical upstream `git clone` but
8604 // lock to two distinct lacres, defeating the THEORY.md §V.2
8605 // render-determinism contract. Peer with the `:caminho`
8606 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
8607 // sibling path-fonte axis, and the `is_git_ref_name`
8608 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
8609 // axes.
8610 let d = dep_with_fonte(DepSource::Git {
8611 repo: "https://github.com/pleme-io/caixa-*".into(),
8612 tag: Some("v0.1.0".into()),
8613 rev: None,
8614 branch: None,
8615 });
8616 let err = d.validate().unwrap_err();
8617 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8618 panic!("expected FonteRepoShape, got other variant");
8619 };
8620 assert_eq!(nome, "caixa-teia");
8621 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
8622 assert!(
8623 reason.contains("must not contain `*`"),
8624 "reason must surface the shell-glob arm, got {reason:?}"
8625 );
8626 assert!(
8627 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
8628 "reason must name the shell-glob / pathname-expansion / \
8629 RFC-3986-sub-delims rationale, got {reason:?}"
8630 );
8631 }
8632
8633 #[test]
8634 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
8635 // The fail-before-pass-after pin for the symmetric bash
8636 // `globstar` recursive-glob paste footgun: an author pastes
8637 // a `ls github.com/pleme-io/**/x` (the canonical
8638 // `globstar`-shopt-enabled recursive-listing tail) into the
8639 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
8640 // the per-byte arm fires on the first `*`. Pinned
8641 // separately from the single-`*` shape so a future
8642 // diagnostic-surface change that special-cased the
8643 // double-`*` form surfaces here.
8644 let d = dep_with_fonte(DepSource::Git {
8645 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
8646 tag: Some("v0.1.0".into()),
8647 rev: None,
8648 branch: None,
8649 });
8650 let err = d.validate().unwrap_err();
8651 let DepError::FonteRepoShape { reason, .. } = err else {
8652 panic!("expected FonteRepoShape, got other variant");
8653 };
8654 assert!(
8655 reason.contains("must not contain `*`"),
8656 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8657 got {reason:?}"
8658 );
8659 }
8660
8661 #[test]
8662 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8663 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8664 // both per-byte arms inside the same `for &b in s.as_bytes()`
8665 // loop, so the byte that appears first in the value's byte
8666 // order wins. A `:repo
8667 // "https://github.com/p/x#readme*tail"` carries both `#` and
8668 // `*`; the `#` byte appears first, so the fragment-`#` arm
8669 // fires, surfacing the more self-locating diagnostic on the
8670 // byte the author pasted earliest in the URL. Mirrors the
8671 // peer cascade discipline
8672 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8673 // on the prior `:repo` byte-class arm.
8674 let d = dep_with_fonte(DepSource::Git {
8675 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8676 tag: Some("v0.1.0".into()),
8677 rev: None,
8678 branch: None,
8679 });
8680 let err = d.validate().unwrap_err();
8681 let DepError::FonteRepoShape { reason, .. } = err else {
8682 panic!("expected FonteRepoShape, got other variant");
8683 };
8684 assert!(
8685 reason.contains("must not contain `#`"),
8686 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8687 appears first in value), got {reason:?}"
8688 );
8689 }
8690
8691 #[test]
8692 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8693 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8694 // arm are both per-byte arms inside the same `for &b in
8695 // s.as_bytes()` loop, so the byte that appears first in the
8696 // value's byte order wins. A `:repo
8697 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8698 // the `$` byte appears first, so the var-expansion arm
8699 // fires, surfacing the more self-locating diagnostic on the
8700 // byte the author pasted earliest in the URL. Pins the
8701 // natural-order cascade so a future reorder of the per-byte
8702 // arms surfaces here — `*` is the most recent byte-class
8703 // arm, so the cascade-pin sweep extends to cover the
8704 // immediately prior `$` byte arm firing first when ordered
8705 // ahead of `*` in the value.
8706 let d = dep_with_fonte(DepSource::Git {
8707 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
8708 tag: Some("v0.1.0".into()),
8709 rev: None,
8710 branch: None,
8711 });
8712 let err = d.validate().unwrap_err();
8713 let DepError::FonteRepoShape { reason, .. } = err else {
8714 panic!("expected FonteRepoShape, got other variant");
8715 };
8716 assert!(
8717 reason.contains("must not contain `$`"),
8718 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8719 byte appears first in value), got {reason:?}"
8720 );
8721 }
8722
8723 #[test]
8724 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8725 // The fail-before-pass-after pin for the canonical paste-from-
8726 // shell-prompt subshell-grouping footgun on `:repo`. An author
8727 // pastes a doc / README snippet carrying a regex-alternation
8728 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8729 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8730 // `:repo` slot, forgetting to substitute one literal org name.
8731 // Until this arm landed the `(` byte silently passed every
8732 // prior `is_git_repo_url` arm (no whitespace, no control
8733 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8734 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8735 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8736 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8737 // URL spec's special-query percent-encode set maps `(` →
8738 // `%28` and `)` → `%29` on the wire, so the byte rides
8739 // verbatim into the lacre's per-dep BLAKE3 closure but is
8740 // silently rewritten at libcurl's URL-parser layer —
8741 // defeating the THEORY.md §V.2 render-determinism contract on
8742 // the same axis the prior twelve byte-class arms close.
8743 let d = dep_with_fonte(DepSource::Git {
8744 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8745 tag: Some("v0.1.0".into()),
8746 rev: None,
8747 branch: None,
8748 });
8749 let err = d.validate().unwrap_err();
8750 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8751 panic!("expected FonteRepoShape, got other variant");
8752 };
8753 assert_eq!(nome, "caixa-teia");
8754 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8755 assert!(
8756 reason.contains("must not contain `(`"),
8757 "reason must surface the subshell-open-paren arm, got {reason:?}"
8758 );
8759 assert!(
8760 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8761 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8762 got {reason:?}"
8763 );
8764 }
8765
8766 #[test]
8767 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8768 // The symmetric arm pin on the closing `)` byte: an author
8769 // pastes a `$(date)` command-substitution wrapper or a
8770 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8771 // Pinned separately from the opening `(` shape so a future
8772 // diagnostic-surface change that only checked one boundary
8773 // surfaces here. The `(` byte appears earlier in the
8774 // canonical regex / subshell wrapper so the per-byte loop
8775 // fires on `(` first; this test exercises a `:repo` value
8776 // carrying only the closing `)` byte (no opening paren) so
8777 // the `)` arm fires directly — pinning the byte-class arm
8778 // independent of order.
8779 let d = dep_with_fonte(DepSource::Git {
8780 repo: "github:pleme-io/caixa-teia)tail".into(),
8781 tag: Some("v0.1.0".into()),
8782 rev: None,
8783 branch: None,
8784 });
8785 let err = d.validate().unwrap_err();
8786 let DepError::FonteRepoShape { reason, .. } = err else {
8787 panic!("expected FonteRepoShape, got other variant");
8788 };
8789 assert!(
8790 reason.contains("must not contain `)`"),
8791 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8792 got {reason:?}"
8793 );
8794 }
8795
8796 #[test]
8797 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8798 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8799 // are both per-byte arms inside the same `for &b in
8800 // s.as_bytes()` loop, so the byte that appears first in the
8801 // value's byte order wins. A `:repo
8802 // "https://github.com/p/x#readme(tail)"` carries both `#` and
8803 // `(`; the `#` byte appears first, so the fragment-`#` arm
8804 // fires, surfacing the more self-locating diagnostic on the
8805 // byte the author pasted earliest in the URL. Mirrors the
8806 // peer cascade discipline
8807 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8808 // on the prior `:repo` byte-class arm.
8809 let d = dep_with_fonte(DepSource::Git {
8810 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8811 tag: Some("v0.1.0".into()),
8812 rev: None,
8813 branch: None,
8814 });
8815 let err = d.validate().unwrap_err();
8816 let DepError::FonteRepoShape { reason, .. } = err else {
8817 panic!("expected FonteRepoShape, got other variant");
8818 };
8819 assert!(
8820 reason.contains("must not contain `#`"),
8821 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8822 byte appears first in value), got {reason:?}"
8823 );
8824 }
8825
8826 #[test]
8827 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8828 // Cascade pin: the glob-`*` arm (the immediate-predecessor
8829 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8830 // per-byte arms inside the same `for &b in s.as_bytes()`
8831 // loop, so the byte that appears first in the value's byte
8832 // order wins. A `:repo
8833 // "https://github.com/p/x-*-(date)"` carries both `*` and
8834 // `(`; the `*` byte appears first, so the glob arm fires,
8835 // surfacing the more self-locating diagnostic on the byte
8836 // the author pasted earliest in the URL. Pins the natural-
8837 // order cascade so a future reorder of the per-byte arms
8838 // surfaces here — `(` is the most recent byte-class arm,
8839 // so the cascade-pin sweep extends to cover the immediately
8840 // prior `*` byte arm firing first when ordered ahead of `(`
8841 // in the value.
8842 let d = dep_with_fonte(DepSource::Git {
8843 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8844 tag: Some("v0.1.0".into()),
8845 rev: None,
8846 branch: None,
8847 });
8848 let err = d.validate().unwrap_err();
8849 let DepError::FonteRepoShape { reason, .. } = err else {
8850 panic!("expected FonteRepoShape, got other variant");
8851 };
8852 assert!(
8853 reason.contains("must not contain `*`"),
8854 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8855 appears first in value), got {reason:?}"
8856 );
8857 }
8858
8859 #[test]
8860 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8861 // The fail-before-pass-after pin for the canonical paste-from-
8862 // doc-shell-quoting footgun on `:repo`. An author copies a
8863 // README quick-start snippet (`$ git clone "https://github.com/
8864 // foo/bar"`) and keeps the surrounding double-quote bytes when
8865 // pasting into the `:repo` slot — the doc wraps the URL in
8866 // double quotes so the shell doesn't re-lex metachars inside,
8867 // but the typed slot is itself a byte-level string parser, not
8868 // a shell context, so the quote bytes ride into the value
8869 // verbatim. Until this arm landed the `"` byte silently passed
8870 // every prior `is_git_repo_url` arm (no whitespace, no control
8871 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8872 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8873 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8874 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8875 // `` ` ``) every URL parser is required to refuse or percent-
8876 // encode, and the WHATWG URL spec's 'C0 control percent-encode
8877 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8878 // into the lacre's per-dep BLAKE3 closure but is silently
8879 // rewritten at libcurl's URL-parser layer, defeating the
8880 // THEORY.md §V.2 render-determinism contract.
8881 let d = dep_with_fonte(DepSource::Git {
8882 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8883 tag: Some("v0.1.0".into()),
8884 rev: None,
8885 branch: None,
8886 });
8887 let err = d.validate().unwrap_err();
8888 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8889 panic!("expected FonteRepoShape, got other variant");
8890 };
8891 assert_eq!(nome, "caixa-teia");
8892 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8893 assert!(
8894 reason.contains("must not contain `\"`"),
8895 "reason must surface the shell-double-quote arm, got {reason:?}"
8896 );
8897 assert!(
8898 reason.contains("double-quote") || reason.contains("'delims'"),
8899 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8900 got {reason:?}"
8901 );
8902 }
8903
8904 #[test]
8905 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8906 // The symmetric stray-quote tail pin: an author pastes only a
8907 // closing `"` from a shell-history line like `git clone
8908 // "https://github.com/foo/bar" && cd …` (the trim went too
8909 // far in one direction but not the other) into the `:repo`
8910 // slot. Pinned separately from the wrapped-quote shape so a
8911 // future diagnostic-surface change that only checked one
8912 // boundary (only leading, only trailing, only paired) surfaces
8913 // here — the per-byte arm fires anywhere `"` appears.
8914 let d = dep_with_fonte(DepSource::Git {
8915 repo: "github:pleme-io/caixa-teia\"".into(),
8916 tag: Some("v0.1.0".into()),
8917 rev: None,
8918 branch: None,
8919 });
8920 let err = d.validate().unwrap_err();
8921 let DepError::FonteRepoShape { reason, .. } = err else {
8922 panic!("expected FonteRepoShape, got other variant");
8923 };
8924 assert!(
8925 reason.contains("must not contain `\"`"),
8926 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8927 got {reason:?}"
8928 );
8929 }
8930
8931 #[test]
8932 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8933 // Cascade pin: the fragment-`#` arm and the double-quote arm
8934 // are both per-byte arms inside the same `for &b in
8935 // s.as_bytes()` loop, so the byte that appears first in the
8936 // value's byte order wins. A `:repo
8937 // "https://github.com/p/x#readme\"tail"` carries both `#` and
8938 // `"`; the `#` byte appears first, so the fragment-`#` arm
8939 // fires, surfacing the more self-locating diagnostic on the
8940 // byte the author pasted earliest in the URL.
8941 let d = dep_with_fonte(DepSource::Git {
8942 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8943 tag: Some("v0.1.0".into()),
8944 rev: None,
8945 branch: None,
8946 });
8947 let err = d.validate().unwrap_err();
8948 let DepError::FonteRepoShape { reason, .. } = err else {
8949 panic!("expected FonteRepoShape, got other variant");
8950 };
8951 assert!(
8952 reason.contains("must not contain `#`"),
8953 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8954 byte appears first in value), got {reason:?}"
8955 );
8956 }
8957
8958 #[test]
8959 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8960 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8961 // byte-class arm, 3b99147) and the double-quote arm are both
8962 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8963 // so the byte that appears first in the value's byte order
8964 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8965 // and `"`; the `(` byte appears first, so the subshell arm
8966 // fires, surfacing the more self-locating diagnostic on the
8967 // byte the author pasted earliest in the URL. Pins the natural-
8968 // order cascade so a future reorder of the per-byte arms
8969 // surfaces here — `"` is the most recent byte-class arm, so
8970 // the cascade-pin sweep extends to cover the immediately prior
8971 // `(` byte arm firing first when ordered ahead of `"` in the
8972 // value.
8973 let d = dep_with_fonte(DepSource::Git {
8974 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8975 tag: Some("v0.1.0".into()),
8976 rev: None,
8977 branch: None,
8978 });
8979 let err = d.validate().unwrap_err();
8980 let DepError::FonteRepoShape { reason, .. } = err else {
8981 panic!("expected FonteRepoShape, got other variant");
8982 };
8983 assert!(
8984 reason.contains("must not contain `(`"),
8985 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8986 byte appears first in value), got {reason:?}"
8987 );
8988 }
8989
8990 #[test]
8991 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8992 // The fail-before-pass-after pin for the canonical paste-from-
8993 // doc-strong-quoting footgun on `:repo`. An author copies a
8994 // security-conscious README quick-start snippet (`$ git clone
8995 // 'https://github.com/foo/bar'`) and keeps the surrounding
8996 // single-quote bytes when pasting into the `:repo` slot — the
8997 // doc strong-quotes the URL so the shell suppresses every form
8998 // of expansion on the bytes inside (no `$`, no backtick, no
8999 // glob, no word-splitting), but the typed slot is itself a
9000 // byte-level string parser, not a shell context, so the quote
9001 // bytes ride into the value verbatim. Until this arm landed the
9002 // `'` byte silently passed every prior `is_git_repo_url` arm
9003 // (no whitespace, no control chars, no non-ASCII, no `#`, no
9004 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
9005 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
9006 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
9007 // set, peer with the `\"` 'delims' double-quote arm and the
9008 // partner ASCII shell-string-delimiter byte every byte-level
9009 // string parser sharing a value-shape with a shell argument
9010 // must refuse on a URL-shaped slot.
9011 let d = dep_with_fonte(DepSource::Git {
9012 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
9013 tag: Some("v0.1.0".into()),
9014 rev: None,
9015 branch: None,
9016 });
9017 let err = d.validate().unwrap_err();
9018 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9019 panic!("expected FonteRepoShape, got other variant");
9020 };
9021 assert_eq!(nome, "caixa-teia");
9022 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
9023 assert!(
9024 reason.contains("must not contain `'`"),
9025 "reason must surface the shell-single-quote arm, got {reason:?}"
9026 );
9027 assert!(
9028 reason.contains("single-quote") || reason.contains("strong-quote"),
9029 "reason must name the shell-single-quote / strong-quote rationale, \
9030 got {reason:?}"
9031 );
9032 }
9033
9034 #[test]
9035 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
9036 // The symmetric English-typography pin: an author writes
9037 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
9038 // from-prose idiom every README / commit-message / chat-thread
9039 // reference to a repo carries) expecting the substrate to
9040 // coerce it to a kebab-case slug — but the byte rides into the
9041 // lacre verbatim. Pinned separately from the wrapped-quote
9042 // shape so a future diagnostic-surface change that only checked
9043 // the boundary positions (only leading, only trailing, only
9044 // paired) surfaces here — the per-byte arm fires anywhere `'`
9045 // appears in the value.
9046 let d = dep_with_fonte(DepSource::Git {
9047 repo: "github:pleme-io/repo's-fork".into(),
9048 tag: Some("v0.1.0".into()),
9049 rev: None,
9050 branch: None,
9051 });
9052 let err = d.validate().unwrap_err();
9053 let DepError::FonteRepoShape { reason, .. } = err else {
9054 panic!("expected FonteRepoShape, got other variant");
9055 };
9056 assert!(
9057 reason.contains("must not contain `'`"),
9058 "reason must surface the shell-single-quote arm on the mid-string \
9059 apostrophe shape, got {reason:?}"
9060 );
9061 }
9062
9063 #[test]
9064 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
9065 // Cascade pin: the fragment-`#` arm and the single-quote arm
9066 // are both per-byte arms inside the same `for &b in
9067 // s.as_bytes()` loop, so the byte that appears first in the
9068 // value's byte order wins. A `:repo
9069 // "https://github.com/p/x#readme'tail"` carries both `#` and
9070 // `'`; the `#` byte appears first, so the fragment-`#` arm
9071 // fires, surfacing the more self-locating diagnostic on the
9072 // byte the author pasted earliest in the URL.
9073 let d = dep_with_fonte(DepSource::Git {
9074 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
9075 tag: Some("v0.1.0".into()),
9076 rev: None,
9077 branch: None,
9078 });
9079 let err = d.validate().unwrap_err();
9080 let DepError::FonteRepoShape { reason, .. } = err else {
9081 panic!("expected FonteRepoShape, got other variant");
9082 };
9083 assert!(
9084 reason.contains("must not contain `#`"),
9085 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
9086 byte appears first in value), got {reason:?}"
9087 );
9088 }
9089
9090 #[test]
9091 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
9092 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
9093 // byte-class arm, 4267d8b) and the single-quote arm are both
9094 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9095 // so the byte that appears first in the value's byte order
9096 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
9097 // `'`; the `"` byte appears first, so the double-quote arm
9098 // fires, surfacing the more self-locating diagnostic on the
9099 // byte the author pasted earliest in the URL. Pins the natural-
9100 // order cascade so a future reorder of the per-byte arms
9101 // surfaces here — `'` is the most recent byte-class arm, so
9102 // the cascade-pin sweep extends to cover the immediately prior
9103 // `"` byte arm firing first when ordered ahead of `'` in the
9104 // value.
9105 let d = dep_with_fonte(DepSource::Git {
9106 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
9107 tag: Some("v0.1.0".into()),
9108 rev: None,
9109 branch: None,
9110 });
9111 let err = d.validate().unwrap_err();
9112 let DepError::FonteRepoShape { reason, .. } = err else {
9113 panic!("expected FonteRepoShape, got other variant");
9114 };
9115 assert!(
9116 reason.contains("must not contain `\"`"),
9117 "reason must surface the double-quote arm (fires before single-quote when `\"` \
9118 byte appears first in value), got {reason:?}"
9119 );
9120 }
9121
9122 #[test]
9123 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
9124 // The fail-before-pass-after pin for the canonical paste-from-
9125 // shell-history footgun on `:repo`. An author copies a `git
9126 // clone <url>!sudo make install` one-liner from a README's
9127 // quick-start snippet, intending the trailing `!sudo` as a
9128 // shell-history-expansion reference but the typed slot is itself
9129 // a byte-level string parser, not a shell context, so the byte
9130 // rides into the value verbatim. Until this arm landed the `!`
9131 // byte silently passed every prior `is_git_repo_url` arm (no
9132 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
9133 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
9134 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
9135 // start with `-` or `:`); bash with the default `histexpand`
9136 // mode rewrites `!command` to the most recent history entry
9137 // beginning with `command`, the canonical RCE-class injection
9138 // vector when the byte rides into a shell argument.
9139 let d = dep_with_fonte(DepSource::Git {
9140 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
9141 tag: Some("v0.1.0".into()),
9142 rev: None,
9143 branch: None,
9144 });
9145 let err = d.validate().unwrap_err();
9146 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9147 panic!("expected FonteRepoShape, got other variant");
9148 };
9149 assert_eq!(nome, "caixa-teia");
9150 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
9151 assert!(
9152 reason.contains("must not contain `!`"),
9153 "reason must surface the shell-history-expansion arm, got {reason:?}"
9154 );
9155 assert!(
9156 reason.contains("history-expansion") || reason.contains("bang"),
9157 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
9158 );
9159 }
9160
9161 #[test]
9162 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
9163 // The symmetric `!!` repeat-prior-command pin: an author paste-
9164 // trims a `git clone <url>` retry idiom from shell history that
9165 // expands to the previous command via `!!`. Pinned separately
9166 // from the wrapped `!command` shape so a future diagnostic-
9167 // surface change that only checked the leading or paired-bang
9168 // position surfaces here — the per-byte arm fires anywhere `!`
9169 // appears in the value.
9170 let d = dep_with_fonte(DepSource::Git {
9171 repo: "github:pleme-io/caixa-teia!!".into(),
9172 tag: Some("v0.1.0".into()),
9173 rev: None,
9174 branch: None,
9175 });
9176 let err = d.validate().unwrap_err();
9177 let DepError::FonteRepoShape { reason, .. } = err else {
9178 panic!("expected FonteRepoShape, got other variant");
9179 };
9180 assert!(
9181 reason.contains("must not contain `!`"),
9182 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
9183 got {reason:?}"
9184 );
9185 }
9186
9187 #[test]
9188 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
9189 // Cascade pin: the fragment-`#` arm and the bang arm are both
9190 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9191 // so the byte that appears first in the value's byte order
9192 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
9193 // both `#` and `!`; the `#` byte appears first, so the
9194 // fragment-`#` arm fires, surfacing the more self-locating
9195 // diagnostic on the byte the author pasted earliest in the URL.
9196 let d = dep_with_fonte(DepSource::Git {
9197 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
9198 tag: Some("v0.1.0".into()),
9199 rev: None,
9200 branch: None,
9201 });
9202 let err = d.validate().unwrap_err();
9203 let DepError::FonteRepoShape { reason, .. } = err else {
9204 panic!("expected FonteRepoShape, got other variant");
9205 };
9206 assert!(
9207 reason.contains("must not contain `#`"),
9208 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
9209 appears first in value), got {reason:?}"
9210 );
9211 }
9212
9213 #[test]
9214 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
9215 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
9216 // byte-class arm, e7a109f) and the bang arm are both per-byte
9217 // arms inside the same `for &b in s.as_bytes()` loop, so the
9218 // byte that appears first in the value's byte order wins. A
9219 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
9220 // `'` byte appears first, so the single-quote arm fires,
9221 // surfacing the more self-locating diagnostic on the byte the
9222 // author pasted earliest in the URL. Pins the natural-order
9223 // cascade so a future reorder of the per-byte arms surfaces
9224 // here — `!` is the most recent byte-class arm, so the
9225 // cascade-pin sweep extends to cover the immediately prior `'`
9226 // byte arm firing first when ordered ahead of `!` in the value.
9227 let d = dep_with_fonte(DepSource::Git {
9228 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
9229 tag: Some("v0.1.0".into()),
9230 rev: None,
9231 branch: None,
9232 });
9233 let err = d.validate().unwrap_err();
9234 let DepError::FonteRepoShape { reason, .. } = err else {
9235 panic!("expected FonteRepoShape, got other variant");
9236 };
9237 assert!(
9238 reason.contains("must not contain `'`"),
9239 "reason must surface the single-quote arm (fires before bang when `'` byte \
9240 appears first in value), got {reason:?}"
9241 );
9242 }
9243
9244 #[test]
9245 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
9246 // The fail-before-pass-after pin for the canonical
9247 // list-separator-belongs-to-list-grammar footgun on `:repo`.
9248 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
9249 // one-liner from a multi-repo bootstrap doc, intending the
9250 // comma to separate multiple repo entries but the typed
9251 // `:repo` slot names *one* repo (the list-separator belongs
9252 // to the `:deps` list grammar, not to the value). Until this
9253 // arm landed the `,` byte silently passed every prior
9254 // `is_git_repo_url` arm (no whitespace, no control chars, no
9255 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
9256 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
9257 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
9258 // `:`); the byte rode into the lacre's per-dep content-
9259 // address and the resolver's `git clone <repo>` subprocess
9260 // invocation, where no host's repo registry resolved the
9261 // comma-bearing slug.
9262 let d = dep_with_fonte(DepSource::Git {
9263 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
9264 tag: Some("v0.1.0".into()),
9265 rev: None,
9266 branch: None,
9267 });
9268 let err = d.validate().unwrap_err();
9269 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9270 panic!("expected FonteRepoShape, got other variant");
9271 };
9272 assert_eq!(nome, "caixa-teia");
9273 assert_eq!(
9274 repo,
9275 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
9276 );
9277 assert!(
9278 reason.contains("must not contain `,`"),
9279 "reason must surface the list-separator-comma arm, got {reason:?}"
9280 );
9281 assert!(
9282 reason.contains("list-separator") || reason.contains("sub-delims"),
9283 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
9284 got {reason:?}"
9285 );
9286 }
9287
9288 #[test]
9289 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
9290 // The symmetric trailing-`,` paste-from-prose pin: an author
9291 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
9292 // comma every README-prose list-of-projects sentence carries,
9293 // mistakenly retained when the slug is pasted mid-sentence)
9294 // expecting the substrate to coerce it to a kebab-case slug.
9295 // Pinned separately from the wrapped mid-token shape so a
9296 // future diagnostic-surface change that only checked the
9297 // leading or paired-comma position surfaces here — the
9298 // per-byte arm fires anywhere `,` appears in the value.
9299 let d = dep_with_fonte(DepSource::Git {
9300 repo: "github:pleme-io/caixa-feira,".into(),
9301 tag: Some("v0.1.0".into()),
9302 rev: None,
9303 branch: None,
9304 });
9305 let err = d.validate().unwrap_err();
9306 let DepError::FonteRepoShape { reason, .. } = err else {
9307 panic!("expected FonteRepoShape, got other variant");
9308 };
9309 assert!(
9310 reason.contains("must not contain `,`"),
9311 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
9312 got {reason:?}"
9313 );
9314 }
9315
9316 #[test]
9317 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
9318 // Cascade pin: the fragment-`#` arm and the comma arm are
9319 // both per-byte arms inside the same `for &b in s.as_bytes()`
9320 // loop, so the byte that appears first in the value's byte
9321 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
9322 // carries both `#` and `,`; the `#` byte appears first, so
9323 // the fragment-`#` arm fires, surfacing the more self-
9324 // locating diagnostic on the byte the author pasted earliest
9325 // in the URL.
9326 let d = dep_with_fonte(DepSource::Git {
9327 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
9328 tag: Some("v0.1.0".into()),
9329 rev: None,
9330 branch: None,
9331 });
9332 let err = d.validate().unwrap_err();
9333 let DepError::FonteRepoShape { reason, .. } = err else {
9334 panic!("expected FonteRepoShape, got other variant");
9335 };
9336 assert!(
9337 reason.contains("must not contain `#`"),
9338 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
9339 appears first in value), got {reason:?}"
9340 );
9341 }
9342
9343 #[test]
9344 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
9345 // Cascade pin: the bang-`!` arm (the immediate-predecessor
9346 // byte-class arm, 7d53c68) and the comma arm are both
9347 // per-byte arms inside the same `for &b in s.as_bytes()`
9348 // loop, so the byte that appears first in the value's byte
9349 // order wins. A `:repo "github:p/x!mid,tail"` carries both
9350 // `!` and `,`; the `!` byte appears first, so the bang arm
9351 // fires, surfacing the more self-locating diagnostic on the
9352 // byte the author pasted earliest in the URL. Pins the
9353 // natural-order cascade so a future reorder of the per-byte
9354 // arms surfaces here — `,` is the most recent byte-class
9355 // arm, so the cascade-pin sweep extends to cover the
9356 // immediately prior `!` byte arm firing first when ordered
9357 // ahead of `,` in the value.
9358 let d = dep_with_fonte(DepSource::Git {
9359 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
9360 tag: Some("v0.1.0".into()),
9361 rev: None,
9362 branch: None,
9363 });
9364 let err = d.validate().unwrap_err();
9365 let DepError::FonteRepoShape { reason, .. } = err else {
9366 panic!("expected FonteRepoShape, got other variant");
9367 };
9368 assert!(
9369 reason.contains("must not contain `!`"),
9370 "reason must surface the bang arm (fires before comma when `!` byte \
9371 appears first in value), got {reason:?}"
9372 );
9373 }
9374
9375 #[test]
9376 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
9377 // The fail-before-pass-after pin for the canonical
9378 // shell-env-var-assignment-belongs-to-shell-grammar footgun
9379 // on `:repo`. An author copies
9380 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
9381 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
9382 // git clone <url>`, etc. — the canonical
9383 // git-troubleshooting README idiom for a one-shot env-var
9384 // scoped to the `git clone` invocation) from a shell-prompt
9385 // one-liner, intending the `KEY=VALUE` prefix as a shell-
9386 // grammar env-var assignment but the typed `:repo` slot is
9387 // a value parser, not a shell context, so the bytes ride
9388 // into the value verbatim. Until this arm landed the `=`
9389 // byte silently passed every prior `is_git_repo_url` arm
9390 // (no whitespace, no control chars, no non-ASCII, no `#`,
9391 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
9392 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
9393 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
9394 // the byte rode into the lacre's per-dep content-address
9395 // and the resolver's `git clone <repo>` subprocess
9396 // invocation, where the upstream host's git porcelain
9397 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
9398 // path that no host's repo registry resolves.
9399 let d = dep_with_fonte(DepSource::Git {
9400 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
9401 tag: Some("v0.1.0".into()),
9402 rev: None,
9403 branch: None,
9404 });
9405 let err = d.validate().unwrap_err();
9406 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9407 panic!("expected FonteRepoShape, got other variant");
9408 };
9409 assert_eq!(nome, "caixa-teia");
9410 assert_eq!(
9411 repo,
9412 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
9413 );
9414 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
9415 // appears before the ` ` byte at position 21, so the `=`
9416 // arm fires (not the whitespace arm) — both arms guard
9417 // the slot, but the per-byte for-loop scans left-to-right
9418 // and the first matching byte wins.
9419 assert!(
9420 reason.contains("must not contain `=`"),
9421 "reason must surface the equals-`=` arm on the env-var-assignment \
9422 paste shape, got {reason:?}"
9423 );
9424 assert!(
9425 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
9426 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
9427 );
9428 }
9429
9430 #[test]
9431 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
9432 // The symmetric paste-from-gitconfig pin: an author copies
9433 // `url=https://github.com/p/x` from `git config --get-all
9434 // remote.origin.url` output, a `.gitconfig` `[remote
9435 // "origin"] url = https://…` ini-stanza paste, or a
9436 // `git config remote.origin.url <value>` doc snippet,
9437 // intending the `url=` prefix as the ini-key but the typed
9438 // `:repo` slot is a URL value parser, not a gitconfig
9439 // grammar. With no leading whitespace and no earlier-arm
9440 // bytes in the value, the `=` arm itself fires (rather
9441 // than cascading to the whitespace arm as in the env-var
9442 // paste shape). Pinned separately so a future diagnostic-
9443 // surface change that only checked the whitespace-leading
9444 // shape surfaces here — the per-byte arm fires anywhere
9445 // `=` appears in the value.
9446 let d = dep_with_fonte(DepSource::Git {
9447 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
9448 tag: Some("v0.1.0".into()),
9449 rev: None,
9450 branch: None,
9451 });
9452 let err = d.validate().unwrap_err();
9453 let DepError::FonteRepoShape { reason, .. } = err else {
9454 panic!("expected FonteRepoShape, got other variant");
9455 };
9456 assert!(
9457 reason.contains("must not contain `=`"),
9458 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
9459 paste shape, got {reason:?}"
9460 );
9461 assert!(
9462 reason.contains("key-value-separator") || reason.contains("sub-delims"),
9463 "reason must name the key-value-separator / RFC-3986-sub-delims \
9464 rationale, got {reason:?}"
9465 );
9466 }
9467
9468 #[test]
9469 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
9470 // Cascade pin: the fragment-`#` arm and the `=` arm are
9471 // both per-byte arms inside the same `for &b in s.as_bytes()`
9472 // loop, so the byte that appears first in the value's byte
9473 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
9474 // carries both `#` and `=`; the `#` byte appears first, so
9475 // the fragment-`#` arm fires, surfacing the more self-
9476 // locating diagnostic on the byte the author pasted earliest
9477 // in the URL.
9478 let d = dep_with_fonte(DepSource::Git {
9479 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
9480 tag: Some("v0.1.0".into()),
9481 rev: None,
9482 branch: None,
9483 });
9484 let err = d.validate().unwrap_err();
9485 let DepError::FonteRepoShape { reason, .. } = err else {
9486 panic!("expected FonteRepoShape, got other variant");
9487 };
9488 assert!(
9489 reason.contains("must not contain `#`"),
9490 "reason must surface the fragment-`#` arm (fires before equals when \
9491 `#` byte appears first in value), got {reason:?}"
9492 );
9493 }
9494
9495 #[test]
9496 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
9497 // Cascade pin: the comma-`,` arm (the immediate-predecessor
9498 // byte-class arm, 775b80e) and the `=` arm are both per-byte
9499 // arms inside the same `for &b in s.as_bytes()` loop, so
9500 // the byte that appears first in the value's byte order
9501 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
9502 // and `=`; the `,` byte appears first, so the comma arm
9503 // fires, surfacing the more self-locating diagnostic on
9504 // the byte the author pasted earliest in the URL. Pins the
9505 // natural-order cascade so a future reorder of the per-byte
9506 // arms surfaces here — `=` is the most recent byte-class
9507 // arm, so the cascade-pin sweep extends to cover the
9508 // immediately prior `,` byte arm firing first when ordered
9509 // ahead of `=` in the value.
9510 let d = dep_with_fonte(DepSource::Git {
9511 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
9512 tag: Some("v0.1.0".into()),
9513 rev: None,
9514 branch: None,
9515 });
9516 let err = d.validate().unwrap_err();
9517 let DepError::FonteRepoShape { reason, .. } = err else {
9518 panic!("expected FonteRepoShape, got other variant");
9519 };
9520 assert!(
9521 reason.contains("must not contain `,`"),
9522 "reason must surface the comma arm (fires before equals when `,` byte \
9523 appears first in value), got {reason:?}"
9524 );
9525 }
9526
9527 #[test]
9528 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
9529 // The fail-before-pass-after pin for the canonical paste-from-
9530 // browser-address-bar percent-encoded-space footgun on `:repo`.
9531 // An author copies `https://github.com/p/x%20test` from a
9532 // browser address bar (or a percent-encoded README hyperlink,
9533 // or a `curl --data-urlencode` shell-pipeline output)
9534 // intending `%20` as the URL encoding of a literal space; the
9535 // typed `:repo` slot already rejects the literal space byte
9536 // (the whitespace arm at the top of `is_git_repo_url`), so an
9537 // author trying to express "I really meant a space" reaches
9538 // for percent-encoding. Until this arm landed the `%` byte
9539 // silently passed every prior `is_git_repo_url` arm and rode
9540 // verbatim into the lacre's per-dep content-address — but
9541 // libcurl re-percent-encodes `%` to `%25` on the wire (since
9542 // `%` is reserved as the escape-sequence lead-in), so the
9543 // wire request becomes `https://github.com/p/x%2520test`, a
9544 // path the lacre's content-address never names. The classic
9545 // render-determinism violation on the encoding-mechanism axis
9546 // itself.
9547 let d = dep_with_fonte(DepSource::Git {
9548 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
9549 tag: Some("v0.1.0".into()),
9550 rev: None,
9551 branch: None,
9552 });
9553 let err = d.validate().unwrap_err();
9554 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9555 panic!("expected FonteRepoShape, got other variant");
9556 };
9557 assert_eq!(nome, "caixa-teia");
9558 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
9559 assert!(
9560 reason.contains("must not contain `%`"),
9561 "reason must surface the percent-`%` arm on the percent-encoded-space \
9562 paste shape, got {reason:?}"
9563 );
9564 assert!(
9565 reason.contains("percent-encoding") || reason.contains("%25"),
9566 "reason must name the percent-encoding / `%25` re-encoding rationale, \
9567 got {reason:?}"
9568 );
9569 }
9570
9571 #[test]
9572 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
9573 // The symmetric over-encoded-path-separator pin: an author
9574 // writes `:repo "https://github.com/p%2Fx"` intending the
9575 // `%2F` as the URL encoding of `/` (the canonical
9576 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
9577 // footgun every API client library and OAuth redirect-URI
9578 // documentation surfaces — the `/` is the URL-path-separator
9579 // and some templates percent-encode it to escape interpretation
9580 // as a path separator). The GitHub Smart-HTTP transport
9581 // resolves the URL's path-segment grammar before the
9582 // percent-decoding pass, so the value identifies a different
9583 // resource on the wire than the literal-`/` form the lacre's
9584 // content-address must agree with — two authors whose `:repo`
9585 // values differ only in their `/` vs `%2F` presence lock to
9586 // two distinct BLAKE3 closures for the byte-identical upstream
9587 // `git clone`. Pinned separately so a future diagnostic
9588 // surface that only catches the `%20` shape surfaces here too.
9589 let d = dep_with_fonte(DepSource::Git {
9590 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
9591 tag: Some("v0.1.0".into()),
9592 rev: None,
9593 branch: None,
9594 });
9595 let err = d.validate().unwrap_err();
9596 let DepError::FonteRepoShape { reason, .. } = err else {
9597 panic!("expected FonteRepoShape, got other variant");
9598 };
9599 assert!(
9600 reason.contains("must not contain `%`"),
9601 "reason must surface the percent-`%` arm on the over-encoded-path \
9602 shape, got {reason:?}"
9603 );
9604 assert!(
9605 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9606 "reason must name the render-determinism / BLAKE3-closure rationale, \
9607 got {reason:?}"
9608 );
9609 }
9610
9611 #[test]
9612 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
9613 // Cascade pin: the fragment-`#` arm and the `%` arm are both
9614 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9615 // so the byte that appears first in the value's byte order
9616 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
9617 // both `#` and `%`; the `#` byte appears first, so the
9618 // fragment-`#` arm fires, surfacing the more self-locating
9619 // diagnostic on the byte the author pasted earliest in the URL.
9620 let d = dep_with_fonte(DepSource::Git {
9621 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
9622 tag: Some("v0.1.0".into()),
9623 rev: None,
9624 branch: None,
9625 });
9626 let err = d.validate().unwrap_err();
9627 let DepError::FonteRepoShape { reason, .. } = err else {
9628 panic!("expected FonteRepoShape, got other variant");
9629 };
9630 assert!(
9631 reason.contains("must not contain `#`"),
9632 "reason must surface the fragment-`#` arm (fires before percent when \
9633 `#` byte appears first in value), got {reason:?}"
9634 );
9635 }
9636
9637 #[test]
9638 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
9639 // Cascade pin: the equals-`=` arm (the immediate-predecessor
9640 // byte-class arm, acf99af) and the `%` arm are both per-byte
9641 // arms inside the same `for &b in s.as_bytes()` loop, so the
9642 // byte that appears first in the value's byte order wins.
9643 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
9644 // the `=` byte appears first, so the equals arm fires,
9645 // surfacing the more self-locating diagnostic on the byte the
9646 // author pasted earliest in the URL. Pins the natural-order
9647 // cascade so a future reorder of the per-byte arms surfaces
9648 // here — `%` is the most recent byte-class arm, so the
9649 // cascade-pin sweep extends to cover the immediately prior
9650 // `=` byte arm firing first when ordered ahead of `%` in the
9651 // value.
9652 let d = dep_with_fonte(DepSource::Git {
9653 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9654 tag: Some("v0.1.0".into()),
9655 rev: None,
9656 branch: None,
9657 });
9658 let err = d.validate().unwrap_err();
9659 let DepError::FonteRepoShape { reason, .. } = err else {
9660 panic!("expected FonteRepoShape, got other variant");
9661 };
9662 assert!(
9663 reason.contains("must not contain `=`"),
9664 "reason must surface the equals arm (fires before percent when `=` byte \
9665 appears first in value), got {reason:?}"
9666 );
9667 }
9668
9669 #[test]
9670 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9671 // The fail-before-pass-after pin for the canonical paste-from-
9672 // shell-history footgun on `:repo`. An author copies a
9673 // `git clone <url>` line from their terminal followed by a
9674 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9675 // history shorthand (the `^old^new^` form re-runs the prior
9676 // history entry with the first `old` substituted by `new`,
9677 // bash's default behavior on interactive sessions with
9678 // `set -o histexpand`), forgetting to trim the trailing
9679 // `^...^...` shell-history fragment from the URL value. The
9680 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9681 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9682 // classes), the WHATWG URL spec's 'fragment percent-encode
9683 // set' maps `^` → `%5E` on the wire, so the byte rides
9684 // verbatim into the lacre's per-dep content-address but
9685 // libcurl re-encodes it to `%5E` at `git clone` time — the
9686 // classic render-determinism violation on the same axis the
9687 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9688 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9689 // `#` arms close.
9690 let d = dep_with_fonte(DepSource::Git {
9691 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9692 tag: Some("v0.1.0".into()),
9693 rev: None,
9694 branch: None,
9695 });
9696 let err = d.validate().unwrap_err();
9697 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9698 panic!("expected FonteRepoShape, got other variant");
9699 };
9700 assert_eq!(nome, "caixa-teia");
9701 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9702 assert!(
9703 reason.contains("must not contain `^`"),
9704 "reason must surface the caret-`^` arm on the paste-from-shell-history \
9705 shape, got {reason:?}"
9706 );
9707 assert!(
9708 reason.contains("history-substitution") || reason.contains("%5E"),
9709 "reason must name the shell-history-substitution / `%5E` wire-encoding \
9710 rationale, got {reason:?}"
9711 );
9712 }
9713
9714 #[test]
9715 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9716 // The symmetric paste-from-doc-grep-pipeline footgun: an
9717 // author writes `:repo "github:p/^archived"` after copying a
9718 // `grep '^archived'` regex-anchor / negation idiom from a
9719 // doc / README quick-listing snippet, expecting the substrate
9720 // to coerce it to a literal repo name. The byte rides
9721 // verbatim into the lacre's per-dep content-address and
9722 // diverges from the byte-identical literal `archived` form
9723 // every other author authored — the canonical render-
9724 // determinism violation pin on the second footgun shape the
9725 // caret-`^` arm closes.
9726 let d = dep_with_fonte(DepSource::Git {
9727 repo: "github:pleme-io/^archived".into(),
9728 tag: Some("v0.1.0".into()),
9729 rev: None,
9730 branch: None,
9731 });
9732 let err = d.validate().unwrap_err();
9733 let DepError::FonteRepoShape { reason, .. } = err else {
9734 panic!("expected FonteRepoShape, got other variant");
9735 };
9736 assert!(
9737 reason.contains("must not contain `^`"),
9738 "reason must surface the caret-`^` arm on the regex-anchor shape, \
9739 got {reason:?}"
9740 );
9741 assert!(
9742 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9743 "reason must name the render-determinism / BLAKE3-closure rationale, \
9744 got {reason:?}"
9745 );
9746 }
9747
9748 #[test]
9749 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9750 // Cascade pin: the `%` arm (the immediate-predecessor byte-
9751 // class arm, a323db8) and the `^` arm are both per-byte arms
9752 // inside the same `for &b in s.as_bytes()` loop, so the byte
9753 // that appears first in the value's byte order wins. A
9754 // `:repo "https://github.com/p/x%20mid^tail"` carries both
9755 // `%` and `^`; the `%` byte appears first, so the percent
9756 // arm fires, surfacing the more self-locating diagnostic on
9757 // the byte the author pasted earliest in the URL. Pins the
9758 // natural-order cascade so a future reorder of the per-byte
9759 // arms surfaces here — `^` is the most recent byte-class arm,
9760 // so the cascade-pin sweep extends to cover the immediately
9761 // prior `%` byte arm firing first when ordered ahead of `^`
9762 // in the value.
9763 let d = dep_with_fonte(DepSource::Git {
9764 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9765 tag: Some("v0.1.0".into()),
9766 rev: None,
9767 branch: None,
9768 });
9769 let err = d.validate().unwrap_err();
9770 let DepError::FonteRepoShape { reason, .. } = err else {
9771 panic!("expected FonteRepoShape, got other variant");
9772 };
9773 assert!(
9774 reason.contains("must not contain `%`"),
9775 "reason must surface the percent arm (fires before caret when `%` byte \
9776 appears first in value), got {reason:?}"
9777 );
9778 }
9779
9780 #[test]
9781 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9782 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9783 // (no `github:` prefix, no scheme). Every documented form
9784 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9785 // `file://`, or `git@host:path`); a bare `org/repo` is
9786 // ambiguous (`git clone` reads as a relative filesystem path
9787 // rather than the GitHub-shorthand expansion the author
9788 // probably intended) and the gate rejects the shape upstream.
9789 let d = dep_with_fonte(DepSource::Git {
9790 repo: "pleme-io/caixa-teia".into(),
9791 tag: Some("v0.1.0".into()),
9792 rev: None,
9793 branch: None,
9794 });
9795 let err = d.validate().unwrap_err();
9796 let DepError::FonteRepoShape { reason, .. } = err else {
9797 panic!("expected FonteRepoShape, got other variant");
9798 };
9799 assert!(
9800 reason.contains("must contain a `:`"),
9801 "reason must surface the missing-`:` arm, got {reason:?}"
9802 );
9803 assert!(
9804 reason.contains("github:"),
9805 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9806 );
9807 }
9808
9809 #[test]
9810 fn validate_rejects_git_fonte_with_repo_leading_colon() {
9811 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9812 // scheme that no git porcelain entry-point accepts. Pinned
9813 // separately from the missing-`:` arm because a value with a
9814 // leading `:` does technically contain a `:` separator; the
9815 // shape gate rejects on a dedicated arm so the diagnostic
9816 // names the specific footgun.
9817 let d = dep_with_fonte(DepSource::Git {
9818 repo: ":pleme-io/caixa-teia".into(),
9819 tag: Some("v0.1.0".into()),
9820 rev: None,
9821 branch: None,
9822 });
9823 let err = d.validate().unwrap_err();
9824 let DepError::FonteRepoShape { reason, .. } = err else {
9825 panic!("expected FonteRepoShape, got other variant");
9826 };
9827 assert!(
9828 reason.contains("must not start with `:`"),
9829 "reason must surface the leading-`:` arm, got {reason:?}"
9830 );
9831 }
9832
9833 #[test]
9834 fn validate_rejects_git_fonte_with_repo_too_long() {
9835 // The cap arm — a `:repo` value longer than
9836 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9837 // structurally untenable on every realistic landing site (the
9838 // resolver's `git clone` invocation, the future M4 CR
9839 // materializer's per-dep `repo:` axis); a value of that length
9840 // is almost certainly a paste-from-binary slug.
9841 let too_long = format!(
9842 "github:pleme-io/{}",
9843 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9844 );
9845 let d = dep_with_fonte(DepSource::Git {
9846 repo: too_long.clone(),
9847 tag: Some("v0.1.0".into()),
9848 rev: None,
9849 branch: None,
9850 });
9851 let err = d.validate().unwrap_err();
9852 let DepError::FonteRepoShape { reason, .. } = err else {
9853 panic!("expected FonteRepoShape, got other variant");
9854 };
9855 assert!(
9856 reason.contains("2048"),
9857 "reason must name the cap, got {reason:?}"
9858 );
9859 }
9860
9861 #[test]
9862 fn validate_accepts_canonical_git_fonte_repo_shapes() {
9863 // The positive-control sweep: every documented author shape on
9864 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9865 // must pass the value-shape gate. Pinned so a future tightening
9866 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9867 // here as a structural decision. Each form is exercised with the
9868 // same canonical `:tag` pin so only the `:repo` axis varies.
9869 for repo in [
9870 // The pleme-io registry-shorthand convention — `github:org/repo`.
9871 "github:pleme-io/caixa-teia",
9872 // Other host-aliased shorthands (the resolver's pluggable
9873 // host-prefix table).
9874 "gitlab:pleme-io/caixa-teia",
9875 "codeberg:pleme-io/caixa-teia",
9876 "sourcehut:~pleme-io/caixa-teia",
9877 // Full HTTPS URL with and without `.git` suffix.
9878 "https://github.com/pleme-io/caixa-teia",
9879 "https://github.com/pleme-io/caixa-teia.git",
9880 // HTTP (rare; dev / mirror).
9881 "http://example.com/pleme-io/caixa-teia.git",
9882 // SSH URL.
9883 "ssh://git@github.com/pleme-io/caixa-teia.git",
9884 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9885 // Scp-style SSH — the canonical `git@host:path` short form.
9886 "git@github.com:pleme-io/caixa-teia.git",
9887 "git@git.example.com:team/private.git",
9888 // Anonymous git protocol.
9889 "git://git.example.com/pleme-io/caixa-teia.git",
9890 // Local file URL (dev path).
9891 "file:///tmp/caixa-teia",
9892 ] {
9893 let d = dep_with_fonte(DepSource::Git {
9894 repo: repo.into(),
9895 tag: Some("v0.1.0".into()),
9896 rev: None,
9897 branch: None,
9898 });
9899 d.validate()
9900 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9901 }
9902 }
9903
9904 #[test]
9905 fn fonte_repo_empty_takes_precedence_over_shape() {
9906 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9907 // diagnostic; doesn't try to parse the URL shape) fires before
9908 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9909 // keeps its narrower error message. Mirrors
9910 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9911 // on the ordering layer.
9912 let d = dep_with_fonte(DepSource::Git {
9913 repo: String::new(),
9914 tag: Some("v0.1.0".into()),
9915 rev: None,
9916 branch: None,
9917 });
9918 let err = d.validate().unwrap_err();
9919 assert!(
9920 matches!(err, DepError::FonteRepoEmpty { .. }),
9921 "got {err:?}"
9922 );
9923 }
9924
9925 #[test]
9926 fn fonte_repo_shape_fires_before_pin_missing() {
9927 // Order pin: a malformed `:repo` value on a dep with no pin set
9928 // surfaces the `:repo` shape diagnostic (the more self-locating
9929 // axis — the `:repo` is the load-bearing identity of the source;
9930 // a missing pin is downstream from "do we even know the repo")
9931 // rather than collapsing onto the pin-missing diagnostic. The
9932 // shape gate runs inline before the pin enumeration in
9933 // `DepSource::validate`.
9934 let d = dep_with_fonte(DepSource::Git {
9935 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9936 tag: None,
9937 rev: None,
9938 branch: None,
9939 });
9940 let err = d.validate().unwrap_err();
9941 assert!(
9942 matches!(err, DepError::FonteRepoShape { .. }),
9943 "got {err:?}"
9944 );
9945 }
9946
9947 #[test]
9948 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9949 // The diagnostic-shape pin: the error names the offending
9950 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9951 // so the author can grep their caixa.lisp without re-running
9952 // the build. Mirrors the diagnostic-shape sweep on every prior
9953 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9954 let d = dep_with_fonte(DepSource::Git {
9955 repo: "pleme-io/caixa-teia".into(),
9956 tag: Some("v0.1.0".into()),
9957 rev: None,
9958 branch: None,
9959 });
9960 let err = d.validate().unwrap_err();
9961 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9962 panic!("expected FonteRepoShape, got other variant");
9963 };
9964 assert_eq!(nome, "caixa-teia");
9965 assert_eq!(repo, "pleme-io/caixa-teia");
9966 assert!(
9967 !reason.is_empty(),
9968 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9969 );
9970 }
9971
9972 #[test]
9973 fn validate_rejects_git_fonte_with_no_pin() {
9974 // The fail-before-pass-after pin for the canonical
9975 // `(:tipo git :repo "github:pleme-io/x")` shape with no
9976 // :tag/:rev/:branch — until this gate landed the resolver's
9977 // ResolveError::MissingPin surfaced at fetch time, far from the
9978 // source caixa.lisp. The new gate moves the check to validate
9979 // time and names the offending dep.
9980 let d = dep_with_fonte(DepSource::Git {
9981 repo: "github:pleme-io/caixa-teia".into(),
9982 tag: None,
9983 rev: None,
9984 branch: None,
9985 });
9986 let err = d.validate().unwrap_err();
9987 assert!(
9988 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9989 "got {err:?}"
9990 );
9991 }
9992
9993 #[test]
9994 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9995 // The canonical "pin drift" footgun: an author writes
9996 // `:tag "v1"` and later adds `:branch "main"` without removing
9997 // the :tag, and the resolver silently picks :tag (precedence
9998 // :rev > :tag > :branch). The :branch was dropped with no
9999 // diagnostic. The gate now rejects multi-pin shapes so the
10000 // author makes the precedence explicit at the source.
10001 let d = dep_with_fonte(DepSource::Git {
10002 repo: "github:pleme-io/caixa-teia".into(),
10003 tag: Some("v0.1.0".into()),
10004 rev: None,
10005 branch: Some("main".into()),
10006 });
10007 let err = d.validate().unwrap_err();
10008 let DepError::FontePinAmbiguous { nome, pins } = err else {
10009 panic!("expected FontePinAmbiguous");
10010 };
10011 assert_eq!(nome, "caixa-teia");
10012 assert!(pins.contains(":tag"));
10013 assert!(pins.contains(":branch"));
10014 assert!(!pins.contains(":rev"));
10015 }
10016
10017 #[test]
10018 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
10019 // Sibling arm of the pin-drift footgun: :tag + :rev set
10020 // simultaneously. Pinned separately so a future relaxation
10021 // that only catches the (:tag, :branch) pair surfaces here.
10022 let d = dep_with_fonte(DepSource::Git {
10023 repo: "github:pleme-io/caixa-teia".into(),
10024 tag: Some("v0.1.0".into()),
10025 rev: Some("c0ffee".into()),
10026 branch: None,
10027 });
10028 let err = d.validate().unwrap_err();
10029 let DepError::FontePinAmbiguous { nome, pins } = err else {
10030 panic!("expected FontePinAmbiguous");
10031 };
10032 assert_eq!(nome, "caixa-teia");
10033 assert!(pins.contains(":tag"));
10034 assert!(pins.contains(":rev"));
10035 }
10036
10037 #[test]
10038 fn validate_rejects_git_fonte_with_all_three_pins() {
10039 // The maximal ambiguity case — every pin axis set. Pinned so a
10040 // future relaxation that only catches pairs surfaces here. The
10041 // diagnostic must enumerate every offending axis so the author
10042 // sees the full set, not just the first match.
10043 let d = dep_with_fonte(DepSource::Git {
10044 repo: "github:pleme-io/caixa-teia".into(),
10045 tag: Some("v0.1.0".into()),
10046 rev: Some("c0ffee".into()),
10047 branch: Some("main".into()),
10048 });
10049 let err = d.validate().unwrap_err();
10050 let DepError::FontePinAmbiguous { nome, pins } = err else {
10051 panic!("expected FontePinAmbiguous");
10052 };
10053 assert_eq!(nome, "caixa-teia");
10054 assert!(pins.contains(":tag"));
10055 assert!(pins.contains(":rev"));
10056 assert!(pins.contains(":branch"));
10057 }
10058
10059 #[test]
10060 fn validate_rejects_git_fonte_with_empty_tag_pin() {
10061 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
10062 // inner string is empty. Distinct from FontePinMissing (where
10063 // every axis is None) — pinned separately so a future
10064 // tightening collapsing them surfaces here as a structural
10065 // decision.
10066 let d = dep_with_fonte(DepSource::Git {
10067 repo: "github:pleme-io/caixa-teia".into(),
10068 tag: Some(String::new()),
10069 rev: None,
10070 branch: None,
10071 });
10072 let err = d.validate().unwrap_err();
10073 let DepError::FontePinEmpty { nome, pin } = err else {
10074 panic!("expected FontePinEmpty");
10075 };
10076 assert_eq!(nome, "caixa-teia");
10077 assert_eq!(pin, ":tag");
10078 }
10079
10080 #[test]
10081 fn validate_rejects_git_fonte_with_empty_rev_pin() {
10082 // Sibling arm — the empty-pin diagnostic names which axis
10083 // carries the empty value, so the author's grep target is
10084 // unambiguous.
10085 let d = dep_with_fonte(DepSource::Git {
10086 repo: "github:pleme-io/caixa-teia".into(),
10087 tag: None,
10088 rev: Some(String::new()),
10089 branch: None,
10090 });
10091 let err = d.validate().unwrap_err();
10092 let DepError::FontePinEmpty { nome, pin } = err else {
10093 panic!("expected FontePinEmpty");
10094 };
10095 assert_eq!(nome, "caixa-teia");
10096 assert_eq!(pin, ":rev");
10097 }
10098
10099 #[test]
10100 fn validate_rejects_path_fonte_with_empty_caminho() {
10101 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
10102 // until this gate landed the resolver's
10103 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
10104 // fetch time — not actionable. The new gate moves the check to
10105 // validate time and names the offending dep.
10106 let d = dep_with_fonte(DepSource::Path {
10107 caminho: String::new(),
10108 });
10109 let err = d.validate().unwrap_err();
10110 assert!(
10111 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
10112 "got {err:?}"
10113 );
10114 }
10115
10116 #[test]
10117 fn validate_rejects_path_fonte_with_absolute_caminho() {
10118 // The fail-before-pass-after pin for the absolute-`:caminho`
10119 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
10120 // Until this gate landed an absolute `:caminho` silently
10121 // passed validate; the lacre pipeline embedded the
10122 // host-specific filesystem path verbatim in its
10123 // content-address (`conteudo: format!("path:{caminho}")`,
10124 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
10125 // differed per machine — the build succeeded but two CI
10126 // runners with different `${HOME}` layouts emitted two
10127 // distinct lacres for the byte-identical caixa, silently
10128 // breaking the THEORY.md §V.2 render-determinism contract
10129 // far from the source caixa.lisp. The new gate moves the
10130 // check to validate time and names the offending dep +
10131 // caminho verbatim.
10132 let d = dep_with_fonte(DepSource::Path {
10133 caminho: "/home/me/work/caixa-teia".into(),
10134 });
10135 let err = d.validate().unwrap_err();
10136 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
10137 panic!("expected FonteCaminhoAbsolute, got other variant");
10138 };
10139 assert_eq!(nome, "caixa-teia");
10140 assert_eq!(caminho, "/home/me/work/caixa-teia");
10141 }
10142
10143 #[test]
10144 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
10145 // The canonical sibling-workspace dep form
10146 // (`:caminho "../caixa-teia"`) remains accepted. The
10147 // absolute-path gate above is specifically narrower than the
10148 // shared [`crate::render::is_sandboxed_relative_path`]
10149 // predicate (which additionally forbids `..` traversal): a
10150 // local-path dep's canonical author surface is the in-tree
10151 // sibling-workspace path, so a full sandboxed-relative-path
10152 // lift would structurally reject every legitimate path-fonte
10153 // dep. Pinned so a future tightening to the full predicate
10154 // surfaces here as a structural decision, not a silent break.
10155 let d = dep_with_fonte(DepSource::Path {
10156 caminho: "../caixa-teia".into(),
10157 });
10158 d.validate().unwrap();
10159 }
10160
10161 #[test]
10162 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
10163 // A multi-segment relative `:caminho`
10164 // (`"vendor/forks/caixa-teia"`) remains accepted — the
10165 // absolute-path gate brackets the host-layout-leaking shape
10166 // at the leading-`/` boundary only; every relative shape past
10167 // the empty arm continues to pass. Pinned alongside the
10168 // `..`-traversal positive control so a future tightening
10169 // surfaces the full set of legitimate relative forms here
10170 // rather than at a downstream consumer.
10171 let d = dep_with_fonte(DepSource::Path {
10172 caminho: "vendor/forks/caixa-teia".into(),
10173 });
10174 d.validate().unwrap();
10175 }
10176
10177 #[test]
10178 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
10179 // The fail-before-pass-after pin for the tilde-expansion
10180 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
10181 // Until this gate landed the b94fd83 absolute arm let `~/foo`
10182 // through (`Path::is_absolute` returns false on a leading `~`
10183 // — the tilde is a shell-expansion convention, not a POSIX
10184 // path component), so the lacre embedded the value verbatim
10185 // and the resolver folded it through `Path::join` without
10186 // expansion, looking for a literal `./~/work/caixa-teia`
10187 // subdirectory and failing at resolve time with a
10188 // `No such file or directory` error far from the source
10189 // caixa.lisp. The new gate moves the check to validate time
10190 // and names the offending dep + caminho verbatim.
10191 let d = dep_with_fonte(DepSource::Path {
10192 caminho: "~/work/caixa-teia".into(),
10193 });
10194 let err = d.validate().unwrap_err();
10195 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
10196 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
10197 };
10198 assert_eq!(nome, "caixa-teia");
10199 assert_eq!(caminho, "~/work/caixa-teia");
10200 }
10201
10202 #[test]
10203 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
10204 // The bare `~` form (canonical "I meant `$HOME` and forgot
10205 // the rest"): both the leading-tilde arm catches it and the
10206 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
10207 // sweeps through the same arm. Pinned both to ensure the
10208 // gate doesn't narrow to `~/` only.
10209 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
10210 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10211 let err = d.validate().unwrap_err();
10212 assert!(
10213 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10214 "{s:?} → {err:?}",
10215 );
10216 }
10217 }
10218
10219 #[test]
10220 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
10221 // The leading-`~` is the canonical shell-expansion footgun —
10222 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
10223 // backup-file-suffix idiom) is a legitimate POSIX path byte
10224 // with no shell-expansion semantic at the leading position.
10225 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
10226 // sweep that would break every legitimate-shape backup-file
10227 // path.
10228 let d = dep_with_fonte(DepSource::Path {
10229 caminho: "../foo~bar/caixa-teia".into(),
10230 });
10231 d.validate().unwrap();
10232 }
10233
10234 #[test]
10235 fn fonte_caminho_empty_fires_before_tilde_expansion() {
10236 // Cascade pin: the empty arm structurally precedes the
10237 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
10238 // pin establishes the precedence at the diagnostic-shape
10239 // level should a future codec round-trip ever produce a
10240 // probe-as-both value. Mirrors the peer
10241 // `fonte_repo_empty_fires_before_pin_missing` cascade
10242 // discipline.
10243 let d = dep_with_fonte(DepSource::Path {
10244 caminho: String::new(),
10245 });
10246 let err = d.validate().unwrap_err();
10247 assert!(
10248 matches!(err, DepError::FonteCaminhoEmpty { .. }),
10249 "got {err:?}",
10250 );
10251 }
10252
10253 #[test]
10254 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
10255 // Diagnostic-shape pin (peer with
10256 // `validate_rejects_path_fonte_with_absolute_caminho`'s
10257 // payload assertion): the error's Display surfaces both the
10258 // offending `:nome` and the offending `:caminho` verbatim
10259 // so a `feira lint` run can render the diagnostic without
10260 // re-parsing.
10261 let d = dep_with_fonte(DepSource::Path {
10262 caminho: "~alice/dev/caixa-teia".into(),
10263 });
10264 let rendered = d.validate().unwrap_err().to_string();
10265 assert!(
10266 rendered.contains("caixa-teia"),
10267 "diagnostic must name the offending dep: {rendered}",
10268 );
10269 assert!(
10270 rendered.contains("~alice/dev/caixa-teia"),
10271 "diagnostic must quote the offending caminho: {rendered}",
10272 );
10273 assert!(
10274 rendered.contains('~'),
10275 "diagnostic must reference the tilde footgun: {rendered}",
10276 );
10277 }
10278
10279 #[test]
10280 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
10281 // The fail-before-pass-after pin for the shell-variable-
10282 // expansion `:caminho` shape: `(:tipo path :caminho
10283 // "$HOME/work/caixa-teia")`. Until this gate landed the
10284 // b94fd83 absolute arm + the a5c248e tilde arm both let
10285 // `$HOME/foo` through (`Path::is_absolute` returns false on
10286 // a leading `$` — the `$` is a shell convention, not a POSIX
10287 // path component; `starts_with('~')` returns false too), so
10288 // the lacre embedded the value verbatim and the resolver
10289 // folded it through `Path::join` without `$`-expansion,
10290 // looking for a literal `./$HOME/work/caixa-teia`
10291 // subdirectory and failing at resolve time with a
10292 // `No such file or directory` error far from the source
10293 // caixa.lisp. The new gate moves the check to validate time
10294 // and names the offending dep + caminho verbatim.
10295 let d = dep_with_fonte(DepSource::Path {
10296 caminho: "$HOME/work/caixa-teia".into(),
10297 });
10298 let err = d.validate().unwrap_err();
10299 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
10300 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
10301 };
10302 assert_eq!(nome, "caixa-teia");
10303 assert_eq!(caminho, "$HOME/work/caixa-teia");
10304 }
10305
10306 #[test]
10307 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
10308 // Sweep over every leading-`$` shape: the `${VAR}`-braced
10309 // form (canonical "paste-from-CI-manifest" footgun every
10310 // GitHub Actions / GitLab CI / Drone manifest carries on
10311 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
10312 // canonical "I'm referencing a per-user config dir"),
10313 // and the bare `$` (canonical "I meant `$HOME` and forgot
10314 // the rest"). All shapes route through the same gate's
10315 // byte check. Pinned so the gate doesn't narrow to a
10316 // single shape (e.g. `$HOME/` only).
10317 for s in [
10318 "${HOME}/work/caixa-teia",
10319 "${WORKSPACE}/caixa-teia",
10320 "$XDG_CONFIG_HOME/caixa",
10321 "$",
10322 ] {
10323 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10324 let err = d.validate().unwrap_err();
10325 assert!(
10326 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10327 "{s:?} → {err:?}",
10328 );
10329 }
10330 }
10331
10332 #[test]
10333 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
10334 // The `$` byte is the canonical shell-variable-expansion /
10335 // command-substitution / arithmetic-expansion sentinel and
10336 // is rejected at *every* position on the `:caminho` axis: the
10337 // leading arm surfaces `FonteCaminhoVarExpansion`, the
10338 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
10339 // (6620f39). Pinned so a future arm doesn't narrow the gate
10340 // back to the leading position and re-open the paste-from-
10341 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
10342 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
10343 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
10344 // the lacre content-address (`path:{caminho}`,
10345 // caixa-resolver/src/resolve.rs:189).
10346 let d = dep_with_fonte(DepSource::Path {
10347 caminho: "../foo$bar/caixa-teia".into(),
10348 });
10349 let err = d.validate().unwrap_err();
10350 assert!(
10351 matches!(
10352 err,
10353 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
10354 ),
10355 "got {err:?}",
10356 );
10357 }
10358
10359 #[test]
10360 fn fonte_caminho_tilde_fires_before_var_expansion() {
10361 // Cascade pin: the tilde arm structurally precedes the var
10362 // arm (the bytes `~` and `$` don't overlap at the leading
10363 // position), but the pin establishes the precedence at the
10364 // diagnostic-shape level should a future codec round-trip
10365 // ever produce a probe-as-both value. Mirrors the peer
10366 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
10367 // discipline on the immediate-predecessor arm.
10368 let d = dep_with_fonte(DepSource::Path {
10369 caminho: "~/work/caixa-teia".into(),
10370 });
10371 let err = d.validate().unwrap_err();
10372 assert!(
10373 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10374 "got {err:?}",
10375 );
10376 }
10377
10378 #[test]
10379 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
10380 // Diagnostic-shape pin (peer with
10381 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
10382 // payload assertion on the immediate-predecessor arm): the
10383 // error's Display surfaces both the offending `:nome` and
10384 // the offending `:caminho` verbatim plus the `$` footgun
10385 // character itself so a `feira lint` run can render the
10386 // diagnostic without re-parsing.
10387 let d = dep_with_fonte(DepSource::Path {
10388 caminho: "${WORKSPACE}/caixa-teia".into(),
10389 });
10390 let rendered = d.validate().unwrap_err().to_string();
10391 assert!(
10392 rendered.contains("caixa-teia"),
10393 "diagnostic must name the offending dep: {rendered}",
10394 );
10395 assert!(
10396 rendered.contains("${WORKSPACE}/caixa-teia"),
10397 "diagnostic must quote the offending caminho: {rendered}",
10398 );
10399 assert!(
10400 rendered.contains('$'),
10401 "diagnostic must reference the dollar footgun: {rendered}",
10402 );
10403 }
10404
10405 #[test]
10406 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
10407 // The fail-before-pass-after pin for the load-bearing NUL byte:
10408 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
10409 // routes the path through `CString::new` which fails with
10410 // `NulError`); until this gate landed a `:caminho
10411 // "../caixa\0teia"` silently passed validate, the lacre
10412 // pipeline embedded the value verbatim, and the failure
10413 // surfaced at the resolver's `Path::join` → `CString::new`
10414 // boundary with a non-self-locating `NulError` far from the
10415 // source caixa.lisp. The new gate moves the check to validate
10416 // time and names the offending dep + caminho + offending byte
10417 // verbatim.
10418 let d = dep_with_fonte(DepSource::Path {
10419 caminho: "../caixa\0teia".into(),
10420 });
10421 let err = d.validate().unwrap_err();
10422 let DepError::FonteCaminhoControlChar {
10423 nome,
10424 caminho,
10425 byte,
10426 } = err
10427 else {
10428 panic!("expected FonteCaminhoControlChar, got {err:?}");
10429 };
10430 assert_eq!(nome, "caixa-teia");
10431 assert_eq!(caminho, "../caixa\0teia");
10432 assert_eq!(byte, 0x00);
10433 }
10434
10435 #[test]
10436 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
10437 // The canonical paste-from-multiline-doc footgun on `:caminho`
10438 // — author copies `"../caixa-teia\n"` (trailing newline) out
10439 // of a multi-line code-fence or, worse, a `:caminho
10440 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
10441 // injection sibling on the path axis the `is_git_repo_url`
10442 // control-char arm already closes on `:repo`). Pinned
10443 // separately from the NUL arm so a future relaxation that
10444 // catches one but not the other surfaces here.
10445 let d = dep_with_fonte(DepSource::Path {
10446 caminho: "../caixa-teia\n".into(),
10447 });
10448 let err = d.validate().unwrap_err();
10449 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10450 panic!("expected FonteCaminhoControlChar, got {err:?}");
10451 };
10452 assert_eq!(byte, 0x0A);
10453 }
10454
10455 #[test]
10456 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
10457 // The CRLF sibling of the LF arm — Windows-line-ending
10458 // paste-from-multiline-doc on a `\r\n`-terminated buffer
10459 // leaves a stray `\r` mid-string after the LF strip. Pinned
10460 // separately from the LF arm so a future relaxation that
10461 // only catches LF surfaces here.
10462 let d = dep_with_fonte(DepSource::Path {
10463 caminho: "../caixa-teia\r".into(),
10464 });
10465 let err = d.validate().unwrap_err();
10466 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10467 panic!("expected FonteCaminhoControlChar, got {err:?}");
10468 };
10469 assert_eq!(byte, 0x0D);
10470 }
10471
10472 #[test]
10473 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
10474 // The canonical paste-from-aligned-table footgun — a `\t`
10475 // mid-`:caminho` is invisible in most editors but rides
10476 // through the lacre's content-address verbatim, so two
10477 // paste-from-distinct-tables (one editor strips tabs, one
10478 // preserves them) yield divergent lacres for the byte-
10479 // identical-looking caixa. Pinned separately from the
10480 // whitespace-shaped LF/CR arms so a future relaxation that
10481 // narrows to line-terminator-only surfaces here.
10482 let d = dep_with_fonte(DepSource::Path {
10483 caminho: "../caixa\tteia".into(),
10484 });
10485 let err = d.validate().unwrap_err();
10486 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10487 panic!("expected FonteCaminhoControlChar, got {err:?}");
10488 };
10489 assert_eq!(byte, 0x09);
10490 }
10491
10492 #[test]
10493 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
10494 // The DEL byte (`0x7F`) closes the upper-end paste-from-
10495 // binary-blob footgun — the gate's contract is `b < 0x20 ||
10496 // b == 0x7F`, matching the `is_git_repo_url` /
10497 // `is_git_ref_name` predicates' control-char arms. Pinned
10498 // separately from the lower-range arms so a future narrowing
10499 // to `< 0x20` only surfaces here.
10500 let d = dep_with_fonte(DepSource::Path {
10501 caminho: "../caixa\x7fteia".into(),
10502 });
10503 let err = d.validate().unwrap_err();
10504 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10505 panic!("expected FonteCaminhoControlChar, got {err:?}");
10506 };
10507 assert_eq!(byte, 0x7F);
10508 }
10509
10510 #[test]
10511 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
10512 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
10513 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
10514 // are opaque byte sequences and UTF-8 multi-byte sequences
10515 // are a legitimate filename shape (the `café-teia/foo` idiom).
10516 // Pinned so the gate doesn't widen to a full ASCII-only sweep
10517 // that would break every legitimate-shape UTF-8 path.
10518 let d = dep_with_fonte(DepSource::Path {
10519 caminho: "../café-teia/foo".into(),
10520 });
10521 d.validate().unwrap();
10522 }
10523
10524 #[test]
10525 fn fonte_caminho_var_fires_before_control_char() {
10526 // Cascade pin: the var-expansion arm structurally precedes the
10527 // control-char arm. A value like `"$\n"` probes positive on
10528 // both arms (`starts_with('$')` and contains LF), but the
10529 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
10530 // wins so the author sees the more self-locating shell-
10531 // expansion arm first. Mirrors the
10532 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10533 // discipline on the immediate-predecessor arm.
10534 let d = dep_with_fonte(DepSource::Path {
10535 caminho: "$HOME\n".into(),
10536 });
10537 let err = d.validate().unwrap_err();
10538 assert!(
10539 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10540 "got {err:?}",
10541 );
10542 }
10543
10544 #[test]
10545 fn validate_rejects_path_fonte_with_leading_space_caminho() {
10546 // The fail-before-pass-after pin for the leading ASCII space
10547 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
10548 // Until this gate landed the b94fd83 absolute arm + the a5c248e
10549 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
10550 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
10551 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
10552 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
10553 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
10554 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
10555 // are caught, but the most common whitespace `0x20` space is
10556 // not). The lacre embedded the value verbatim and the resolver
10557 // folded it through `Path::join` looking for a literal `./ ../
10558 // caixa-teia` subdirectory and failing at resolve time with a
10559 // non-self-locating `No such file or directory` error far from
10560 // the source caixa.lisp. The new gate moves the check to
10561 // validate time and names the offending dep + caminho verbatim.
10562 let d = dep_with_fonte(DepSource::Path {
10563 caminho: " ../caixa-teia".into(),
10564 });
10565 let err = d.validate().unwrap_err();
10566 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
10567 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
10568 };
10569 assert_eq!(nome, "caixa-teia");
10570 assert_eq!(caminho, " ../caixa-teia");
10571 }
10572
10573 #[test]
10574 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
10575 // The aligned-doc paste footgun sweep: more than one leading
10576 // space (`" ../caixa-teia"` — the canonical "I selected the
10577 // aligned column from a four-`:fonte`-entry `:deps` block"
10578 // paste) routes through the same gate's `starts_with(' ')`
10579 // byte check. Pinned so the gate doesn't narrow to a
10580 // single-space prefix.
10581 let d = dep_with_fonte(DepSource::Path {
10582 caminho: " ../caixa-teia".into(),
10583 });
10584 let err = d.validate().unwrap_err();
10585 assert!(
10586 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10587 "got {err:?}",
10588 );
10589 }
10590
10591 #[test]
10592 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
10593 // The leading-space is the canonical paste-from-aligned-doc
10594 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
10595 // canonical "I have a directory with a space in its name"
10596 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
10597 // legitimate path with no whitespace-leak semantic at the
10598 // non-leading position. Pinned so the gate doesn't widen to a
10599 // full no-space-anywhere sweep that would break every
10600 // legitimate-shape space-in-filename path.
10601 let d = dep_with_fonte(DepSource::Path {
10602 caminho: "../my dir/caixa-teia".into(),
10603 });
10604 d.validate().unwrap();
10605 }
10606
10607 #[test]
10608 fn fonte_caminho_var_fires_before_leading_whitespace() {
10609 // Cascade pin: the var-expansion arm structurally precedes the
10610 // leading-whitespace arm. A value like `"$ "` would probe positive
10611 // on var (`starts_with('$')`) but the leading-byte arms walk
10612 // left-to-right so the var arm fires on the leading `$` before
10613 // the leading-whitespace arm probes. Mirrors the
10614 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10615 // discipline on the immediate-predecessor arms.
10616 let d = dep_with_fonte(DepSource::Path {
10617 caminho: "$VAR".into(),
10618 });
10619 let err = d.validate().unwrap_err();
10620 assert!(
10621 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10622 "got {err:?}",
10623 );
10624 }
10625
10626 #[test]
10627 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
10628 // Cascade pin: the leading-whitespace arm structurally precedes
10629 // the control-char arm. A value like `" ../foo\n"` probes
10630 // positive on both (starts with space AND contains LF), but
10631 // the narrower leading-byte diagnostic
10632 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
10633 // more self-locating paste-from-aligned-doc arm first. Mirrors
10634 // the `fonte_caminho_var_fires_before_control_char` cascade
10635 // discipline on the immediate-predecessor arm.
10636 let d = dep_with_fonte(DepSource::Path {
10637 caminho: " ../foo\n".into(),
10638 });
10639 let err = d.validate().unwrap_err();
10640 assert!(
10641 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10642 "got {err:?}",
10643 );
10644 }
10645
10646 #[test]
10647 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10648 // Diagnostic-shape pin (peer with
10649 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10650 // payload assertion on the immediate-predecessor arm): the
10651 // error's Display surfaces both the offending `:nome` and the
10652 // offending `:caminho` verbatim, so a `feira lint` run can
10653 // render the diagnostic without re-parsing and the author can
10654 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10655 // one edit.
10656 let d = dep_with_fonte(DepSource::Path {
10657 caminho: " ../caixa-teia".into(),
10658 });
10659 let rendered = d.validate().unwrap_err().to_string();
10660 assert!(
10661 rendered.contains("caixa-teia"),
10662 "diagnostic must name the offending dep: {rendered}",
10663 );
10664 assert!(
10665 rendered.contains(" ../caixa-teia"),
10666 "diagnostic must quote the offending caminho: {rendered}",
10667 );
10668 assert!(
10669 rendered.contains("space"),
10670 "diagnostic must name the space footgun: {rendered}",
10671 );
10672 }
10673
10674 #[test]
10675 fn fonte_caminho_absolute_fires_before_control_char() {
10676 // Cascade pin on the sibling leading-byte arm: a leading `/`
10677 // value with embedded control byte (`"/etc/passwd\n"`) routes
10678 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10679 // — the host-layout-leak diagnostic is the load-bearing axis,
10680 // the control byte is the secondary observation. Same precedence
10681 // logic on every prior leading-byte arm.
10682 let d = dep_with_fonte(DepSource::Path {
10683 caminho: "/etc/passwd\n".into(),
10684 });
10685 let err = d.validate().unwrap_err();
10686 assert!(
10687 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10688 "got {err:?}",
10689 );
10690 }
10691
10692 #[test]
10693 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10694 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10695 // injection `:caminho` shape sweep. Until this gate landed
10696 // every prior leading-byte arm passed a leading-`-` value
10697 // through: `Path::is_absolute` returns false on `-` (the
10698 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10699 // `starts_with('$')` / `starts_with(' ')` all return false,
10700 // and `0x2D` sits outside the control-byte set. The lacre
10701 // embedded the value verbatim and the resolver folded it
10702 // through `Path::join` looking for a literal `./-rf` /
10703 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10704 // `Path::join` time is non-self-locating but harmless, while
10705 // the failure at every downstream `git -C {caminho}` /
10706 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10707 // is arbitrary-CLI-arg-injection because none of those
10708 // porcelains carry a `--` argument-list terminator between
10709 // the flag block and the path argument. The new arm moves the
10710 // rejection to `Caixa::from_lisp` boundary time and names
10711 // the offending dep + caminho verbatim.
10712 //
10713 // Sweep spans the canonical CLI-arg-injection shapes matching
10714 // the peer sweep on the sibling `is_git_ref_name` /
10715 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10716 // `find -rf` reinterpretation vector), `-C` (the `git -C`
10717 // change-directory-config-injection paste), long-flag
10718 // `--upload-pack=cat /etc/passwd` (the canonical
10719 // arbitrary-command-execution vector on every git porcelain
10720 // entry point), git-config-injection `--config=core.merge=ours`,
10721 // and the degenerate single-byte `-` value.
10722 for caminho in [
10723 "-rf",
10724 "-C",
10725 "--upload-pack=cat /etc/passwd",
10726 "--config=core.merge=ours",
10727 "-",
10728 ] {
10729 let d = dep_with_fonte(DepSource::Path {
10730 caminho: caminho.into(),
10731 });
10732 let err = d.validate().unwrap_err();
10733 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10734 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10735 };
10736 assert_eq!(nome, "caixa-teia");
10737 assert_eq!(got, caminho);
10738 }
10739 }
10740
10741 #[test]
10742 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10743 // The leading-`-` is the canonical CLI-arg-injection footgun
10744 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10745 // canonical kebab-separator-between-alphanumeric-segments
10746 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10747 // — a mid-path segment starting with `-`, still a legitimate
10748 // POSIX filename byte at that non-leading position because the
10749 // subprocess reads the whole `{caminho}` value as one positional
10750 // argument, so only the very first byte of the composite path
10751 // string is at the CLI-arg-injection boundary) is a legitimate
10752 // path with no CLI-flag-reinterpretation semantic at the non-
10753 // leading position of the top-level value. Pinned so the gate
10754 // doesn't widen to a full no-`-`-anywhere sweep that would
10755 // break every legitimate-shape kebab-in-filename path (i.e.
10756 // essentially every sibling-workspace caixa dep).
10757 for caminho in [
10758 "../caixa-teia",
10759 "../caixa-teia/-hidden",
10760 "./my-lib",
10761 "../foo-bar/baz",
10762 ] {
10763 let d = dep_with_fonte(DepSource::Path {
10764 caminho: caminho.into(),
10765 });
10766 d.validate()
10767 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10768 }
10769 }
10770
10771 #[test]
10772 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10773 // Cascade pin: the leading-whitespace arm structurally precedes
10774 // the leading-hyphen arm. A value like `" -rf"` probes positive
10775 // on both (leading space AND, one byte in, a `-` — though the
10776 // leading-hyphen arm probes only the very first byte so it
10777 // wouldn't fire on this value; the pin instead documents the
10778 // arm order on the more common "leading space then a hyphen"
10779 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10780 // The narrower leading-space diagnostic (the paste-from-aligned-
10781 // doc footgun) wins so the author sees the more self-locating
10782 // whitespace arm first. Mirrors the
10783 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10784 // discipline on the immediate-predecessor arm.
10785 let d = dep_with_fonte(DepSource::Path {
10786 caminho: " -rf".into(),
10787 });
10788 let err = d.validate().unwrap_err();
10789 assert!(
10790 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10791 "got {err:?}",
10792 );
10793 }
10794
10795 #[test]
10796 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10797 // Cascade pin: the leading-hyphen arm structurally precedes
10798 // the control-char arm. A value like `"-rf\n"` probes positive
10799 // on both (starts with `-` AND contains LF), but the narrower
10800 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10801 // the author sees the more self-locating CLI-arg-injection arm
10802 // first. Mirrors the
10803 // `fonte_caminho_leading_whitespace_fires_before_control_char`
10804 // cascade discipline on the immediate-predecessor arm.
10805 let d = dep_with_fonte(DepSource::Path {
10806 caminho: "-rf\n".into(),
10807 });
10808 let err = d.validate().unwrap_err();
10809 assert!(
10810 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10811 "got {err:?}",
10812 );
10813 }
10814
10815 #[test]
10816 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10817 // Diagnostic-shape pin (peer with
10818 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10819 // payload assertion on the immediate-predecessor arm): the
10820 // error's Display surfaces both the offending `:nome` and the
10821 // offending `:caminho` verbatim plus the CLI-argument-injection
10822 // vocabulary, so a `feira lint` run can render the diagnostic
10823 // without re-parsing and the author can grep their caixa.lisp
10824 // for `:caminho "<value>"` and fix it in one edit.
10825 let d = dep_with_fonte(DepSource::Path {
10826 caminho: "--upload-pack=cat /etc/passwd".into(),
10827 });
10828 let rendered = d.validate().unwrap_err().to_string();
10829 assert!(
10830 rendered.contains("caixa-teia"),
10831 "diagnostic must name the offending dep: {rendered}",
10832 );
10833 assert!(
10834 rendered.contains("--upload-pack=cat /etc/passwd"),
10835 "diagnostic must quote the offending caminho: {rendered}",
10836 );
10837 assert!(
10838 rendered.contains("CLI-argument-injection"),
10839 "diagnostic must name the CLI-argument-injection vector: {rendered}",
10840 );
10841 assert!(
10842 rendered.contains("`-`"),
10843 "diagnostic must name the offending byte: {rendered}",
10844 );
10845 }
10846
10847 #[test]
10848 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10849 // Diagnostic-shape pin (peer with
10850 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10851 // payload assertion on the immediate-predecessor arm): the
10852 // error's Display surfaces the offending `:nome`, the
10853 // offending `:caminho` verbatim, and the offending byte in
10854 // hex form (`0x09` for tab) so a `feira lint` run can render
10855 // the diagnostic without re-parsing.
10856 let d = dep_with_fonte(DepSource::Path {
10857 caminho: "../caixa\tteia".into(),
10858 });
10859 let rendered = d.validate().unwrap_err().to_string();
10860 assert!(
10861 rendered.contains("caixa-teia"),
10862 "diagnostic must name the offending dep: {rendered}",
10863 );
10864 assert!(
10865 rendered.contains("../caixa\tteia"),
10866 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10867 );
10868 assert!(
10869 rendered.contains("0x09"),
10870 "diagnostic must name the offending byte in hex: {rendered:?}",
10871 );
10872 }
10873
10874 #[test]
10875 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10876 // The fail-before-pass-after pin for the canonical Windows-
10877 // path-separator paste footgun: an author who pastes a path
10878 // from Windows-Explorer's `Copy as path`, PowerShell's
10879 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10880 // produces `..\caixa-teia`-shape values that silently passed
10881 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10882 // false; `\` is neither a leading-byte sentinel nor a
10883 // control byte). On POSIX resolvers the value rides through
10884 // `Path::join` as a literal directory name and fails at
10885 // resolve time with `No such file or directory`; on Windows
10886 // resolvers the value resolves to the parent's sibling — two
10887 // distinct directories for the byte-identical caixa.lisp.
10888 // The new arm moves the rejection to validate time and names
10889 // the offending dep + caminho verbatim.
10890 let d = dep_with_fonte(DepSource::Path {
10891 caminho: "..\\caixa-teia".into(),
10892 });
10893 let err = d.validate().unwrap_err();
10894 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10895 panic!("expected FonteCaminhoBackslash, got {err:?}");
10896 };
10897 assert_eq!(nome, "caixa-teia");
10898 assert_eq!(caminho, "..\\caixa-teia");
10899 }
10900
10901 #[test]
10902 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10903 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10904 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10905 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10906 // false (POSIX absolute paths start with `/`, drive letters
10907 // are not a POSIX concept), so the b94fd83 absolute arm
10908 // doesn't fire; the value contains `\` bytes that this arm
10909 // now catches with the more self-locating Windows-path-
10910 // separator diagnostic. Pinned separately from the bare
10911 // `..\caixa-teia` shape so a future arm that targets only
10912 // leading-`..\` doesn't regress the drive-letter coverage.
10913 let d = dep_with_fonte(DepSource::Path {
10914 caminho: "C:\\work\\caixa-teia".into(),
10915 });
10916 let err = d.validate().unwrap_err();
10917 assert!(
10918 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10919 "got {err:?}",
10920 );
10921 }
10922
10923 #[test]
10924 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10925 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10926 // PowerShell tab-completion-on-a-directory append). Pinned
10927 // separately from the embedded-`\` shape so the gate's
10928 // contract is "any `\` anywhere", not "any `\` not at end".
10929 let d = dep_with_fonte(DepSource::Path {
10930 caminho: "..\\caixa-teia\\".into(),
10931 });
10932 let err = d.validate().unwrap_err();
10933 assert!(
10934 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10935 "got {err:?}",
10936 );
10937 }
10938
10939 #[test]
10940 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10941 // The positive-control pin: the gate targets `\` only,
10942 // never `/`. The canonical relative POSIX path
10943 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10944 // so legitimate nested-directory deps aren't broken. Pinned
10945 // so the gate doesn't accidentally widen to a "no path
10946 // separators at all" sweep.
10947 let d = dep_with_fonte(DepSource::Path {
10948 caminho: "../caixa-teia/foo/bar".into(),
10949 });
10950 d.validate().unwrap();
10951 }
10952
10953 #[test]
10954 fn fonte_caminho_control_char_fires_before_backslash() {
10955 // Cascade pin: the control-char arm structurally precedes the
10956 // backslash arm. A value like `"..\caixa\0teia"` probes
10957 // positive on both (`\` byte + NUL byte), but the control-
10958 // char diagnostic wins so the author sees the more self-
10959 // locating POSIX-syscall-rejected-byte diagnostic first
10960 // (NUL outright breaks `CString::new` at every `std::fs`
10961 // syscall boundary; the `\` divergence is the cross-OS-
10962 // separator axis). Mirrors the
10963 // `fonte_caminho_var_fires_before_control_char` cascade
10964 // discipline on the immediate-predecessor arm.
10965 let d = dep_with_fonte(DepSource::Path {
10966 caminho: "..\\caixa\0teia".into(),
10967 });
10968 let err = d.validate().unwrap_err();
10969 assert!(
10970 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10971 "got {err:?}",
10972 );
10973 }
10974
10975 #[test]
10976 fn fonte_caminho_absolute_fires_before_backslash() {
10977 // Cascade pin on the load-bearing leading-byte arm: a leading
10978 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10979 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10980 // — the host-layout-leak diagnostic is the load-bearing
10981 // axis, the `\` byte is the secondary observation. Same
10982 // precedence logic as every prior leading-byte arm.
10983 let d = dep_with_fonte(DepSource::Path {
10984 caminho: "/etc/passwd\\foo".into(),
10985 });
10986 let err = d.validate().unwrap_err();
10987 assert!(
10988 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10989 "got {err:?}",
10990 );
10991 }
10992
10993 #[test]
10994 fn fonte_caminho_var_fires_before_backslash() {
10995 // Cascade pin on the var-expansion arm: a leading-`$` value
10996 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10997 // PowerShell-env-var paste-from-CI-manifest footgun) routes
10998 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10999 // The shell-expansion diagnostic is the more self-locating
11000 // axis since both the leading `$` and the embedded `\`
11001 // are Windows-shell artifacts but the `$` is the root-cause
11002 // surface (an author who removes the `$` is likely to leave
11003 // the `\` too).
11004 let d = dep_with_fonte(DepSource::Path {
11005 caminho: "$WORKSPACE\\caixa-teia".into(),
11006 });
11007 let err = d.validate().unwrap_err();
11008 assert!(
11009 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11010 "got {err:?}",
11011 );
11012 }
11013
11014 #[test]
11015 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
11016 // Diagnostic-shape pin (peer with the prior
11017 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
11018 // on every preceding arm): the error's Display surfaces the
11019 // offending `:nome` and the offending `:caminho` verbatim
11020 // so a `feira lint` run can render the diagnostic without
11021 // re-parsing.
11022 let d = dep_with_fonte(DepSource::Path {
11023 caminho: "..\\caixa-teia".into(),
11024 });
11025 let rendered = d.validate().unwrap_err().to_string();
11026 assert!(
11027 rendered.contains("caixa-teia"),
11028 "diagnostic must name the offending dep: {rendered}",
11029 );
11030 assert!(
11031 rendered.contains("..\\caixa-teia"),
11032 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11033 );
11034 assert!(
11035 rendered.contains('\\'),
11036 "diagnostic must reference the backslash footgun: {rendered:?}",
11037 );
11038 }
11039
11040 #[test]
11041 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
11042 // The fail-before-pass-after pin for the canonical trailing-`/`
11043 // paste footgun: an author who shell-tab-completes a sibling
11044 // directory (every interactive shell — bash/zsh/fish/nushell —
11045 // appends `/` on tab-completing a directory) produces
11046 // `"../caixa-teia/"`-shape values that silently passed every
11047 // prior arm (the leading byte is `.`, no control bytes, no
11048 // backslash). `Path::join` resolves both shapes to the same
11049 // directory at the resolver, but the lacre embeds the value
11050 // verbatim and the BLAKE3 closures diverge across two
11051 // workstations whose authors differ only in tab-completion
11052 // habits.
11053 let d = dep_with_fonte(DepSource::Path {
11054 caminho: "../caixa-teia/".into(),
11055 });
11056 let err = d.validate().unwrap_err();
11057 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
11058 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
11059 };
11060 assert_eq!(nome, "caixa-teia");
11061 assert_eq!(caminho, "../caixa-teia/");
11062 }
11063
11064 #[test]
11065 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
11066 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
11067 // directory and tab-completed it" footgun). Pinned separately
11068 // from the canonical `"../caixa-teia/"` shape so the gate's
11069 // contract is "any trailing `/`", not "trailing `/` after a leaf
11070 // name".
11071 let d = dep_with_fonte(DepSource::Path {
11072 caminho: "./".into(),
11073 });
11074 let err = d.validate().unwrap_err();
11075 assert!(
11076 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
11077 "got {err:?}",
11078 );
11079 }
11080
11081 #[test]
11082 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
11083 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
11084 // that double-templated `${VAR}/` over an already-`/`-suffixed
11085 // path" footgun). The gate fires on the last byte being `/`
11086 // regardless of how many `/` precede it; the arm contract is
11087 // "the value ends with `/`", structurally.
11088 let d = dep_with_fonte(DepSource::Path {
11089 caminho: "../caixa-teia//".into(),
11090 });
11091 let err = d.validate().unwrap_err();
11092 assert!(
11093 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
11094 "got {err:?}",
11095 );
11096 }
11097
11098 #[test]
11099 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
11100 // The `"../"` shape (the canonical "I want the parent" tab-
11101 // completion footgun on a bare `..` path). Pinned separately so
11102 // the gate doesn't accidentally narrow to "trailing `/` only on
11103 // multi-segment paths".
11104 let d = dep_with_fonte(DepSource::Path {
11105 caminho: "../".into(),
11106 });
11107 let err = d.validate().unwrap_err();
11108 assert!(
11109 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
11110 "got {err:?}",
11111 );
11112 }
11113
11114 #[test]
11115 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
11116 // The positive-control pin: the gate targets the trailing byte
11117 // only, never internal `/` separators. The canonical nested
11118 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
11119 // to validate cleanly so legitimate deeply-nested deps aren't
11120 // broken. Pinned so the gate doesn't accidentally widen to a
11121 // "no `/` separators anywhere" sweep that would defeat the
11122 // entire path-fonte author surface.
11123 let d = dep_with_fonte(DepSource::Path {
11124 caminho: "../caixa-teia/foo/bar".into(),
11125 });
11126 d.validate().unwrap();
11127 }
11128
11129 #[test]
11130 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
11131 // The positive-control pin on the degenerate single-`.` shape
11132 // (the canonical "the caixa.lisp's own directory" idiom). The
11133 // gate fires on the trailing byte being `/`, not on the path
11134 // being short, so `"."` (one byte, not `/`) must continue to
11135 // validate cleanly.
11136 let d = dep_with_fonte(DepSource::Path {
11137 caminho: ".".into(),
11138 });
11139 d.validate().unwrap();
11140 }
11141
11142 #[test]
11143 fn fonte_caminho_control_char_fires_before_trailing_slash() {
11144 // Cascade pin: the control-char arm structurally precedes the
11145 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
11146 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
11147 // (control bytes are the paste-from-multiline-doc footgun the
11148 // d624c8d arm already closes). Mirrors the
11149 // `fonte_caminho_control_char_fires_before_backslash` cascade
11150 // discipline on the immediate-predecessor arm.
11151 let d = dep_with_fonte(DepSource::Path {
11152 caminho: "../foo\n/".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_backslash_fires_before_trailing_slash() {
11163 // Cascade pin on the backslash arm: a value like `"..\foo/"`
11164 // ends in `/` but the embedded `\` is the load-bearing
11165 // diagnostic (the cross-host-OS-separator divergence vector
11166 // the 3a4e1d7 arm closes). Same precedence logic as the prior
11167 // narrower-diagnostic-first cascade.
11168 let d = dep_with_fonte(DepSource::Path {
11169 caminho: "..\\caixa-teia/".into(),
11170 });
11171 let err = d.validate().unwrap_err();
11172 assert!(
11173 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11174 "got {err:?}",
11175 );
11176 }
11177
11178 #[test]
11179 fn fonte_caminho_absolute_fires_before_trailing_slash() {
11180 // Cascade pin on the load-bearing leading-byte arm: a leading
11181 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
11182 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
11183 // — the host-layout-leak diagnostic is the load-bearing axis,
11184 // the trailing `/` is the secondary observation. Same
11185 // precedence logic as every prior leading-byte arm.
11186 let d = dep_with_fonte(DepSource::Path {
11187 caminho: "/etc/passwd/".into(),
11188 });
11189 let err = d.validate().unwrap_err();
11190 assert!(
11191 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11192 "got {err:?}",
11193 );
11194 }
11195
11196 #[test]
11197 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
11198 // Diagnostic-shape pin (peer with the prior
11199 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
11200 // every preceding arm): the error's Display surfaces the
11201 // offending `:nome` and the offending `:caminho` verbatim so a
11202 // `feira lint` run can render the diagnostic without re-parsing.
11203 let d = dep_with_fonte(DepSource::Path {
11204 caminho: "../caixa-teia/".into(),
11205 });
11206 let rendered = d.validate().unwrap_err().to_string();
11207 assert!(
11208 rendered.contains("caixa-teia"),
11209 "diagnostic must name the offending dep: {rendered}",
11210 );
11211 assert!(
11212 rendered.contains("../caixa-teia/"),
11213 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11214 );
11215 assert!(
11216 rendered.contains("trailing"),
11217 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
11218 );
11219 }
11220
11221 // -- :caminho shell-redirection metacharacter arm -----------------------
11222
11223 #[test]
11224 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
11225 // The fail-before-pass-after pin for the canonical output-redirection
11226 // paste footgun: an author copies a shell pipeline tail
11227 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
11228 // line including the `> build.log` redirect" idiom) and silently
11229 // passed every prior arm (`Path::is_absolute` false on `..`, no
11230 // control bytes, no backslash, doesn't end in `/`). The lacre
11231 // embedded the value verbatim, the resolver folded it through
11232 // `Path::join` looking for a literal `./../caixa-teia>build.log`
11233 // subdirectory, and the failure surfaced at resolve time with a
11234 // non-self-locating `No such file or directory` error. The new arm
11235 // moves the rejection to validate time and names the offending dep
11236 // + caminho + byte verbatim.
11237 let d = dep_with_fonte(DepSource::Path {
11238 caminho: "../caixa-teia>build.log".into(),
11239 });
11240 let err = d.validate().unwrap_err();
11241 let DepError::FonteCaminhoShellRedirection {
11242 nome,
11243 caminho,
11244 byte,
11245 } = err
11246 else {
11247 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11248 };
11249 assert_eq!(nome, "caixa-teia");
11250 assert_eq!(caminho, "../caixa-teia>build.log");
11251 assert_eq!(byte, b'>');
11252 }
11253
11254 #[test]
11255 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
11256 // The symmetric input-redirection paste shape
11257 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
11258 // `command < input.lisp` line from a tatara-lisp REPL log"
11259 // idiom). Pinned separately from the `>` shape so the gate's
11260 // contract is "any `<` or `>` anywhere", not single-byte coverage.
11261 let d = dep_with_fonte(DepSource::Path {
11262 caminho: "../caixa-teia<input.lisp".into(),
11263 });
11264 let err = d.validate().unwrap_err();
11265 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
11266 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11267 };
11268 assert_eq!(byte, b'<');
11269 }
11270
11271 #[test]
11272 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
11273 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
11274 // "I forgot the source side of the redirect" idiom). Pinned
11275 // separately from the embedded-byte shapes so the gate covers
11276 // every position, not only mid-path.
11277 let d = dep_with_fonte(DepSource::Path {
11278 caminho: ">../caixa-teia".into(),
11279 });
11280 let err = d.validate().unwrap_err();
11281 assert!(
11282 matches!(
11283 err,
11284 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11285 ),
11286 "got {err:?}",
11287 );
11288 }
11289
11290 #[test]
11291 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
11292 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
11293 // the canonical "I copied a `>>` append redirect" idiom). The arm
11294 // fires on the first `>` encountered; pinned so a future arm that
11295 // tries to distinguish `>` from `>>` doesn't break the broader
11296 // contract.
11297 let d = dep_with_fonte(DepSource::Path {
11298 caminho: "../caixa-teia>>build.log".into(),
11299 });
11300 let err = d.validate().unwrap_err();
11301 assert!(
11302 matches!(
11303 err,
11304 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11305 ),
11306 "got {err:?}",
11307 );
11308 }
11309
11310 #[test]
11311 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
11312 // The positive-control pin: the gate targets only `<` / `>`,
11313 // never adjacent printable ASCII or POSIX-valid bytes. The
11314 // canonical relative POSIX path (`"../caixa-teia"`) and a
11315 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
11316 // continue to validate cleanly so the gate doesn't widen to a
11317 // "no printable punctuation anywhere" sweep that would defeat
11318 // the entire path-fonte author surface.
11319 let d = dep_with_fonte(DepSource::Path {
11320 caminho: "../caixa-teia/foo/bar".into(),
11321 });
11322 d.validate().unwrap();
11323 }
11324
11325 #[test]
11326 fn fonte_caminho_backslash_fires_before_shell_redirection() {
11327 // Cascade pin on the immediate-predecessor arm: a value carrying
11328 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
11329 // canonical "I pasted a Windows-shell command with output
11330 // redirect" footgun) routes through `FonteCaminhoBackslash` not
11331 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
11332 // divergence is the load-bearing axis (an author who removes
11333 // the `\` is the root-cause edit; the `>` falls away in the
11334 // same edit since it's downstream of the Windows-shell
11335 // convention).
11336 let d = dep_with_fonte(DepSource::Path {
11337 caminho: "..\\caixa-teia>build.log".into(),
11338 });
11339 let err = d.validate().unwrap_err();
11340 assert!(
11341 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11342 "got {err:?}",
11343 );
11344 }
11345
11346 #[test]
11347 fn fonte_caminho_control_char_fires_before_shell_redirection() {
11348 // Cascade pin on the embedded-control-byte arm: a value carrying
11349 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
11350 // canonical paste-from-multiline-doc footgun where a newline
11351 // landed mid-caminho) routes through `FonteCaminhoControlChar`
11352 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
11353 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11354 // load-bearing axis on every value that probes positive for
11355 // both — mirrors the cascade discipline on every prior arm.
11356 let d = dep_with_fonte(DepSource::Path {
11357 caminho: "../foo\n>bar".into(),
11358 });
11359 let err = d.validate().unwrap_err();
11360 assert!(
11361 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11362 "got {err:?}",
11363 );
11364 }
11365
11366 #[test]
11367 fn fonte_caminho_absolute_fires_before_shell_redirection() {
11368 // Cascade pin on the load-bearing leading-byte arm: a leading
11369 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
11370 // routes through `FonteCaminhoAbsolute` not
11371 // `FonteCaminhoShellRedirection` — the host-layout-leak
11372 // diagnostic is the load-bearing axis, the `>` byte is the
11373 // secondary observation. Same precedence logic as every prior
11374 // leading-byte arm.
11375 let d = dep_with_fonte(DepSource::Path {
11376 caminho: "/etc/passwd>out".into(),
11377 });
11378 let err = d.validate().unwrap_err();
11379 assert!(
11380 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11381 "got {err:?}",
11382 );
11383 }
11384
11385 #[test]
11386 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
11387 // Cascade pin on the immediate-successor arm: a value carrying
11388 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
11389 // canonical "I tab-completed a path that already had a
11390 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
11391 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11392 // the more semantic-locating axis (an author who removes the
11393 // `<` / `>` typically also drops the trailing separator since
11394 // both are paste-from-shell artifacts).
11395 let d = dep_with_fonte(DepSource::Path {
11396 caminho: "../foo></".into(),
11397 });
11398 let err = d.validate().unwrap_err();
11399 assert!(
11400 matches!(
11401 err,
11402 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11403 ),
11404 "got {err:?}",
11405 );
11406 }
11407
11408 #[test]
11409 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
11410 // Diagnostic-shape pin (peer with
11411 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
11412 // payload assertion on the closest peer arm that also carries a
11413 // `byte` field): the error's Display surfaces the offending
11414 // `:nome`, the offending `:caminho` verbatim, and the offending
11415 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
11416 // run can render the diagnostic without re-parsing.
11417 let d = dep_with_fonte(DepSource::Path {
11418 caminho: "../caixa-teia>build.log".into(),
11419 });
11420 let rendered = d.validate().unwrap_err().to_string();
11421 assert!(
11422 rendered.contains("caixa-teia"),
11423 "diagnostic must name the offending dep: {rendered}",
11424 );
11425 assert!(
11426 rendered.contains("../caixa-teia>build.log"),
11427 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11428 );
11429 assert!(
11430 rendered.contains("0x3e"),
11431 "diagnostic must name the offending byte in hex: {rendered:?}",
11432 );
11433 assert!(
11434 rendered.contains("redirection"),
11435 "diagnostic must name the shell-redirection footgun: {rendered:?}",
11436 );
11437 }
11438
11439 // -- :caminho shell-pipe metacharacter arm ----------------------------
11440
11441 #[test]
11442 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
11443 // The fail-before-pass-after pin for the canonical shell-pipe
11444 // paste footgun: an author copies a shell-history line
11445 // (`"../caixa-teia | grep foo"` — the canonical "I selected
11446 // the whole `ls dir | grep` line out of zsh history") and
11447 // silently passed every prior arm (`Path::is_absolute` false
11448 // on `..`, no control bytes, no backslash, no `<` / `>`,
11449 // doesn't end in `/`). The lacre embedded the value verbatim,
11450 // the resolver folded it through `Path::join` looking for a
11451 // literal `./../caixa-teia | grep foo` subdirectory, and the
11452 // failure surfaced at resolve time with a non-self-locating
11453 // `No such file or directory` error. The new arm moves the
11454 // rejection to validate time and names the offending dep +
11455 // caminho verbatim.
11456 let d = dep_with_fonte(DepSource::Path {
11457 caminho: "../caixa-teia | grep foo".into(),
11458 });
11459 let err = d.validate().unwrap_err();
11460 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
11461 panic!("expected FonteCaminhoShellPipe, got {err:?}");
11462 };
11463 assert_eq!(nome, "caixa-teia");
11464 assert_eq!(caminho, "../caixa-teia | grep foo");
11465 }
11466
11467 #[test]
11468 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
11469 // Leading-position `|` shape (`"|../caixa-teia"` — the
11470 // degenerate "I forgot the source side of the pipe" idiom).
11471 // Pinned separately from the embedded-byte shape so the gate
11472 // covers every position, not only mid-path.
11473 let d = dep_with_fonte(DepSource::Path {
11474 caminho: "|../caixa-teia".into(),
11475 });
11476 let err = d.validate().unwrap_err();
11477 assert!(
11478 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11479 "got {err:?}",
11480 );
11481 }
11482
11483 #[test]
11484 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
11485 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
11486 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
11487 // idiom). The arm fires on the first `|` encountered; pinned
11488 // so a future arm that tries to distinguish `|` from `||`
11489 // doesn't break the broader contract.
11490 let d = dep_with_fonte(DepSource::Path {
11491 caminho: "../caixa-teia||fallback".into(),
11492 });
11493 let err = d.validate().unwrap_err();
11494 assert!(
11495 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11496 "got {err:?}",
11497 );
11498 }
11499
11500 #[test]
11501 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
11502 // The positive-control pin: the gate targets only `|`, never
11503 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11504 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11505 // pathed variant with adjacent printable punctuation
11506 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11507 // cleanly so the gate doesn't widen to a "no printable
11508 // punctuation anywhere" sweep that would defeat the entire
11509 // path-fonte author surface.
11510 let d = dep_with_fonte(DepSource::Path {
11511 caminho: "../caixa-teia/sub-dir.v2".into(),
11512 });
11513 d.validate().unwrap();
11514 }
11515
11516 #[test]
11517 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
11518 // Cascade pin on the immediate-predecessor arm: a value carrying
11519 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
11520 // canonical "I pasted a `cmd < input | tee` pipeline tail"
11521 // footgun) routes through `FonteCaminhoShellRedirection` not
11522 // `FonteCaminhoShellPipe`. The input/output redirection
11523 // metachar carries the more self-locating `byte: u8` payload
11524 // (it names which of `<` or `>` triggered), so the prior arm
11525 // wins on every probe-as-both value — same cascade discipline
11526 // every prior `:caminho` arm establishes.
11527 let d = dep_with_fonte(DepSource::Path {
11528 caminho: "../caixa-teia<input|tee".into(),
11529 });
11530 let err = d.validate().unwrap_err();
11531 assert!(
11532 matches!(
11533 err,
11534 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
11535 ),
11536 "got {err:?}",
11537 );
11538 }
11539
11540 #[test]
11541 fn fonte_caminho_backslash_fires_before_shell_pipe() {
11542 // Cascade pin on the upstream backslash arm: a value carrying
11543 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
11544 // "I pasted a Windows-shell command with pipe to tee"
11545 // footgun) routes through `FonteCaminhoBackslash` not
11546 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
11547 // divergence is the load-bearing axis on every probe-as-both
11548 // value (an author who removes the `\` is the root-cause edit;
11549 // the `|` falls away in the same edit since it's downstream of
11550 // the Windows-shell convention).
11551 let d = dep_with_fonte(DepSource::Path {
11552 caminho: "..\\caixa-teia|tee".into(),
11553 });
11554 let err = d.validate().unwrap_err();
11555 assert!(
11556 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11557 "got {err:?}",
11558 );
11559 }
11560
11561 #[test]
11562 fn fonte_caminho_control_char_fires_before_shell_pipe() {
11563 // Cascade pin on the embedded-control-byte arm: a value
11564 // carrying both a control byte and `|` (`"../foo\n|bar"` —
11565 // the canonical paste-from-multiline-doc footgun where a
11566 // newline landed mid-caminho) routes through
11567 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
11568 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11569 // diagnostic is the load-bearing axis on every value that
11570 // probes positive for both — mirrors the cascade discipline
11571 // on every prior arm.
11572 let d = dep_with_fonte(DepSource::Path {
11573 caminho: "../foo\n|bar".into(),
11574 });
11575 let err = d.validate().unwrap_err();
11576 assert!(
11577 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11578 "got {err:?}",
11579 );
11580 }
11581
11582 #[test]
11583 fn fonte_caminho_absolute_fires_before_shell_pipe() {
11584 // Cascade pin on the load-bearing leading-byte arm: a leading
11585 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
11586 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
11587 // — the host-layout-leak diagnostic is the load-bearing axis,
11588 // the `|` byte is the secondary observation. Same precedence
11589 // logic as every prior leading-byte arm.
11590 let d = dep_with_fonte(DepSource::Path {
11591 caminho: "/etc/passwd|tee".into(),
11592 });
11593 let err = d.validate().unwrap_err();
11594 assert!(
11595 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11596 "got {err:?}",
11597 );
11598 }
11599
11600 #[test]
11601 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
11602 // Cascade pin on the immediate-successor arm: a value carrying
11603 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
11604 // "I tab-completed a path that already had a pipeline tail"
11605 // footgun) routes through `FonteCaminhoShellPipe` not
11606 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11607 // the more semantic-locating axis (an author who removes the
11608 // `|` typically also drops the trailing separator since both
11609 // are paste-from-shell artifacts).
11610 let d = dep_with_fonte(DepSource::Path {
11611 caminho: "../foo|tee/".into(),
11612 });
11613 let err = d.validate().unwrap_err();
11614 assert!(
11615 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11616 "got {err:?}",
11617 );
11618 }
11619
11620 #[test]
11621 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
11622 // Diagnostic-shape pin (peer with
11623 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
11624 // on the closest single-byte peer arm): the error's Display
11625 // surfaces the offending `:nome` and the offending `:caminho`
11626 // verbatim, and names the shell-pipe footgun explicitly so a
11627 // `feira lint` run can render the diagnostic without
11628 // re-parsing.
11629 let d = dep_with_fonte(DepSource::Path {
11630 caminho: "../caixa-teia | grep foo".into(),
11631 });
11632 let rendered = d.validate().unwrap_err().to_string();
11633 assert!(
11634 rendered.contains("caixa-teia"),
11635 "diagnostic must name the offending dep: {rendered}",
11636 );
11637 assert!(
11638 rendered.contains("../caixa-teia | grep foo"),
11639 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11640 );
11641 assert!(
11642 rendered.contains('|'),
11643 "diagnostic must reference the pipe footgun: {rendered:?}",
11644 );
11645 assert!(
11646 rendered.contains("pipe"),
11647 "diagnostic must name the shell-pipe footgun: {rendered:?}",
11648 );
11649 }
11650
11651 // -- :caminho shell-command-separator metacharacter arm ---------------
11652
11653 #[test]
11654 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11655 // The fail-before-pass-after pin for the canonical shell-command-
11656 // separator paste footgun: an author copies a shell one-liner
11657 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11658 // whole `cd path; do-thing` chain out of a shell-history block")
11659 // and silently passed every prior arm (`Path::is_absolute` false
11660 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11661 // doesn't end in `/`). The lacre embedded the value verbatim, the
11662 // resolver folded it through `Path::join` looking for a literal
11663 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11664 // surfaced at resolve time with a non-self-locating `No such file
11665 // or directory` error. The new arm moves the rejection to validate
11666 // time and names the offending dep + caminho verbatim.
11667 let d = dep_with_fonte(DepSource::Path {
11668 caminho: "../caixa-teia; rm -rf build".into(),
11669 });
11670 let err = d.validate().unwrap_err();
11671 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11672 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11673 };
11674 assert_eq!(nome, "caixa-teia");
11675 assert_eq!(caminho, "../caixa-teia; rm -rf build");
11676 }
11677
11678 #[test]
11679 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11680 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11681 // "I forgot the prior command side of the separator" idiom).
11682 // Pinned separately from the embedded-byte shape so the gate
11683 // covers every position, not only mid-path.
11684 let d = dep_with_fonte(DepSource::Path {
11685 caminho: ";../caixa-teia".into(),
11686 });
11687 let err = d.validate().unwrap_err();
11688 assert!(
11689 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11690 "got {err:?}",
11691 );
11692 }
11693
11694 #[test]
11695 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11696 // The POSIX `case` arm `;;` terminator shape
11697 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11698 // arm tail" idiom). The arm fires on the first `;` encountered;
11699 // pinned so a future arm that tries to distinguish `;` from `;;`
11700 // doesn't break the broader contract.
11701 let d = dep_with_fonte(DepSource::Path {
11702 caminho: "../caixa-teia;;next".into(),
11703 });
11704 let err = d.validate().unwrap_err();
11705 assert!(
11706 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11707 "got {err:?}",
11708 );
11709 }
11710
11711 #[test]
11712 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11713 // The positive-control pin: the gate targets only `;`, never
11714 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11715 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11716 // pathed variant with adjacent printable punctuation
11717 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11718 // cleanly so the gate doesn't widen to a "no printable
11719 // punctuation anywhere" sweep that would defeat the entire
11720 // path-fonte author surface.
11721 let d = dep_with_fonte(DepSource::Path {
11722 caminho: "../caixa-teia/sub-dir.v2".into(),
11723 });
11724 d.validate().unwrap();
11725 }
11726
11727 #[test]
11728 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11729 // Cascade pin on the immediate-predecessor arm: a value carrying
11730 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11731 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11732 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11733 // pipeline-tail paste is the load-bearing root-cause edit on
11734 // every probe-as-both value (an author who removes the `|`
11735 // typically also drops the trailing `; cleanup` since both are
11736 // the same paste-from-shell-history artifact) — same cascade
11737 // discipline every prior `:caminho` arm establishes.
11738 let d = dep_with_fonte(DepSource::Path {
11739 caminho: "../caixa-teia | tee; rm".into(),
11740 });
11741 let err = d.validate().unwrap_err();
11742 assert!(
11743 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11744 "got {err:?}",
11745 );
11746 }
11747
11748 #[test]
11749 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11750 // Cascade pin on the upstream shell-redirection arm: a value
11751 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11752 // the canonical "I pasted a `cmd > log; cleanup` chain"
11753 // footgun) routes through `FonteCaminhoShellRedirection` not
11754 // `FonteCaminhoShellSemicolon`. The input/output redirection
11755 // metachar carries the more self-locating `byte: u8` payload
11756 // (it names which of `<` or `>` triggered), so the prior arm
11757 // wins on every probe-as-both value.
11758 let d = dep_with_fonte(DepSource::Path {
11759 caminho: "../caixa-teia>log; rm".into(),
11760 });
11761 let err = d.validate().unwrap_err();
11762 assert!(
11763 matches!(
11764 err,
11765 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11766 ),
11767 "got {err:?}",
11768 );
11769 }
11770
11771 #[test]
11772 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11773 // Cascade pin on the upstream backslash arm: a value carrying
11774 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11775 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11776 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11777 // The cross-host-OS-separator divergence is the load-bearing axis
11778 // on every probe-as-both value (an author who removes the `\` is
11779 // the root-cause edit; the `;` falls away in the same edit since
11780 // it's downstream of the Windows-shell convention).
11781 let d = dep_with_fonte(DepSource::Path {
11782 caminho: "..\\caixa-teia;rm".into(),
11783 });
11784 let err = d.validate().unwrap_err();
11785 assert!(
11786 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11787 "got {err:?}",
11788 );
11789 }
11790
11791 #[test]
11792 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11793 // Cascade pin on the embedded-control-byte arm: a value carrying
11794 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11795 // paste-from-multiline-doc footgun where a newline landed mid-
11796 // caminho) routes through `FonteCaminhoControlChar` not
11797 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11798 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11799 // on every value that probes positive for both — mirrors the
11800 // cascade discipline on every prior arm.
11801 let d = dep_with_fonte(DepSource::Path {
11802 caminho: "../foo\n;bar".into(),
11803 });
11804 let err = d.validate().unwrap_err();
11805 assert!(
11806 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11807 "got {err:?}",
11808 );
11809 }
11810
11811 #[test]
11812 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11813 // Cascade pin on the load-bearing leading-byte arm: a leading
11814 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11815 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11816 // — the host-layout-leak diagnostic is the load-bearing axis,
11817 // the `;` byte is the secondary observation. Same precedence
11818 // logic as every prior leading-byte arm.
11819 let d = dep_with_fonte(DepSource::Path {
11820 caminho: "/etc/passwd;rm".into(),
11821 });
11822 let err = d.validate().unwrap_err();
11823 assert!(
11824 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11825 "got {err:?}",
11826 );
11827 }
11828
11829 #[test]
11830 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11831 // Cascade pin on the immediate-successor arm: a value carrying
11832 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11833 // "I tab-completed a path that already had a `; cleanup` tail"
11834 // footgun) routes through `FonteCaminhoShellSemicolon` not
11835 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11836 // the more semantic-locating axis (an author who removes the
11837 // `;` typically also drops the trailing separator since both
11838 // are paste-from-shell artifacts).
11839 let d = dep_with_fonte(DepSource::Path {
11840 caminho: "../foo;rm/".into(),
11841 });
11842 let err = d.validate().unwrap_err();
11843 assert!(
11844 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11845 "got {err:?}",
11846 );
11847 }
11848
11849 #[test]
11850 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11851 // Diagnostic-shape pin (peer with
11852 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11853 // on the closest single-byte peer arm): the error's Display
11854 // surfaces the offending `:nome` and the offending `:caminho`
11855 // verbatim, and names the shell-command-separator footgun
11856 // explicitly so a `feira lint` run can render the diagnostic
11857 // without re-parsing.
11858 let d = dep_with_fonte(DepSource::Path {
11859 caminho: "../caixa-teia; rm -rf build".into(),
11860 });
11861 let rendered = d.validate().unwrap_err().to_string();
11862 assert!(
11863 rendered.contains("caixa-teia"),
11864 "diagnostic must name the offending dep: {rendered}",
11865 );
11866 assert!(
11867 rendered.contains("../caixa-teia; rm -rf build"),
11868 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11869 );
11870 assert!(
11871 rendered.contains(';'),
11872 "diagnostic must reference the semicolon footgun: {rendered:?}",
11873 );
11874 assert!(
11875 rendered.contains("command-separator"),
11876 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11877 );
11878 }
11879
11880 #[test]
11881 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11882 // The fail-before-pass-after pin for the canonical shell-
11883 // background-task paste footgun: an author copies a shell one-
11884 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11885 // the whole `cd path & sleep 1` background-launch out of a
11886 // shell-history block") and silently passed every prior arm
11887 // (`Path::is_absolute` false on `..`, no control bytes, no
11888 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11889 // The lacre embedded the value verbatim, the resolver folded it
11890 // through `Path::join` looking for a literal `./../caixa-teia &
11891 // sleep 1` subdirectory, and the failure surfaced at resolve
11892 // time with a non-self-locating `No such file or directory`
11893 // error. The new arm moves the rejection to validate time and
11894 // names the offending dep + caminho verbatim.
11895 let d = dep_with_fonte(DepSource::Path {
11896 caminho: "../caixa-teia & sleep 1".into(),
11897 });
11898 let err = d.validate().unwrap_err();
11899 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11900 panic!("expected FonteCaminhoShellBackground, got {err:?}");
11901 };
11902 assert_eq!(nome, "caixa-teia");
11903 assert_eq!(caminho, "../caixa-teia & sleep 1");
11904 }
11905
11906 #[test]
11907 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11908 // Leading-position `&` shape (`"&../caixa-teia"` — the
11909 // degenerate "I forgot the prior command side of the
11910 // background terminator" idiom). Pinned separately from the
11911 // embedded-byte shape so the gate covers every position, not
11912 // only mid-path.
11913 let d = dep_with_fonte(DepSource::Path {
11914 caminho: "&../caixa-teia".into(),
11915 });
11916 let err = d.validate().unwrap_err();
11917 assert!(
11918 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11919 "got {err:?}",
11920 );
11921 }
11922
11923 #[test]
11924 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11925 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11926 // canonical "I copied a `cd path && make` build chain" idiom
11927 // every Makefile / shell-script wraps). The arm fires on the
11928 // first `&` encountered; pinned so a future arm that tries to
11929 // distinguish `&` from `&&` doesn't break the broader contract.
11930 let d = dep_with_fonte(DepSource::Path {
11931 caminho: "../caixa-teia && make".into(),
11932 });
11933 let err = d.validate().unwrap_err();
11934 assert!(
11935 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11936 "got {err:?}",
11937 );
11938 }
11939
11940 #[test]
11941 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11942 // The positive-control pin: the gate targets only `&`, never
11943 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11944 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11945 // pathed variant with adjacent printable punctuation
11946 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11947 // cleanly so the gate doesn't widen to a "no printable
11948 // punctuation anywhere" sweep that would defeat the entire
11949 // path-fonte author surface.
11950 let d = dep_with_fonte(DepSource::Path {
11951 caminho: "../caixa-teia/sub-dir.v2".into(),
11952 });
11953 d.validate().unwrap();
11954 }
11955
11956 #[test]
11957 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11958 // Cascade pin on the immediate-predecessor arm: a value carrying
11959 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11960 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11961 // routes through `FonteCaminhoShellSemicolon` not
11962 // `FonteCaminhoShellBackground`. The sequential-command-
11963 // separator paste is the more common shell-history paste idiom
11964 // on every probe-as-both value (an author who removes the `;`
11965 // typically also drops the trailing `& sleep` since both are
11966 // paste-from-shell-history artifacts) — same cascade discipline
11967 // every prior `:caminho` arm establishes.
11968 let d = dep_with_fonte(DepSource::Path {
11969 caminho: "../caixa-teia; rm & sleep".into(),
11970 });
11971 let err = d.validate().unwrap_err();
11972 assert!(
11973 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11974 "got {err:?}",
11975 );
11976 }
11977
11978 #[test]
11979 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11980 // Cascade pin on the upstream shell-pipe arm: a value carrying
11981 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11982 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11983 // chain" footgun) routes through `FonteCaminhoShellPipe` not
11984 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11985 // load-bearing root-cause edit on every probe-as-both value.
11986 let d = dep_with_fonte(DepSource::Path {
11987 caminho: "../caixa-teia | tee & sleep".into(),
11988 });
11989 let err = d.validate().unwrap_err();
11990 assert!(
11991 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11992 "got {err:?}",
11993 );
11994 }
11995
11996 #[test]
11997 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11998 // Cascade pin on the upstream shell-redirection arm: a value
11999 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
12000 // the canonical "I pasted a `cmd > log & sleep` background-
12001 // redirect chain" footgun) routes through
12002 // `FonteCaminhoShellRedirection` not
12003 // `FonteCaminhoShellBackground`. The input/output redirection
12004 // metachar carries the more self-locating `byte: u8` payload
12005 // (it names which of `<` or `>` triggered), so the prior arm
12006 // wins on every probe-as-both value.
12007 let d = dep_with_fonte(DepSource::Path {
12008 caminho: "../caixa-teia>log & sleep".into(),
12009 });
12010 let err = d.validate().unwrap_err();
12011 assert!(
12012 matches!(
12013 err,
12014 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12015 ),
12016 "got {err:?}",
12017 );
12018 }
12019
12020 #[test]
12021 fn fonte_caminho_backslash_fires_before_shell_background() {
12022 // Cascade pin on the upstream backslash arm: a value carrying
12023 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
12024 // "I pasted a Windows-shell `cd ..\path & sleep` background-
12025 // launch chain") routes through `FonteCaminhoBackslash` not
12026 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
12027 // divergence is the load-bearing axis on every probe-as-both
12028 // value (an author who removes the `\` is the root-cause edit;
12029 // the `&` falls away in the same edit since it's downstream of
12030 // the Windows-shell convention).
12031 let d = dep_with_fonte(DepSource::Path {
12032 caminho: "..\\caixa-teia & sleep".into(),
12033 });
12034 let err = d.validate().unwrap_err();
12035 assert!(
12036 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12037 "got {err:?}",
12038 );
12039 }
12040
12041 #[test]
12042 fn fonte_caminho_control_char_fires_before_shell_background() {
12043 // Cascade pin on the embedded-control-byte arm: a value
12044 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
12045 // the canonical paste-from-multiline-doc footgun where a
12046 // newline landed mid-caminho) routes through
12047 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
12048 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
12049 // diagnostic is the load-bearing axis on every value that
12050 // probes positive for both — mirrors the cascade discipline on
12051 // every prior arm.
12052 let d = dep_with_fonte(DepSource::Path {
12053 caminho: "../foo\n&sleep".into(),
12054 });
12055 let err = d.validate().unwrap_err();
12056 assert!(
12057 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12058 "got {err:?}",
12059 );
12060 }
12061
12062 #[test]
12063 fn fonte_caminho_absolute_fires_before_shell_background() {
12064 // Cascade pin on the load-bearing leading-byte arm: a leading
12065 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
12066 // through `FonteCaminhoAbsolute` not
12067 // `FonteCaminhoShellBackground` — the host-layout-leak
12068 // diagnostic is the load-bearing axis, the `&` byte is the
12069 // secondary observation. Same precedence logic as every prior
12070 // leading-byte arm.
12071 let d = dep_with_fonte(DepSource::Path {
12072 caminho: "/etc/passwd & sleep".into(),
12073 });
12074 let err = d.validate().unwrap_err();
12075 assert!(
12076 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12077 "got {err:?}",
12078 );
12079 }
12080
12081 #[test]
12082 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
12083 // Cascade pin on the immediate-successor arm: a value carrying
12084 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
12085 // canonical "I tab-completed a path that already had a `&
12086 // sleep` background-launch tail" footgun) routes through
12087 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
12088 // The embedded shell-metachar is the more semantic-locating
12089 // axis (an author who removes the `&` typically also drops
12090 // the trailing separator since both are paste-from-shell
12091 // artifacts).
12092 let d = dep_with_fonte(DepSource::Path {
12093 caminho: "../foo&sleep/".into(),
12094 });
12095 let err = d.validate().unwrap_err();
12096 assert!(
12097 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12098 "got {err:?}",
12099 );
12100 }
12101
12102 #[test]
12103 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
12104 // Diagnostic-shape pin (peer with
12105 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
12106 // on the closest single-byte peer arm): the error's Display
12107 // surfaces the offending `:nome` and the offending `:caminho`
12108 // verbatim, and names the shell-background / logical-AND
12109 // footgun explicitly so a `feira lint` run can render the
12110 // diagnostic without re-parsing.
12111 let d = dep_with_fonte(DepSource::Path {
12112 caminho: "../caixa-teia & sleep 1".into(),
12113 });
12114 let rendered = d.validate().unwrap_err().to_string();
12115 assert!(
12116 rendered.contains("caixa-teia"),
12117 "diagnostic must name the offending dep: {rendered}",
12118 );
12119 assert!(
12120 rendered.contains("../caixa-teia & sleep 1"),
12121 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12122 );
12123 assert!(
12124 rendered.contains('&'),
12125 "diagnostic must reference the ampersand footgun: {rendered:?}",
12126 );
12127 assert!(
12128 rendered.contains("background") || rendered.contains("list-AND"),
12129 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
12130 );
12131 }
12132
12133 #[test]
12134 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
12135 // The fail-before-pass-after pin for the canonical shell-
12136 // command-substitution paste footgun: an author copies a
12137 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
12138 // — the canonical "I pasted a path that included a `pwd`
12139 // / `whoami` / `date` legacy command-substitution expansion
12140 // out of a shell-history block") and silently passed every
12141 // prior arm (`Path::is_absolute` false on `..`, no control
12142 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
12143 // end in `/`). The lacre embedded the value verbatim, the
12144 // resolver folded it through `Path::join` looking for a
12145 // literal `./../caixa-teia/`whoami`` subdirectory, and the
12146 // failure surfaced at resolve time with a non-self-locating
12147 // `No such file or directory` error. The new arm moves the
12148 // rejection to validate time and names the offending dep +
12149 // caminho verbatim.
12150 let d = dep_with_fonte(DepSource::Path {
12151 caminho: "../caixa-teia/`whoami`".into(),
12152 });
12153 let err = d.validate().unwrap_err();
12154 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
12155 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
12156 };
12157 assert_eq!(nome, "caixa-teia");
12158 assert_eq!(caminho, "../caixa-teia/`whoami`");
12159 }
12160
12161 #[test]
12162 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
12163 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
12164 // the canonical `<backtick>pwd<backtick>/path` working-
12165 // directory expansion shape every shell-side path-composition
12166 // idiom carries). Pinned separately from the embedded-byte
12167 // shape so the gate covers every position, not only mid-path.
12168 let d = dep_with_fonte(DepSource::Path {
12169 caminho: "`pwd`/caixa-teia".into(),
12170 });
12171 let err = d.validate().unwrap_err();
12172 assert!(
12173 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12174 "got {err:?}",
12175 );
12176 }
12177
12178 #[test]
12179 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
12180 // Trailing-position backtick shape (`"../caixa-teia`"` — the
12181 // degenerate "I selected an unbalanced backtick out of a
12182 // shell-history block" idiom that probes for the cascade's
12183 // last-byte handling). The trailing-`/` arm fires only on
12184 // last-byte `/`; an unbalanced trailing backtick must route
12185 // through this arm regardless of position.
12186 let d = dep_with_fonte(DepSource::Path {
12187 caminho: "../caixa-teia`".into(),
12188 });
12189 let err = d.validate().unwrap_err();
12190 assert!(
12191 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12192 "got {err:?}",
12193 );
12194 }
12195
12196 #[test]
12197 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
12198 // The canonical balanced-pair shape (``"../<backtick>cat
12199 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
12200 // command-injection paste idiom every shell-side hardening
12201 // guide enumerates first). The arm fires on the first
12202 // backtick encountered; pinned so a future arm that tries to
12203 // distinguish the opening from the closing byte doesn't break
12204 // the broader contract.
12205 let d = dep_with_fonte(DepSource::Path {
12206 caminho: "../`cat /etc/passwd`".into(),
12207 });
12208 let err = d.validate().unwrap_err();
12209 assert!(
12210 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12211 "got {err:?}",
12212 );
12213 }
12214
12215 #[test]
12216 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
12217 // The positive-control pin: the gate targets only the
12218 // backtick byte, never adjacent printable ASCII or POSIX-
12219 // valid bytes. The canonical relative POSIX path
12220 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
12221 // adjacent printable punctuation
12222 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
12223 // cleanly so the gate doesn't widen to a "no printable
12224 // punctuation anywhere" sweep that would defeat the entire
12225 // path-fonte author surface.
12226 let d = dep_with_fonte(DepSource::Path {
12227 caminho: "../caixa-teia/sub-dir.v2".into(),
12228 });
12229 d.validate().unwrap();
12230 }
12231
12232 #[test]
12233 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
12234 // Cascade pin on the immediate-predecessor arm: a value
12235 // carrying both `&` and a backtick (``"../caixa-teia &
12236 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
12237 // `cmd & <backtick>sleep N<backtick>` background-launch +
12238 // command-substitution chain" footgun) routes through
12239 // `FonteCaminhoShellBackground` not
12240 // `FonteCaminhoShellCommandSubstitution`. The background-
12241 // launch tail is the more common shell-history paste idiom
12242 // on every probe-as-both value — same cascade discipline
12243 // every prior `:caminho` arm establishes.
12244 let d = dep_with_fonte(DepSource::Path {
12245 caminho: "../caixa-teia & `sleep 1`".into(),
12246 });
12247 let err = d.validate().unwrap_err();
12248 assert!(
12249 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12250 "got {err:?}",
12251 );
12252 }
12253
12254 #[test]
12255 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
12256 // Cascade pin on the upstream shell-semicolon arm: a value
12257 // carrying both `;` and a backtick (``"../caixa-teia;
12258 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12259 // `cmd; <backtick>follow-up<backtick>` sequential-chain
12260 // footgun) routes through `FonteCaminhoShellSemicolon` not
12261 // `FonteCaminhoShellCommandSubstitution`. The sequential-
12262 // command-separator paste is the load-bearing root-cause
12263 // edit on every probe-as-both value.
12264 let d = dep_with_fonte(DepSource::Path {
12265 caminho: "../caixa-teia; `whoami`".into(),
12266 });
12267 let err = d.validate().unwrap_err();
12268 assert!(
12269 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12270 "got {err:?}",
12271 );
12272 }
12273
12274 #[test]
12275 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
12276 // Cascade pin on the upstream shell-pipe arm: a value
12277 // carrying both `|` and a backtick (``"../caixa-teia |
12278 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
12279 // command-substitution paste idiom) routes through
12280 // `FonteCaminhoShellPipe` not
12281 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
12282 // paste is the load-bearing root-cause edit on every
12283 // probe-as-both value.
12284 let d = dep_with_fonte(DepSource::Path {
12285 caminho: "../caixa-teia | `tee log`".into(),
12286 });
12287 let err = d.validate().unwrap_err();
12288 assert!(
12289 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12290 "got {err:?}",
12291 );
12292 }
12293
12294 #[test]
12295 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
12296 // Cascade pin on the upstream shell-redirection arm: a value
12297 // carrying both `>` and a backtick (``"../caixa-teia>log
12298 // <backtick>date<backtick>"`` — the canonical "I pasted a
12299 // `cmd > log <backtick>date<backtick>` redirect-plus-
12300 // substitution chain" footgun) routes through
12301 // `FonteCaminhoShellRedirection` not
12302 // `FonteCaminhoShellCommandSubstitution`. The input/output
12303 // redirection metachar carries the more self-locating `byte`
12304 // payload (it names which of `<` or `>` triggered), so the
12305 // prior arm wins on every probe-as-both value.
12306 let d = dep_with_fonte(DepSource::Path {
12307 caminho: "../caixa-teia>log `date`".into(),
12308 });
12309 let err = d.validate().unwrap_err();
12310 assert!(
12311 matches!(
12312 err,
12313 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12314 ),
12315 "got {err:?}",
12316 );
12317 }
12318
12319 #[test]
12320 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
12321 // Cascade pin on the upstream backslash arm: a value
12322 // carrying both `\` and a backtick (``"..\caixa-teia
12323 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12324 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
12325 // chain") routes through `FonteCaminhoBackslash` not
12326 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
12327 // separator divergence is the load-bearing axis on every
12328 // probe-as-both value (an author who removes the `\` is the
12329 // root-cause edit; the backtick falls away in the same edit
12330 // since it's downstream of the Windows-shell convention).
12331 let d = dep_with_fonte(DepSource::Path {
12332 caminho: "..\\caixa-teia `whoami`".into(),
12333 });
12334 let err = d.validate().unwrap_err();
12335 assert!(
12336 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12337 "got {err:?}",
12338 );
12339 }
12340
12341 #[test]
12342 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
12343 // Cascade pin on the embedded-control-byte arm: a value
12344 // carrying both a control byte and a backtick (`"../foo\n
12345 // `whoami`"` — the canonical paste-from-multiline-doc
12346 // footgun where a newline landed mid-caminho between two
12347 // paste fragments) routes through `FonteCaminhoControlChar`
12348 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
12349 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
12350 // is the load-bearing axis on every value that probes
12351 // positive for both — mirrors the cascade discipline on
12352 // every prior arm.
12353 let d = dep_with_fonte(DepSource::Path {
12354 caminho: "../foo\n`whoami`".into(),
12355 });
12356 let err = d.validate().unwrap_err();
12357 assert!(
12358 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12359 "got {err:?}",
12360 );
12361 }
12362
12363 #[test]
12364 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
12365 // Cascade pin on the load-bearing leading-byte arm: a
12366 // leading `/` value with embedded backtick (``"/etc/passwd
12367 // <backtick>whoami<backtick>"``) routes through
12368 // `FonteCaminhoAbsolute` not
12369 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
12370 // leak diagnostic is the load-bearing axis, the backtick
12371 // byte is the secondary observation. Same precedence logic
12372 // as every prior leading-byte arm.
12373 let d = dep_with_fonte(DepSource::Path {
12374 caminho: "/etc/passwd `whoami`".into(),
12375 });
12376 let err = d.validate().unwrap_err();
12377 assert!(
12378 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12379 "got {err:?}",
12380 );
12381 }
12382
12383 #[test]
12384 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
12385 // Cascade pin on the immediate-successor arm: a value
12386 // carrying both a backtick and a trailing `/`
12387 // (``"../`whoami`/"`` — the canonical "I tab-completed a
12388 // path that already had a backticked `whoami` substitution
12389 // tail" footgun) routes through
12390 // `FonteCaminhoShellCommandSubstitution` not
12391 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12392 // is the more semantic-locating axis (an author who removes
12393 // the backtick typically also drops the trailing separator
12394 // since both are paste-from-shell artifacts).
12395 let d = dep_with_fonte(DepSource::Path {
12396 caminho: "../`whoami`/".into(),
12397 });
12398 let err = d.validate().unwrap_err();
12399 assert!(
12400 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12401 "got {err:?}",
12402 );
12403 }
12404
12405 #[test]
12406 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
12407 // Diagnostic-shape pin (peer with
12408 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
12409 // on the closest single-byte peer arm): the error's Display
12410 // surfaces the offending `:nome` and the offending `:caminho`
12411 // verbatim, and names the shell-command-substitution footgun
12412 // explicitly so a `feira lint` run can render the diagnostic
12413 // without re-parsing.
12414 let d = dep_with_fonte(DepSource::Path {
12415 caminho: "../caixa-teia/`whoami`".into(),
12416 });
12417 let rendered = d.validate().unwrap_err().to_string();
12418 assert!(
12419 rendered.contains("caixa-teia"),
12420 "diagnostic must name the offending dep: {rendered}",
12421 );
12422 assert!(
12423 rendered.contains("../caixa-teia/`whoami`"),
12424 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12425 );
12426 assert!(
12427 rendered.contains('`'),
12428 "diagnostic must reference the backtick footgun: {rendered:?}",
12429 );
12430 assert!(
12431 rendered.contains("command-substitution"),
12432 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
12433 );
12434 }
12435
12436 #[test]
12437 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
12438 // The fail-before-pass-after pin for the canonical pathname-
12439 // expansion paste footgun: an author copies an `ls
12440 // ../caixa-teia/*` shell-listing tail into the `:caminho`
12441 // slot and silently passes every prior arm
12442 // (`Path::is_absolute` false on `..`, no control bytes, no
12443 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
12444 // doesn't end in `/`). The lacre embedded the value
12445 // verbatim, the resolver folded it through `Path::join`
12446 // looking for a literal `./../caixa-teia/*` subdirectory,
12447 // and the failure surfaced at resolve time with a non-self-
12448 // locating `No such file or directory` error. The new arm
12449 // moves the rejection to validate time and names the
12450 // offending dep + caminho + byte verbatim.
12451 let d = dep_with_fonte(DepSource::Path {
12452 caminho: "../caixa-teia/*".into(),
12453 });
12454 let err = d.validate().unwrap_err();
12455 let DepError::FonteCaminhoShellGlob {
12456 nome,
12457 caminho,
12458 byte,
12459 } = err
12460 else {
12461 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12462 };
12463 assert_eq!(nome, "caixa-teia");
12464 assert_eq!(caminho, "../caixa-teia/*");
12465 assert_eq!(byte, b'*');
12466 }
12467
12468 #[test]
12469 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
12470 // The symmetric single-char-wildcard paste shape
12471 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
12472 // out of shell history" idiom). Pinned separately from the
12473 // `*` shape so the gate's contract is "any `*` or `?`
12474 // anywhere", not single-byte coverage.
12475 let d = dep_with_fonte(DepSource::Path {
12476 caminho: "../foo?".into(),
12477 });
12478 let err = d.validate().unwrap_err();
12479 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
12480 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12481 };
12482 assert_eq!(byte, b'?');
12483 }
12484
12485 #[test]
12486 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
12487 // Leading-position `*` shape (`"*/caixa-teia"` — the
12488 // degenerate "I selected only the wildcard prefix out of a
12489 // shell-glob expression" idiom). Pinned separately from the
12490 // embedded-byte shapes so the gate covers every position,
12491 // not only mid-path.
12492 let d = dep_with_fonte(DepSource::Path {
12493 caminho: "*/caixa-teia".into(),
12494 });
12495 let err = d.validate().unwrap_err();
12496 assert!(
12497 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12498 "got {err:?}",
12499 );
12500 }
12501
12502 #[test]
12503 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
12504 // The bash/zsh `globstar` recursive-glob shape
12505 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
12506 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
12507 // The arm fires on the first `*` encountered; pinned so a
12508 // future arm that tries to distinguish single `*` from
12509 // double `**` doesn't break the broader contract.
12510 let d = dep_with_fonte(DepSource::Path {
12511 caminho: "../caixa-teia/**/foo".into(),
12512 });
12513 let err = d.validate().unwrap_err();
12514 assert!(
12515 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12516 "got {err:?}",
12517 );
12518 }
12519
12520 #[test]
12521 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
12522 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
12523 // — the "I selected `*.lisp` to mean every Lisp source file
12524 // in the dep root" footgun the prior arms structurally
12525 // cannot catch since `.` is a POSIX-valid path-component
12526 // byte). Pinned so the gate's contract covers the most
12527 // idiomatic glob-paste shape every author meets first.
12528 let d = dep_with_fonte(DepSource::Path {
12529 caminho: "../caixa-teia/*.lisp".into(),
12530 });
12531 let err = d.validate().unwrap_err();
12532 assert!(
12533 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12534 "got {err:?}",
12535 );
12536 }
12537
12538 #[test]
12539 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
12540 // The positive-control pin: the gate targets only `*` /
12541 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
12542 // The canonical relative POSIX path (`"../caixa-teia"`) and
12543 // a nested deeply-pathed variant with adjacent printable
12544 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12545 // to validate cleanly so the gate doesn't widen to a "no
12546 // printable punctuation anywhere" sweep that would defeat
12547 // the entire path-fonte author surface.
12548 let d = dep_with_fonte(DepSource::Path {
12549 caminho: "../caixa-teia/sub-dir.v2".into(),
12550 });
12551 d.validate().unwrap();
12552 }
12553
12554 #[test]
12555 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
12556 // Cascade pin on the immediate-predecessor arm: a value
12557 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
12558 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
12559 // command-substitution + glob chain") routes through
12560 // `FonteCaminhoShellCommandSubstitution` not
12561 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
12562 // injection vector is the load-bearing root-cause edit on
12563 // every probe-as-both value — same cascade discipline every
12564 // prior `:caminho` arm establishes.
12565 let d = dep_with_fonte(DepSource::Path {
12566 caminho: "../`whoami`/*".into(),
12567 });
12568 let err = d.validate().unwrap_err();
12569 assert!(
12570 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12571 "got {err:?}",
12572 );
12573 }
12574
12575 #[test]
12576 fn fonte_caminho_shell_background_fires_before_shell_glob() {
12577 // Cascade pin on the upstream shell-background arm: a value
12578 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
12579 // canonical "I pasted a `cmd & ls /*` background + glob
12580 // chain" footgun) routes through `FonteCaminhoShellBackground`
12581 // not `FonteCaminhoShellGlob`. The background-launch tail is
12582 // the load-bearing root-cause edit on every probe-as-both
12583 // value.
12584 let d = dep_with_fonte(DepSource::Path {
12585 caminho: "../caixa-teia & ls /*".into(),
12586 });
12587 let err = d.validate().unwrap_err();
12588 assert!(
12589 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12590 "got {err:?}",
12591 );
12592 }
12593
12594 #[test]
12595 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
12596 // Cascade pin on the upstream shell-semicolon arm: a value
12597 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
12598 // canonical sequential-cleanup + glob paste idiom) routes
12599 // through `FonteCaminhoShellSemicolon` not
12600 // `FonteCaminhoShellGlob`. The sequential-command-separator
12601 // paste is the load-bearing root-cause edit on every
12602 // probe-as-both value.
12603 let d = dep_with_fonte(DepSource::Path {
12604 caminho: "../caixa-teia; rm *".into(),
12605 });
12606 let err = d.validate().unwrap_err();
12607 assert!(
12608 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12609 "got {err:?}",
12610 );
12611 }
12612
12613 #[test]
12614 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
12615 // Cascade pin on the upstream shell-pipe arm: a value
12616 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
12617 // canonical pipeline-to-glob paste idiom) routes through
12618 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
12619 // pipeline-tail paste is the load-bearing root-cause edit
12620 // on every probe-as-both value.
12621 let d = dep_with_fonte(DepSource::Path {
12622 caminho: "../caixa-teia | ls *".into(),
12623 });
12624 let err = d.validate().unwrap_err();
12625 assert!(
12626 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12627 "got {err:?}",
12628 );
12629 }
12630
12631 #[test]
12632 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
12633 // Cascade pin on the upstream shell-redirection arm: a value
12634 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
12635 // canonical "I pasted a `cmd > log *` redirect-plus-glob
12636 // chain" footgun) routes through
12637 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
12638 // The input/output redirection metachar carries the more
12639 // self-locating `byte` payload (it names which of `<` or `>`
12640 // triggered), so the prior arm wins on every probe-as-both
12641 // value.
12642 let d = dep_with_fonte(DepSource::Path {
12643 caminho: "../caixa-teia>log *".into(),
12644 });
12645 let err = d.validate().unwrap_err();
12646 assert!(
12647 matches!(
12648 err,
12649 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12650 ),
12651 "got {err:?}",
12652 );
12653 }
12654
12655 #[test]
12656 fn fonte_caminho_backslash_fires_before_shell_glob() {
12657 // Cascade pin on the upstream backslash arm: a value
12658 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12659 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12660 // expression" footgun) routes through
12661 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12662 // cross-host-OS-separator divergence is the load-bearing
12663 // axis on every probe-as-both value (an author who removes
12664 // the `\` is the root-cause edit; the `*` falls away in the
12665 // same edit since it's downstream of the Windows-shell
12666 // convention).
12667 let d = dep_with_fonte(DepSource::Path {
12668 caminho: "..\\caixa-teia\\*".into(),
12669 });
12670 let err = d.validate().unwrap_err();
12671 assert!(
12672 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12673 "got {err:?}",
12674 );
12675 }
12676
12677 #[test]
12678 fn fonte_caminho_control_char_fires_before_shell_glob() {
12679 // Cascade pin on the embedded-control-byte arm: a value
12680 // carrying both a control byte and `*` (`"../foo\n*"` — the
12681 // canonical paste-from-multiline-doc footgun where a
12682 // newline landed mid-caminho between two paste fragments)
12683 // routes through `FonteCaminhoControlChar` not
12684 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12685 // NUL-`CString::new`-fail diagnostic is the load-bearing
12686 // axis on every value that probes positive for both —
12687 // mirrors the cascade discipline on every prior arm.
12688 let d = dep_with_fonte(DepSource::Path {
12689 caminho: "../foo\n*".into(),
12690 });
12691 let err = d.validate().unwrap_err();
12692 assert!(
12693 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12694 "got {err:?}",
12695 );
12696 }
12697
12698 #[test]
12699 fn fonte_caminho_absolute_fires_before_shell_glob() {
12700 // Cascade pin on the load-bearing leading-byte arm: a
12701 // leading `/` value with embedded `*` (`"/etc/*"`) routes
12702 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12703 // — the host-layout-leak diagnostic is the load-bearing
12704 // axis, the glob byte is the secondary observation. Same
12705 // precedence logic as every prior leading-byte arm.
12706 let d = dep_with_fonte(DepSource::Path {
12707 caminho: "/etc/*".into(),
12708 });
12709 let err = d.validate().unwrap_err();
12710 assert!(
12711 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12712 "got {err:?}",
12713 );
12714 }
12715
12716 #[test]
12717 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12718 // Cascade pin on the immediate-successor arm: a value
12719 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12720 // canonical "I tab-completed a path that already had a
12721 // glob-expansion tail" footgun) routes through
12722 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12723 // The embedded shell-metachar is the more semantic-locating
12724 // axis (an author who removes the `*` typically also drops
12725 // the trailing separator since both are paste-from-shell
12726 // artifacts).
12727 let d = dep_with_fonte(DepSource::Path {
12728 caminho: "../foo*/".into(),
12729 });
12730 let err = d.validate().unwrap_err();
12731 assert!(
12732 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12733 "got {err:?}",
12734 );
12735 }
12736
12737 #[test]
12738 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12739 // Diagnostic-shape pin (peer with
12740 // `fonte_caminho_shell_redirection_diagnostic_*` on the
12741 // closest two-byte peer arm): the error's Display surfaces
12742 // the offending `:nome`, the offending `:caminho` verbatim,
12743 // the offending byte's hex / character form, and names the
12744 // shell-glob / pathname-expansion footgun explicitly so a
12745 // `feira lint` run can render the diagnostic without
12746 // re-parsing.
12747 let d = dep_with_fonte(DepSource::Path {
12748 caminho: "../caixa-teia/*.lisp".into(),
12749 });
12750 let rendered = d.validate().unwrap_err().to_string();
12751 assert!(
12752 rendered.contains("caixa-teia"),
12753 "diagnostic must name the offending dep: {rendered}",
12754 );
12755 assert!(
12756 rendered.contains("../caixa-teia/*.lisp"),
12757 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12758 );
12759 assert!(
12760 rendered.contains("0x2a"),
12761 "diagnostic must surface the offending byte hex: {rendered:?}",
12762 );
12763 assert!(
12764 rendered.contains("glob"),
12765 "diagnostic must name the shell-glob footgun: {rendered:?}",
12766 );
12767 assert!(
12768 rendered.contains("pathname-expansion"),
12769 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12770 );
12771 }
12772
12773 #[test]
12774 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12775 // The fail-before-pass-after pin for the canonical modern-Bourne
12776 // command-substitution paste footgun: an author copies a
12777 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12778 // `$(<cmd>)` expansion would land the current date as a
12779 // subdirectory name and silently passed every prior arm
12780 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12781 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12782 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12783 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12784 // sits mid-path). The lacre embedded the value verbatim, the
12785 // resolver folded it through `Path::join` looking for a literal
12786 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12787 // surfaced at resolve time with a non-self-locating `No such
12788 // file or directory` error. The new arm moves the rejection to
12789 // validate time and names the offending dep + caminho + byte
12790 // verbatim. The arm fires on the first `(` encountered (the
12791 // opening byte of `$(date)`).
12792 let d = dep_with_fonte(DepSource::Path {
12793 caminho: "../caixa-teia/$(date)/build".into(),
12794 });
12795 let err = d.validate().unwrap_err();
12796 let DepError::FonteCaminhoShellSubshellGrouping {
12797 nome,
12798 caminho,
12799 byte,
12800 } = err
12801 else {
12802 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12803 };
12804 assert_eq!(nome, "caixa-teia");
12805 assert_eq!(caminho, "../caixa-teia/$(date)/build");
12806 assert_eq!(byte, b'(');
12807 }
12808
12809 #[test]
12810 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12811 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12812 // the degenerate "I selected an unbalanced closing paren out of
12813 // a shell-history block" idiom that probes for the cascade's
12814 // last-byte handling on a value carrying only the closing byte).
12815 // Pinned separately from the open-paren shape so the gate's
12816 // contract is "any `(` or `)` anywhere", not single-byte
12817 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12818 // caminho_carrying_question_glob` shape on the immediate-
12819 // predecessor `FonteCaminhoShellGlob` arm.
12820 let d = dep_with_fonte(DepSource::Path {
12821 caminho: "../caixa-teia)".into(),
12822 });
12823 let err = d.validate().unwrap_err();
12824 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12825 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12826 };
12827 assert_eq!(byte, b')');
12828 }
12829
12830 #[test]
12831 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12832 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12833 // canonical "I selected a `(cd foo)` subshell-grouping prefix
12834 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12835 // Pinned separately from the embedded-byte shape so the gate
12836 // covers every position, not only mid-path.
12837 let d = dep_with_fonte(DepSource::Path {
12838 caminho: "(cd foo)/caixa-teia".into(),
12839 });
12840 let err = d.validate().unwrap_err();
12841 assert!(
12842 matches!(
12843 err,
12844 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12845 ),
12846 "got {err:?}",
12847 );
12848 }
12849
12850 #[test]
12851 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12852 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12853 // — the canonical "I copied a `(pwd)` working-directory-probe
12854 // subshell-grouping idiom every shell-history block carries"
12855 // footgun). The value carries no other cascade-preceding
12856 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12857 // `*` / `?`) so the arm fires on the first `(` encountered;
12858 // pinned so a future arm that tries to distinguish the
12859 // opening from the closing byte doesn't break the broader
12860 // contract. Mirrors the peer
12861 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12862 // backtick_pair` shape on the upstream `FonteCaminhoShell\
12863 // CommandSubstitution` arm.
12864 let d = dep_with_fonte(DepSource::Path {
12865 caminho: "../(pwd)/caixa-teia".into(),
12866 });
12867 let err = d.validate().unwrap_err();
12868 assert!(
12869 matches!(
12870 err,
12871 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12872 ),
12873 "got {err:?}",
12874 );
12875 }
12876
12877 #[test]
12878 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12879 // The positive-control pin: the gate targets only `(` / `)`,
12880 // never adjacent printable ASCII or POSIX-valid bytes. The
12881 // canonical relative POSIX path (`"../caixa-teia"`) and a
12882 // nested deeply-pathed variant with adjacent printable
12883 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12884 // validate cleanly so the gate doesn't widen to a "no printable
12885 // punctuation anywhere" sweep that would defeat the entire
12886 // path-fonte author surface.
12887 let d = dep_with_fonte(DepSource::Path {
12888 caminho: "../caixa-teia/sub-dir.v2".into(),
12889 });
12890 d.validate().unwrap();
12891 }
12892
12893 #[test]
12894 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12895 // Cascade pin on the immediate-predecessor arm: a value
12896 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12897 // canonical "I pasted a glob expansion followed by a
12898 // subshell-grouping tail" footgun) routes through
12899 // `FonteCaminhoShellGlob` not
12900 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12901 // shape is the more common shell-history paste idiom on every
12902 // probe-as-both value — same cascade discipline every prior
12903 // `:caminho` arm establishes.
12904 let d = dep_with_fonte(DepSource::Path {
12905 caminho: "../caixa-teia/*(date)".into(),
12906 });
12907 let err = d.validate().unwrap_err();
12908 assert!(
12909 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12910 "got {err:?}",
12911 );
12912 }
12913
12914 #[test]
12915 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12916 // Cascade pin on the upstream shell-command-substitution arm: a
12917 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12918 // — the canonical "I pasted a legacy-backtick + modern-paren
12919 // command-substitution chain" footgun) routes through
12920 // `FonteCaminhoShellCommandSubstitution` not
12921 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12922 // command-injection vector is the load-bearing root-cause edit
12923 // on every probe-as-both value.
12924 let d = dep_with_fonte(DepSource::Path {
12925 caminho: "../`whoami`/$(date)".into(),
12926 });
12927 let err = d.validate().unwrap_err();
12928 assert!(
12929 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12930 "got {err:?}",
12931 );
12932 }
12933
12934 #[test]
12935 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12936 // Cascade pin on the upstream shell-background arm: a value
12937 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12938 // the canonical "I pasted a `cmd & (cd foo)` background-launch
12939 // + subshell-grouping chain" footgun) routes through
12940 // `FonteCaminhoShellBackground` not
12941 // `FonteCaminhoShellSubshellGrouping`. The background-launch
12942 // tail is the load-bearing root-cause edit on every probe-as-
12943 // both value.
12944 let d = dep_with_fonte(DepSource::Path {
12945 caminho: "../caixa-teia & (cd foo)".into(),
12946 });
12947 let err = d.validate().unwrap_err();
12948 assert!(
12949 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12950 "got {err:?}",
12951 );
12952 }
12953
12954 #[test]
12955 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12956 // Cascade pin on the upstream shell-semicolon arm: a value
12957 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12958 // the canonical sequential-cleanup + subshell-grouping paste
12959 // idiom) routes through `FonteCaminhoShellSemicolon` not
12960 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12961 // separator paste is the load-bearing root-cause edit on
12962 // every probe-as-both value.
12963 let d = dep_with_fonte(DepSource::Path {
12964 caminho: "../caixa-teia; (cd foo)".into(),
12965 });
12966 let err = d.validate().unwrap_err();
12967 assert!(
12968 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12969 "got {err:?}",
12970 );
12971 }
12972
12973 #[test]
12974 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12975 // Cascade pin on the upstream shell-pipe arm: a value carrying
12976 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12977 // canonical pipeline-to-subshell-grouping paste idiom) routes
12978 // through `FonteCaminhoShellPipe` not
12979 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12980 // is the load-bearing root-cause edit on every probe-as-both
12981 // value.
12982 let d = dep_with_fonte(DepSource::Path {
12983 caminho: "../caixa-teia | (tee log)".into(),
12984 });
12985 let err = d.validate().unwrap_err();
12986 assert!(
12987 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12988 "got {err:?}",
12989 );
12990 }
12991
12992 #[test]
12993 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12994 // Cascade pin on the upstream shell-redirection arm: a value
12995 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12996 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12997 // plus-subshell-grouping chain" footgun) routes through
12998 // `FonteCaminhoShellRedirection` not
12999 // `FonteCaminhoShellSubshellGrouping`. The input/output
13000 // redirection metachar carries the more self-locating `byte`
13001 // payload (it names which of `<` or `>` triggered), so the
13002 // prior arm wins on every probe-as-both value.
13003 let d = dep_with_fonte(DepSource::Path {
13004 caminho: "../caixa-teia>log (cd foo)".into(),
13005 });
13006 let err = d.validate().unwrap_err();
13007 assert!(
13008 matches!(
13009 err,
13010 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13011 ),
13012 "got {err:?}",
13013 );
13014 }
13015
13016 #[test]
13017 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
13018 // Cascade pin on the upstream backslash arm: a value carrying
13019 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
13020 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
13021 // through `FonteCaminhoBackslash` not
13022 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
13023 // separator divergence is the load-bearing axis on every
13024 // probe-as-both value (an author who removes the `\` is the
13025 // root-cause edit; the `(` falls away in the same edit since
13026 // it's downstream of the Windows-shell convention).
13027 let d = dep_with_fonte(DepSource::Path {
13028 caminho: "..\\caixa-teia\\(cd foo)".into(),
13029 });
13030 let err = d.validate().unwrap_err();
13031 assert!(
13032 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13033 "got {err:?}",
13034 );
13035 }
13036
13037 #[test]
13038 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
13039 // Cascade pin on the embedded-control-byte arm: a value
13040 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
13041 // the canonical paste-from-multiline-doc footgun where a
13042 // newline landed mid-caminho between two paste fragments)
13043 // routes through `FonteCaminhoControlChar` not
13044 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
13045 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13046 // load-bearing axis on every value that probes positive for
13047 // both — mirrors the cascade discipline on every prior arm.
13048 let d = dep_with_fonte(DepSource::Path {
13049 caminho: "../foo\n(cd bar)".into(),
13050 });
13051 let err = d.validate().unwrap_err();
13052 assert!(
13053 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13054 "got {err:?}",
13055 );
13056 }
13057
13058 #[test]
13059 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
13060 // Cascade pin on the load-bearing leading-byte arm: a leading
13061 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
13062 // through `FonteCaminhoAbsolute` not
13063 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
13064 // diagnostic is the load-bearing axis, the subshell-grouping
13065 // byte is the secondary observation. Same precedence logic as
13066 // every prior leading-byte arm.
13067 let d = dep_with_fonte(DepSource::Path {
13068 caminho: "/etc/(cd foo)".into(),
13069 });
13070 let err = d.validate().unwrap_err();
13071 assert!(
13072 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13073 "got {err:?}",
13074 );
13075 }
13076
13077 #[test]
13078 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
13079 // Cascade pin on the upstream leading-`$` var-expansion arm: a
13080 // value carrying both a leading `$` and a `(` (`"$(date)/\
13081 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
13082 // command-substitution at the head of a sibling-workspace
13083 // path" footgun) routes through `FonteCaminhoVarExpansion` not
13084 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
13085 // shell-variable-expansion is the more self-locating diagnostic
13086 // on values that probe as both — same load-bearing-leading-
13087 // byte cascade discipline every prior `:caminho` arm
13088 // establishes. Closing both halves of `$(<cmd>)` structurally
13089 // (leading `$` here, trailing `)` on the new arm) excludes the
13090 // entire modern Bourne command-substitution surface from the
13091 // typed `:caminho` accepted set; the cascade preserves the
13092 // narrower leading-byte diagnostic on values that probe both
13093 // halves at the canonical leading position.
13094 let d = dep_with_fonte(DepSource::Path {
13095 caminho: "$(date)/caixa-teia".into(),
13096 });
13097 let err = d.validate().unwrap_err();
13098 assert!(
13099 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13100 "got {err:?}",
13101 );
13102 }
13103
13104 #[test]
13105 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
13106 // Cascade pin on the immediate-successor arm: a value carrying
13107 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
13108 // "I tab-completed a path that already had a subshell-grouping
13109 // expansion tail" footgun) routes through
13110 // `FonteCaminhoShellSubshellGrouping` not
13111 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
13112 // the more semantic-locating axis (an author who removes the
13113 // `(` typically also drops the trailing separator since both
13114 // are paste-from-shell artifacts).
13115 let d = dep_with_fonte(DepSource::Path {
13116 caminho: "../(cd foo)/".into(),
13117 });
13118 let err = d.validate().unwrap_err();
13119 assert!(
13120 matches!(
13121 err,
13122 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13123 ),
13124 "got {err:?}",
13125 );
13126 }
13127
13128 #[test]
13129 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13130 // Diagnostic-shape pin (peer with
13131 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
13132 // on the closest two-byte peer arm): the error's Display
13133 // surfaces the offending `:nome`, the offending `:caminho`
13134 // verbatim, the offending byte's hex / character form, and
13135 // names the shell-subshell-grouping footgun explicitly so a
13136 // `feira lint` run can render the diagnostic without re-
13137 // parsing.
13138 let d = dep_with_fonte(DepSource::Path {
13139 caminho: "../caixa-teia/$(date)/build".into(),
13140 });
13141 let rendered = d.validate().unwrap_err().to_string();
13142 assert!(
13143 rendered.contains("caixa-teia"),
13144 "diagnostic must name the offending dep: {rendered}",
13145 );
13146 assert!(
13147 rendered.contains("../caixa-teia/$(date)/build"),
13148 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13149 );
13150 assert!(
13151 rendered.contains("0x28"),
13152 "diagnostic must surface the offending byte hex: {rendered:?}",
13153 );
13154 assert!(
13155 rendered.contains("subshell-grouping"),
13156 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
13157 );
13158 assert!(
13159 rendered.contains("command-substitution"),
13160 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
13161 {rendered:?}",
13162 );
13163 }
13164
13165 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
13166 //
13167 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
13168 // `)`) byte-pair arm: the same per-byte cascade with the same
13169 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
13170 // `}` brace-expansion / URI-Template placeholder axis. The peer
13171 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
13172 // byte pair on the sibling `:fonte :repo` axis under the same
13173 // banner.
13174
13175 #[test]
13176 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
13177 // The fail-before-pass-after pin for the canonical paste-from-
13178 // shell-history brace-expansion footgun: an author copies a
13179 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
13180 // liner whose `{a,b}` brace expansion fans across two siblings
13181 // and silently passed every prior arm (`Path::is_absolute`
13182 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
13183 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
13184 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
13185 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13186 // value starts with `..` not `$`). The lacre embedded the
13187 // value verbatim, the resolver folded it through `Path::join`
13188 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
13189 // subdirectory, and the failure surfaced at resolve time with
13190 // a non-self-locating `No such file or directory` error. The
13191 // new arm moves the rejection to validate time and names the
13192 // offending dep + caminho + byte verbatim. The arm fires on
13193 // the first `{` encountered.
13194 let d = dep_with_fonte(DepSource::Path {
13195 caminho: "../{caixa-teia,caixa-helm}/build".into(),
13196 });
13197 let err = d.validate().unwrap_err();
13198 let DepError::FonteCaminhoShellBraceExpansion {
13199 nome,
13200 caminho,
13201 byte,
13202 } = err
13203 else {
13204 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13205 };
13206 assert_eq!(nome, "caixa-teia");
13207 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
13208 assert_eq!(byte, b'{');
13209 }
13210
13211 #[test]
13212 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
13213 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
13214 // the degenerate "I selected an unbalanced closing brace out
13215 // of a shell-history block" idiom that probes for the
13216 // cascade's last-byte handling on a value carrying only the
13217 // closing byte). Pinned separately from the open-brace shape
13218 // so the gate's contract is "any `{` or `}` anywhere", not
13219 // single-byte coverage. Mirrors the peer
13220 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
13221 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
13222 // arm.
13223 let d = dep_with_fonte(DepSource::Path {
13224 caminho: "../caixa-teia}".into(),
13225 });
13226 let err = d.validate().unwrap_err();
13227 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
13228 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13229 };
13230 assert_eq!(byte, b'}');
13231 }
13232
13233 #[test]
13234 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
13235 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
13236 // — the canonical "I selected a `{a,b}` brace-expansion prefix
13237 // out of a shell-history one-liner" idiom). Pinned separately
13238 // from the embedded-byte shape so the gate covers every
13239 // position, not only mid-path.
13240 let d = dep_with_fonte(DepSource::Path {
13241 caminho: "{caixa-teia,caixa-helm}/build".into(),
13242 });
13243 let err = d.validate().unwrap_err();
13244 assert!(
13245 matches!(
13246 err,
13247 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13248 ),
13249 "got {err:?}",
13250 );
13251 }
13252
13253 #[test]
13254 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
13255 // The canonical URI-Template / Mustache / Helm doubled-brace
13256 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
13257 // "I copied a `https://github.com/{{org}}/caixa-teia` README
13258 // quick-start / OpenAPI spec / Helm chart `home:` template
13259 // and forgot to substitute the placeholder" footgun). The arm
13260 // fires on the first `{` encountered; pinned so the gate's
13261 // coverage extends from the bare-brace shell-history shape to
13262 // the doubled-brace URI-Template / templating-engine shape.
13263 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
13264 // sibling `:fonte :repo` axis.
13265 let d = dep_with_fonte(DepSource::Path {
13266 caminho: "../{{org}}/caixa-teia".into(),
13267 });
13268 let err = d.validate().unwrap_err();
13269 assert!(
13270 matches!(
13271 err,
13272 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13273 ),
13274 "got {err:?}",
13275 );
13276 }
13277
13278 #[test]
13279 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
13280 // The canonical bash brace-range-expansion shape (`"../caixa-
13281 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
13282 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
13283 // sequence-range form to the `{a,b,c}` comma-separated form).
13284 // The arm fires on the first `{` encountered; pinned so the
13285 // gate's coverage extends from the comma-separated form to
13286 // the integer-range form.
13287 let d = dep_with_fonte(DepSource::Path {
13288 caminho: "../caixa-v{1..10}".into(),
13289 });
13290 let err = d.validate().unwrap_err();
13291 assert!(
13292 matches!(
13293 err,
13294 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13295 ),
13296 "got {err:?}",
13297 );
13298 }
13299
13300 #[test]
13301 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
13302 // The positive-control pin: the gate targets only `{` / `}`,
13303 // never adjacent printable ASCII or POSIX-valid bytes. The
13304 // canonical relative POSIX path (`"../caixa-teia"`) and a
13305 // nested deeply-pathed variant with adjacent printable
13306 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
13307 // validate cleanly so the gate doesn't widen to a "no
13308 // printable punctuation anywhere" sweep that would defeat
13309 // the entire path-fonte author surface. Peer with
13310 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
13311 // on the immediate-predecessor arm.
13312 let d = dep_with_fonte(DepSource::Path {
13313 caminho: "../caixa-teia/sub-dir.v2".into(),
13314 });
13315 d.validate().unwrap();
13316 }
13317
13318 #[test]
13319 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
13320 // Cascade pin on the immediate-predecessor arm: a value
13321 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
13322 // canonical "I pasted a subshell-grouping followed by a
13323 // brace-expansion tail" footgun) routes through
13324 // `FonteCaminhoShellSubshellGrouping` not
13325 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
13326 // shape is the more semantic-locating axis on every probe-
13327 // as-both value because it closes both halves of the modern
13328 // Bourne `$(<cmd>)` command-substitution surface — same
13329 // cascade discipline every prior `:caminho` arm establishes.
13330 let d = dep_with_fonte(DepSource::Path {
13331 caminho: "../(cd foo)/{a,b}".into(),
13332 });
13333 let err = d.validate().unwrap_err();
13334 assert!(
13335 matches!(
13336 err,
13337 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13338 ),
13339 "got {err:?}",
13340 );
13341 }
13342
13343 #[test]
13344 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
13345 // Cascade pin on the upstream shell-glob arm: a value carrying
13346 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
13347 // "I pasted a glob expansion followed by a brace-expansion
13348 // tail" footgun) routes through `FonteCaminhoShellGlob` not
13349 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
13350 // shape is the load-bearing root-cause edit on every
13351 // probe-as-both value.
13352 let d = dep_with_fonte(DepSource::Path {
13353 caminho: "../caixa-teia/*{a,b}".into(),
13354 });
13355 let err = d.validate().unwrap_err();
13356 assert!(
13357 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13358 "got {err:?}",
13359 );
13360 }
13361
13362 #[test]
13363 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
13364 // Cascade pin on the upstream shell-command-substitution arm:
13365 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
13366 // — the canonical "I pasted a legacy-backtick command-
13367 // substitution followed by a brace-expansion fan-out" footgun)
13368 // routes through `FonteCaminhoShellCommandSubstitution` not
13369 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
13370 // command-injection vector is the load-bearing root-cause
13371 // edit on every probe-as-both value.
13372 let d = dep_with_fonte(DepSource::Path {
13373 caminho: "../`whoami`/{a,b}".into(),
13374 });
13375 let err = d.validate().unwrap_err();
13376 assert!(
13377 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13378 "got {err:?}",
13379 );
13380 }
13381
13382 #[test]
13383 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
13384 // Cascade pin on the upstream shell-background arm: a value
13385 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
13386 // canonical "I pasted a `cmd & {fork-fan}` background-launch
13387 // + brace-expansion chain" footgun) routes through
13388 // `FonteCaminhoShellBackground` not
13389 // `FonteCaminhoShellBraceExpansion`. The background-launch
13390 // tail is the load-bearing root-cause edit on every
13391 // probe-as-both value.
13392 let d = dep_with_fonte(DepSource::Path {
13393 caminho: "../caixa-teia & {a,b}".into(),
13394 });
13395 let err = d.validate().unwrap_err();
13396 assert!(
13397 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13398 "got {err:?}",
13399 );
13400 }
13401
13402 #[test]
13403 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
13404 // Cascade pin on the upstream shell-semicolon arm: a value
13405 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
13406 // canonical sequential-cleanup + brace-expansion paste
13407 // idiom) routes through `FonteCaminhoShellSemicolon` not
13408 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
13409 // separator paste is the load-bearing root-cause edit on
13410 // every probe-as-both value.
13411 let d = dep_with_fonte(DepSource::Path {
13412 caminho: "../caixa-teia; {a,b}".into(),
13413 });
13414 let err = d.validate().unwrap_err();
13415 assert!(
13416 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13417 "got {err:?}",
13418 );
13419 }
13420
13421 #[test]
13422 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
13423 // Cascade pin on the upstream shell-pipe arm: a value
13424 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
13425 // — the canonical pipeline-to-brace-expansion paste idiom)
13426 // routes through `FonteCaminhoShellPipe` not
13427 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
13428 // is the load-bearing root-cause edit on every probe-as-
13429 // both value.
13430 let d = dep_with_fonte(DepSource::Path {
13431 caminho: "../caixa-teia | {tee,cat}".into(),
13432 });
13433 let err = d.validate().unwrap_err();
13434 assert!(
13435 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13436 "got {err:?}",
13437 );
13438 }
13439
13440 #[test]
13441 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
13442 // Cascade pin on the upstream shell-redirection arm: a value
13443 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
13444 // the canonical "I pasted a `cmd > log {a,b}` redirect-
13445 // plus-brace-expansion chain" footgun) routes through
13446 // `FonteCaminhoShellRedirection` not
13447 // `FonteCaminhoShellBraceExpansion`. The input/output
13448 // redirection metachar carries the more self-locating
13449 // `byte` payload, so the prior arm wins on every probe-
13450 // as-both value.
13451 let d = dep_with_fonte(DepSource::Path {
13452 caminho: "../caixa-teia>log {a,b}".into(),
13453 });
13454 let err = d.validate().unwrap_err();
13455 assert!(
13456 matches!(
13457 err,
13458 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13459 ),
13460 "got {err:?}",
13461 );
13462 }
13463
13464 #[test]
13465 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
13466 // Cascade pin on the upstream backslash arm: a value
13467 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
13468 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
13469 // chain") routes through `FonteCaminhoBackslash` not
13470 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
13471 // separator divergence is the load-bearing axis on every
13472 // probe-as-both value.
13473 let d = dep_with_fonte(DepSource::Path {
13474 caminho: "..\\caixa-teia\\{a,b}".into(),
13475 });
13476 let err = d.validate().unwrap_err();
13477 assert!(
13478 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13479 "got {err:?}",
13480 );
13481 }
13482
13483 #[test]
13484 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
13485 // Cascade pin on the embedded-control-byte arm: a value
13486 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
13487 // the canonical paste-from-multiline-doc footgun where a
13488 // newline landed mid-caminho between two paste fragments)
13489 // routes through `FonteCaminhoControlChar` not
13490 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
13491 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13492 // load-bearing axis on every value that probes positive for
13493 // both — mirrors the cascade discipline on every prior arm.
13494 let d = dep_with_fonte(DepSource::Path {
13495 caminho: "../foo\n{a,b}".into(),
13496 });
13497 let err = d.validate().unwrap_err();
13498 assert!(
13499 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13500 "got {err:?}",
13501 );
13502 }
13503
13504 #[test]
13505 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
13506 // Cascade pin on the load-bearing leading-byte arm: a
13507 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
13508 // routes through `FonteCaminhoAbsolute` not
13509 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
13510 // diagnostic is the load-bearing axis, the brace-expansion
13511 // byte is the secondary observation. Same precedence logic
13512 // as every prior leading-byte arm.
13513 let d = dep_with_fonte(DepSource::Path {
13514 caminho: "/etc/{a,b}".into(),
13515 });
13516 let err = d.validate().unwrap_err();
13517 assert!(
13518 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13519 "got {err:?}",
13520 );
13521 }
13522
13523 #[test]
13524 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
13525 // Cascade pin on the upstream leading-`$` var-expansion
13526 // arm: a value carrying both a leading `$` and a `{`
13527 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
13528 // `${ORG}` shell-variable + curly-brace expansion at the
13529 // head of a sibling-workspace path" footgun) routes through
13530 // `FonteCaminhoVarExpansion` not
13531 // `FonteCaminhoShellBraceExpansion`. The leading-byte
13532 // shell-variable-expansion is the more self-locating
13533 // diagnostic on values that probe as both — same
13534 // load-bearing-leading-byte cascade discipline every prior
13535 // `:caminho` arm establishes.
13536 let d = dep_with_fonte(DepSource::Path {
13537 caminho: "${ORG}/caixa-teia".into(),
13538 });
13539 let err = d.validate().unwrap_err();
13540 assert!(
13541 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13542 "got {err:?}",
13543 );
13544 }
13545
13546 #[test]
13547 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
13548 // Cascade pin on the immediate-successor arm: a value
13549 // carrying both `{` and a trailing `/`
13550 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
13551 // tab-completed a path that already had a brace-expansion
13552 // expansion tail" footgun) routes through
13553 // `FonteCaminhoShellBraceExpansion` not
13554 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13555 // is the more semantic-locating axis (an author who removes
13556 // the `{` typically also drops the trailing separator since
13557 // both are paste-from-shell artifacts).
13558 let d = dep_with_fonte(DepSource::Path {
13559 caminho: "../{caixa-teia,caixa-helm}/".into(),
13560 });
13561 let err = d.validate().unwrap_err();
13562 assert!(
13563 matches!(
13564 err,
13565 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13566 ),
13567 "got {err:?}",
13568 );
13569 }
13570
13571 #[test]
13572 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13573 // Diagnostic-shape pin (peer with
13574 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13575 // on the closest two-byte peer arm): the error's Display
13576 // surfaces the offending `:nome`, the offending `:caminho`
13577 // verbatim, the offending byte's hex / character form, and
13578 // names the shell-brace-expansion / URI-Template footgun
13579 // explicitly so a `feira lint` run can render the diagnostic
13580 // without re-parsing.
13581 let d = dep_with_fonte(DepSource::Path {
13582 caminho: "../{caixa-teia,caixa-helm}/build".into(),
13583 });
13584 let rendered = d.validate().unwrap_err().to_string();
13585 assert!(
13586 rendered.contains("caixa-teia"),
13587 "diagnostic must name the offending dep: {rendered}",
13588 );
13589 assert!(
13590 rendered.contains("../{caixa-teia,caixa-helm}/build"),
13591 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13592 );
13593 assert!(
13594 rendered.contains("0x7b"),
13595 "diagnostic must surface the offending byte hex: {rendered:?}",
13596 );
13597 assert!(
13598 rendered.contains("brace-expansion"),
13599 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
13600 );
13601 assert!(
13602 rendered.contains("URI Template"),
13603 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
13604 {rendered:?}",
13605 );
13606 }
13607
13608 #[test]
13609 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
13610 // The canonical paste-from-shell-history bracket-glob /
13611 // character-class footgun: an author copies a
13612 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
13613 // `[a-z]` POSIX glob character-class matches every lowercase-
13614 // ASCII-suffix sibling caixa directory and silently passed
13615 // every prior arm (`Path::is_absolute` false on `..`, no
13616 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
13617 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
13618 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
13619 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13620 // value starts with `..` not `$`). The lacre embedded the
13621 // value verbatim, the resolver folded it through
13622 // `Path::join` looking for a literal `./../caixa-[a-z]/
13623 // build` subdirectory, and the failure surfaced at resolve
13624 // time with a non-self-locating `No such file or directory`
13625 // error. The new arm moves the rejection to validate time
13626 // and names the offending dep + caminho + byte verbatim.
13627 // The arm fires on the first `[` encountered.
13628 let d = dep_with_fonte(DepSource::Path {
13629 caminho: "../caixa-[a-z]/build".into(),
13630 });
13631 let err = d.validate().unwrap_err();
13632 let DepError::FonteCaminhoShellBracketExpansion {
13633 nome,
13634 caminho,
13635 byte,
13636 } = err
13637 else {
13638 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13639 };
13640 assert_eq!(nome, "caixa-teia");
13641 assert_eq!(caminho, "../caixa-[a-z]/build");
13642 assert_eq!(byte, b'[');
13643 }
13644
13645 #[test]
13646 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13647 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13648 // — the degenerate "I selected an unbalanced closing bracket
13649 // out of a glob character-class block" idiom that probes for
13650 // the cascade's last-byte handling on a value carrying only
13651 // the closing byte). Pinned separately from the open-bracket
13652 // shape so the gate's contract is "any `[` or `]` anywhere",
13653 // not single-byte coverage. Mirrors the peer
13654 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13655 // shape on the immediate-predecessor
13656 // `FonteCaminhoShellBraceExpansion` arm.
13657 let d = dep_with_fonte(DepSource::Path {
13658 caminho: "../caixa-teia]".into(),
13659 });
13660 let err = d.validate().unwrap_err();
13661 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13662 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13663 };
13664 assert_eq!(byte, b']');
13665 }
13666
13667 #[test]
13668 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13669 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13670 // canonical "I selected a `[caixa-teia]` TOML-table-header /
13671 // glob-character-class prefix out of an aligned config /
13672 // shell-history one-liner" idiom). Pinned separately from
13673 // the embedded-byte shape so the gate covers every position,
13674 // not only mid-path.
13675 let d = dep_with_fonte(DepSource::Path {
13676 caminho: "[caixa-teia]/build".into(),
13677 });
13678 let err = d.validate().unwrap_err();
13679 assert!(
13680 matches!(
13681 err,
13682 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13683 ),
13684 "got {err:?}",
13685 );
13686 }
13687
13688 #[test]
13689 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13690 // The canonical TOML inline-array / YAML flow-sequence
13691 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13692 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13693 // inline-array out of a sibling-Cargo manifest" cross-idiom
13694 // leak; the symmetric YAML flow-sequence form `paths: [/a,
13695 // /b]` paste-from-values.yaml shape carries the same
13696 // bracket pair). The arm fires on the first `[` encountered;
13697 // pinned so the gate's coverage extends from the bare-
13698 // bracket glob-character-class shape to the TOML / YAML /
13699 // JSON array-literal shape.
13700 let d = dep_with_fonte(DepSource::Path {
13701 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13702 });
13703 let err = d.validate().unwrap_err();
13704 assert!(
13705 matches!(
13706 err,
13707 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13708 ),
13709 "got {err:?}",
13710 );
13711 }
13712
13713 #[test]
13714 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13715 // The canonical POSIX `test` / `[` builtin command paste
13716 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13717 // script conditional every paste-from-shell-script idiom
13718 // carries; bash's `[[ <expr> ]]` extended-test grammar
13719 // would surface the same byte pair). The arm fires on the
13720 // first `[` encountered; pinned so the gate's coverage
13721 // extends from the embedded-glob-character-class shape to
13722 // the leading-`test`-builtin / extended-test form.
13723 let d = dep_with_fonte(DepSource::Path {
13724 caminho: "../[ -d caixa-teia ]".into(),
13725 });
13726 let err = d.validate().unwrap_err();
13727 assert!(
13728 matches!(
13729 err,
13730 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13731 ),
13732 "got {err:?}",
13733 );
13734 }
13735
13736 #[test]
13737 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13738 // The positive-control pin: the gate targets only `[` /
13739 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13740 // The canonical relative POSIX path (`"../caixa-teia"`) and
13741 // a nested deeply-pathed variant with adjacent printable
13742 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13743 // to validate cleanly so the gate doesn't widen to a "no
13744 // printable punctuation anywhere" sweep that would defeat
13745 // the entire path-fonte author surface. Peer with
13746 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13747 // on the immediate-predecessor arm.
13748 let d = dep_with_fonte(DepSource::Path {
13749 caminho: "../caixa-teia/sub-dir.v2".into(),
13750 });
13751 d.validate().unwrap();
13752 }
13753
13754 #[test]
13755 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13756 // Cascade pin on the immediate-predecessor arm: a value
13757 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13758 // canonical "I pasted a brace-expansion fan followed by a
13759 // glob-character-class tail" footgun) routes through
13760 // `FonteCaminhoShellBraceExpansion` not
13761 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13762 // fan is the load-bearing root-cause edit on every
13763 // probe-as-both value because the bracket-class tail
13764 // typically rides on a prior brace-expansion expansion;
13765 // same cascade discipline every prior `:caminho` arm
13766 // establishes.
13767 let d = dep_with_fonte(DepSource::Path {
13768 caminho: "../{a,b}[ch]".into(),
13769 });
13770 let err = d.validate().unwrap_err();
13771 assert!(
13772 matches!(
13773 err,
13774 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13775 ),
13776 "got {err:?}",
13777 );
13778 }
13779
13780 #[test]
13781 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13782 // Cascade pin on the upstream shell-subshell-grouping arm:
13783 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13784 // the canonical "I pasted a subshell-grouping followed by
13785 // a glob-character-class tail" footgun) routes through
13786 // `FonteCaminhoShellSubshellGrouping` not
13787 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13788 // `$(<cmd>)` command-substitution boundary is the load-
13789 // bearing axis on every probe-as-both value.
13790 let d = dep_with_fonte(DepSource::Path {
13791 caminho: "../(cd foo)/[ch]".into(),
13792 });
13793 let err = d.validate().unwrap_err();
13794 assert!(
13795 matches!(
13796 err,
13797 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13798 ),
13799 "got {err:?}",
13800 );
13801 }
13802
13803 #[test]
13804 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13805 // Cascade pin on the upstream shell-glob arm: a value
13806 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13807 // canonical "I pasted a `*.[ch]` C-source-file glob whose
13808 // unbounded `*` precedes the bracket character-class"
13809 // footgun) routes through `FonteCaminhoShellGlob` not
13810 // `FonteCaminhoShellBracketExpansion`. The unbounded
13811 // pathname-expansion sentinel is the load-bearing root-
13812 // cause edit on every probe-as-both value — the unbounded
13813 // `*` carries the more aggressive expansion vector than
13814 // the bounded `[ch]` class, so the prior arm wins.
13815 let d = dep_with_fonte(DepSource::Path {
13816 caminho: "../caixa-teia/*[ch]".into(),
13817 });
13818 let err = d.validate().unwrap_err();
13819 assert!(
13820 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13821 "got {err:?}",
13822 );
13823 }
13824
13825 #[test]
13826 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13827 // Cascade pin on the upstream shell-command-substitution
13828 // arm: a value carrying both a backtick and `[`
13829 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13830 // legacy-backtick command-substitution followed by a
13831 // glob-character-class tail" footgun) routes through
13832 // `FonteCaminhoShellCommandSubstitution` not
13833 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13834 // command-injection vector is the load-bearing root-cause
13835 // edit on every probe-as-both value.
13836 let d = dep_with_fonte(DepSource::Path {
13837 caminho: "../`whoami`/[ch]".into(),
13838 });
13839 let err = d.validate().unwrap_err();
13840 assert!(
13841 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13842 "got {err:?}",
13843 );
13844 }
13845
13846 #[test]
13847 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13848 // Cascade pin on the upstream shell-background arm: a
13849 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13850 // — the canonical "I pasted a `cmd & [glob]` background-
13851 // launch + bracket-class chain" footgun) routes through
13852 // `FonteCaminhoShellBackground` not
13853 // `FonteCaminhoShellBracketExpansion`. The background-
13854 // launch tail is the load-bearing root-cause edit on
13855 // every probe-as-both value.
13856 let d = dep_with_fonte(DepSource::Path {
13857 caminho: "../caixa-teia & [ch]".into(),
13858 });
13859 let err = d.validate().unwrap_err();
13860 assert!(
13861 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13862 "got {err:?}",
13863 );
13864 }
13865
13866 #[test]
13867 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13868 // Cascade pin on the upstream shell-semicolon arm: a value
13869 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13870 // canonical sequential-cleanup + bracket-class paste
13871 // idiom) routes through `FonteCaminhoShellSemicolon` not
13872 // `FonteCaminhoShellBracketExpansion`. The sequential-
13873 // command-separator paste is the load-bearing root-cause
13874 // edit on every probe-as-both value.
13875 let d = dep_with_fonte(DepSource::Path {
13876 caminho: "../caixa-teia; [ch]".into(),
13877 });
13878 let err = d.validate().unwrap_err();
13879 assert!(
13880 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13881 "got {err:?}",
13882 );
13883 }
13884
13885 #[test]
13886 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13887 // Cascade pin on the upstream shell-pipe arm: a value
13888 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13889 // the canonical pipeline-to-bracket-class paste idiom)
13890 // routes through `FonteCaminhoShellPipe` not
13891 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13892 // paste is the load-bearing root-cause edit on every
13893 // probe-as-both value.
13894 let d = dep_with_fonte(DepSource::Path {
13895 caminho: "../caixa-teia | [tee]".into(),
13896 });
13897 let err = d.validate().unwrap_err();
13898 assert!(
13899 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13900 "got {err:?}",
13901 );
13902 }
13903
13904 #[test]
13905 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13906 // Cascade pin on the upstream shell-redirection arm: a
13907 // value carrying both `>` and `[` (`"../caixa-teia>log
13908 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13909 // redirect-plus-bracket chain" footgun) routes through
13910 // `FonteCaminhoShellRedirection` not
13911 // `FonteCaminhoShellBracketExpansion`. The input/output
13912 // redirection metachar carries the more self-locating
13913 // `byte` payload, so the prior arm wins on every
13914 // probe-as-both value.
13915 let d = dep_with_fonte(DepSource::Path {
13916 caminho: "../caixa-teia>log [ch]".into(),
13917 });
13918 let err = d.validate().unwrap_err();
13919 assert!(
13920 matches!(
13921 err,
13922 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13923 ),
13924 "got {err:?}",
13925 );
13926 }
13927
13928 #[test]
13929 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13930 // Cascade pin on the upstream backslash arm: a value
13931 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13932 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13933 // chain") routes through `FonteCaminhoBackslash` not
13934 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13935 // separator divergence is the load-bearing axis on every
13936 // probe-as-both value.
13937 let d = dep_with_fonte(DepSource::Path {
13938 caminho: "..\\caixa-teia\\[ch]".into(),
13939 });
13940 let err = d.validate().unwrap_err();
13941 assert!(
13942 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13943 "got {err:?}",
13944 );
13945 }
13946
13947 #[test]
13948 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13949 // Cascade pin on the embedded-control-byte arm: a value
13950 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13951 // the canonical paste-from-multiline-doc footgun where a
13952 // newline landed mid-caminho between two paste fragments)
13953 // routes through `FonteCaminhoControlChar` not
13954 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13955 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13956 // the load-bearing axis on every value that probes
13957 // positive for both — mirrors the cascade discipline on
13958 // every prior arm.
13959 let d = dep_with_fonte(DepSource::Path {
13960 caminho: "../foo\n[ch]".into(),
13961 });
13962 let err = d.validate().unwrap_err();
13963 assert!(
13964 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13965 "got {err:?}",
13966 );
13967 }
13968
13969 #[test]
13970 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13971 // Cascade pin on the load-bearing leading-byte arm: a
13972 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13973 // routes through `FonteCaminhoAbsolute` not
13974 // `FonteCaminhoShellBracketExpansion` — the host-layout-
13975 // leak diagnostic is the load-bearing axis, the bracket-
13976 // expansion byte is the secondary observation. Same
13977 // precedence logic as every prior leading-byte arm.
13978 let d = dep_with_fonte(DepSource::Path {
13979 caminho: "/etc/[ch]".into(),
13980 });
13981 let err = d.validate().unwrap_err();
13982 assert!(
13983 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13984 "got {err:?}",
13985 );
13986 }
13987
13988 #[test]
13989 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13990 // Cascade pin on the upstream leading-`$` var-expansion
13991 // arm: a value carrying both a leading `$` and a `[`
13992 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13993 // variable + bracket-class at the head of a sibling-
13994 // workspace path" footgun) routes through
13995 // `FonteCaminhoVarExpansion` not
13996 // `FonteCaminhoShellBracketExpansion`. The leading-byte
13997 // shell-variable-expansion is the more self-locating
13998 // diagnostic on values that probe as both — same
13999 // load-bearing-leading-byte cascade discipline every
14000 // prior `:caminho` arm establishes.
14001 let d = dep_with_fonte(DepSource::Path {
14002 caminho: "$DIR/[ch]".into(),
14003 });
14004 let err = d.validate().unwrap_err();
14005 assert!(
14006 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14007 "got {err:?}",
14008 );
14009 }
14010
14011 #[test]
14012 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
14013 // Cascade pin on the immediate-successor arm: a value
14014 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
14015 // the canonical "I tab-completed a path that already had
14016 // a bracket-glob-character-class expansion tail" footgun)
14017 // routes through `FonteCaminhoShellBracketExpansion` not
14018 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14019 // is the more semantic-locating axis (an author who
14020 // removes the `[` typically also drops the trailing
14021 // separator since both are paste-from-shell artifacts).
14022 let d = dep_with_fonte(DepSource::Path {
14023 caminho: "../[a-z]/".into(),
14024 });
14025 let err = d.validate().unwrap_err();
14026 assert!(
14027 matches!(
14028 err,
14029 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14030 ),
14031 "got {err:?}",
14032 );
14033 }
14034
14035 #[test]
14036 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14037 // Diagnostic-shape pin (peer with
14038 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14039 // on the closest two-byte peer arm): the error's Display
14040 // surfaces the offending `:nome`, the offending `:caminho`
14041 // verbatim, the offending byte's hex / character form, and
14042 // names the shell-bracket-expansion / glob-character-class
14043 // footgun explicitly so a `feira lint` run can render the
14044 // diagnostic without re-parsing.
14045 let d = dep_with_fonte(DepSource::Path {
14046 caminho: "../caixa-[a-z]/build".into(),
14047 });
14048 let rendered = d.validate().unwrap_err().to_string();
14049 assert!(
14050 rendered.contains("caixa-teia"),
14051 "diagnostic must name the offending dep: {rendered}",
14052 );
14053 assert!(
14054 rendered.contains("../caixa-[a-z]/build"),
14055 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14056 );
14057 assert!(
14058 rendered.contains("0x5b"),
14059 "diagnostic must surface the offending byte hex: {rendered:?}",
14060 );
14061 assert!(
14062 rendered.contains("bracket-expansion"),
14063 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
14064 );
14065 assert!(
14066 rendered.contains("glob-character-class"),
14067 "diagnostic must reference the POSIX glob-character-class vocabulary: \
14068 {rendered:?}",
14069 );
14070 }
14071
14072 #[test]
14073 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
14074 // The canonical paste-from-shell-history strong-quoted
14075 // sibling-workspace-path footgun: an author copies a
14076 // `cd '../caixa-teia'` shell-history one-liner whose strong-
14077 // quoting preserved the path across a whitespace paste
14078 // boundary and silently passed every prior arm
14079 // (`Path::is_absolute` false on `'..`, no control bytes, no
14080 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
14081 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
14082 // doesn't end in `/`; the leading-`$` f4efe9c
14083 // `FonteCaminhoVarExpansion` arm doesn't fire because the
14084 // value starts with `'` not `$`). The lacre embedded the
14085 // value verbatim, the resolver folded it through
14086 // `Path::join` looking for a literal `./'../caixa-teia'`
14087 // subdirectory, and the failure surfaced at resolve time
14088 // with a non-self-locating `No such file or directory`
14089 // error. The new arm moves the rejection to validate time
14090 // and names the offending dep + caminho + byte verbatim.
14091 // The arm fires on the first `'` encountered.
14092 let d = dep_with_fonte(DepSource::Path {
14093 caminho: "'../caixa-teia'".into(),
14094 });
14095 let err = d.validate().unwrap_err();
14096 let DepError::FonteCaminhoShellQuoteGrouping {
14097 nome,
14098 caminho,
14099 byte,
14100 } = err
14101 else {
14102 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
14103 };
14104 assert_eq!(nome, "caixa-teia");
14105 assert_eq!(caminho, "'../caixa-teia'");
14106 assert_eq!(byte, b'\'');
14107 }
14108
14109 #[test]
14110 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
14111 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
14112 // — the canonical paste-from-JSON-config / paste-from-YAML-
14113 // flow-scalar / paste-from-TOML-basic-string / paste-from-
14114 // tatara-lisp-string-literal cross-idiom leak). Pinned
14115 // separately from the single-quote shape so the gate's
14116 // contract is "any `'` or `\"` anywhere", not single-byte
14117 // coverage. Mirrors the peer
14118 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
14119 // shape on the immediate-predecessor
14120 // `FonteCaminhoShellBracketExpansion` arm.
14121 let d = dep_with_fonte(DepSource::Path {
14122 caminho: "\"../caixa-teia\"".into(),
14123 });
14124 let err = d.validate().unwrap_err();
14125 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
14126 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
14127 };
14128 assert_eq!(byte, b'"');
14129 }
14130
14131 #[test]
14132 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
14133 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
14134 // canonical "I pasted a JSON key-value pair fragment into
14135 // the middle of the path" idiom). Pinned separately from
14136 // the leading-byte shape so the gate covers every position,
14137 // not only leading.
14138 let d = dep_with_fonte(DepSource::Path {
14139 caminho: "../\"caixa-teia\"".into(),
14140 });
14141 let err = d.validate().unwrap_err();
14142 assert!(
14143 matches!(
14144 err,
14145 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
14146 ),
14147 "got {err:?}",
14148 );
14149 }
14150
14151 #[test]
14152 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
14153 // The canonical YAML double-quoted flow-scalar cross-idiom
14154 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
14155 // `path: \"...\"` YAML flow-scalar entry out of an aligned
14156 // values.yaml / K8s manifest and dropped it verbatim into
14157 // the `:caminho` slot including the `path: ` key prefix"
14158 // paste-idiom). The arm fires on the first `"` encountered;
14159 // pinned so the gate's coverage extends from the bare-quote
14160 // paste shape to the aligned-YAML-manifest cross-idiom-leak
14161 // shape.
14162 let d = dep_with_fonte(DepSource::Path {
14163 caminho: "path: \"../caixa-teia\"".into(),
14164 });
14165 let err = d.validate().unwrap_err();
14166 assert!(
14167 matches!(
14168 err,
14169 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
14170 ),
14171 "got {err:?}",
14172 );
14173 }
14174
14175 #[test]
14176 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
14177 // The positive-control pin: the gate targets only `'` /
14178 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
14179 // The canonical relative POSIX path (`"../caixa-teia"`) and
14180 // a nested deeply-pathed variant with adjacent printable
14181 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14182 // to validate cleanly so the gate doesn't widen to a "no
14183 // printable punctuation anywhere" sweep that would defeat
14184 // the entire path-fonte author surface. Peer with
14185 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
14186 // on the immediate-predecessor arm.
14187 let d = dep_with_fonte(DepSource::Path {
14188 caminho: "../caixa-teia/sub-dir.v2".into(),
14189 });
14190 d.validate().unwrap();
14191 }
14192
14193 #[test]
14194 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
14195 // Cascade pin on the immediate-predecessor arm: a value
14196 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
14197 // "I pasted a glob-character-class followed by a strong-
14198 // quoted literal tail" footgun) routes through
14199 // `FonteCaminhoShellBracketExpansion` not
14200 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
14201 // expansion is the load-bearing root-cause edit on every
14202 // probe-as-both value; same cascade discipline every prior
14203 // `:caminho` arm establishes.
14204 let d = dep_with_fonte(DepSource::Path {
14205 caminho: "../[a-z]'x'".into(),
14206 });
14207 let err = d.validate().unwrap_err();
14208 assert!(
14209 matches!(
14210 err,
14211 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14212 ),
14213 "got {err:?}",
14214 );
14215 }
14216
14217 #[test]
14218 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
14219 // Cascade pin on the upstream shell-brace-expansion arm: a
14220 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
14221 // canonical "I pasted a brace-expansion fan followed by a
14222 // strong-quoted literal tail" footgun) routes through
14223 // `FonteCaminhoShellBraceExpansion` not
14224 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
14225 // is the load-bearing root-cause edit on every probe-as-
14226 // both value.
14227 let d = dep_with_fonte(DepSource::Path {
14228 caminho: "../{a,b}'x'".into(),
14229 });
14230 let err = d.validate().unwrap_err();
14231 assert!(
14232 matches!(
14233 err,
14234 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14235 ),
14236 "got {err:?}",
14237 );
14238 }
14239
14240 #[test]
14241 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
14242 // Cascade pin on the upstream shell-subshell-grouping arm:
14243 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
14244 // the canonical "I pasted a subshell-grouping followed by
14245 // a strong-quoted literal tail" footgun) routes through
14246 // `FonteCaminhoShellSubshellGrouping` not
14247 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
14248 // `$(<cmd>)` command-substitution boundary is the load-
14249 // bearing axis on every probe-as-both value.
14250 let d = dep_with_fonte(DepSource::Path {
14251 caminho: "../(cd foo)/'x'".into(),
14252 });
14253 let err = d.validate().unwrap_err();
14254 assert!(
14255 matches!(
14256 err,
14257 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14258 ),
14259 "got {err:?}",
14260 );
14261 }
14262
14263 #[test]
14264 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
14265 // Cascade pin on the upstream shell-glob arm: a value
14266 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
14267 // canonical "I pasted a `*` unbounded pathname-expansion
14268 // followed by a strong-quoted literal tail" footgun) routes
14269 // through `FonteCaminhoShellGlob` not
14270 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
14271 // expansion sentinel is the load-bearing root-cause edit
14272 // on every probe-as-both value.
14273 let d = dep_with_fonte(DepSource::Path {
14274 caminho: "../caixa-teia/*'x'".into(),
14275 });
14276 let err = d.validate().unwrap_err();
14277 assert!(
14278 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14279 "got {err:?}",
14280 );
14281 }
14282
14283 #[test]
14284 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
14285 // Cascade pin on the upstream shell-command-substitution
14286 // arm: a value carrying both a backtick and `'`
14287 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
14288 // legacy-backtick command-substitution followed by a
14289 // strong-quoted literal tail" footgun) routes through
14290 // `FonteCaminhoShellCommandSubstitution` not
14291 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
14292 // command-injection vector is the load-bearing root-cause
14293 // edit on every probe-as-both value.
14294 let d = dep_with_fonte(DepSource::Path {
14295 caminho: "../`whoami`/'x'".into(),
14296 });
14297 let err = d.validate().unwrap_err();
14298 assert!(
14299 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14300 "got {err:?}",
14301 );
14302 }
14303
14304 #[test]
14305 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
14306 // Cascade pin on the upstream shell-background arm: a value
14307 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
14308 // canonical "I pasted a `cmd & 'literal'` background-launch
14309 // + quote chain" footgun) routes through
14310 // `FonteCaminhoShellBackground` not
14311 // `FonteCaminhoShellQuoteGrouping`. The background-launch
14312 // tail is the load-bearing root-cause edit on every
14313 // probe-as-both value.
14314 let d = dep_with_fonte(DepSource::Path {
14315 caminho: "../caixa-teia & 'x'".into(),
14316 });
14317 let err = d.validate().unwrap_err();
14318 assert!(
14319 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14320 "got {err:?}",
14321 );
14322 }
14323
14324 #[test]
14325 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
14326 // Cascade pin on the upstream shell-semicolon arm: a value
14327 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
14328 // canonical sequential-cleanup + quote paste idiom) routes
14329 // through `FonteCaminhoShellSemicolon` not
14330 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
14331 // separator paste is the load-bearing root-cause edit on
14332 // every probe-as-both value.
14333 let d = dep_with_fonte(DepSource::Path {
14334 caminho: "../caixa-teia; 'x'".into(),
14335 });
14336 let err = d.validate().unwrap_err();
14337 assert!(
14338 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14339 "got {err:?}",
14340 );
14341 }
14342
14343 #[test]
14344 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
14345 // Cascade pin on the upstream shell-pipe arm: a value
14346 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
14347 // canonical pipeline-to-quoted-literal paste idiom) routes
14348 // through `FonteCaminhoShellPipe` not
14349 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
14350 // is the load-bearing root-cause edit on every probe-as-
14351 // both value.
14352 let d = dep_with_fonte(DepSource::Path {
14353 caminho: "../caixa-teia | 'x'".into(),
14354 });
14355 let err = d.validate().unwrap_err();
14356 assert!(
14357 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14358 "got {err:?}",
14359 );
14360 }
14361
14362 #[test]
14363 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
14364 // Cascade pin on the upstream shell-redirection arm: a
14365 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
14366 // — the canonical "I pasted a `cmd > log 'literal'`
14367 // redirect-plus-quote chain" footgun) routes through
14368 // `FonteCaminhoShellRedirection` not
14369 // `FonteCaminhoShellQuoteGrouping`. The input/output
14370 // redirection metachar carries the more self-locating
14371 // `byte` payload, so the prior arm wins on every probe-as-
14372 // both value.
14373 let d = dep_with_fonte(DepSource::Path {
14374 caminho: "../caixa-teia>log 'x'".into(),
14375 });
14376 let err = d.validate().unwrap_err();
14377 assert!(
14378 matches!(
14379 err,
14380 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14381 ),
14382 "got {err:?}",
14383 );
14384 }
14385
14386 #[test]
14387 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
14388 // Cascade pin on the upstream backslash arm: a value
14389 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
14390 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
14391 // chain" footgun) routes through `FonteCaminhoBackslash`
14392 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
14393 // separator divergence is the load-bearing axis on every
14394 // probe-as-both value.
14395 let d = dep_with_fonte(DepSource::Path {
14396 caminho: "..\\caixa-teia\\'x'".into(),
14397 });
14398 let err = d.validate().unwrap_err();
14399 assert!(
14400 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14401 "got {err:?}",
14402 );
14403 }
14404
14405 #[test]
14406 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
14407 // Cascade pin on the embedded-control-byte arm: a value
14408 // carrying both a control byte and `'` (`"../foo\n'x'"` —
14409 // the canonical paste-from-multiline-doc footgun where a
14410 // newline landed mid-caminho between two paste fragments)
14411 // routes through `FonteCaminhoControlChar` not
14412 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
14413 // rejected-byte / NUL-`CString::new`-fail diagnostic is
14414 // the load-bearing axis on every value that probes
14415 // positive for both — mirrors the cascade discipline on
14416 // every prior arm.
14417 let d = dep_with_fonte(DepSource::Path {
14418 caminho: "../foo\n'x'".into(),
14419 });
14420 let err = d.validate().unwrap_err();
14421 assert!(
14422 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14423 "got {err:?}",
14424 );
14425 }
14426
14427 #[test]
14428 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
14429 // Cascade pin on the load-bearing leading-byte arm: a
14430 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
14431 // through `FonteCaminhoAbsolute` not
14432 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
14433 // diagnostic is the load-bearing axis, the quote byte is
14434 // the secondary observation. Same precedence logic as every
14435 // prior leading-byte arm.
14436 let d = dep_with_fonte(DepSource::Path {
14437 caminho: "/etc/'x'".into(),
14438 });
14439 let err = d.validate().unwrap_err();
14440 assert!(
14441 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14442 "got {err:?}",
14443 );
14444 }
14445
14446 #[test]
14447 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
14448 // Cascade pin on the upstream leading-`$` var-expansion
14449 // arm: a value carrying both a leading `$` and a `'`
14450 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
14451 // variable + quoted literal at the head of a sibling-
14452 // workspace path" footgun) routes through
14453 // `FonteCaminhoVarExpansion` not
14454 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
14455 // shell-variable-expansion is the more self-locating
14456 // diagnostic on values that probe as both — same
14457 // load-bearing-leading-byte cascade discipline every
14458 // prior `:caminho` arm establishes.
14459 let d = dep_with_fonte(DepSource::Path {
14460 caminho: "$DIR/'x'".into(),
14461 });
14462 let err = d.validate().unwrap_err();
14463 assert!(
14464 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14465 "got {err:?}",
14466 );
14467 }
14468
14469 #[test]
14470 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
14471 // Cascade pin on the immediate-successor arm: a value
14472 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
14473 // — the canonical "I tab-completed a path whose strong-
14474 // quoted body already carried the quoting from a shell-
14475 // history paste" footgun) routes through
14476 // `FonteCaminhoShellQuoteGrouping` not
14477 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14478 // is the more semantic-locating axis (an author who removes
14479 // the `'` typically also drops the trailing separator since
14480 // both are paste-from-shell artifacts).
14481 let d = dep_with_fonte(DepSource::Path {
14482 caminho: "../'caixa-teia'/".into(),
14483 });
14484 let err = d.validate().unwrap_err();
14485 assert!(
14486 matches!(
14487 err,
14488 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14489 ),
14490 "got {err:?}",
14491 );
14492 }
14493
14494 #[test]
14495 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
14496 // Diagnostic-shape pin (peer with
14497 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14498 // on the closest two-byte peer arm): the error's Display
14499 // surfaces the offending `:nome`, the offending `:caminho`
14500 // verbatim, the offending byte's hex / character form, and
14501 // names the shell-quote-grouping / cross-config-DSL-string-
14502 // literal-delimiter footgun explicitly so a `feira lint`
14503 // run can render the diagnostic without re-parsing.
14504 let d = dep_with_fonte(DepSource::Path {
14505 caminho: "'../caixa-teia'".into(),
14506 });
14507 let rendered = d.validate().unwrap_err().to_string();
14508 assert!(
14509 rendered.contains("caixa-teia"),
14510 "diagnostic must name the offending dep: {rendered}",
14511 );
14512 assert!(
14513 rendered.contains("'../caixa-teia'"),
14514 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14515 );
14516 assert!(
14517 rendered.contains("0x27"),
14518 "diagnostic must surface the offending byte hex: {rendered:?}",
14519 );
14520 assert!(
14521 rendered.contains("quote-grouping"),
14522 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
14523 );
14524 assert!(
14525 rendered.contains("string-literal"),
14526 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
14527 vocabulary: {rendered:?}",
14528 );
14529 }
14530
14531 #[test]
14532 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
14533 // The canonical paste-from-shell-history-with-trailing-
14534 // annotation footgun: an author pastes a `cd ../caixa-teia
14535 // # legacy sibling` shell-history one-liner whose unquoted `#`
14536 // comment-lead separates the path from an inline annotation.
14537 // The POSIX shell trims the annotation to `../caixa-teia`
14538 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
14539 // `Path::is_absolute` returns false on `..`, `#` is neither
14540 // a leading-byte sentinel nor a control byte nor `\` nor
14541 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
14542 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
14543 // `"`, and the value's last byte isn't `/` — so the value
14544 // silently passed every prior arm. The resolver folded the
14545 // value through `Path::join` looking for a literal
14546 // `./../caixa-teia # legacy sibling` subdirectory and the
14547 // failure surfaced at resolve time with a non-self-locating
14548 // `No such file or directory` error. The new arm moves the
14549 // rejection to validate time and names the offending dep +
14550 // caminho + byte verbatim.
14551 let d = dep_with_fonte(DepSource::Path {
14552 caminho: "../caixa-teia # legacy sibling".into(),
14553 });
14554 let err = d.validate().unwrap_err();
14555 let DepError::FonteCaminhoShellComment {
14556 nome,
14557 caminho,
14558 byte,
14559 } = err
14560 else {
14561 panic!("expected FonteCaminhoShellComment, got {err:?}");
14562 };
14563 assert_eq!(nome, "caixa-teia");
14564 assert_eq!(caminho, "../caixa-teia # legacy sibling");
14565 assert_eq!(byte, b'#');
14566 }
14567
14568 #[test]
14569 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
14570 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
14571 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
14572 // canonical "I copied a `path: ../caixa-teia # pin` YAML
14573 // scalar-plus-comment entry out of an aligned values.yaml and
14574 // dropped it verbatim into the `:caminho` slot" paste-idiom).
14575 // Pinned separately from the shell-history shape so the
14576 // gate's coverage extends from the single-space `#` shape to
14577 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
14578 // requires the `#` to be preceded by whitespace to lex as a
14579 // comment (bare `foo#bar` is a single scalar); the double-
14580 // space paste from an aligned manifest is the canonical
14581 // shape.
14582 let d = dep_with_fonte(DepSource::Path {
14583 caminho: "../caixa-teia # pin".into(),
14584 });
14585 let err = d.validate().unwrap_err();
14586 assert!(
14587 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14588 "got {err:?}",
14589 );
14590 }
14591
14592 #[test]
14593 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
14594 // The URL-fragment-identifier paste shape
14595 // (`"../caixa-teia#readme"` — the canonical
14596 // paste-from-browser-address-bar permalink shape where the
14597 // browser preserved the `#anchor` tail on the copy). Pinned
14598 // separately from the whitespace-separated shell / YAML
14599 // comment shapes so the gate covers the unpadded RFC 3986
14600 // §3.5 fragment-delimiter position too, not only positions
14601 // preceded by unquoted whitespace. Peer with the immediate-
14602 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
14603 // (a68f818) which closes the same byte under the same URL-
14604 // fragment-identifier banner.
14605 let d = dep_with_fonte(DepSource::Path {
14606 caminho: "../caixa-teia#readme".into(),
14607 });
14608 let err = d.validate().unwrap_err();
14609 assert!(
14610 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14611 "got {err:?}",
14612 );
14613 }
14614
14615 #[test]
14616 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
14617 // Leading-position `#` shape (`"#../caixa-teia"` — the
14618 // "I copied a shell-comment-out entry from a commented-out
14619 // dep row" footgun). Pinned separately from the embedded
14620 // shapes so the gate covers every position, not only
14621 // whitespace-preceded / mid-value.
14622 let d = dep_with_fonte(DepSource::Path {
14623 caminho: "#../caixa-teia".into(),
14624 });
14625 let err = d.validate().unwrap_err();
14626 assert!(
14627 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14628 "got {err:?}",
14629 );
14630 }
14631
14632 #[test]
14633 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
14634 // The positive-control pin: the gate targets only `#`,
14635 // never adjacent printable ASCII or POSIX-valid bytes. The
14636 // canonical relative POSIX path (`"../caixa-teia"`) and a
14637 // nested deeply-pathed variant with adjacent printable
14638 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14639 // to validate cleanly so the gate doesn't widen to a "no
14640 // printable punctuation anywhere" sweep that would defeat
14641 // the entire path-fonte author surface. Peer with
14642 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
14643 // on the immediate-predecessor arm.
14644 let d = dep_with_fonte(DepSource::Path {
14645 caminho: "../caixa-teia/sub-dir.v2".into(),
14646 });
14647 d.validate().unwrap();
14648 }
14649
14650 #[test]
14651 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14652 // Cascade pin on the immediate-predecessor arm: a value
14653 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14654 // "I pasted a strong-quoted literal followed by a URL-
14655 // fragment permalink tail" footgun) routes through
14656 // `FonteCaminhoShellQuoteGrouping` not
14657 // `FonteCaminhoShellComment`. The shell-string-literal-
14658 // delimiter is the load-bearing root-cause edit on every
14659 // probe-as-both value; same cascade discipline every prior
14660 // `:caminho` arm establishes.
14661 let d = dep_with_fonte(DepSource::Path {
14662 caminho: "../'x'#pin".into(),
14663 });
14664 let err = d.validate().unwrap_err();
14665 assert!(
14666 matches!(
14667 err,
14668 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14669 ),
14670 "got {err:?}",
14671 );
14672 }
14673
14674 #[test]
14675 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14676 // Cascade pin on the upstream shell-bracket-expansion arm:
14677 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14678 // canonical "I pasted a glob-character-class followed by a
14679 // URL-fragment tail" footgun) routes through
14680 // `FonteCaminhoShellBracketExpansion` not
14681 // `FonteCaminhoShellComment`. The glob-character-class
14682 // expansion is the load-bearing root-cause edit on every
14683 // probe-as-both value.
14684 let d = dep_with_fonte(DepSource::Path {
14685 caminho: "../[a-z]#pin".into(),
14686 });
14687 let err = d.validate().unwrap_err();
14688 assert!(
14689 matches!(
14690 err,
14691 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14692 ),
14693 "got {err:?}",
14694 );
14695 }
14696
14697 #[test]
14698 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14699 // Cascade pin on the upstream shell-brace-expansion arm: a
14700 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14701 // canonical "I pasted a brace-expansion fan followed by a
14702 // URL-fragment tail" footgun) routes through
14703 // `FonteCaminhoShellBraceExpansion` not
14704 // `FonteCaminhoShellComment`. The brace-expansion fan is the
14705 // load-bearing root-cause edit on every probe-as-both value.
14706 let d = dep_with_fonte(DepSource::Path {
14707 caminho: "../{a,b}#pin".into(),
14708 });
14709 let err = d.validate().unwrap_err();
14710 assert!(
14711 matches!(
14712 err,
14713 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14714 ),
14715 "got {err:?}",
14716 );
14717 }
14718
14719 #[test]
14720 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14721 // Cascade pin on the upstream shell-subshell-grouping arm:
14722 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14723 // the canonical "I pasted a subshell-grouping followed by a
14724 // URL-fragment tail" footgun) routes through
14725 // `FonteCaminhoShellSubshellGrouping` not
14726 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14727 // command-substitution boundary is the load-bearing axis on
14728 // every probe-as-both value.
14729 let d = dep_with_fonte(DepSource::Path {
14730 caminho: "../(cd foo)#pin".into(),
14731 });
14732 let err = d.validate().unwrap_err();
14733 assert!(
14734 matches!(
14735 err,
14736 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14737 ),
14738 "got {err:?}",
14739 );
14740 }
14741
14742 #[test]
14743 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14744 // Cascade pin on the upstream shell-glob arm: a value
14745 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14746 // canonical "I pasted a `*` unbounded pathname-expansion
14747 // followed by a URL-fragment tail" footgun) routes through
14748 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14749 // The unbounded pathname-expansion sentinel is the load-
14750 // bearing root-cause edit on every probe-as-both value.
14751 let d = dep_with_fonte(DepSource::Path {
14752 caminho: "../caixa-teia/*#pin".into(),
14753 });
14754 let err = d.validate().unwrap_err();
14755 assert!(
14756 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14757 "got {err:?}",
14758 );
14759 }
14760
14761 #[test]
14762 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14763 // Cascade pin on the upstream shell-command-substitution
14764 // arm: a value carrying both a backtick and `#`
14765 // (``"../`whoami`#pin"`` — the canonical "I pasted a
14766 // legacy-backtick command-substitution followed by a URL-
14767 // fragment tail" footgun) routes through
14768 // `FonteCaminhoShellCommandSubstitution` not
14769 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14770 // injection vector is the load-bearing root-cause edit on
14771 // every probe-as-both value.
14772 let d = dep_with_fonte(DepSource::Path {
14773 caminho: "../`whoami`#pin".into(),
14774 });
14775 let err = d.validate().unwrap_err();
14776 assert!(
14777 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14778 "got {err:?}",
14779 );
14780 }
14781
14782 #[test]
14783 fn fonte_caminho_shell_background_fires_before_shell_comment() {
14784 // Cascade pin on the upstream shell-background arm: a value
14785 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14786 // the canonical "I pasted a `cmd &` background-launch
14787 // followed by a URL-fragment tail" footgun) routes through
14788 // `FonteCaminhoShellBackground` not
14789 // `FonteCaminhoShellComment`. The background-launch tail is
14790 // the load-bearing root-cause edit on every probe-as-both
14791 // value.
14792 let d = dep_with_fonte(DepSource::Path {
14793 caminho: "../caixa-teia&pin#tail".into(),
14794 });
14795 let err = d.validate().unwrap_err();
14796 assert!(
14797 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14798 "got {err:?}",
14799 );
14800 }
14801
14802 #[test]
14803 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14804 // Cascade pin on the upstream shell-semicolon arm: a value
14805 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14806 // the canonical sequential-cleanup + URL-fragment paste
14807 // idiom) routes through `FonteCaminhoShellSemicolon` not
14808 // `FonteCaminhoShellComment`. The sequential-command-
14809 // separator paste is the load-bearing root-cause edit on
14810 // every probe-as-both value.
14811 let d = dep_with_fonte(DepSource::Path {
14812 caminho: "../caixa-teia;pin#tail".into(),
14813 });
14814 let err = d.validate().unwrap_err();
14815 assert!(
14816 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14817 "got {err:?}",
14818 );
14819 }
14820
14821 #[test]
14822 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14823 // Cascade pin on the upstream shell-pipe arm: a value
14824 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14825 // the canonical pipeline-to-URL-fragment paste idiom) routes
14826 // through `FonteCaminhoShellPipe` not
14827 // `FonteCaminhoShellComment`. The pipeline-tail paste is
14828 // the load-bearing root-cause edit on every probe-as-both
14829 // value.
14830 let d = dep_with_fonte(DepSource::Path {
14831 caminho: "../caixa-teia|pin#tail".into(),
14832 });
14833 let err = d.validate().unwrap_err();
14834 assert!(
14835 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14836 "got {err:?}",
14837 );
14838 }
14839
14840 #[test]
14841 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14842 // Cascade pin on the upstream shell-redirection arm: a
14843 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14844 // — the canonical "I pasted a `cmd > log` redirect followed
14845 // by a URL-fragment tail" footgun) routes through
14846 // `FonteCaminhoShellRedirection` not
14847 // `FonteCaminhoShellComment`. The input/output redirection
14848 // metachar carries the more self-locating `byte` payload,
14849 // so the prior arm wins on every probe-as-both value.
14850 let d = dep_with_fonte(DepSource::Path {
14851 caminho: "../caixa-teia>log#pin".into(),
14852 });
14853 let err = d.validate().unwrap_err();
14854 assert!(
14855 matches!(
14856 err,
14857 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14858 ),
14859 "got {err:?}",
14860 );
14861 }
14862
14863 #[test]
14864 fn fonte_caminho_backslash_fires_before_shell_comment() {
14865 // Cascade pin on the upstream backslash arm: a value
14866 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14867 // canonical "I pasted a Windows-shell path followed by a
14868 // URL-fragment tail" footgun) routes through
14869 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14870 // The cross-host-OS-separator divergence is the load-
14871 // bearing axis on every probe-as-both value.
14872 let d = dep_with_fonte(DepSource::Path {
14873 caminho: "..\\caixa-teia#pin".into(),
14874 });
14875 let err = d.validate().unwrap_err();
14876 assert!(
14877 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14878 "got {err:?}",
14879 );
14880 }
14881
14882 #[test]
14883 fn fonte_caminho_control_char_fires_before_shell_comment() {
14884 // Cascade pin on the embedded-control-byte arm: a value
14885 // carrying both a control byte and `#` (`"../foo\n#pin"` —
14886 // the canonical paste-from-multiline-doc footgun where a
14887 // newline landed mid-caminho between the path and an
14888 // annotation) routes through `FonteCaminhoControlChar` not
14889 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14890 // byte diagnostic is the load-bearing axis on every value
14891 // that probes positive for both — mirrors the cascade
14892 // discipline on every prior arm.
14893 let d = dep_with_fonte(DepSource::Path {
14894 caminho: "../foo\n#pin".into(),
14895 });
14896 let err = d.validate().unwrap_err();
14897 assert!(
14898 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14899 "got {err:?}",
14900 );
14901 }
14902
14903 #[test]
14904 fn fonte_caminho_absolute_fires_before_shell_comment() {
14905 // Cascade pin on the load-bearing leading-byte arm: a
14906 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14907 // routes through `FonteCaminhoAbsolute` not
14908 // `FonteCaminhoShellComment` — the host-layout-leak
14909 // diagnostic is the load-bearing axis, the fragment byte is
14910 // the secondary observation. Same precedence logic as every
14911 // prior leading-byte arm.
14912 let d = dep_with_fonte(DepSource::Path {
14913 caminho: "/etc/foo#pin".into(),
14914 });
14915 let err = d.validate().unwrap_err();
14916 assert!(
14917 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14918 "got {err:?}",
14919 );
14920 }
14921
14922 #[test]
14923 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14924 // Cascade pin on the upstream leading-`$` var-expansion
14925 // arm: a value carrying both a leading `$` and a `#`
14926 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14927 // shell-variable at the head of a sibling-workspace path
14928 // followed by a URL-fragment tail" footgun) routes through
14929 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14930 // The leading-byte shell-variable-expansion is the more
14931 // self-locating diagnostic on values that probe as both.
14932 let d = dep_with_fonte(DepSource::Path {
14933 caminho: "$DIR/foo#pin".into(),
14934 });
14935 let err = d.validate().unwrap_err();
14936 assert!(
14937 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14938 "got {err:?}",
14939 );
14940 }
14941
14942 #[test]
14943 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14944 // Cascade pin on the immediate-successor arm: a value
14945 // carrying both `#` and a trailing `/`
14946 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14947 // a URL-fragment-carrying path" footgun) routes through
14948 // `FonteCaminhoShellComment` not
14949 // `FonteCaminhoTrailingSlash`. The embedded fragment /
14950 // comment-lead byte is the more semantic-locating axis (an
14951 // author who removes the `#pin` fragment typically also
14952 // drops the trailing separator since both are paste-from-
14953 // URL / paste-from-shell-tab-completion artifacts).
14954 let d = dep_with_fonte(DepSource::Path {
14955 caminho: "../caixa-teia#pin/".into(),
14956 });
14957 let err = d.validate().unwrap_err();
14958 assert!(
14959 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14960 "got {err:?}",
14961 );
14962 }
14963
14964 #[test]
14965 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14966 // Diagnostic-shape pin (peer with
14967 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14968 // on the immediate-predecessor arm): the error's Display
14969 // surfaces the offending `:nome`, the offending `:caminho`
14970 // verbatim, the offending byte's hex / character form, and
14971 // names the shell-comment / URL-fragment-identifier /
14972 // YAML-comment cross-config-DSL footgun explicitly so a
14973 // `feira lint` run can render the diagnostic without
14974 // re-parsing.
14975 let d = dep_with_fonte(DepSource::Path {
14976 caminho: "../caixa-teia#readme".into(),
14977 });
14978 let rendered = d.validate().unwrap_err().to_string();
14979 assert!(
14980 rendered.contains("caixa-teia"),
14981 "diagnostic must name the offending dep: {rendered}",
14982 );
14983 assert!(
14984 rendered.contains("../caixa-teia#readme"),
14985 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14986 );
14987 assert!(
14988 rendered.contains("0x23"),
14989 "diagnostic must surface the offending byte hex: {rendered:?}",
14990 );
14991 assert!(
14992 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14993 "diagnostic must name the shell-comment footgun: {rendered:?}",
14994 );
14995 assert!(
14996 rendered.contains("fragment") || rendered.contains("URL-fragment"),
14997 "diagnostic must reference the URL-fragment-identifier vocabulary: \
14998 {rendered:?}",
14999 );
15000 }
15001
15002 #[test]
15003 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
15004 // The canonical paste-from-browser-address-bar percent-
15005 // encoded-space footgun: an author copies `../caixa%20teia`
15006 // out of a URL-encoded README hyperlink / browser address
15007 // bar / percent-encoded permalink expecting `%20` to decode
15008 // to a literal space at the filesystem layer. POSIX
15009 // `std::path::Path` treats `%` as a literal path-component
15010 // byte, so `Path::join` looks for a literal
15011 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
15012 // returns false on `..`, `%` is neither a leading-byte
15013 // sentinel nor a control byte nor `\` nor `<` / `>` nor
15014 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
15015 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
15016 // and the value's last byte isn't `/` — so the value
15017 // silently passed every prior arm. The new arm moves the
15018 // rejection to validate time and names the offending dep +
15019 // caminho + byte verbatim.
15020 let d = dep_with_fonte(DepSource::Path {
15021 caminho: "../caixa%20teia".into(),
15022 });
15023 let err = d.validate().unwrap_err();
15024 let DepError::FonteCaminhoUrlPercentEncoding {
15025 nome,
15026 caminho,
15027 byte,
15028 } = err
15029 else {
15030 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
15031 };
15032 assert_eq!(nome, "caixa-teia");
15033 assert_eq!(caminho, "../caixa%20teia");
15034 assert_eq!(byte, b'%');
15035 }
15036
15037 #[test]
15038 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
15039 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
15040 // intending the `%2F` as the URL encoding of `/`) locks a
15041 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
15042 // the byte-identical `path:../caixa/teia` form. Pinned
15043 // separately from the space-encoded shape so the gate's
15044 // coverage extends past the single canonical `%20` example
15045 // to any two-hex-digit percent-encoded sequence.
15046 let d = dep_with_fonte(DepSource::Path {
15047 caminho: "../caixa%2Fteia".into(),
15048 });
15049 let err = d.validate().unwrap_err();
15050 assert!(
15051 matches!(
15052 err,
15053 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15054 ),
15055 "got {err:?}",
15056 );
15057 }
15058
15059 #[test]
15060 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
15061 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
15062 // where `%` isn't followed by two hex digits) — every
15063 // WHATWG-conformant URL parser rejects the value at parse
15064 // time per RFC 3986 §2.1, but the byte would silently ride
15065 // into the lacre before the resolver subprocess crosses the
15066 // URL-parser boundary. Pinned separately from the well-
15067 // formed `%HH` shapes so the gate covers every percent-
15068 // occurrence, not only strictly-conformant escapes.
15069 let d = dep_with_fonte(DepSource::Path {
15070 caminho: "../caixa-teia%foo".into(),
15071 });
15072 let err = d.validate().unwrap_err();
15073 assert!(
15074 matches!(
15075 err,
15076 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15077 ),
15078 "got {err:?}",
15079 );
15080 }
15081
15082 #[test]
15083 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
15084 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
15085 // — the canonical paste-from-top-of-doc YAML directive
15086 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
15087 // separately from embedded shapes so the gate covers the
15088 // leading-position `%` too, not only mid-value occurrences.
15089 let d = dep_with_fonte(DepSource::Path {
15090 caminho: "%YAML/../caixa-teia".into(),
15091 });
15092 let err = d.validate().unwrap_err();
15093 assert!(
15094 matches!(
15095 err,
15096 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15097 ),
15098 "got {err:?}",
15099 );
15100 }
15101
15102 #[test]
15103 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
15104 // The printf-format-specifier paste shape
15105 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
15106 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
15107 // 134 format-string-injection vector). Pinned separately
15108 // from the URL-encoding shapes so the gate's rationale
15109 // extends past the RFC 3986 axis to the C / POSIX printf
15110 // format-directive-lead axis.
15111 let d = dep_with_fonte(DepSource::Path {
15112 caminho: "../caixa-%s-teia".into(),
15113 });
15114 let err = d.validate().unwrap_err();
15115 assert!(
15116 matches!(
15117 err,
15118 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15119 ),
15120 "got {err:?}",
15121 );
15122 }
15123
15124 #[test]
15125 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
15126 // The positive-control pin: the gate targets only `%`,
15127 // never adjacent printable ASCII or POSIX-valid bytes. The
15128 // canonical relative POSIX path (`"../caixa-teia"`) and a
15129 // nested deeply-pathed variant with adjacent printable
15130 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
15131 // to validate cleanly so the gate doesn't widen to a "no
15132 // printable punctuation anywhere" sweep that would defeat
15133 // the entire path-fonte author surface. Peer with
15134 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
15135 // on the immediate-predecessor arm.
15136 let d = dep_with_fonte(DepSource::Path {
15137 caminho: "../caixa-teia/sub-dir.v2".into(),
15138 });
15139 d.validate().unwrap();
15140 }
15141
15142 #[test]
15143 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
15144 // Cascade pin on the immediate-predecessor arm: a value
15145 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
15146 // canonical "I pasted a URL-fragment permalink followed by a
15147 // percent-encoded space tail" footgun) routes through
15148 // `FonteCaminhoShellComment` not
15149 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
15150 // identifier is the load-bearing downstream-truncation edit
15151 // on every probe-as-both value; same cascade discipline
15152 // every prior `:caminho` arm establishes.
15153 let d = dep_with_fonte(DepSource::Path {
15154 caminho: "../caixa-teia#pin%20".into(),
15155 });
15156 let err = d.validate().unwrap_err();
15157 assert!(
15158 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
15159 "got {err:?}",
15160 );
15161 }
15162
15163 #[test]
15164 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
15165 // Cascade pin on the upstream shell-quote-grouping arm: a
15166 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
15167 // canonical "I pasted a strong-quoted literal followed by
15168 // a percent-encoded space" footgun) routes through
15169 // `FonteCaminhoShellQuoteGrouping` not
15170 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
15171 // literal-delimiter is the load-bearing root-cause edit on
15172 // every probe-as-both value.
15173 let d = dep_with_fonte(DepSource::Path {
15174 caminho: "../'x'%20teia".into(),
15175 });
15176 let err = d.validate().unwrap_err();
15177 assert!(
15178 matches!(
15179 err,
15180 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
15181 ),
15182 "got {err:?}",
15183 );
15184 }
15185
15186 #[test]
15187 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
15188 // Cascade pin on the upstream backslash arm: a value
15189 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
15190 // canonical "I pasted a Windows-shell path followed by a
15191 // percent-encoded space" footgun) routes through
15192 // `FonteCaminhoBackslash` not
15193 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
15194 // separator divergence is the load-bearing root-cause edit
15195 // on every probe-as-both value.
15196 let d = dep_with_fonte(DepSource::Path {
15197 caminho: "..\\caixa%20teia".into(),
15198 });
15199 let err = d.validate().unwrap_err();
15200 assert!(
15201 matches!(err, DepError::FonteCaminhoBackslash { .. }),
15202 "got {err:?}",
15203 );
15204 }
15205
15206 #[test]
15207 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
15208 // Cascade pin on the upstream control-char arm: a value
15209 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
15210 // the canonical "I pasted a paste-from-binary-blob path
15211 // followed by a percent-encoded space" footgun) routes
15212 // through `FonteCaminhoControlChar` not
15213 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
15214 // rejected byte is the load-bearing root-cause edit on
15215 // every probe-as-both value.
15216 let d = dep_with_fonte(DepSource::Path {
15217 caminho: "../caixa\0%20teia".into(),
15218 });
15219 let err = d.validate().unwrap_err();
15220 assert!(
15221 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
15222 "got {err:?}",
15223 );
15224 }
15225
15226 #[test]
15227 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
15228 // Cascade pin on the upstream absolute-path arm: a value
15229 // that's both absolute and carries `%` (`"/etc/passwd%20"`
15230 // — the canonical "I pasted an absolute path with a
15231 // percent-encoded space tail" footgun) routes through
15232 // `FonteCaminhoAbsolute` not
15233 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
15234 // the load-bearing root-cause edit on every probe-as-both
15235 // value.
15236 let d = dep_with_fonte(DepSource::Path {
15237 caminho: "/etc/passwd%20".into(),
15238 });
15239 let err = d.validate().unwrap_err();
15240 assert!(
15241 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
15242 "got {err:?}",
15243 );
15244 }
15245
15246 #[test]
15247 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
15248 // Cascade pin on the upstream var-expansion arm: a value
15249 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
15250 // — the canonical "I pasted a `$HOME`-rooted path with a
15251 // percent-encoded space" footgun) routes through
15252 // `FonteCaminhoVarExpansion` not
15253 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
15254 // expansion is the load-bearing root-cause edit on every
15255 // probe-as-both value.
15256 let d = dep_with_fonte(DepSource::Path {
15257 caminho: "$HOME/caixa%20teia".into(),
15258 });
15259 let err = d.validate().unwrap_err();
15260 assert!(
15261 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15262 "got {err:?}",
15263 );
15264 }
15265
15266 #[test]
15267 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
15268 // Cascade pin on the immediate-successor arm: a value
15269 // carrying both `%` and a trailing `/`
15270 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
15271 // percent-encoded-space-carrying path" footgun) routes
15272 // through `FonteCaminhoUrlPercentEncoding` not
15273 // `FonteCaminhoTrailingSlash`. The embedded percent-
15274 // encoding-escape byte is the more semantic-locating axis
15275 // (an author who decodes the `%20` to a literal space is
15276 // likely to also tab-strip the trailing separator since
15277 // both are paste-from-URL / paste-from-shell-tab-completion
15278 // artifacts).
15279 let d = dep_with_fonte(DepSource::Path {
15280 caminho: "../caixa%20teia/".into(),
15281 });
15282 let err = d.validate().unwrap_err();
15283 assert!(
15284 matches!(
15285 err,
15286 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15287 ),
15288 "got {err:?}",
15289 );
15290 }
15291
15292 #[test]
15293 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
15294 // Diagnostic-shape pin (peer with
15295 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
15296 // on the immediate-predecessor arm): the error's Display
15297 // surfaces the offending `:nome`, the offending `:caminho`
15298 // verbatim, the offending byte's hex / character form, and
15299 // names the URL-percent-encoding-escape / printf-format-
15300 // specifier footgun explicitly so a `feira lint` run can
15301 // render the diagnostic without re-parsing.
15302 let d = dep_with_fonte(DepSource::Path {
15303 caminho: "../caixa%20teia".into(),
15304 });
15305 let rendered = d.validate().unwrap_err().to_string();
15306 assert!(
15307 rendered.contains("caixa-teia"),
15308 "diagnostic must name the offending dep: {rendered}",
15309 );
15310 assert!(
15311 rendered.contains("../caixa%20teia"),
15312 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15313 );
15314 assert!(
15315 rendered.contains("0x25"),
15316 "diagnostic must surface the offending byte hex: {rendered:?}",
15317 );
15318 assert!(
15319 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
15320 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
15321 );
15322 assert!(
15323 rendered.contains("printf") || rendered.contains("format-specifier"),
15324 "diagnostic must reference the printf-format-specifier vocabulary: \
15325 {rendered:?}",
15326 );
15327 }
15328
15329 #[test]
15330 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
15331 // The canonical embedded-`$` shell-variable-expansion paste
15332 // shape (`"../foo$HOME/bar"` — an author copies a partially-
15333 // substituted shell one-liner where the leading segment is a
15334 // literal `../foo` while the mid segment carries the un-
15335 // substituted `$HOME` template). The leading-`$` position is
15336 // already gated by the f4efe9c leading-byte arm which routes
15337 // through `FonteCaminhoVarExpansion`; this arm closes the
15338 // last positional gap on `$` — every position on the axis is
15339 // structurally rejected.
15340 let d = dep_with_fonte(DepSource::Path {
15341 caminho: "../foo$HOME/bar".into(),
15342 });
15343 let err = d.validate().unwrap_err();
15344 let DepError::FonteCaminhoShellVariableExpansion {
15345 nome,
15346 caminho,
15347 byte,
15348 } = err
15349 else {
15350 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
15351 };
15352 assert_eq!(nome, "caixa-teia");
15353 assert_eq!(caminho, "../foo$HOME/bar");
15354 assert_eq!(byte, b'$');
15355 }
15356
15357 #[test]
15358 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
15359 // The symmetric braced-CI-manifest paste shape
15360 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
15361 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
15362 // footgun). Pinned separately from the bare-`$VAR` shape so
15363 // the gate covers both POSIX shell §2.6 Parameter Expansion
15364 // syntactic forms, not only the unbraced variant. The
15365 // embedded `{` byte in `${...}` is also caught by the 598b770
15366 // shell-brace-expansion arm but that arm fires earlier in
15367 // the cascade — the `$` arm's coverage extends to `${...}`
15368 // structurally, so the diagnostic asserted here is the
15369 // brace-expansion one (which is a valid outcome; the point
15370 // of the pin is that the value never survives validation).
15371 let d = dep_with_fonte(DepSource::Path {
15372 caminho: "../foo${WORKSPACE}/bar".into(),
15373 });
15374 let err = d.validate().unwrap_err();
15375 assert!(
15376 matches!(
15377 err,
15378 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
15379 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15380 ),
15381 "got {err:?}",
15382 );
15383 }
15384
15385 #[test]
15386 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
15387 // The paste-from-shell-prompt command-substitution idiom
15388 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
15389 // `$VAR` shape so the gate's rationale extends to POSIX shell
15390 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
15391 // legacy `` `<cmd>` `` form is already closed by the c370458
15392 // backtick arm). The embedded `(` byte in `$(...)` is also
15393 // caught structurally by the 0633c91 shell-subshell-grouping
15394 // arm which fires earlier in the cascade — the diagnostic
15395 // asserted here is either outcome, since both structurally
15396 // reject the value; the point of the pin is that the value
15397 // never survives validation.
15398 let d = dep_with_fonte(DepSource::Path {
15399 caminho: "../foo$(whoami)/bar".into(),
15400 });
15401 let err = d.validate().unwrap_err();
15402 assert!(
15403 matches!(
15404 err,
15405 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
15406 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15407 ),
15408 "got {err:?}",
15409 );
15410 }
15411
15412 #[test]
15413 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
15414 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
15415 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
15416 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
15417 // idiom copied into a caminho template). None of the prior
15418 // shell-metachar arms cover this shape (`1` is a bare digit;
15419 // no `(` / `{` / letter follows the `$`), so the arm is the
15420 // sole gate on the shape.
15421 let d = dep_with_fonte(DepSource::Path {
15422 caminho: "../foo$1/bar".into(),
15423 });
15424 let err = d.validate().unwrap_err();
15425 assert!(
15426 matches!(
15427 err,
15428 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15429 ),
15430 "got {err:?}",
15431 );
15432 }
15433
15434 #[test]
15435 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
15436 // The positive-control pin (peer with
15437 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
15438 // on the immediate-predecessor arm): the gate targets only
15439 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
15440 // A relative POSIX path carrying dashes / dots / slashes /
15441 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15442 // validate cleanly so the gate doesn't widen to a "no
15443 // printable punctuation anywhere" sweep that would defeat
15444 // the entire path-fonte author surface.
15445 let d = dep_with_fonte(DepSource::Path {
15446 caminho: "../caixa-teia/sub-dir.v2".into(),
15447 });
15448 d.validate().unwrap();
15449 }
15450
15451 #[test]
15452 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
15453 // Cascade pin on the leading-`$` sibling arm at line 540: a
15454 // value starting with `$` and carrying an embedded `$` too
15455 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
15456 // fully-templated CI path with two un-substituted variables")
15457 // routes through `FonteCaminhoVarExpansion` not
15458 // `FonteCaminhoShellVariableExpansion`. The leading-byte
15459 // host-layout-leak is the load-bearing self-locating axis
15460 // (the leading position dominates the semantic-locating
15461 // rationale on every probe-as-both value); the embedded
15462 // arm's positional-agnostic sweep catches only values whose
15463 // leading byte doesn't route through the earlier leading-
15464 // byte arms.
15465 let d = dep_with_fonte(DepSource::Path {
15466 caminho: "$HOME/foo$WORKSPACE/bar".into(),
15467 });
15468 let err = d.validate().unwrap_err();
15469 assert!(
15470 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15471 "got {err:?}",
15472 );
15473 }
15474
15475 #[test]
15476 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
15477 // Cascade pin on the immediate-predecessor arm: a value
15478 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
15479 // — the canonical "I pasted a percent-encoded space adjacent
15480 // to a `$HOME` template") routes through
15481 // `FonteCaminhoUrlPercentEncoding` not
15482 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
15483 // encoding-escape byte is the more semantic-locating axis
15484 // (the paste-from-browser-address-bar shape is the load-
15485 // bearing self-locating edit); same cascade discipline every
15486 // prior `:caminho` arm establishes.
15487 let d = dep_with_fonte(DepSource::Path {
15488 caminho: "../foo%20$HOME/bar".into(),
15489 });
15490 let err = d.validate().unwrap_err();
15491 assert!(
15492 matches!(
15493 err,
15494 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15495 ),
15496 "got {err:?}",
15497 );
15498 }
15499
15500 #[test]
15501 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
15502 // Cascade pin on the immediate-successor arm: a value
15503 // carrying both embedded `$` and a trailing `/`
15504 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
15505 // `$HOME`-template-carrying path") routes through
15506 // `FonteCaminhoShellVariableExpansion` not
15507 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
15508 // expansion byte is the more semantic-locating axis on
15509 // probe-as-both values (an author who substitutes the
15510 // `$HOME` template with a literal value is likely to also
15511 // tab-strip the trailing separator).
15512 let d = dep_with_fonte(DepSource::Path {
15513 caminho: "../foo$HOME/bar/".into(),
15514 });
15515 let err = d.validate().unwrap_err();
15516 assert!(
15517 matches!(
15518 err,
15519 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15520 ),
15521 "got {err:?}",
15522 );
15523 }
15524
15525 #[test]
15526 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15527 // Diagnostic-shape pin (peer with
15528 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
15529 // on the immediate-predecessor arm): the error's Display
15530 // surfaces the offending `:nome`, the offending `:caminho`
15531 // verbatim, the offending byte's hex / character form, and
15532 // names the shell-variable-expansion / command-substitution
15533 // footgun explicitly so a `feira lint` run can render the
15534 // diagnostic without re-parsing.
15535 let d = dep_with_fonte(DepSource::Path {
15536 caminho: "../foo$HOME/bar".into(),
15537 });
15538 let rendered = d.validate().unwrap_err().to_string();
15539 assert!(
15540 rendered.contains("caixa-teia"),
15541 "diagnostic must name the offending dep: {rendered}",
15542 );
15543 assert!(
15544 rendered.contains("../foo$HOME/bar"),
15545 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15546 );
15547 assert!(
15548 rendered.contains("0x24"),
15549 "diagnostic must surface the offending byte hex: {rendered:?}",
15550 );
15551 assert!(
15552 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
15553 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
15554 );
15555 assert!(
15556 rendered.contains("command-substitution") || rendered.contains("command substitution"),
15557 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
15558 );
15559 }
15560
15561 #[test]
15562 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
15563 // The fail-before-pass-after pin for the canonical paste-from-
15564 // shell-history footgun on `:caminho`. An author copies a `cd
15565 // ../caixa-teia && !sudo make install` one-liner from a quick-
15566 // start README, intending the trailing `!sudo` as a shell-
15567 // history-expansion reference but the typed slot is itself a
15568 // byte-level string parser, not a shell context, so the byte
15569 // rides into the value verbatim. Until this arm landed the `!`
15570 // byte silently passed every prior `:caminho` cascade arm
15571 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
15572 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
15573 // `#` / `%` / `$`); bash with the default `histexpand` mode
15574 // rewrites `!command` to the most recent history entry
15575 // beginning with `command`, the canonical RCE-class injection
15576 // vector when the byte rides into a shell argument executed
15577 // under `bash -i` (the operator-notebook interactive shell).
15578 let d = dep_with_fonte(DepSource::Path {
15579 caminho: "../caixa-teia!sudo".into(),
15580 });
15581 let err = d.validate().unwrap_err();
15582 let DepError::FonteCaminhoShellHistoryExpansion {
15583 nome,
15584 caminho,
15585 byte,
15586 } = err
15587 else {
15588 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
15589 };
15590 assert_eq!(nome, "caixa-teia");
15591 assert_eq!(caminho, "../caixa-teia!sudo");
15592 assert_eq!(byte, b'!');
15593 }
15594
15595 #[test]
15596 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
15597 // The symmetric `!!` repeat-prior-command paste idiom (peer with
15598 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
15599 // on `is_git_repo_url`). Pinned separately from the wrapped
15600 // `!command` shape so a future diagnostic-surface change that
15601 // only checked the leading or paired-bang position surfaces
15602 // here — the per-byte arm fires anywhere `!` appears in the
15603 // value, including at consecutive positions in the middle.
15604 let d = dep_with_fonte(DepSource::Path {
15605 caminho: "../foo!!/bar".into(),
15606 });
15607 let err = d.validate().unwrap_err();
15608 assert!(
15609 matches!(
15610 err,
15611 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15612 ),
15613 "got {err:?}",
15614 );
15615 }
15616
15617 #[test]
15618 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
15619 // The English-typography enthusiasm-form paste-from-prose
15620 // idiom: an author writes `:caminho "../caixa-teia!"`
15621 // expecting the substrate to coerce it to a kebab-case slug.
15622 // Pinned separately from the `!<word>` shell-history shape so
15623 // the gate's rationale extends to the paste-from-prose surface
15624 // (the same rationale the peer `is_git_repo_url` bang arm at
15625 // 7d53c68 covers). None of the prior shell-metachar arms cover
15626 // this shape (no `!<word>` reference and no `!!` repeat), so
15627 // the arm is the sole gate on the shape.
15628 let d = dep_with_fonte(DepSource::Path {
15629 caminho: "../caixa-teia!".into(),
15630 });
15631 let err = d.validate().unwrap_err();
15632 assert!(
15633 matches!(
15634 err,
15635 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15636 ),
15637 "got {err:?}",
15638 );
15639 }
15640
15641 #[test]
15642 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
15643 // The positive-control pin (peer with
15644 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
15645 // on the immediate-predecessor arm): the gate targets only
15646 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15647 // A relative POSIX path carrying dashes / dots / slashes /
15648 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15649 // validate cleanly so the gate doesn't widen to a "no
15650 // printable punctuation anywhere" sweep that would defeat
15651 // the entire path-fonte author surface.
15652 let d = dep_with_fonte(DepSource::Path {
15653 caminho: "../caixa-teia/sub-dir.v2".into(),
15654 });
15655 d.validate().unwrap();
15656 }
15657
15658 #[test]
15659 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15660 // Cascade pin on the immediate-predecessor arm: a value
15661 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15662 // — the canonical "I pasted a `$HOME`-templated path adjacent
15663 // to a trailing `!sudo` history-expansion") routes through
15664 // `FonteCaminhoShellVariableExpansion` not
15665 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15666 // expansion byte is the more semantic-locating axis on
15667 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15668 // template shape is the load-bearing self-locating edit);
15669 // same cascade discipline every prior `:caminho` arm
15670 // establishes.
15671 let d = dep_with_fonte(DepSource::Path {
15672 caminho: "../foo$HOME/bar!sudo".into(),
15673 });
15674 let err = d.validate().unwrap_err();
15675 assert!(
15676 matches!(
15677 err,
15678 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15679 ),
15680 "got {err:?}",
15681 );
15682 }
15683
15684 #[test]
15685 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15686 // Cascade pin on the immediate-successor arm: a value carrying
15687 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15688 // — the canonical "I tab-completed a `!sudo`-carrying path")
15689 // routes through `FonteCaminhoShellHistoryExpansion` not
15690 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15691 // expansion byte is the more semantic-locating axis on probe-
15692 // as-both values (an author who removes the `!sudo` history
15693 // reference is likely to also tab-strip the trailing separator).
15694 let d = dep_with_fonte(DepSource::Path {
15695 caminho: "../caixa-teia!sudo/".into(),
15696 });
15697 let err = d.validate().unwrap_err();
15698 assert!(
15699 matches!(
15700 err,
15701 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15702 ),
15703 "got {err:?}",
15704 );
15705 }
15706
15707 #[test]
15708 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15709 // Diagnostic-shape pin (peer with
15710 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15711 // on the immediate-predecessor arm): the error's Display
15712 // surfaces the offending `:nome`, the offending `:caminho`
15713 // verbatim, the offending byte's hex / character form, and
15714 // names the shell-history-expansion / bang-operator footgun
15715 // explicitly so a `feira lint` run can render the diagnostic
15716 // without re-parsing.
15717 let d = dep_with_fonte(DepSource::Path {
15718 caminho: "../caixa-teia!sudo".into(),
15719 });
15720 let rendered = d.validate().unwrap_err().to_string();
15721 assert!(
15722 rendered.contains("caixa-teia"),
15723 "diagnostic must name the offending dep: {rendered}",
15724 );
15725 assert!(
15726 rendered.contains("../caixa-teia!sudo"),
15727 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15728 );
15729 assert!(
15730 rendered.contains("0x21"),
15731 "diagnostic must surface the offending byte hex: {rendered:?}",
15732 );
15733 assert!(
15734 rendered.contains("history-expansion") || rendered.contains("history expansion"),
15735 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15736 );
15737 assert!(
15738 rendered.contains("bang"),
15739 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15740 );
15741 }
15742
15743 #[test]
15744 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15745 // The fail-before-pass-after pin for the canonical paste-from-
15746 // shell-history-quick-substitution footgun on `:caminho`. An
15747 // author copies a `git clone <bad-url>` line from their terminal,
15748 // corrects it via bash's `^bad^good` quick-substitution history
15749 // operator (bash reference §9.3, `set -o histexpand` mode's
15750 // default for interactive sessions), and pastes the trailing
15751 // `^bad^good` substitution fragment into a `:caminho` value
15752 // without trimming the leading `git clone` prefix — the byte
15753 // rides into the manifest verbatim. Until this arm landed the
15754 // `^` byte silently passed every prior `:caminho` cascade arm
15755 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15756 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15757 // `%` / `$` / `!`); bash with the default `histexpand` mode
15758 // rewrites the prior command's `bad` string to `good` and re-
15759 // executes it, the paired-operator half of the `set -o
15760 // histexpand` feature the peer `!` arm already closes the prefix
15761 // half of. The peer `is_git_repo_url` axis rejects the byte at
15762 // 49e142f under the same shell-history-substitution / RFC-3986-
15763 // unwise banner.
15764 let d = dep_with_fonte(DepSource::Path {
15765 caminho: "../foo^bad^good".into(),
15766 });
15767 let err = d.validate().unwrap_err();
15768 let DepError::FonteCaminhoShellHistorySubstitution {
15769 nome,
15770 caminho,
15771 byte,
15772 } = err
15773 else {
15774 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15775 };
15776 assert_eq!(nome, "caixa-teia");
15777 assert_eq!(caminho, "../foo^bad^good");
15778 assert_eq!(byte, b'^');
15779 }
15780
15781 #[test]
15782 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15783 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15784 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15785 // on `is_git_repo_url`). An author copies a `grep '^archived'`
15786 // regex-anchor / negation idiom from a doc snippet and the byte
15787 // rides in verbatim. Pinned separately from the `^old^new^`
15788 // quick-substitution shape so a future diagnostic-surface change
15789 // that only checked the paired-caret history-substitution
15790 // position surfaces here — the per-byte arm fires anywhere `^`
15791 // appears in the value, including at a solitary leading-of-
15792 // segment position.
15793 let d = dep_with_fonte(DepSource::Path {
15794 caminho: "../foo/^archived".into(),
15795 });
15796 let err = d.validate().unwrap_err();
15797 assert!(
15798 matches!(
15799 err,
15800 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15801 ),
15802 "got {err:?}",
15803 );
15804 }
15805
15806 #[test]
15807 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15808 // The trailing-`^` history-substitution-open shape — an author
15809 // starts typing a `^bad^good` quick-substitution but pastes only
15810 // the leading `^` sentinel before context-switching (a bash-
15811 // reference §9.3 valid histexpand prefix on its own — even a
15812 // solitary `^` on the prior command's whole re-execution shape).
15813 // Pinned separately from the `^old^new^` full-form and the leading-
15814 // of-segment `^archived` regex-anchor shape so the gate's
15815 // rationale extends to the paste-from-shell-history-with-only-
15816 // the-first-byte-selected surface. None of the prior shell-
15817 // metachar arms cover this shape.
15818 let d = dep_with_fonte(DepSource::Path {
15819 caminho: "../caixa-teia^".into(),
15820 });
15821 let err = d.validate().unwrap_err();
15822 assert!(
15823 matches!(
15824 err,
15825 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15826 ),
15827 "got {err:?}",
15828 );
15829 }
15830
15831 #[test]
15832 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15833 // The positive-control pin (peer with
15834 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15835 // on the immediate-predecessor arm): the gate targets only
15836 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15837 // A relative POSIX path carrying dashes / dots / slashes /
15838 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15839 // continue to validate cleanly so the gate doesn't widen to
15840 // a "no printable punctuation anywhere" sweep that would
15841 // defeat the entire path-fonte author surface.
15842 let d = dep_with_fonte(DepSource::Path {
15843 caminho: "../caixa-teia/sub_v2.rc".into(),
15844 });
15845 d.validate().unwrap();
15846 }
15847
15848 #[test]
15849 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15850 // Cascade pin on the immediate-predecessor arm: a value carrying
15851 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15852 // canonical "I pasted a `!sudo` history-reference next to a
15853 // `^bad^good` quick-substitution") routes through
15854 // `FonteCaminhoShellHistoryExpansion` not
15855 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15856 // the more semantic-locating axis on probe-as-both values (an
15857 // author who removes the `!sudo` reference is likely to also
15858 // strip the paired `^` substitution fragment); same cascade
15859 // discipline every prior `:caminho` arm establishes.
15860 let d = dep_with_fonte(DepSource::Path {
15861 caminho: "../foo!sudo^bad^good".into(),
15862 });
15863 let err = d.validate().unwrap_err();
15864 assert!(
15865 matches!(
15866 err,
15867 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15868 ),
15869 "got {err:?}",
15870 );
15871 }
15872
15873 #[test]
15874 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15875 // Cascade pin on the immediate-successor arm: a value carrying
15876 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15877 // the canonical "I tab-completed a `^bad^good`-carrying path")
15878 // routes through `FonteCaminhoShellHistorySubstitution` not
15879 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15880 // substitution byte is the more semantic-locating axis on probe-
15881 // as-both values (an author who removes the `^bad^good`
15882 // substitution fragment is likely to also tab-strip the trailing
15883 // separator).
15884 let d = dep_with_fonte(DepSource::Path {
15885 caminho: "../foo^bad^good/".into(),
15886 });
15887 let err = d.validate().unwrap_err();
15888 assert!(
15889 matches!(
15890 err,
15891 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15892 ),
15893 "got {err:?}",
15894 );
15895 }
15896
15897 #[test]
15898 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15899 {
15900 // Diagnostic-shape pin (peer with
15901 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15902 // on the immediate-predecessor arm): the error's Display
15903 // surfaces the offending `:nome`, the offending `:caminho`
15904 // verbatim, the offending byte's hex form, and names the
15905 // shell-history-substitution / RFC-3986-'unwise' / regex-
15906 // negation footgun explicitly so a `feira lint` run can render
15907 // the diagnostic without re-parsing.
15908 let d = dep_with_fonte(DepSource::Path {
15909 caminho: "../foo^bad^good".into(),
15910 });
15911 let rendered = d.validate().unwrap_err().to_string();
15912 assert!(
15913 rendered.contains("caixa-teia"),
15914 "diagnostic must name the offending dep: {rendered}",
15915 );
15916 assert!(
15917 rendered.contains("../foo^bad^good"),
15918 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15919 );
15920 assert!(
15921 rendered.contains("0x5e") || rendered.contains("0x5E"),
15922 "diagnostic must surface the offending byte hex: {rendered:?}",
15923 );
15924 assert!(
15925 rendered.contains("history-substitution") || rendered.contains("history substitution"),
15926 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15927 );
15928 assert!(
15929 rendered.contains("unwise"),
15930 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15931 );
15932 }
15933
15934 #[test]
15935 fn fonte_repo_empty_fires_before_pin_missing() {
15936 // Order pin: empty `:repo` is the more self-locating diagnostic
15937 // (every git source needs a repo; the pin discussion is
15938 // secondary), so it fires before the pin-missing arm even when
15939 // both are violated. Mirrors the
15940 // `nome_empty_takes_precedence_over_versao_invalid` ordering
15941 // discipline on the per-entry layer.
15942 let d = dep_with_fonte(DepSource::Git {
15943 repo: String::new(),
15944 tag: None,
15945 rev: None,
15946 branch: None,
15947 });
15948 let err = d.validate().unwrap_err();
15949 assert!(
15950 matches!(err, DepError::FonteRepoEmpty { .. }),
15951 "got {err:?}"
15952 );
15953 }
15954
15955 #[test]
15956 fn fonte_pin_missing_fires_before_pin_empty() {
15957 // Order pin: a fully-None pin set is structurally distinct from
15958 // a Some(empty) pin — the first surfaces as FontePinMissing
15959 // (no axis chosen), the second as FontePinEmpty (axis chosen
15960 // but value blank). Pin the disjoint relationship so a future
15961 // unification collapses to one variant only as a structural
15962 // decision.
15963 let d = dep_with_fonte(DepSource::Git {
15964 repo: "github:pleme-io/caixa-teia".into(),
15965 tag: None,
15966 rev: None,
15967 branch: None,
15968 });
15969 assert!(matches!(
15970 d.validate().unwrap_err(),
15971 DepError::FontePinMissing { .. }
15972 ));
15973 }
15974
15975 #[test]
15976 fn nome_empty_takes_precedence_over_fonte_invalid() {
15977 // Order pin: a per-entry diagnostic without a non-empty :nome
15978 // can't be self-locating, so :nome "" fires first even when
15979 // :fonte is also malformed. Mirrors
15980 // `nome_empty_takes_precedence_over_versao_invalid` on the
15981 // adjacent axis.
15982 let mut d = dep_with_fonte(DepSource::Git {
15983 repo: String::new(),
15984 tag: None,
15985 rev: None,
15986 branch: None,
15987 });
15988 d.nome = String::new();
15989 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15990 }
15991
15992 #[test]
15993 fn versao_invalid_takes_precedence_over_fonte_invalid() {
15994 // Order pin: the :versao parse-side diagnostic is narrower than
15995 // the :fonte shape diagnostic — a malformed :versao always names
15996 // the parser's reason, which is more actionable than the
15997 // :fonte gate's "the pins are wrong" wording. Pin the ordering
15998 // so a re-ordering surfaces here.
15999 let mut d = dep_with_fonte(DepSource::Git {
16000 repo: String::new(),
16001 tag: None,
16002 rev: None,
16003 branch: None,
16004 });
16005 d.versao = "v0.1".into();
16006 let err = d.validate().unwrap_err();
16007 assert!(
16008 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
16009 "got {err:?}"
16010 );
16011 }
16012
16013 #[test]
16014 fn fonte_invalid_diagnostic_carries_offending_nome() {
16015 // The diagnostic-shape pin: every :fonte error variant names
16016 // the offending dep's :nome verbatim, so the author can grep
16017 // caixa.lisp for the `:nome "<n>"` block and fix it in one
16018 // edit. Cover all seven variants so a future variant addition
16019 // forces a parallel diagnostic-shape decision.
16020 for (case, fonte) in [
16021 (
16022 "repo-empty",
16023 DepSource::Git {
16024 repo: String::new(),
16025 tag: Some("v1".into()),
16026 rev: None,
16027 branch: None,
16028 },
16029 ),
16030 (
16031 "repo-shape",
16032 DepSource::Git {
16033 repo: "github:p/x ".into(),
16034 tag: Some("v1".into()),
16035 rev: None,
16036 branch: None,
16037 },
16038 ),
16039 (
16040 "pin-missing",
16041 DepSource::Git {
16042 repo: "github:p/x".into(),
16043 tag: None,
16044 rev: None,
16045 branch: None,
16046 },
16047 ),
16048 (
16049 "pin-ambiguous",
16050 DepSource::Git {
16051 repo: "github:p/x".into(),
16052 tag: Some("v1".into()),
16053 rev: None,
16054 branch: Some("main".into()),
16055 },
16056 ),
16057 (
16058 "pin-empty",
16059 DepSource::Git {
16060 repo: "github:p/x".into(),
16061 tag: Some(String::new()),
16062 rev: None,
16063 branch: None,
16064 },
16065 ),
16066 (
16067 "caminho-empty",
16068 DepSource::Path {
16069 caminho: String::new(),
16070 },
16071 ),
16072 (
16073 "caminho-absolute",
16074 DepSource::Path {
16075 caminho: "/home/me/work/caixa-teia".into(),
16076 },
16077 ),
16078 ] {
16079 let d = dep_with_fonte(fonte);
16080 let msg = d
16081 .validate()
16082 .expect_err(&format!("{case}: expected fonte error"))
16083 .to_string();
16084 assert!(
16085 msg.contains("\"caixa-teia\""),
16086 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16087 );
16088 }
16089 }
16090
16091 // -- :tag / :branch value-shape gate ----------------------------------
16092
16093 #[test]
16094 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
16095 // The canonical paste-from-doc footgun on `:tag` — author
16096 // copies `"v0.1.0 "` (trailing space) out of a release-notes
16097 // paragraph. Until this gate landed the empty-pin arm passed
16098 // (the string isn't empty), the resolver issued
16099 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
16100 // surfaced at clone time with a quoting-confused git error
16101 // far from the source caixa.lisp. The new gate moves the
16102 // check to caixa-build time and names the offending dep +
16103 // pin + value verbatim.
16104 let d = dep_with_fonte(DepSource::Git {
16105 repo: "github:pleme-io/caixa-teia".into(),
16106 tag: Some("v0.1.0 ".into()),
16107 rev: None,
16108 branch: None,
16109 });
16110 let err = d.validate().unwrap_err();
16111 let DepError::FontePinShape {
16112 nome,
16113 pin,
16114 value,
16115 reason,
16116 } = err
16117 else {
16118 panic!("expected FontePinShape, got other variant");
16119 };
16120 assert_eq!(nome, "caixa-teia");
16121 assert_eq!(pin, ":tag");
16122 assert_eq!(value, "v0.1.0 ");
16123 assert!(
16124 reason.contains("whitespace"),
16125 "reason must surface the whitespace arm, got {reason:?}"
16126 );
16127 }
16128
16129 #[test]
16130 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
16131 // The `.lock` suffix is git's atomic-rename guard for
16132 // in-flight ref updates — a refname ending in `.lock` is
16133 // unwritable on disk. Pinned separately from the whitespace
16134 // arm so a future relaxation that admits one but not the
16135 // other surfaces here.
16136 let d = dep_with_fonte(DepSource::Git {
16137 repo: "github:pleme-io/caixa-teia".into(),
16138 tag: Some("v0.1.0.lock".into()),
16139 rev: None,
16140 branch: None,
16141 });
16142 let err = d.validate().unwrap_err();
16143 let DepError::FontePinShape {
16144 pin, value, reason, ..
16145 } = err
16146 else {
16147 panic!("expected FontePinShape, got other variant");
16148 };
16149 assert_eq!(pin, ":tag");
16150 assert_eq!(value, "v0.1.0.lock");
16151 assert!(
16152 reason.contains(".lock"),
16153 "reason must surface the .lock arm, got {reason:?}"
16154 );
16155 }
16156
16157 #[test]
16158 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
16159 // The canonical "branch name with spaces" footgun (`feature
16160 // foo`, `release branch`) — git's refname parser rejects raw
16161 // whitespace, and the failure surfaces at `git checkout
16162 // 'feature foo'` time with a quoting-confused error far from
16163 // the source caixa.lisp. Pinned on the `:branch` axis so the
16164 // gate-applies-to-both-:tag-and-:branch contract is a build-
16165 // error to relax.
16166 let d = dep_with_fonte(DepSource::Git {
16167 repo: "github:pleme-io/caixa-teia".into(),
16168 tag: None,
16169 rev: None,
16170 branch: Some("feature/foo bar".into()),
16171 });
16172 let err = d.validate().unwrap_err();
16173 let DepError::FontePinShape {
16174 pin, value, reason, ..
16175 } = err
16176 else {
16177 panic!("expected FontePinShape, got other variant");
16178 };
16179 assert_eq!(pin, ":branch");
16180 assert_eq!(value, "feature/foo bar");
16181 assert!(
16182 reason.contains("whitespace"),
16183 "reason must surface the whitespace arm, got {reason:?}"
16184 );
16185 }
16186
16187 #[test]
16188 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
16189 // The `refs/heads/main` shape — the canonical "I copied the
16190 // fully-qualified ref out of `git show-ref` instead of the
16191 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
16192 // at clone time, so this resolves to a literal ref named
16193 // `refs/heads/refs/heads/main` on disk; the silent double-
16194 // prefix is the load-bearing reason to gate at validate.
16195 // The diagnostic must enumerate the leaf the author probably
16196 // meant (`"main"`) so the fix is one edit.
16197 let d = dep_with_fonte(DepSource::Git {
16198 repo: "github:pleme-io/caixa-teia".into(),
16199 tag: None,
16200 rev: None,
16201 branch: Some("refs/heads/main".into()),
16202 });
16203 let err = d.validate().unwrap_err();
16204 let DepError::FontePinShape {
16205 pin, value, reason, ..
16206 } = err
16207 else {
16208 panic!("expected FontePinShape, got other variant");
16209 };
16210 assert_eq!(pin, ":branch");
16211 assert_eq!(value, "refs/heads/main");
16212 assert!(
16213 reason.contains("fully-qualified"),
16214 "reason must surface the qualified-prefix arm, got {reason:?}"
16215 );
16216 assert!(
16217 reason.contains("\"main\""),
16218 "reason must quote the leaf the author probably meant, got {reason:?}"
16219 );
16220 }
16221
16222 #[test]
16223 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
16224 // Sibling arm of the qualified-prefix gate on the `:tag`
16225 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
16226 // footgun). Pinned separately so a future relaxation that
16227 // only catches the `:branch` arm surfaces here.
16228 let d = dep_with_fonte(DepSource::Git {
16229 repo: "github:pleme-io/caixa-teia".into(),
16230 tag: Some("refs/tags/v0.1.0".into()),
16231 rev: None,
16232 branch: None,
16233 });
16234 let err = d.validate().unwrap_err();
16235 let DepError::FontePinShape {
16236 pin, value, reason, ..
16237 } = err
16238 else {
16239 panic!("expected FontePinShape, got other variant");
16240 };
16241 assert_eq!(pin, ":tag");
16242 assert_eq!(value, "refs/tags/v0.1.0");
16243 assert!(
16244 reason.contains("fully-qualified"),
16245 "reason must surface the qualified-prefix arm, got {reason:?}"
16246 );
16247 assert!(
16248 reason.contains("\"v0.1.0\""),
16249 "reason must quote the leaf the author probably meant, got {reason:?}"
16250 );
16251 }
16252
16253 #[test]
16254 fn validate_rejects_git_fonte_with_branch_named_at() {
16255 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
16256 // unsourceable. Pinned so a future relaxation that admits
16257 // any single-character refname surfaces here.
16258 let d = dep_with_fonte(DepSource::Git {
16259 repo: "github:pleme-io/caixa-teia".into(),
16260 tag: None,
16261 rev: None,
16262 branch: Some("@".into()),
16263 });
16264 let err = d.validate().unwrap_err();
16265 let DepError::FontePinShape { pin, value, .. } = err else {
16266 panic!("expected FontePinShape, got other variant");
16267 };
16268 assert_eq!(pin, ":branch");
16269 assert_eq!(value, "@");
16270 }
16271
16272 #[test]
16273 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
16274 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
16275 // a `:tag "../escape"` (path-traversal-shaped slug) silently
16276 // passes parse and surfaces as a refname-parse error or, on
16277 // older git, a literal `../escape` checkout that escapes the
16278 // refs/ directory tree. Pinned separately from the
16279 // qualified-prefix arm so a future relaxation that catches
16280 // one but not the other surfaces here.
16281 let d = dep_with_fonte(DepSource::Git {
16282 repo: "github:pleme-io/caixa-teia".into(),
16283 tag: Some("../escape".into()),
16284 rev: None,
16285 branch: None,
16286 });
16287 let err = d.validate().unwrap_err();
16288 let DepError::FontePinShape { pin, value, .. } = err else {
16289 panic!("expected FontePinShape, got other variant");
16290 };
16291 assert_eq!(pin, ":tag");
16292 assert_eq!(value, "../escape");
16293 }
16294
16295 #[test]
16296 fn validate_accepts_git_fonte_with_hierarchical_branch() {
16297 // The positive-control pin: hierarchical refnames with one or
16298 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
16299 // canonical idiom) round-trip through the gate. Pinned
16300 // separately from the leaf-`"main"` positive control so a
16301 // future tightening that rejects all multi-component refnames
16302 // surfaces here.
16303 let d = dep_with_fonte(DepSource::Git {
16304 repo: "github:pleme-io/caixa-teia".into(),
16305 tag: None,
16306 rev: None,
16307 branch: Some("feature/checkout-rewrite".into()),
16308 });
16309 d.validate().unwrap();
16310 }
16311
16312 #[test]
16313 fn validate_accepts_git_fonte_with_prerelease_tag() {
16314 // The positive-control pin: semver pre-release shape
16315 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
16316 // (only consecutive `..` and trailing `.` are rejected), the
16317 // mid-component hyphen is allowed. Pinned separately from
16318 // the bare-`"v0.1.0"` positive control so a future tightening
16319 // that rejects pre-release tags surfaces here.
16320 let d = dep_with_fonte(DepSource::Git {
16321 repo: "github:pleme-io/caixa-teia".into(),
16322 tag: Some("v0.1.0-alpha.1".into()),
16323 rev: None,
16324 branch: None,
16325 });
16326 d.validate().unwrap();
16327 }
16328
16329 #[test]
16330 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
16331 // The `:rev` axis is routed through `crate::render::is_git_oid`
16332 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
16333 // value with refname-shape punctuation (here, a `:` mid-string
16334 // — would be a refname violation under `is_git_ref_name` too)
16335 // is rejected at the OID-shape gate. The two predicates
16336 // partition the `:fonte` pin axes structurally: an `:rev` value
16337 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
16338 // *still* rejected here because every refname character outside
16339 // `[0-9a-f]` fails the OID gate. Same shape as
16340 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
16341 // on the refname-shaped axes — the diagnostic names the
16342 // offending dep + pin + value verbatim. The flip-from-accept
16343 // case the prior `:tag`/`:branch` gate left as a "future axis"
16344 // (e70d213) — now landed.
16345 let d = dep_with_fonte(DepSource::Git {
16346 repo: "github:pleme-io/caixa-teia".into(),
16347 tag: None,
16348 rev: Some("c0ffee:notarefname".into()),
16349 branch: None,
16350 });
16351 let err = d.validate().unwrap_err();
16352 let DepError::FontePinShape {
16353 nome,
16354 pin,
16355 value,
16356 reason,
16357 } = err
16358 else {
16359 panic!("expected FontePinShape, got other variant");
16360 };
16361 assert_eq!(nome, "caixa-teia");
16362 assert_eq!(pin, ":rev");
16363 assert_eq!(value, "c0ffee:notarefname");
16364 assert!(
16365 !reason.is_empty(),
16366 "FontePinShape `reason` must carry the predicate's wording verbatim"
16367 );
16368 }
16369
16370 #[test]
16371 fn validate_accepts_git_fonte_with_rev_full_sha1() {
16372 // The positive-control pin on the SHA-1 OID width: exactly 40
16373 // lowercase hex characters — the canonical `git rev-parse HEAD`
16374 // emission on a SHA-1-hashed repository (the default on every
16375 // pre-2.42 git and the canonical pleme-io substrate hash).
16376 // Pinned separately from the SHA-256 positive control so a
16377 // future tightening that only admits one width surfaces here.
16378 let d = dep_with_fonte(DepSource::Git {
16379 repo: "github:pleme-io/caixa-teia".into(),
16380 tag: None,
16381 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
16382 branch: None,
16383 });
16384 d.validate().unwrap();
16385 }
16386
16387 #[test]
16388 fn validate_accepts_git_fonte_with_rev_full_sha256() {
16389 // The positive-control pin on the SHA-256 OID width: exactly
16390 // 64 lowercase hex characters — `git`'s
16391 // `extensions.objectFormat = sha256` emission (GA since Git
16392 // 2.42 / Oct 2023). The substrate admits either canonical
16393 // width so an `:rev` authored against a SHA-256-hashed
16394 // upstream round-trips through the gate without per-repo
16395 // configuration. Pinned separately from the SHA-1 positive
16396 // control so a future tightening that drops one width surfaces
16397 // here as a structural decision.
16398 let d = dep_with_fonte(DepSource::Git {
16399 repo: "github:pleme-io/caixa-teia".into(),
16400 tag: None,
16401 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
16402 branch: None,
16403 });
16404 d.validate().unwrap();
16405 }
16406
16407 #[test]
16408 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
16409 // The canonical `git log --short` / `git rev-parse --short HEAD`
16410 // paste-from-release-notes footgun: a 7-char prefix (git's
16411 // default `core.abbrev`) silently passes string emptiness
16412 // checks and resolves to one commit today, but becomes ambiguous
16413 // tomorrow as the repo grows. Until this gate landed the empty-
16414 // pin arm passed (the string isn't empty) and the resolver
16415 // accepted the prefix through git's separate prefix-lookup pass
16416 // — defeating the reproducibility contract `:rev` carries vs.
16417 // `:tag` / `:branch`. The new gate moves the check to caixa-
16418 // build time and names the offending dep + pin + value verbatim.
16419 let d = dep_with_fonte(DepSource::Git {
16420 repo: "github:pleme-io/caixa-teia".into(),
16421 tag: None,
16422 rev: Some("c0ffee0".into()),
16423 branch: None,
16424 });
16425 let err = d.validate().unwrap_err();
16426 let DepError::FontePinShape {
16427 pin, value, reason, ..
16428 } = err
16429 else {
16430 panic!("expected FontePinShape, got other variant");
16431 };
16432 assert_eq!(pin, ":rev");
16433 assert_eq!(value, "c0ffee0");
16434 assert!(
16435 reason.contains("abbreviated") || reason.contains("ambiguous"),
16436 "reason must surface the abbreviation arm, got {reason:?}"
16437 );
16438 }
16439
16440 #[test]
16441 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
16442 // The canonical "I pasted the SHA in uppercase" footgun: `git
16443 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
16444 // bearing `:rev` round-trips inconsistently across the
16445 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
16446 // equality-check pipeline and fails the lacre's content-
16447 // addressing probe with a confusing case-only diff. Pinned
16448 // separately from the non-hex arm so a future relaxation that
16449 // admits one but not the other surfaces here.
16450 let d = dep_with_fonte(DepSource::Git {
16451 repo: "github:pleme-io/caixa-teia".into(),
16452 tag: None,
16453 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
16454 branch: None,
16455 });
16456 let err = d.validate().unwrap_err();
16457 let DepError::FontePinShape {
16458 pin, value, reason, ..
16459 } = err
16460 else {
16461 panic!("expected FontePinShape, got other variant");
16462 };
16463 assert_eq!(pin, ":rev");
16464 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
16465 assert!(
16466 reason.contains("uppercase"),
16467 "reason must surface the uppercase arm, got {reason:?}"
16468 );
16469 }
16470
16471 #[test]
16472 fn validate_rejects_git_fonte_with_rev_refname_value() {
16473 // The cross-axis mis-slot footgun: `:rev "main"` — the author
16474 // conflated `:rev` (hex commit ID, immutable) and `:branch`
16475 // (mutable ref pointing at whatever HEAD is today). Until this
16476 // gate landed the resolver silently dispatched on the value
16477 // shape ("`main` doesn't look like a SHA, fall back to
16478 // refname"), defeating the `:rev` reproducibility contract.
16479 // The new gate rejects every non-hex value on the `:rev` axis,
16480 // so the `:rev`/`:branch` boundary is structurally enforced —
16481 // a refname in the `:rev` slot is a build error, not a
16482 // resolver-time silent reinterpretation.
16483 let d = dep_with_fonte(DepSource::Git {
16484 repo: "github:pleme-io/caixa-teia".into(),
16485 tag: None,
16486 rev: Some("main".into()),
16487 branch: None,
16488 });
16489 let err = d.validate().unwrap_err();
16490 let DepError::FontePinShape {
16491 pin, value, reason, ..
16492 } = err
16493 else {
16494 panic!("expected FontePinShape, got other variant");
16495 };
16496 assert_eq!(pin, ":rev");
16497 assert_eq!(value, "main");
16498 // 4 chars `main` fails the length arm before the character arm,
16499 // so the diagnostic surfaces the abbreviation wording (same
16500 // path the `c0ffee0` 7-char fixture lands on); the structural
16501 // assertion is just that the `:rev "main"` value is rejected.
16502 assert!(
16503 !reason.is_empty(),
16504 "FontePinShape reason must be non-empty for refname-shaped :rev"
16505 );
16506 }
16507
16508 #[test]
16509 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
16510 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
16511 // conflated `:rev` and `:tag`. Pinned separately from the
16512 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
16513 // that catches one but not the other surfaces here. The
16514 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
16515 // assertion is just that the cross-axis mis-slot is a build
16516 // error, regardless of which sub-arm surfaces the diagnostic
16517 // (`is_git_oid` rejects at the first violation; longer
16518 // tag-shape values would hit the non-hex arm instead).
16519 let d = dep_with_fonte(DepSource::Git {
16520 repo: "github:pleme-io/caixa-teia".into(),
16521 tag: None,
16522 rev: Some("v0.1.0".into()),
16523 branch: None,
16524 });
16525 let err = d.validate().unwrap_err();
16526 let DepError::FontePinShape {
16527 pin, value, reason, ..
16528 } = err
16529 else {
16530 panic!("expected FontePinShape, got other variant");
16531 };
16532 assert_eq!(pin, ":rev");
16533 assert_eq!(value, "v0.1.0");
16534 assert!(
16535 !reason.is_empty(),
16536 "FontePinShape reason must be non-empty for tag-shaped :rev"
16537 );
16538 }
16539
16540 #[test]
16541 fn validate_rejects_git_fonte_with_rev_too_long() {
16542 // Boundary case on the upper end: 41 hex chars — one past the
16543 // SHA-1 width, well below the SHA-256 width. Pin so a future
16544 // relaxation that admits "long enough to be a SHA" without
16545 // matching either canonical width surfaces here. The diagnostic
16546 // names the offending length verbatim so the author's grep
16547 // target is unambiguous (either trim one char or paste the
16548 // full SHA-256).
16549 let too_long: String = "0".repeat(41);
16550 let d = dep_with_fonte(DepSource::Git {
16551 repo: "github:pleme-io/caixa-teia".into(),
16552 tag: None,
16553 rev: Some(too_long.clone()),
16554 branch: None,
16555 });
16556 let err = d.validate().unwrap_err();
16557 let DepError::FontePinShape {
16558 pin, value, reason, ..
16559 } = err
16560 else {
16561 panic!("expected FontePinShape, got other variant");
16562 };
16563 assert_eq!(pin, ":rev");
16564 assert_eq!(value, too_long);
16565 assert!(
16566 reason.contains("41"),
16567 "reason must surface the offending length verbatim, got {reason:?}"
16568 );
16569 }
16570
16571 #[test]
16572 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
16573 // The canonical paste-from-doc footgun on `:rev` — author
16574 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
16575 // commit-message paragraph. Until this gate landed the empty-
16576 // pin arm passed (the string isn't empty), the resolver issued
16577 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
16578 // clone time with a quoting-confused git error far from the
16579 // source caixa.lisp. The new gate moves the check to caixa-
16580 // build time. Length is 41 (40 hex + space) so the length arm
16581 // fires first — pinned separately from the pure-length arm to
16582 // ensure the diagnostic surfaces *some* parser wording, not
16583 // silently pass through.
16584 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
16585 let d = dep_with_fonte(DepSource::Git {
16586 repo: "github:pleme-io/caixa-teia".into(),
16587 tag: None,
16588 rev: Some(with_space.clone()),
16589 branch: None,
16590 });
16591 let err = d.validate().unwrap_err();
16592 let DepError::FontePinShape {
16593 pin, value, reason, ..
16594 } = err
16595 else {
16596 panic!("expected FontePinShape, got other variant");
16597 };
16598 assert_eq!(pin, ":rev");
16599 assert_eq!(value, with_space);
16600 assert!(
16601 !reason.is_empty(),
16602 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
16603 );
16604 }
16605
16606 #[test]
16607 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
16608 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
16609 // variant on this axis names the offending dep's `:nome` + the
16610 // `:rev` axis + the offending value verbatim, so the author's
16611 // grep target is the literal `:rev "<value>"` block in
16612 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
16613 // carries_offending_nome_pin_value` test on the refname-shaped
16614 // (`:tag` / `:branch`) axes.
16615 let d = dep_with_fonte(DepSource::Git {
16616 repo: "github:p/x".into(),
16617 tag: None,
16618 rev: Some("not-a-sha".into()),
16619 branch: None,
16620 });
16621 let msg = d
16622 .validate()
16623 .expect_err(":rev: expected FontePinShape")
16624 .to_string();
16625 assert!(
16626 msg.contains("\"caixa-teia\""),
16627 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16628 );
16629 assert!(
16630 msg.contains(":rev"),
16631 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
16632 );
16633 assert!(
16634 msg.contains("not-a-sha"),
16635 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
16636 );
16637 }
16638
16639 #[test]
16640 fn fonte_pin_empty_fires_before_pin_shape() {
16641 // Order pin: a `Some("")` `:tag` is the more self-locating
16642 // diagnostic (the author chose an axis but left it blank;
16643 // grep is unambiguous), so it fires before the shape gate
16644 // even when both arms would match. Pinned so a future
16645 // reordering surfaces here. Mirrors the
16646 // `fonte_repo_empty_fires_before_pin_missing` ordering
16647 // discipline on the peer per-axis arms.
16648 let d = dep_with_fonte(DepSource::Git {
16649 repo: "github:pleme-io/caixa-teia".into(),
16650 tag: Some(String::new()),
16651 rev: None,
16652 branch: None,
16653 });
16654 assert!(matches!(
16655 d.validate().unwrap_err(),
16656 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16657 ));
16658 }
16659
16660 #[test]
16661 fn fonte_pin_shape_fires_after_repo_empty() {
16662 // Order pin: `:repo ""` is the more self-locating axis
16663 // (every git source needs a repo; the per-pin shape gate is
16664 // secondary), so the repo-empty arm fires before the
16665 // per-pin shape arm even when both are violated. Pinned so
16666 // a future reordering surfaces here. Mirrors
16667 // `fonte_repo_empty_fires_before_pin_missing` on the
16668 // adjacent axis pair.
16669 let d = dep_with_fonte(DepSource::Git {
16670 repo: String::new(),
16671 tag: Some("v0.1.0 ".into()),
16672 rev: None,
16673 branch: None,
16674 });
16675 assert!(matches!(
16676 d.validate().unwrap_err(),
16677 DepError::FonteRepoEmpty { .. }
16678 ));
16679 }
16680
16681 #[test]
16682 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16683 // Diagnostic-shape pin across both refname-shaped axes
16684 // (`:tag` + `:branch`): every `FontePinShape` variant names
16685 // the offending dep's `:nome` + the offending pin axis + the
16686 // offending value verbatim, so the author's grep target is
16687 // unambiguous (the literal `:tag "<value>"` / `:branch
16688 // "<value>"` lands in caixa.lisp with quotes). Cover both
16689 // pin axes so a future variant addition forces a parallel
16690 // diagnostic-shape decision.
16691 for (pin_label, fonte) in [
16692 (
16693 ":tag",
16694 DepSource::Git {
16695 repo: "github:p/x".into(),
16696 tag: Some("v0.1.0~1".into()),
16697 rev: None,
16698 branch: None,
16699 },
16700 ),
16701 (
16702 ":branch",
16703 DepSource::Git {
16704 repo: "github:p/x".into(),
16705 tag: None,
16706 rev: None,
16707 branch: Some("feature/foo*".into()),
16708 },
16709 ),
16710 ] {
16711 let d = dep_with_fonte(fonte);
16712 let msg = d
16713 .validate()
16714 .expect_err(&format!("{pin_label}: expected FontePinShape"))
16715 .to_string();
16716 assert!(
16717 msg.contains("\"caixa-teia\""),
16718 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16719 );
16720 assert!(
16721 msg.contains(pin_label),
16722 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16723 );
16724 }
16725 }
16726
16727 #[test]
16728 fn git_source_json_round_trip() {
16729 let src = DepSource::Git {
16730 repo: "github:pleme-io/caixa-teia".into(),
16731 tag: Some("v0.1.0".into()),
16732 rev: None,
16733 branch: None,
16734 };
16735 let s = serde_json::to_string(&src).unwrap();
16736 assert!(s.contains(&format!(
16737 r#""{tipo}":"{git}""#,
16738 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16739 git = crate::render::DEP_SOURCE_TIPO_GIT,
16740 )));
16741 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16742 assert!(s.contains(r#""tag":"v0.1.0""#));
16743 assert!(!s.contains("rev"));
16744 assert!(!s.contains("branch"));
16745 let round: DepSource = serde_json::from_str(&s).unwrap();
16746 assert_eq!(round, src);
16747 }
16748
16749 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16750 //
16751 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16752 // attribute on [`DepSource`] pins three load-bearing byte-sequences
16753 // that flow into every serialized `Dep.fonte` block: the outer
16754 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16755 // the two admitted variant-tag values `"git"` / `"path"` the
16756 // `rename_all = "lowercase"` attribute pins as the discriminator's
16757 // closed-set arms. The three pin tests below round-trip a
16758 // fully-populated variant of each arm through
16759 // [`serde_json::to_value`] and assert each canonical byte-sequence
16760 // appears at its axis — pins a hypothetical future
16761 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16762 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16763 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16764 // at build time rather than at fetch time when the resolver's
16765 // `Dep.fonte` dispatch silently fails to match on the drifted
16766 // discriminator. Same "serialize-and-check" discipline the peer
16767 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16768 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16769 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16770 // family in caixa-core lacking a lifted peer.
16771
16772 #[test]
16773 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16774 // Fail-before-pass-after: a future `tag = "type"` at the derive
16775 // attribute would serialize under `"type":"git"`, and this test
16776 // would trip because `"tipo"` no longer appears at the emitted
16777 // discriminator key. A future `rename_all = "kebab-case"` /
16778 // `"snake_case"` (both no-ops on `Git` since it lacks internal
16779 // word boundaries) is caught by the sibling
16780 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16781 // pin below (Path has no internal boundary either but the pair
16782 // catches any per-arm inconsistency). A future variant rename
16783 // `Git` → `Repository` would emit `"tipo":"repository"` and
16784 // trip this pin.
16785 let src = DepSource::Git {
16786 repo: "github:pleme-io/caixa-teia".into(),
16787 tag: Some("v0.1.0".into()),
16788 rev: None,
16789 branch: None,
16790 };
16791 let json = serde_json::to_value(&src).unwrap();
16792 let obj = json.as_object().expect("Git serializes as a JSON object");
16793 assert_eq!(
16794 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16795 .and_then(serde_json::Value::as_str),
16796 Some(crate::render::DEP_SOURCE_TIPO_GIT),
16797 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16798 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16799 detected in {json}"
16800 );
16801 }
16802
16803 #[test]
16804 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16805 // Fail-before-pass-after: a future variant rename `Path` →
16806 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16807 // this pin. A per-consumer disambiguation as the `defcaixa`
16808 // macro stabilizes ("caminho" → "path" for English-uniformity)
16809 // is scoped to the inner field key, not the discriminator; this
16810 // pin is orthogonal to that and catches only the outer
16811 // discriminator drift.
16812 let src = DepSource::Path {
16813 caminho: "../caixa-teia".into(),
16814 };
16815 let json = serde_json::to_value(&src).unwrap();
16816 let obj = json.as_object().expect("Path serializes as a JSON object");
16817 assert_eq!(
16818 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16819 .and_then(serde_json::Value::as_str),
16820 Some(crate::render::DEP_SOURCE_TIPO_PATH),
16821 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16822 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16823 detected in {json}"
16824 );
16825 }
16826
16827 #[test]
16828 fn dep_source_key_consts_are_pairwise_distinct() {
16829 // Cross-axis collapse detector: a hypothetical future edit that
16830 // accidentally set two of the three consts to the same byte
16831 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16832 // pass every per-arm serialize pin above but silently collapse
16833 // the discriminator's closed-set arms onto one another; this pin
16834 // catches the collapse at build time.
16835 assert_ne!(
16836 crate::render::DEP_SOURCE_KEY_TIPO,
16837 crate::render::DEP_SOURCE_TIPO_GIT,
16838 );
16839 assert_ne!(
16840 crate::render::DEP_SOURCE_KEY_TIPO,
16841 crate::render::DEP_SOURCE_TIPO_PATH,
16842 );
16843 assert_ne!(
16844 crate::render::DEP_SOURCE_TIPO_GIT,
16845 crate::render::DEP_SOURCE_TIPO_PATH,
16846 );
16847 }
16848
16849 #[test]
16850 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16851 // Shape pin against `rename_all` drift: the two variant-tag
16852 // consts must be ASCII-lowercase-only to match the
16853 // `rename_all = "lowercase"` attribute the derive uses; a future
16854 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16855 // would emit `"GIT"` / `"Git"` instead and trip this pin.
16856 for (label, s) in [
16857 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16858 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16859 ] {
16860 assert!(!s.is_empty(), "{label} must not be empty");
16861 assert!(
16862 s.bytes().all(|b| b.is_ascii_lowercase()),
16863 "{label} must be ASCII-lowercase-only (matching \
16864 rename_all = \"lowercase\"), got {s:?}",
16865 );
16866 }
16867 }
16868
16869 // ── per-entry :caracteristicas set-not-multiset gate ────────────
16870 //
16871 // Every Vec-keyed-by-name authoring surface on the typed Caixa
16872 // surface that identifies its entries by a name field now uniformly
16873 // closes the set-not-multiset discipline at build time (cite
16874 // `validate_caracteristicas`'s peer-axis enumeration). The
16875 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16876 // set-shaped (a feature is either enabled or not — there is no
16877 // `feature × 2` semantic), so two entries naming the same feature
16878 // are a redundant declaration the caixa-resolver's lacre pipeline
16879 // would silently dedup at resolve time. The empty-feature arm
16880 // closes the parallel "operationally-meaningless value" axis on
16881 // the same slot. Same linear-walk + `HashSet` + first-collision
16882 // shape every peer set gate uses; same empty-first cascade every
16883 // peer per-entry shape + duplicate gate uses (the empty-feature
16884 // axis is the more-actionable defect since two `""` entries would
16885 // both report `caracteristica: ""` under a duplicate-first
16886 // ordering, with no way to distinguish the offending site).
16887
16888 fn dep_with_features(features: &[&str]) -> Dep {
16889 Dep {
16890 nome: "caixa-teia".into(),
16891 versao: "^0.1".into(),
16892 fonte: None,
16893 opcional: false,
16894 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16895 }
16896 }
16897
16898 #[test]
16899 fn validate_rejects_empty_caracteristica() {
16900 // Fail-before-pass-after pin: every pre-gate codebase accepted
16901 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16902 // imposed no per-entry shape contract), the dep validated, and
16903 // the empty feature would have reached the future caixa-resolver
16904 // lacre pipeline as a no-op feature enable — silently dropping
16905 // the author's intent far from the source `caixa.lisp`. The new
16906 // gate surfaces the structural defect at the typed-validate
16907 // surface with a self-locating diagnostic naming the offending
16908 // dep's `:nome`.
16909 let d = dep_with_features(&[""]);
16910 assert!(
16911 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16912 "expected CaracteristicaEmpty, got {:?}",
16913 d.validate(),
16914 );
16915 }
16916
16917 #[test]
16918 fn validate_rejects_duplicate_caracteristica() {
16919 // Fail-before-pass-after pin on the set-not-multiset arm: the
16920 // feature-toggle slot is set-shaped, so `(:caracteristicas
16921 // ("http" "http"))` is a redundant declaration the lacre
16922 // pipeline dedupes silently at resolve time. The diagnostic
16923 // names the offending dep + the colliding feature verbatim so
16924 // the author can grep their caixa.lisp for `:caracteristicas`
16925 // and fix it in one edit. First-collision determinism is
16926 // pinned separately below.
16927 let d = dep_with_features(&["http", "http"]);
16928 assert!(
16929 matches!(
16930 d.validate().unwrap_err(),
16931 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16932 if nome == "caixa-teia" && caracteristica == "http"
16933 ),
16934 "expected CaracteristicaDuplicate, got {:?}",
16935 d.validate(),
16936 );
16937 }
16938
16939 #[test]
16940 fn validate_accepts_distinct_caracteristicas() {
16941 // The canonical authoring shape — every feature distinct — must
16942 // remain a clean pass (positive control sweep). Covers the
16943 // canonical kebab-case feature names a target caixa typically
16944 // declares.
16945 dep_with_features(&["http", "json", "tls"])
16946 .validate()
16947 .unwrap();
16948 }
16949
16950 #[test]
16951 fn validate_accepts_single_caracteristica() {
16952 // Single-element list is the minimum non-empty shape; passes
16953 // the gate as the identity of the duplicate check (no second
16954 // entry to collide with).
16955 dep_with_features(&["http"]).validate().unwrap();
16956 }
16957
16958 #[test]
16959 fn validate_accepts_empty_caracteristicas_list() {
16960 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16961 // produces `caracteristicas: Vec::new()`; the empty list is
16962 // the gate's empty-set identity and passes vacuously. Pin
16963 // this so a future tightening that requires ≥1 feature
16964 // surfaces here as a test failure rather than a silent
16965 // contract narrowing.
16966 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16967 assert!(dep_with_features(&[]).validate().is_ok());
16968 }
16969
16970 #[test]
16971 fn validate_caracteristica_empty_fires_before_duplicate() {
16972 // Empty-first cascade: an entry with an empty feature *and*
16973 // duplicate entries surfaces the empty diagnostic first. The
16974 // empty-feature axis is the more-actionable defect since
16975 // `caracteristica: ""` is unambiguous; under duplicate-first
16976 // ordering the diagnostic could report the empty string from
16977 // either of two empty entries with no way to distinguish.
16978 // Mirrors the peer empty-before-duplicate ordering
16979 // discipline every per-entry shape + duplicate gate establishes
16980 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16981 // `DuplicateChildCaixa`, `validate_membros`'s
16982 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16983 let d = dep_with_features(&["", "http", "http"]);
16984 assert!(matches!(
16985 d.validate().unwrap_err(),
16986 DepError::CaracteristicaEmpty { .. }
16987 ));
16988 }
16989
16990 #[test]
16991 fn validate_caracteristica_duplicate_first_collision_determinism() {
16992 // Three matching entries: the second occurrence surfaces the
16993 // diagnostic (the second is the first *collision* — the first
16994 // entry is the establishing one, not a duplicate). Mirrors
16995 // every peer first-collision posture
16996 // (`SupervisorError::DuplicateChildCaixa` reports the second
16997 // collision, `AplicacaoError::MembroDuplicate` reports the
16998 // second, `DepError::DuplicateNome` reports the second).
16999 // Pinning this so a future shortcut that flips to last-
17000 // collision (or non-deterministic) surfaces here.
17001 let d = dep_with_features(&["http", "http", "http"]);
17002 assert!(matches!(
17003 d.validate().unwrap_err(),
17004 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
17005 ));
17006 }
17007
17008 #[test]
17009 fn validate_per_entry_shape_fires_before_caracteristicas() {
17010 // Per-entry shape precedence: a dep with a malformed `:nome`
17011 // (uppercase) AND duplicate `:caracteristicas` surfaces the
17012 // narrower `NomeInvalid` diagnostic first, not the set-gate
17013 // diagnostic. The `:nome` is the self-locating axis (every
17014 // diagnostic from the caracteristicas gate quotes the
17015 // offending dep's `:nome` to anchor the grep target —
17016 // surfacing the malformed name first keeps that anchor
17017 // valid). Same precedence shape every peer per-entry-shape
17018 // arm establishes against its peer set-gate
17019 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
17020 // on the cross-entry `:nome` axis).
17021 let d = Dep {
17022 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
17023 versao: "^0.1".into(),
17024 fonte: None,
17025 opcional: false,
17026 caracteristicas: vec!["http".into(), "http".into()],
17027 };
17028 assert!(matches!(
17029 d.validate().unwrap_err(),
17030 DepError::NomeInvalid { .. }
17031 ));
17032 }
17033
17034 // ── per-entry :caracteristicas value-shape gate ──────────────────
17035 //
17036 // Until this gate landed `:caracteristicas` only refused the empty
17037 // string and cross-entry duplicates: a non-empty distinct but
17038 // structurally invalid feature name silently passed validate and the
17039 // failure surfaced at `cargo metadata` time as Cargo's
17040 // `restricted_names::validate_feature_name` parser rejection, far from
17041 // the source `caixa.lisp` with no field naming which `:deps` entry's
17042 // `:caracteristicas` carried the typo. The lifted predicate makes the
17043 // Cargo-feature-name-grammar intersection-floor a substrate-level
17044 // invariant at validate time. Same trajectory as the eight peer
17045 // value-shape predicates each typed surface downstream of a structured
17046 // grammar already follows.
17047
17048 #[test]
17049 fn validate_rejects_caracteristica_with_leading_plus() {
17050 // Fail-before-pass-after pin on the canonical Cargo
17051 // `+<feature>` activation-form-in-feature-name-slot footgun.
17052 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
17053 // `+optional-feature` as an enablement of a previously-disabled
17054 // feature; pasting that activation form into `:caracteristicas`
17055 // (which names the feature itself) silently passed pre-gate and
17056 // failed at `cargo metadata` parse time.
17057 let d = dep_with_features(&["+http"]);
17058 let err = d.validate().unwrap_err();
17059 assert!(
17060 matches!(
17061 err,
17062 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
17063 if nome == "caixa-teia" && caracteristica == "+http"
17064 ),
17065 "expected CaracteristicaInvalid, got {err:?}"
17066 );
17067 }
17068
17069 #[test]
17070 fn validate_rejects_caracteristica_with_leading_hyphen() {
17071 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
17072 // is a legitimate continuation character (kebab-case feature
17073 // names like `runtime-tokio` pass) but Cargo rejects it at the
17074 // start; the structural defect — and its CLI-argument-injection
17075 // adjacency at any downstream Cargo subprocess invocation — is
17076 // closed at validate time, not at `cargo metadata` time.
17077 let d = dep_with_features(&["-json"]);
17078 let err = d.validate().unwrap_err();
17079 assert!(
17080 matches!(
17081 err,
17082 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
17083 ),
17084 "expected CaracteristicaInvalid, got {err:?}"
17085 );
17086 }
17087
17088 #[test]
17089 fn validate_rejects_caracteristica_with_leading_dot() {
17090 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
17091 // a legitimate continuation character (version-suffix shapes
17092 // like `feat.v2` pass) but the leading-dot form is the
17093 // canonical dotted-version-suffix-as-feature-name confusion.
17094 let d = dep_with_features(&[".feat"]);
17095 let err = d.validate().unwrap_err();
17096 assert!(matches!(
17097 err,
17098 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
17099 ));
17100 }
17101
17102 #[test]
17103 fn validate_rejects_caracteristica_with_whitespace() {
17104 // Fail-before-pass-after pin on the embedded-whitespace footgun:
17105 // a feature name with a space inside is structurally a multi-
17106 // token blob (the canonical paste-from-doc footgun, or an
17107 // accidental `"http server"` where the author meant
17108 // `"http-server"`).
17109 let d = dep_with_features(&["http feature"]);
17110 let err = d.validate().unwrap_err();
17111 assert!(matches!(
17112 err,
17113 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
17114 ));
17115 }
17116
17117 #[test]
17118 fn validate_rejects_caracteristica_with_comma() {
17119 // Fail-before-pass-after pin on the embedded-comma footgun:
17120 // the list-separator-belongs-to-the-list-grammar
17121 // miscomprehension where the author writes
17122 // `:caracteristicas ("http,json")` intending two features but
17123 // the `Vec<String>` field consumes the bare token as one entry.
17124 let d = dep_with_features(&["http,json"]);
17125 let err = d.validate().unwrap_err();
17126 assert!(matches!(
17127 err,
17128 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
17129 ));
17130 }
17131
17132 #[test]
17133 fn validate_rejects_caracteristica_with_slash() {
17134 // Fail-before-pass-after pin on the embedded-slash footgun:
17135 // Cargo's `dep/feat` namespaced-dep syntax applies inside
17136 // `[dependencies.<dep>.features]` list entries that already
17137 // name the parent dep (so the syntax says "enable feature
17138 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
17139 // per-dep already (a sibling slot on the `Dep` itself), so the
17140 // segment separator within an entry must be `-`, `_`, `+`,
17141 // or `.`. The diagnostic remediation points at the canonical
17142 // Cargo namespaced-dep discipline.
17143 let d = dep_with_features(&["http/json"]);
17144 let err = d.validate().unwrap_err();
17145 assert!(matches!(
17146 err,
17147 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
17148 ));
17149 }
17150
17151 #[test]
17152 fn validate_rejects_caracteristica_with_non_ascii() {
17153 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
17154 // byte footgun: NFC-vs-NFD normalization across filesystems
17155 // silently rewrites the feature-key, breaking the lacre's
17156 // content-addressing invariant. Pinned at a canonical
17157 // smart-quote-paste shape (`café`) where the raw `é` byte is the
17158 // documented APFS round-trip break.
17159 let d = dep_with_features(&["caf\u{e9}"]);
17160 let err = d.validate().unwrap_err();
17161 assert!(matches!(
17162 err,
17163 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
17164 ));
17165 }
17166
17167 #[test]
17168 fn validate_rejects_caracteristica_with_control_character() {
17169 // Fail-before-pass-after pin on the embedded-control-character
17170 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
17171 // feature name is the canonical paste-from-multiline-doc
17172 // footgun the predicate's reason wording specifically calls out.
17173 let d = dep_with_features(&["http\njson"]);
17174 let err = d.validate().unwrap_err();
17175 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
17176 }
17177
17178 #[test]
17179 fn validate_accepts_canonical_caracteristicas_shapes() {
17180 // Positive control sweep: every canonical Cargo feature name
17181 // shape the pleme-io ecosystem uses must still pass. Mirrors
17182 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
17183 // sweep — drift between either landing site and the predicate's
17184 // accepted set is a build error visible at this pair of tests,
17185 // not a per-renderer "this passed validate but failed at
17186 // cargo metadata time" surprise on the next acceptance.
17187 for s in [
17188 "http",
17189 "json",
17190 "derive",
17191 "serde_json",
17192 "runtime-tokio",
17193 "tokio.full",
17194 "v0.1",
17195 "http+json",
17196 "_internal",
17197 "__private",
17198 "default",
17199 "rt-multi-thread",
17200 "feat.v2",
17201 ] {
17202 let d = dep_with_features(&[s]);
17203 d.validate().unwrap_or_else(|e| {
17204 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
17205 });
17206 }
17207 }
17208
17209 #[test]
17210 fn validate_caracteristica_empty_fires_before_invalid() {
17211 // Cascade precedence pin: an entry list with both an empty
17212 // feature AND an invalid-shape feature surfaces the
17213 // `CaracteristicaEmpty` arm first (the empty value carries no
17214 // self-locating data — `caracteristica: ""` is the diagnostic
17215 // with no way to anchor a grep target — so closing the empty
17216 // axis first preserves the per-entry-shape diagnostic's
17217 // self-locating discipline). Same empty-first cascade every
17218 // peer per-entry shape gate establishes
17219 // (`SupervisorSpec::validate`'s `EmptyChildName` before
17220 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
17221 // before `MembroCaixaInvalid`).
17222 let d = dep_with_features(&["", "+http"]);
17223 assert!(matches!(
17224 d.validate().unwrap_err(),
17225 DepError::CaracteristicaEmpty { .. }
17226 ));
17227 }
17228
17229 #[test]
17230 fn validate_caracteristica_invalid_fires_before_duplicate() {
17231 // Per-entry-shape precedence pin: an entry list with the same
17232 // invalid feature shape declared twice surfaces the
17233 // `CaracteristicaInvalid` diagnostic on the first entry, not
17234 // the `CaracteristicaDuplicate` on the second collision. The
17235 // per-entry shape gate fires before the cross-entry set gate
17236 // — same precedence shape every peer two-arm-plus-set gate
17237 // establishes (`SupervisorSpec::validate`'s
17238 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
17239 // `validate_membros`'s `MembroCaixaInvalid` before
17240 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
17241 // cross-list `DuplicateNome`).
17242 let d = dep_with_features(&["+http", "+http"]);
17243 assert!(matches!(
17244 d.validate().unwrap_err(),
17245 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
17246 ));
17247 }
17248
17249 #[test]
17250 fn validate_rejects_caracteristica_at_65_byte_boundary() {
17251 // Boundary pin on the 64-byte cap — both the boundary-accepting
17252 // case and the boundary-exceeding case in one place, so a
17253 // future cap shift surfaces both arms simultaneously, mirroring
17254 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
17255 // predicate-level pin at the dep-axis landing site.
17256 let max_ok = "a".repeat(64);
17257 dep_with_features(&[&max_ok])
17258 .validate()
17259 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
17260 let too_long = "a".repeat(65);
17261 let d = dep_with_features(&[&too_long]);
17262 assert!(matches!(
17263 d.validate().unwrap_err(),
17264 DepError::CaracteristicaInvalid { .. }
17265 ));
17266 }
17267
17268 // ── self-dep cross-slot gate ─────────────────────────────────────
17269
17270 #[test]
17271 fn validate_no_self_dep_rejects_self_in_deps() {
17272 // A caixa whose `:deps` lists its own `:nome` is a one-node
17273 // cycle in the lacre closure's dep-graph traversal — rejected,
17274 // naming the parent and the offending list tag.
17275 let deps = vec![
17276 Dep::simple("caixa-teia", "^0.1"),
17277 Dep::simple("orquestra", "^0.1"),
17278 ];
17279 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17280 assert!(
17281 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17282 "got {err:?}"
17283 );
17284 }
17285
17286 #[test]
17287 fn validate_no_self_dep_rejects_self_in_deps_dev() {
17288 // Same gate on the `:deps-dev` axis — neither dep list is a
17289 // second-class citizen on the self-edge invariant.
17290 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17291 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17292 assert!(
17293 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17294 "got {err:?}"
17295 );
17296 }
17297
17298 #[test]
17299 fn validate_no_self_dep_deps_fires_before_deps_dev() {
17300 // Walk order pin: a caixa that self-references on both lists
17301 // surfaces the `:deps` arm first — the load-bearing axis the
17302 // lacre closure resolves at every build. Mirrors the canonical
17303 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
17304 let deps = vec![Dep::simple("orquestra", "^0.1")];
17305 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
17306 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
17307 assert!(
17308 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17309 "got {err:?}"
17310 );
17311 }
17312
17313 #[test]
17314 fn validate_no_self_dep_accepts_distinct_names() {
17315 // Positive control: every dep names a distinct caixa. The
17316 // canonical author surface — peer of
17317 // [`validate_no_self_supervision_accepts_distinct_children`].
17318 let deps = vec![
17319 Dep::simple("caixa-teia", "^0.1"),
17320 Dep::simple("caixa-arch", "^0.1"),
17321 ];
17322 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
17323 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
17324 }
17325
17326 #[test]
17327 fn validate_no_self_dep_empty_lists_pass() {
17328 // A caixa with no declared deps has nothing to self-reference —
17329 // the gate is vacuously satisfied. Peer of
17330 // [`validate_no_self_supervision_empty_children_is_ok`].
17331 validate_no_self_dep(&[], &[], "orquestra").unwrap();
17332 }
17333
17334 #[test]
17335 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
17336 // Diagnostic-shape pin (peer with
17337 // [`validate_no_self_supervision`]'s diagnostic): the error's
17338 // Display surfaces both the offending list tag and the
17339 // parent's `:nome` verbatim, so the author can grep their
17340 // caixa.lisp for the offending block in one edit. Names
17341 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
17342 // surface — every legitimate "I want to use code from this
17343 // caixa" intent routes through one of those three slots.
17344 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17345 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
17346 .unwrap_err()
17347 .to_string();
17348 assert!(
17349 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17350 "diagnostic must name the offending list tag: {rendered}",
17351 );
17352 assert!(
17353 rendered.contains("orquestra"),
17354 "diagnostic must quote the parent caixa name: {rendered}",
17355 );
17356 assert!(
17357 rendered.contains(":bibliotecas"),
17358 "diagnostic must point at the corrective code-surface slot: {rendered}",
17359 );
17360 }
17361
17362 #[test]
17363 fn validate_no_self_dep_accepts_coincidental_substring_match() {
17364 // Identity is exact-string equality, not substring — a dep
17365 // named `"orquestra-helper"` is a distinct caixa even when the
17366 // parent is `"orquestra"`. Pin the exact-match discipline so a
17367 // future relaxation that uses `contains` surfaces here, peer
17368 // with the supervision-tree and Aplicacao-membership gates
17369 // which all use exact-string equality on the typed identity.
17370 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
17371 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17372 }
17373
17374 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
17375
17376 #[test]
17377 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
17378 // Scalar-value pin: the two author-facing kebab-case labels the
17379 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
17380 // the two-list dep-graph slot axis, one arm per typed slot.
17381 // Mirrors the peer scalar-value pin the sibling
17382 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
17383 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
17384 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
17385 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
17386 // (882f498) M3 top-level author-labels, and
17387 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
17388 // Supervisor top-level author-labels carry, so every kind-scoped
17389 // typed-slot-family axis routes through one canonical per-arm
17390 // declaration.
17391 //
17392 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
17393 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
17394 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
17395 // for symmetry) lands as an edit to exactly one const, and
17396 // every consumer that reaches for the label picks it up at
17397 // build time rather than at runtime as a downstream mismatch on
17398 // a `DepError::DuplicateNome { list: … }` diagnostic far from
17399 // the rename's commit.
17400 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
17401 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
17402 }
17403
17404 #[test]
17405 fn dep_author_key_consts_are_pairwise_distinct() {
17406 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
17407 // must not collapse onto one byte-string. A future copy-paste
17408 // slip that renamed both consts to the same value (or a rebrand
17409 // that dropped the `-dev` suffix from one but not the other)
17410 // would leave every `DepError::DuplicateNome { list: … }`
17411 // diagnostic naming an unattributable list — the linter would
17412 // route the author to the wrong caixa.lisp block, or the
17413 // cross-list precedence gate
17414 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
17415 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
17416 // duplicate. Peer of the sibling
17417 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
17418 // other top-level kind-scoped slot-family axes carry
17419 // (implicitly held by their different byte-values today).
17420 assert_ne!(
17421 crate::render::DEP_AUTHOR_KEY_DEPS,
17422 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17423 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
17424 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
17425 self-locates the offending block in the author's caixa.lisp",
17426 );
17427 }
17428
17429 #[test]
17430 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
17431 // Production-through-const pin: the two per-arm list tags
17432 // [`validate_no_self_dep`] threads onto the `list:` field of a
17433 // returned [`DepError::DepIsSelf`] route through the lifted
17434 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
17435 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
17436 // the walker (a rename that reaches one arm but not the const,
17437 // or vice versa) surfaces here at build time rather than at
17438 // runtime as a `feira lint` diagnostic naming the wrong list
17439 // tag. Mirror of the peer
17440 // [`crate::Caixa::declared_servico_slots`] production tagger
17441 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
17442 // onto the two-list dep-graph gate.
17443 let deps = vec![Dep::simple("orquestra", "^0.1")];
17444 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17445 let DepError::DepIsSelf { list, .. } = err else {
17446 panic!("expected DepIsSelf from :deps walk");
17447 };
17448 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
17449
17450 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17451 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17452 let DepError::DepIsSelf { list, .. } = err else {
17453 panic!("expected DepIsSelf from :deps-dev walk");
17454 };
17455 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
17456 }
17457
17458 // ── Dep::nome accessor pins ───────────────────────────────────────
17459 //
17460 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
17461 // projection over the plain-shorthand / explicit-git / explicit-path
17462 // fixture triad the [`Dep`] docstring lists (so the accessor's
17463 // accept-set is exercised across every author-surface `:fonte`
17464 // shape); by-borrow pointer identity so the projection stays
17465 // zero-copy at every consumer site; and validate-composition through
17466 // the [`validate_no_self_dep`] cross-slot gate reading its
17467 // parent-name equality check through the lifted accessor rather than
17468 // the raw field.
17469
17470 #[test]
17471 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
17472 // Plain-shorthand form (`:fonte None`).
17473 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
17474 // Explicit git-source form with a tag pin — same accessor path.
17475 assert_eq!(
17476 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
17477 "caixa-teia",
17478 );
17479 // Explicit path-source form.
17480 assert_eq!(
17481 Dep {
17482 nome: "caixa-teia".to_string(),
17483 versao: "0.1.0".to_string(),
17484 fonte: Some(DepSource::Path {
17485 caminho: "../caixa-teia".to_string(),
17486 }),
17487 opcional: false,
17488 caracteristicas: Vec::new(),
17489 }
17490 .nome(),
17491 "caixa-teia",
17492 );
17493 // The empty-string `:nome` sentinel (which [`Dep::validate`]
17494 // refuses through the [`DepError::NomeEmpty`] arm) still round-
17495 // trips as an empty `&str` through the accessor — the accessor is
17496 // a projection, not a gate; the gate is [`Dep::validate`].
17497 assert_eq!(Dep::simple("", "^0.1").nome(), "");
17498 }
17499
17500 #[test]
17501 fn dep_nome_is_by_borrow_pointer_identity() {
17502 // Zero-copy pin: the accessor must borrow into the field's own
17503 // storage, not clone. If a future rewrite regresses to
17504 // `self.nome.clone().leak()` or an owned-buffer shape, the two
17505 // pointers diverge and this pin fails at build time.
17506 let d = Dep::simple("caixa-teia", "^0.1");
17507 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
17508 }
17509
17510 // ── Dep::versao_requirement accessor pins ─────────────────────────
17511 //
17512 // Three coherence pins on the lifted `Dep::versao_requirement`
17513 // accessor: byte-equal projection over the plain-shorthand /
17514 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
17515 // lists plus the empty-sentinel that round-trips as `""` (the accessor
17516 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
17517 // borrow pointer identity so the projection stays zero-copy at every
17518 // consumer site; and validate-composition through the
17519 // [`crate::render::require_valid_versao_requirement`] cascade reading
17520 // its requirement-shape check through the lifted accessor rather than
17521 // the raw field.
17522 #[test]
17523 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
17524 // Plain-shorthand form (`:fonte None`).
17525 assert_eq!(
17526 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
17527 "^0.1",
17528 );
17529 // Explicit git-source form with a tag pin — same accessor path.
17530 assert_eq!(
17531 Dep::git(
17532 "caixa-teia",
17533 "~0.1.2",
17534 "github:pleme-io/caixa-teia",
17535 "v0.1.0"
17536 )
17537 .versao_requirement(),
17538 "~0.1.2",
17539 );
17540 // Explicit path-source form.
17541 assert_eq!(
17542 Dep {
17543 nome: "caixa-teia".to_string(),
17544 versao: "0.1.0".to_string(),
17545 fonte: Some(DepSource::Path {
17546 caminho: "../caixa-teia".to_string(),
17547 }),
17548 opcional: false,
17549 caracteristicas: Vec::new(),
17550 }
17551 .versao_requirement(),
17552 "0.1.0",
17553 );
17554 // The wildcard requirement (`"*"`) — the shorthand
17555 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
17556 // verbatim through the accessor as `"*"`, same byte-shape the
17557 // author wrote.
17558 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
17559 // The empty-string `:versao` sentinel (which [`Dep::validate`]
17560 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
17561 // trips as an empty `&str` through the accessor — the accessor is
17562 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
17563 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
17564 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
17565 }
17566
17567 #[test]
17568 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
17569 // Zero-copy pin: the accessor must borrow into the field's own
17570 // storage, not clone. If a future rewrite regresses to
17571 // `self.versao.clone().leak()` or an owned-buffer shape, the two
17572 // pointers diverge and this pin fails at build time. Peer of the
17573 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
17574 // discipline extended onto the requirement-carrying axis.
17575 let d = Dep::simple("caixa-teia", "^0.1");
17576 assert!(std::ptr::eq(
17577 d.versao_requirement().as_ptr(),
17578 d.versao.as_ptr(),
17579 ));
17580 }
17581
17582 #[test]
17583 fn dep_validate_reads_requirement_through_accessor() {
17584 // Composition pin: the [`Dep::validate`]
17585 // [`crate::render::require_valid_versao_requirement`] cascade
17586 // consumes the requirement string through the lifted accessor —
17587 // both the requirement-gate input and the
17588 // [`DepError::VersaoInvalid`] error-body carrier route through
17589 // `self.versao_requirement()`. A valid requirement passes
17590 // (positive control); a malformed-but-non-empty requirement fails
17591 // and the diagnostic quotes the offending byte-string verbatim
17592 // (same shape the accessor projects), so a future regression that
17593 // detoured the requirement carrier through a different byte-
17594 // string (say the parsed `VersionReq`'s `Display`, or a
17595 // normalized rewrite) would surface here at build time. The
17596 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
17597 // ahead of the parse arm, pinning the empty-first cascade the
17598 // accessor's `""` sentinel round-trip acknowledges.
17599 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17600 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
17601 assert!(
17602 matches!(
17603 &err,
17604 DepError::VersaoInvalid {
17605 nome,
17606 versao,
17607 ..
17608 } if nome == "caixa-teia" && versao == "v0.1",
17609 ),
17610 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
17611 );
17612 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
17613 assert!(
17614 matches!(
17615 &err,
17616 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
17617 ),
17618 "expected VersaoEmpty from the empty-first arm, got {err:?}",
17619 );
17620 }
17621
17622 // ── Dep::fonte accessor pins ──────────────────────────────────────
17623 //
17624 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
17625 // equal projection over the plain-shorthand (`:fonte None`) /
17626 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
17627 // docstring lists (so the accessor's accept-set is exercised across
17628 // every author-surface `:fonte` shape and both `DepSource` variants);
17629 // pointer identity so the borrowed reference points into the field's
17630 // own `Option<DepSource>` storage (not a cloned side-buffer); and
17631 // validate-composition through the [`Dep::validate`] gate reading
17632 // its per-`:fonte` [`DepSource::validate`] delegation through the
17633 // lifted accessor rather than the raw `if let Some(ref fonte) =
17634 // self.fonte` bracket.
17635
17636 #[test]
17637 fn dep_fonte_returns_declared_source_across_shapes() {
17638 // Plain-shorthand form — `:fonte` omitted, accessor projects
17639 // the `None` partition the resolver-side default-fill treats
17640 // as "resolve through `github:<default-org>/<nome>`".
17641 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
17642 // Explicit git-source form with a tag pin — same accessor path.
17643 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17644 match git.fonte() {
17645 Some(DepSource::Git {
17646 repo,
17647 tag,
17648 rev,
17649 branch,
17650 }) => {
17651 assert_eq!(repo, "github:pleme-io/caixa-teia");
17652 assert_eq!(tag.as_deref(), Some("v0.1.0"));
17653 assert!(rev.is_none());
17654 assert!(branch.is_none());
17655 }
17656 other => panic!("expected explicit git :fonte, got {other:?}"),
17657 }
17658 // Explicit path-source form — the dev-only local-filesystem
17659 // arm the [`Dep`] docstring's third fixture carries.
17660 let path = Dep {
17661 nome: "caixa-teia".to_string(),
17662 versao: "0.1.0".to_string(),
17663 fonte: Some(DepSource::Path {
17664 caminho: "../caixa-teia".to_string(),
17665 }),
17666 opcional: false,
17667 caracteristicas: Vec::new(),
17668 };
17669 match path.fonte() {
17670 Some(DepSource::Path { caminho }) => {
17671 assert_eq!(caminho, "../caixa-teia");
17672 }
17673 other => panic!("expected explicit path :fonte, got {other:?}"),
17674 }
17675 }
17676
17677 #[test]
17678 fn dep_fonte_is_by_borrow_pointer_identity() {
17679 // Zero-copy pin: the accessor must borrow into the field's own
17680 // `Option<DepSource>` storage, not clone into a side buffer. If
17681 // a future rewrite regresses to `self.fonte.clone()` or an
17682 // owned-buffer shape, the two pointers diverge and this pin
17683 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17684 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17685 // identity pins — same by-borrow discipline extended onto the
17686 // outer-`Dep` `Option<&Composite>` composite-reference axis.
17687 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17688 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17689 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17690 assert!(std::ptr::eq(accessed, raw));
17691 }
17692
17693 #[test]
17694 fn dep_validate_reads_fonte_through_accessor() {
17695 // Composition pin: [`Dep::validate`]'s per-`:fonte`
17696 // [`DepSource::validate`] delegation consumes the typed slot
17697 // through the lifted accessor — an author-omitted `:fonte`
17698 // still passes the outer gate (positive control), an explicit
17699 // well-formed git source with exactly one pin passes, and a
17700 // malformed git source (empty `:repo`) surfaces the
17701 // [`DepError::FonteRepoEmpty`] variant quoting the offending
17702 // dep's `:nome` verbatim so a future regression that detoured
17703 // the `:fonte` delegation through a different path (say a
17704 // per-scope override projector) would surface here at build
17705 // time. Peer of the sibling
17706 // `dep_validate_reads_requirement_through_accessor` composition
17707 // pin on the `:versao` axis.
17708 // Positive control 1: no `:fonte` at all.
17709 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17710 // Positive control 2: well-formed git source.
17711 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17712 .validate()
17713 .unwrap();
17714 // Negative control: empty `:repo` — the accessor still returns
17715 // `Some(&DepSource::Git { repo: "", … })` and the delegated
17716 // `DepSource::validate` gate raises the typed carrier.
17717 let bad = Dep {
17718 nome: "caixa-teia".to_string(),
17719 versao: "^0.1".to_string(),
17720 fonte: Some(DepSource::Git {
17721 repo: String::new(),
17722 tag: Some("v0.1.0".to_string()),
17723 rev: None,
17724 branch: None,
17725 }),
17726 opcional: false,
17727 caracteristicas: Vec::new(),
17728 };
17729 let err = bad.validate().unwrap_err();
17730 assert!(
17731 matches!(
17732 &err,
17733 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17734 ),
17735 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17736 );
17737 }
17738
17739 #[test]
17740 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17741 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17742 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17743 // own `:nome` through the lifted accessor rather than the raw
17744 // field. Fails-before-passes-after: with the accessor lifted the
17745 // gate reads its equality check through `dep.nome() ==
17746 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17747 // the diagnostic still names the offending list tag as expected.
17748 let deps = vec![Dep::simple("orquestra", "^0.1")];
17749 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17750 assert!(matches!(
17751 err,
17752 DepError::DepIsSelf {
17753 ref nome,
17754 list,
17755 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17756 ));
17757 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17758 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17759 assert!(matches!(
17760 err,
17761 DepError::DepIsSelf {
17762 ref nome,
17763 list,
17764 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17765 ));
17766 // A non-matching `:nome` passes through the accessor gate.
17767 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17768 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17769 }
17770
17771 // ── Dep::caracteristicas accessor pins ────────────────────────────
17772 //
17773 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17774 // byte-equal projection over the default-empty / single-entry /
17775 // multi-entry fixture triad (so the accessor's accept-set is
17776 // exercised across every author-surface `:caracteristicas` shape,
17777 // matching the peer sibling family's fixture-triad discipline); by-
17778 // borrow pointer identity so the projection stays zero-copy at every
17779 // consumer site; and validate-composition through the
17780 // [`Dep::validate_caracteristicas`] gate reading its per-entry
17781 // linear walk through the lifted accessor rather than the raw
17782 // `for c in &self.caracteristicas` bracket.
17783
17784 #[test]
17785 fn dep_caracteristicas_returns_declared_features_across_shapes() {
17786 // Default-empty form — the [`Dep::simple`] constructor's
17787 // `Vec::new()` fill; the accessor projects the empty slice
17788 // verbatim (no `None` collapse).
17789 assert!(
17790 Dep::simple("caixa-teia", "^0.1")
17791 .caracteristicas()
17792 .is_empty(),
17793 );
17794 // Single-entry form — the canonical Cargo-shaped one-feature
17795 // enable ([`crate::render::is_cargo_feature_name`] accepts the
17796 // `"http"` byte-string as a valid feature name).
17797 let one = Dep {
17798 nome: "caixa-teia".to_string(),
17799 versao: "^0.1".to_string(),
17800 fonte: None,
17801 opcional: false,
17802 caracteristicas: vec!["http".to_string()],
17803 };
17804 assert_eq!(one.caracteristicas(), &["http".to_string()]);
17805 // Multi-entry form — the substrate's set-shaped multi-feature
17806 // enable, exercising the accessor over a length-two slice with
17807 // no duplicate collapse.
17808 let two = Dep {
17809 nome: "caixa-teia".to_string(),
17810 versao: "^0.1".to_string(),
17811 fonte: None,
17812 opcional: false,
17813 caracteristicas: vec!["http".to_string(), "json".to_string()],
17814 };
17815 assert_eq!(
17816 two.caracteristicas(),
17817 &["http".to_string(), "json".to_string()],
17818 );
17819 }
17820
17821 #[test]
17822 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17823 // Zero-copy pin: the accessor must borrow into the field's own
17824 // `Vec<String>` storage, not clone into a side buffer. If a
17825 // future rewrite regresses to `self.caracteristicas.clone()` or
17826 // an owned-buffer shape, the two pointers diverge and this pin
17827 // fails at build time. Peer of the sibling per-`Dep`
17828 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17829 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17830 // borrow discipline extended onto the outer-`Dep` `&[String]`
17831 // slice-projection axis.
17832 let d = Dep {
17833 nome: "caixa-teia".to_string(),
17834 versao: "^0.1".to_string(),
17835 fonte: None,
17836 opcional: false,
17837 caracteristicas: vec!["http".to_string(), "json".to_string()],
17838 };
17839 assert!(std::ptr::eq(
17840 d.caracteristicas().as_ptr(),
17841 d.caracteristicas.as_ptr(),
17842 ));
17843 }
17844
17845 #[test]
17846 fn dep_validate_reads_caracteristicas_through_accessor() {
17847 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17848 // linear walk consumes the feature-toggle list through the
17849 // lifted accessor — a well-formed `:caracteristicas` set passes
17850 // (positive control), an empty-string entry surfaces the
17851 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17852 // `Dep::nome`, and a within-list duplicate surfaces the
17853 // [`DepError::CaracteristicaDuplicate`] variant so a future
17854 // regression that detoured the walk through a different byte-
17855 // string list (say a per-scope override projector) would surface
17856 // here at build time. Peer of the sibling
17857 // `dep_validate_reads_fonte_through_accessor` /
17858 // `dep_validate_reads_requirement_through_accessor` composition
17859 // pins on the `:fonte` / `:versao` axes.
17860 // Positive control: two distinct well-formed feature names pass.
17861 Dep {
17862 nome: "caixa-teia".to_string(),
17863 versao: "^0.1".to_string(),
17864 fonte: None,
17865 opcional: false,
17866 caracteristicas: vec!["http".to_string(), "json".to_string()],
17867 }
17868 .validate()
17869 .unwrap();
17870 // Negative control 1: empty-string feature-name entry — the
17871 // accessor still returns `&[""]` and the walk raises the typed
17872 // empty-first carrier.
17873 let err = Dep {
17874 nome: "caixa-teia".to_string(),
17875 versao: "^0.1".to_string(),
17876 fonte: None,
17877 opcional: false,
17878 caracteristicas: vec![String::new()],
17879 }
17880 .validate()
17881 .unwrap_err();
17882 assert!(
17883 matches!(
17884 &err,
17885 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17886 ),
17887 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17888 );
17889 // Negative control 2: within-list duplicate — the accessor's
17890 // slice view carries both entries, and the walk's dedup arm
17891 // raises the typed duplicate carrier quoting the offending
17892 // feature name verbatim.
17893 let err = Dep {
17894 nome: "caixa-teia".to_string(),
17895 versao: "^0.1".to_string(),
17896 fonte: None,
17897 opcional: false,
17898 caracteristicas: vec!["http".to_string(), "http".to_string()],
17899 }
17900 .validate()
17901 .unwrap_err();
17902 assert!(
17903 matches!(
17904 &err,
17905 DepError::CaracteristicaDuplicate {
17906 nome,
17907 caracteristica,
17908 } if nome == "caixa-teia" && caracteristica == "http",
17909 ),
17910 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17911 );
17912 }
17913
17914 // ── Dep::opcional accessor pins ───────────────────────────────────
17915 //
17916 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17917 // equal projection over the default-`false` / explicit-`true`
17918 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17919 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17920 // exercising the accessor's accept-set over every author-surface
17921 // `:fonte` shape × every author-surface `:opcional` shape; and by-
17922 // `Copy` idempotency so the projection stays value-return (no
17923 // silent detour to a fresh `&bool` borrow that would introduce a
17924 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17925 // shape elides). No composition pin — `:opcional` does not
17926 // participate in [`Dep::validate`] (an opcional dep with any bool
17927 // value is validate-accepted; the missing-source arm is a resolver-
17928 // side runtime dispatch, not a build-time refusal), so the axis
17929 // reduces to the value-shape + `Copy` pin pair the peer
17930 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17931 // outer-`Option<Copy>` accessor pins already carry.
17932
17933 #[test]
17934 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17935 // Default-`false` form via the [`Dep::simple`] constructor —
17936 // the accessor projects the `false` bit the default-fill sets.
17937 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17938 // Default-`false` form via the [`Dep::git`] constructor — same
17939 // default fill; the accessor projects `false` regardless of the
17940 // `:fonte` arm.
17941 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17942 // Explicit-`true` form × plain-shorthand `:fonte` — the
17943 // canonical author-surface "this dep may be missing" shape.
17944 let plain_true = Dep {
17945 nome: "caixa-teia".to_string(),
17946 versao: "^0.1".to_string(),
17947 fonte: None,
17948 opcional: true,
17949 caracteristicas: Vec::new(),
17950 };
17951 assert!(plain_true.opcional());
17952 // Explicit-`true` form × explicit git-source — the accessor
17953 // projects the bit verbatim regardless of the `:fonte` arm.
17954 let git_true = Dep {
17955 nome: "caixa-teia".to_string(),
17956 versao: "^0.1".to_string(),
17957 fonte: Some(DepSource::Git {
17958 repo: "github:pleme-io/caixa-teia".to_string(),
17959 tag: Some("v0.1.0".to_string()),
17960 rev: None,
17961 branch: None,
17962 }),
17963 opcional: true,
17964 caracteristicas: Vec::new(),
17965 };
17966 assert!(git_true.opcional());
17967 // Explicit-`true` form × explicit path-source — the dev-only
17968 // local-filesystem arm the [`Dep`] docstring's third fixture
17969 // carries.
17970 let path_true = Dep {
17971 nome: "caixa-teia".to_string(),
17972 versao: "0.1.0".to_string(),
17973 fonte: Some(DepSource::Path {
17974 caminho: "../caixa-teia".to_string(),
17975 }),
17976 opcional: true,
17977 caracteristicas: Vec::new(),
17978 };
17979 assert!(path_true.opcional());
17980 }
17981
17982 #[test]
17983 fn dep_opcional_projects_bool_by_copy() {
17984 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17985 // (`bool: Copy`) — the accessor does not borrow `&self` past
17986 // the call (no lifetime on the return type), and calling the
17987 // accessor twice on the same [`Dep`] must yield discriminant-
17988 // equal values (idempotent, no side effects on `&self`). Peer
17989 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17990 // `max_restarts_projects_option_by_copy` (eba5211) /
17991 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17992 // outer-`Caixa` altitude — extended here to the outer-`Dep`
17993 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17994 // replaces the pointer-equality claim the sibling per-`Dep`
17995 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17996 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17997 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17998 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17999 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
18000 // the same discriminant, so the axis reduces to discriminant
18001 // equality).
18002 //
18003 // Pins against a future silent detour that returned a fresh
18004 // `&bool` reference (which would type-check but silently
18005 // introduce a borrow of `&self` past the call, collapsing the
18006 // load-bearing "no lifetime on the return type" `Copy`
18007 // projection the plain-`Copy`-scalar axis's `bool` shape
18008 // carries) or a stale-read side effect that flipped the outer
18009 // discriminant on successive calls.
18010 for opcional in [false, true] {
18011 let d = Dep {
18012 nome: "caixa-teia".to_string(),
18013 versao: "^0.1".to_string(),
18014 fonte: None,
18015 opcional,
18016 caracteristicas: Vec::new(),
18017 };
18018 let first = d.opcional();
18019 let second = d.opcional();
18020 assert_eq!(
18021 first, second,
18022 "Dep::opcional must be idempotent — two successive calls \
18023 on the same &self must return the same bool",
18024 );
18025 assert_eq!(
18026 first, opcional,
18027 "Dep::opcional must return :opcional verbatim by Copy — \
18028 got {first}, expected {opcional}",
18029 );
18030 assert_eq!(
18031 d.opcional(),
18032 d.opcional,
18033 "Dep::opcional accessor and self.opcional field access \
18034 must byte-equal — a bit-flip drift would silently split \
18035 the paired resolver-side drop-vs-error dispatch from \
18036 the storage-side default-fill the [`Dep::simple`] / \
18037 [`Dep::git`] constructor pair carries",
18038 );
18039 }
18040 }
18041
18042 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
18043
18044 #[test]
18045 fn sole_pin_returns_none_for_path_source() {
18046 // A path source carries no git-ref, so `sole_pin()` returns
18047 // `None` structurally — the sibling arm every git-fetching
18048 // consumer partitions off before reaching for a git-ref. Pins
18049 // the Path-arm branch of the accessor against a future silent
18050 // detour that treats a `Self::Path` as an unpinned-git source
18051 // and returns the wrong "no pin" signal (e.g. the empty string,
18052 // or a hard-coded `Some("HEAD")` matching the caixa-crd
18053 // path-arm `git_ref` fill).
18054 let s = DepSource::Path {
18055 caminho: "../local-caixa".to_string(),
18056 };
18057 assert_eq!(s.sole_pin(), None);
18058 }
18059
18060 #[test]
18061 fn sole_pin_returns_none_for_unpinned_git_source() {
18062 // The [`DepSource::default_github`] shorthand shape carries no
18063 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
18064 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
18065 // materializes when the author omits `:fonte` entirely, then
18066 // hands to `fetch_git` which raises `ResolveError::MissingPin`
18067 // on the `None` arm — the accessor's return matches the arm
18068 // the resolver's diagnostic keys off.
18069 let s = DepSource::default_github("pleme-io", "caixa-teia");
18070 assert_eq!(s.sole_pin(), None);
18071 }
18072
18073 #[test]
18074 fn sole_pin_returns_rev_when_only_rev_is_set() {
18075 let s = DepSource::Git {
18076 repo: "github:o/x".into(),
18077 tag: None,
18078 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
18079 branch: None,
18080 };
18081 assert_eq!(
18082 s.sole_pin(),
18083 Some("deadbeefcafebabe1234567890abcdef12345678")
18084 );
18085 }
18086
18087 #[test]
18088 fn sole_pin_returns_tag_when_only_tag_is_set() {
18089 let s = DepSource::Git {
18090 repo: "github:o/x".into(),
18091 tag: Some("v0.1.0".into()),
18092 rev: None,
18093 branch: None,
18094 };
18095 assert_eq!(s.sole_pin(), Some("v0.1.0"));
18096 }
18097
18098 #[test]
18099 fn sole_pin_returns_branch_when_only_branch_is_set() {
18100 let s = DepSource::Git {
18101 repo: "github:o/x".into(),
18102 tag: None,
18103 rev: None,
18104 branch: Some("main".into()),
18105 };
18106 assert_eq!(s.sole_pin(), Some("main"));
18107 }
18108
18109 #[test]
18110 fn sole_pin_precedence_rev_beats_tag_and_branch() {
18111 // Precedence: rev > tag > branch. Validate() rejects
18112 // multiple-pin shapes, but the accessor's precedence is defined
18113 // for pre-validate consumers (the resolver's `MissingPin`
18114 // diagnostic path, the caixa-crd round-trip's default `"main"`
18115 // fallback) and as defense-in-depth if the gate is ever
18116 // bypassed. Pins the same precedence caixa-resolver's
18117 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
18118 // inline.
18119 let s = DepSource::Git {
18120 repo: "github:o/x".into(),
18121 tag: Some("v1".into()),
18122 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
18123 branch: Some("main".into()),
18124 };
18125 assert_eq!(
18126 s.sole_pin(),
18127 Some("deadbeefcafebabe1234567890abcdef12345678")
18128 );
18129 }
18130
18131 #[test]
18132 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
18133 let s = DepSource::Git {
18134 repo: "github:o/x".into(),
18135 tag: Some("v1".into()),
18136 rev: None,
18137 branch: Some("main".into()),
18138 };
18139 assert_eq!(s.sole_pin(), Some("v1"));
18140 }
18141
18142 #[test]
18143 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
18144 // Fail-before-pass-after byte-parity pin: the substrate accessor
18145 // must return byte-identical to the inline
18146 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
18147 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
18148 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
18149 // time if the accessor's precedence silently drifts from the
18150 // consumer-side cascade — the exact drift this lift converges
18151 // to one substrate primitive to close structurally.
18152 //
18153 // Iterates through the 2^3 = 8 combinations of (tag, rev,
18154 // branch) each-either-`None`-or-`Some`, so every arm of the
18155 // precedence cascade lands under the pin. `validate()` refuses
18156 // the 4 multi-pin combinations, but the accessor's return is
18157 // defined on all 8.
18158 let vals = [Some("R".to_string()), None];
18159 for tag in &vals {
18160 for rev in &vals {
18161 for branch in &vals {
18162 let s = DepSource::Git {
18163 repo: "github:o/x".into(),
18164 tag: tag.clone(),
18165 rev: rev.clone(),
18166 branch: branch.clone(),
18167 };
18168 // The exact inline cascade the two pre-lift
18169 // consumer sites hand-rolled, byte-for-byte.
18170 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
18171 assert_eq!(
18172 s.sole_pin(),
18173 expected,
18174 "sole_pin() must byte-equal \
18175 rev.or(tag).or(branch) for \
18176 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
18177 a drift would silently split caixa-resolver's \
18178 fetch_git checkout target from caixa-crd's \
18179 dep_into_ref git_ref fill",
18180 );
18181 }
18182 }
18183 }
18184 }
18185
18186 // Fail-before-pass-after pins on the eleven
18187 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
18188 // constructors folded from the [`DepSource::validate_caminho`]
18189 // wire-up sites. Each pins the generated ctor's output to the
18190 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
18191 // any wrapper-side lowercase / trim / re-order / silent-field-swap
18192 // regression on the two-field `{ nome: nome.to_string(), caminho:
18193 // caminho.to_string() }` construction surfaces here rather than at
18194 // a downstream diagnostic-shape mismatch. Peer of the sibling
18195 // `empty_child_version_ctor_matches_struct_literal_wrap` /
18196 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
18197 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
18198 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
18199 // pins on the peer `SupervisorError` / `AplicacaoError` /
18200 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
18201
18202 #[test]
18203 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
18204 assert_eq!(
18205 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
18206 DepError::FonteCaminhoAbsolute {
18207 nome: "caixa-teia".to_string(),
18208 caminho: "/home/me/work/caixa-teia".to_string(),
18209 },
18210 "generated fonte_caminho_absolute ctor must produce byte-equal \
18211 DepError to the open-coded struct-literal wrap on the same \
18212 (&str, &str) fixture",
18213 );
18214 }
18215
18216 #[test]
18217 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
18218 assert_eq!(
18219 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
18220 DepError::FonteCaminhoTildeExpansion {
18221 nome: "caixa-teia".to_string(),
18222 caminho: "~/work/caixa-teia".to_string(),
18223 },
18224 );
18225 }
18226
18227 #[test]
18228 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
18229 assert_eq!(
18230 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
18231 DepError::FonteCaminhoVarExpansion {
18232 nome: "caixa-teia".to_string(),
18233 caminho: "$HOME/work/caixa-teia".to_string(),
18234 },
18235 );
18236 }
18237
18238 #[test]
18239 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
18240 assert_eq!(
18241 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
18242 DepError::FonteCaminhoLeadingWhitespace {
18243 nome: "caixa-teia".to_string(),
18244 caminho: " ../caixa-teia".to_string(),
18245 },
18246 );
18247 }
18248
18249 #[test]
18250 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
18251 assert_eq!(
18252 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
18253 DepError::FonteCaminhoLeadingHyphen {
18254 nome: "caixa-teia".to_string(),
18255 caminho: "-rf".to_string(),
18256 },
18257 );
18258 }
18259
18260 #[test]
18261 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
18262 assert_eq!(
18263 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
18264 DepError::FonteCaminhoBackslash {
18265 nome: "caixa-teia".to_string(),
18266 caminho: "..\\caixa-teia".to_string(),
18267 },
18268 );
18269 }
18270
18271 #[test]
18272 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
18273 assert_eq!(
18274 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
18275 DepError::FonteCaminhoShellPipe {
18276 nome: "caixa-teia".to_string(),
18277 caminho: "../caixa-teia|evil".to_string(),
18278 },
18279 );
18280 }
18281
18282 #[test]
18283 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
18284 assert_eq!(
18285 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
18286 DepError::FonteCaminhoShellSemicolon {
18287 nome: "caixa-teia".to_string(),
18288 caminho: "../caixa-teia;evil".to_string(),
18289 },
18290 );
18291 }
18292
18293 #[test]
18294 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
18295 assert_eq!(
18296 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
18297 DepError::FonteCaminhoShellBackground {
18298 nome: "caixa-teia".to_string(),
18299 caminho: "../caixa-teia&".to_string(),
18300 },
18301 );
18302 }
18303
18304 #[test]
18305 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
18306 assert_eq!(
18307 DepError::fonte_caminho_shell_command_substitution(
18308 "caixa-teia",
18309 "../caixa-teia`whoami`",
18310 ),
18311 DepError::FonteCaminhoShellCommandSubstitution {
18312 nome: "caixa-teia".to_string(),
18313 caminho: "../caixa-teia`whoami`".to_string(),
18314 },
18315 );
18316 }
18317
18318 #[test]
18319 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
18320 assert_eq!(
18321 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
18322 DepError::FonteCaminhoTrailingSlash {
18323 nome: "caixa-teia".to_string(),
18324 caminho: "../caixa-teia/".to_string(),
18325 },
18326 );
18327 }
18328
18329 #[test]
18330 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
18331 // Cross-axis pin: sweep the two constructor input axes
18332 // (`nome: &str`, `caminho: &str`) through a non-default fixture
18333 // pair against every generated arm in the
18334 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
18335 // / trim / truncate / re-order on the two-field
18336 // `{ nome, caminho }` construction — or a silent field swap
18337 // between the two axes at codegen time — surfaces here rather
18338 // than at a downstream diagnostic-shape mismatch. Peer of the
18339 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
18340 // to_string` cross-axis routing pin on the peer
18341 // `SupervisorError` envelope, extended here onto the
18342 // `DepError` `{ nome: String, caminho: String }` envelope so
18343 // every substrate-primitive ctor family in caixa-core
18344 // guarantees each `&str`-field construction routes the
18345 // caller's `&str` verbatim through `.to_string()`.
18346 let nome = "sibling-teia";
18347 let caminho = "../workspace/sibling";
18348 let cases: [(DepError, DepError); 11] = [
18349 (
18350 DepError::fonte_caminho_absolute(nome, caminho),
18351 DepError::FonteCaminhoAbsolute {
18352 nome: nome.to_string(),
18353 caminho: caminho.to_string(),
18354 },
18355 ),
18356 (
18357 DepError::fonte_caminho_tilde_expansion(nome, caminho),
18358 DepError::FonteCaminhoTildeExpansion {
18359 nome: nome.to_string(),
18360 caminho: caminho.to_string(),
18361 },
18362 ),
18363 (
18364 DepError::fonte_caminho_var_expansion(nome, caminho),
18365 DepError::FonteCaminhoVarExpansion {
18366 nome: nome.to_string(),
18367 caminho: caminho.to_string(),
18368 },
18369 ),
18370 (
18371 DepError::fonte_caminho_leading_whitespace(nome, caminho),
18372 DepError::FonteCaminhoLeadingWhitespace {
18373 nome: nome.to_string(),
18374 caminho: caminho.to_string(),
18375 },
18376 ),
18377 (
18378 DepError::fonte_caminho_leading_hyphen(nome, caminho),
18379 DepError::FonteCaminhoLeadingHyphen {
18380 nome: nome.to_string(),
18381 caminho: caminho.to_string(),
18382 },
18383 ),
18384 (
18385 DepError::fonte_caminho_backslash(nome, caminho),
18386 DepError::FonteCaminhoBackslash {
18387 nome: nome.to_string(),
18388 caminho: caminho.to_string(),
18389 },
18390 ),
18391 (
18392 DepError::fonte_caminho_shell_pipe(nome, caminho),
18393 DepError::FonteCaminhoShellPipe {
18394 nome: nome.to_string(),
18395 caminho: caminho.to_string(),
18396 },
18397 ),
18398 (
18399 DepError::fonte_caminho_shell_semicolon(nome, caminho),
18400 DepError::FonteCaminhoShellSemicolon {
18401 nome: nome.to_string(),
18402 caminho: caminho.to_string(),
18403 },
18404 ),
18405 (
18406 DepError::fonte_caminho_shell_background(nome, caminho),
18407 DepError::FonteCaminhoShellBackground {
18408 nome: nome.to_string(),
18409 caminho: caminho.to_string(),
18410 },
18411 ),
18412 (
18413 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
18414 DepError::FonteCaminhoShellCommandSubstitution {
18415 nome: nome.to_string(),
18416 caminho: caminho.to_string(),
18417 },
18418 ),
18419 (
18420 DepError::fonte_caminho_trailing_slash(nome, caminho),
18421 DepError::FonteCaminhoTrailingSlash {
18422 nome: nome.to_string(),
18423 caminho: caminho.to_string(),
18424 },
18425 ),
18426 ];
18427 for (via_ctor, via_struct_literal) in cases {
18428 assert_eq!(
18429 via_ctor, via_struct_literal,
18430 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
18431 through `.to_string()` in declared field order — a field-swap or \
18432 silent-conversion regression surfaces here rather than at a \
18433 downstream diagnostic-shape mismatch",
18434 );
18435 }
18436 }
18437
18438 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
18439 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
18440 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
18441 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
18442 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
18443
18444 #[test]
18445 fn versao_empty_ctor_matches_struct_literal_wrap() {
18446 assert_eq!(
18447 DepError::versao_empty("caixa-teia"),
18448 DepError::VersaoEmpty {
18449 nome: "caixa-teia".to_string(),
18450 },
18451 );
18452 }
18453
18454 #[test]
18455 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
18456 assert_eq!(
18457 DepError::fonte_repo_empty("caixa-teia"),
18458 DepError::FonteRepoEmpty {
18459 nome: "caixa-teia".to_string(),
18460 },
18461 );
18462 }
18463
18464 #[test]
18465 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
18466 assert_eq!(
18467 DepError::fonte_pin_missing("caixa-teia"),
18468 DepError::FontePinMissing {
18469 nome: "caixa-teia".to_string(),
18470 },
18471 );
18472 }
18473
18474 #[test]
18475 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
18476 assert_eq!(
18477 DepError::fonte_caminho_empty("caixa-teia"),
18478 DepError::FonteCaminhoEmpty {
18479 nome: "caixa-teia".to_string(),
18480 },
18481 );
18482 }
18483
18484 #[test]
18485 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
18486 assert_eq!(
18487 DepError::caracteristica_empty("caixa-teia"),
18488 DepError::CaracteristicaEmpty {
18489 nome: "caixa-teia".to_string(),
18490 },
18491 );
18492 }
18493
18494 #[test]
18495 fn dep_nome_only_ctors_route_nome_through_to_string() {
18496 // Cross-axis routing pin: sweep the single constructor input
18497 // axis (`nome: &str`) through a non-default fixture against
18498 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
18499 // any wrapper-side lowercase / trim / truncate at codegen time
18500 // — or a silent field re-name away from the canonical `nome`
18501 // axis on any one variant — surfaces here rather than at a
18502 // downstream diagnostic-shape mismatch. Peer of the sibling
18503 // `fonte_caminho_ctors_route_nome_and_caminho_through_
18504 // to_string` cross-axis routing pin on the same envelope's
18505 // two-slot family (f85f145) and of the peer
18506 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
18507 // pin on the `SupervisorError` single-slot family (db09650).
18508 let nome = "sibling-teia";
18509 let cases: [(DepError, DepError); 5] = [
18510 (
18511 DepError::versao_empty(nome),
18512 DepError::VersaoEmpty {
18513 nome: nome.to_string(),
18514 },
18515 ),
18516 (
18517 DepError::fonte_repo_empty(nome),
18518 DepError::FonteRepoEmpty {
18519 nome: nome.to_string(),
18520 },
18521 ),
18522 (
18523 DepError::fonte_pin_missing(nome),
18524 DepError::FontePinMissing {
18525 nome: nome.to_string(),
18526 },
18527 ),
18528 (
18529 DepError::fonte_caminho_empty(nome),
18530 DepError::FonteCaminhoEmpty {
18531 nome: nome.to_string(),
18532 },
18533 ),
18534 (
18535 DepError::caracteristica_empty(nome),
18536 DepError::CaracteristicaEmpty {
18537 nome: nome.to_string(),
18538 },
18539 ),
18540 ];
18541 for (via_ctor, via_struct_literal) in cases {
18542 assert_eq!(
18543 via_ctor, via_struct_literal,
18544 "dep_nome_only_ctors!-generated ctor must route `nome` \
18545 through `.to_string()` onto the canonical `nome` field \
18546 — a field-rename or silent-conversion regression surfaces \
18547 here rather than at a downstream diagnostic-shape mismatch",
18548 );
18549 }
18550 }
18551
18552 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
18553 // &'static str }` two-slot envelope on `DepError`, strict
18554 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
18555 // same envelope's `{ nome: String }` one-slot shape and of the
18556 // peer `supervisor_caixa_only_ctors!` (db09650) on the
18557 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
18558
18559 #[test]
18560 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
18561 assert_eq!(
18562 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
18563 DepError::DuplicateNome {
18564 nome: "caixa-teia".to_string(),
18565 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18566 },
18567 "generated duplicate_nome ctor must produce byte-equal \
18568 `DepError::DuplicateNome` to the pre-lift struct-literal \
18569 wrap on the same scalar fixtures",
18570 );
18571 }
18572
18573 #[test]
18574 fn dep_is_self_ctor_matches_struct_literal_wrap() {
18575 assert_eq!(
18576 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18577 DepError::DepIsSelf {
18578 nome: "orquestra".to_string(),
18579 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18580 },
18581 "generated dep_is_self ctor must produce byte-equal \
18582 `DepError::DepIsSelf` to the pre-lift struct-literal \
18583 wrap on the same scalar fixtures",
18584 );
18585 }
18586
18587 #[test]
18588 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
18589 // Cross-axis routing pin: sweep the two constructor input axes
18590 // (`nome: &str`, `list: &'static str`) through non-default
18591 // fixtures against every generated arm in the
18592 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
18593 // lowercase / trim / truncate at codegen time — or a silent
18594 // field re-name away from the canonical `nome` / `list` axes
18595 // on any one variant, or a `list` axis silently rerouted
18596 // through `.to_string()` instead of passed as `&'static str`
18597 // verbatim — surfaces here rather than at a downstream
18598 // diagnostic-shape mismatch. Peer of the sibling
18599 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18600 // (792aa92) on the same envelope's one-slot family, and of the
18601 // peer
18602 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
18603 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
18604 // two-slot `{ caixa: String, reason: String }` shape.
18605 let nome = "sibling-teia";
18606 let cases: [(DepError, DepError); 4] = [
18607 (
18608 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18609 DepError::DuplicateNome {
18610 nome: nome.to_string(),
18611 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18612 },
18613 ),
18614 (
18615 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18616 DepError::DuplicateNome {
18617 nome: nome.to_string(),
18618 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18619 },
18620 ),
18621 (
18622 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18623 DepError::DepIsSelf {
18624 nome: nome.to_string(),
18625 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18626 },
18627 ),
18628 (
18629 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18630 DepError::DepIsSelf {
18631 nome: nome.to_string(),
18632 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18633 },
18634 ),
18635 ];
18636 for (via_ctor, via_struct_literal) in cases {
18637 assert_eq!(
18638 via_ctor, via_struct_literal,
18639 "dep_nome_list_ctors!-generated ctor must route `nome` \
18640 through `.to_string()` onto the canonical `nome` field \
18641 and pass `list` verbatim onto the canonical `&'static str` \
18642 `list` field — a field-rename, silent-conversion, or \
18643 axis-swap regression surfaces here rather than at a \
18644 downstream diagnostic-shape mismatch",
18645 );
18646 }
18647 }
18648
18649 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18650 // value: String, reason: String }` four-slot envelope on
18651 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18652 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18653 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18654 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
18655 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
18656 // envelope. Single-variant lift closing the last open-coded ctor
18657 // site on the `:fonte (:tipo git …)` value-shape trajectory.
18658
18659 #[test]
18660 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18661 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18662 // ctor: sweep both wire-up-shape arms (the refname-pin arm
18663 // routing `":tag"` / `":branch"` value through
18664 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18665 // routing `":rev"` through [`crate::render::is_git_oid`]) and
18666 // assert byte-equal `PartialEq` against the pre-lift
18667 // struct-literal, so any wrapper-side field-rename /
18668 // silent-conversion regression surfaces here rather than at a
18669 // downstream diagnostic-shape mismatch. Peer of the sibling
18670 // per-envelope byte-equal ctor pins
18671 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18672 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18673 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18674 assert_eq!(
18675 DepError::fonte_pin_shape(
18676 "caixa-teia",
18677 ":tag",
18678 "v0.1.0 ",
18679 "trailing whitespace".to_string(),
18680 ),
18681 DepError::FontePinShape {
18682 nome: "caixa-teia".to_string(),
18683 pin: ":tag".to_string(),
18684 value: "v0.1.0 ".to_string(),
18685 reason: "trailing whitespace".to_string(),
18686 },
18687 "fonte_pin_shape ctor must produce byte-equal \
18688 `DepError::FontePinShape` to the pre-lift struct-literal \
18689 wrap on a refname-pin (`:tag` / `:branch`) fixture",
18690 );
18691 assert_eq!(
18692 DepError::fonte_pin_shape(
18693 "caixa-teia",
18694 ":rev",
18695 "DEADBEEF",
18696 "abbreviated OID rejected".to_string(),
18697 ),
18698 DepError::FontePinShape {
18699 nome: "caixa-teia".to_string(),
18700 pin: ":rev".to_string(),
18701 value: "DEADBEEF".to_string(),
18702 reason: "abbreviated OID rejected".to_string(),
18703 },
18704 "fonte_pin_shape ctor must produce byte-equal \
18705 `DepError::FontePinShape` to the pre-lift struct-literal \
18706 wrap on a hex-OID-pin (`:rev`) fixture",
18707 );
18708 }
18709
18710 #[test]
18711 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18712 // Cross-axis routing pin: sweep every one of the four
18713 // constructor input axes (`nome: &str`, `pin: &str`,
18714 // `value: &str`, `reason: String`) through non-default
18715 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18716 // any wrapper-side lowercase / trim / truncate at codegen time
18717 // — or a silent field re-name / axis-swap on any one of the
18718 // four fields, or a `reason` axis silently routed through
18719 // `.to_string()` instead of forwarded owned — surfaces here
18720 // rather than at a downstream diagnostic-shape mismatch. Peer
18721 // of the sibling
18722 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18723 // (792aa92) and
18724 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18725 // pin (6f5e0cd) on the same envelope's one- and two-slot
18726 // families. Distinct-per-axis fixtures rule out any two-axis
18727 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18728 // etc.) that would still pass a same-fixture-per-axis pin.
18729 let nome = "sibling-teia";
18730 let pin = ":branch";
18731 let value = "feature/bar";
18732 let reason = "embedded space".to_string();
18733 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18734 let via_struct_literal = DepError::FontePinShape {
18735 nome: nome.to_string(),
18736 pin: pin.to_string(),
18737 value: value.to_string(),
18738 reason: reason.clone(),
18739 };
18740 assert_eq!(
18741 via_ctor, via_struct_literal,
18742 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18743 through `.to_string()` onto their canonical fields and \
18744 forward `reason` owned onto the canonical `reason` field \
18745 — a field-rename, silent-conversion, or axis-swap \
18746 regression surfaces here rather than at a downstream \
18747 diagnostic-shape mismatch",
18748 );
18749 let DepError::FontePinShape {
18750 nome: n,
18751 pin: p,
18752 value: v,
18753 reason: r,
18754 } = via_ctor
18755 else {
18756 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18757 };
18758 assert_eq!(n, nome);
18759 assert_eq!(p, pin);
18760 assert_eq!(v, value);
18761 assert_eq!(r, reason);
18762 }
18763
18764 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18765 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18766 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18767 // the same envelope's `{ nome: String, caminho: String }` two-slot
18768 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18769 // same envelope's `{ nome: String }` one-slot shape.
18770
18771 #[test]
18772 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18773 assert_eq!(
18774 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18775 DepError::FonteCaminhoControlChar {
18776 nome: "caixa-teia".to_string(),
18777 caminho: "../caixa-teia\x00foo".to_string(),
18778 byte: 0x00,
18779 },
18780 );
18781 }
18782
18783 #[test]
18784 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18785 assert_eq!(
18786 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18787 DepError::FonteCaminhoShellRedirection {
18788 nome: "caixa-teia".to_string(),
18789 caminho: "../caixa-teia>log".to_string(),
18790 byte: b'>',
18791 },
18792 );
18793 }
18794
18795 #[test]
18796 #[allow(
18797 clippy::too_many_lines,
18798 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18799 byte-classification arm on the {nome,caminho,byte} envelope; \
18800 the linear per-variant repetition is exactly what the sweep \
18801 is pinning — a helper macro would hide the shape the fold is \
18802 keying on"
18803 )]
18804 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18805 // Cross-axis routing pin: sweep the three constructor input axes
18806 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18807 // non-default fixture triple against every generated arm in the
18808 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18809 // lowercase / trim / truncate on the two `&str` axes — a silent
18810 // field swap between `nome` and `caminho`, or a silent
18811 // re-classification of the offending byte — surfaces here rather
18812 // than at a downstream diagnostic-shape mismatch. Peer of the
18813 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18814 // to_string` cross-axis routing pin on the same envelope's
18815 // two-slot family (f85f145) and of the sibling
18816 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18817 // same envelope's one-slot family (792aa92), extended here onto
18818 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18819 // envelope so every substrate-primitive ctor family in
18820 // caixa-core's `DepError` envelope guarantees each field routes
18821 // the caller's value verbatim through `.to_string()` (or byte-
18822 // identity for `byte: u8`) in declared field order.
18823 let nome = "sibling-teia";
18824 let caminho = "../workspace/sibling";
18825 let byte = 0x2A_u8;
18826 let cases: [(DepError, DepError); 12] = [
18827 (
18828 DepError::fonte_caminho_control_char(nome, caminho, byte),
18829 DepError::FonteCaminhoControlChar {
18830 nome: nome.to_string(),
18831 caminho: caminho.to_string(),
18832 byte,
18833 },
18834 ),
18835 (
18836 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18837 DepError::FonteCaminhoShellRedirection {
18838 nome: nome.to_string(),
18839 caminho: caminho.to_string(),
18840 byte,
18841 },
18842 ),
18843 (
18844 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18845 DepError::FonteCaminhoShellGlob {
18846 nome: nome.to_string(),
18847 caminho: caminho.to_string(),
18848 byte,
18849 },
18850 ),
18851 (
18852 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18853 DepError::FonteCaminhoShellSubshellGrouping {
18854 nome: nome.to_string(),
18855 caminho: caminho.to_string(),
18856 byte,
18857 },
18858 ),
18859 (
18860 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18861 DepError::FonteCaminhoShellBraceExpansion {
18862 nome: nome.to_string(),
18863 caminho: caminho.to_string(),
18864 byte,
18865 },
18866 ),
18867 (
18868 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18869 DepError::FonteCaminhoShellBracketExpansion {
18870 nome: nome.to_string(),
18871 caminho: caminho.to_string(),
18872 byte,
18873 },
18874 ),
18875 (
18876 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18877 DepError::FonteCaminhoShellQuoteGrouping {
18878 nome: nome.to_string(),
18879 caminho: caminho.to_string(),
18880 byte,
18881 },
18882 ),
18883 (
18884 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18885 DepError::FonteCaminhoShellComment {
18886 nome: nome.to_string(),
18887 caminho: caminho.to_string(),
18888 byte,
18889 },
18890 ),
18891 (
18892 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18893 DepError::FonteCaminhoUrlPercentEncoding {
18894 nome: nome.to_string(),
18895 caminho: caminho.to_string(),
18896 byte,
18897 },
18898 ),
18899 (
18900 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18901 DepError::FonteCaminhoShellVariableExpansion {
18902 nome: nome.to_string(),
18903 caminho: caminho.to_string(),
18904 byte,
18905 },
18906 ),
18907 (
18908 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18909 DepError::FonteCaminhoShellHistoryExpansion {
18910 nome: nome.to_string(),
18911 caminho: caminho.to_string(),
18912 byte,
18913 },
18914 ),
18915 (
18916 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18917 DepError::FonteCaminhoShellHistorySubstitution {
18918 nome: nome.to_string(),
18919 caminho: caminho.to_string(),
18920 byte,
18921 },
18922 ),
18923 ];
18924 for (via_ctor, via_struct_literal) in cases {
18925 assert_eq!(
18926 via_ctor, via_struct_literal,
18927 "fonte_caminho_byte_ctors!-generated ctor must route \
18928 (nome, caminho, byte) through `.to_string()` / byte-\
18929 identity in declared field order — a field-swap or \
18930 silent-conversion regression surfaces here rather than \
18931 at a downstream diagnostic-shape mismatch",
18932 );
18933 }
18934 }
18935
18936 #[test]
18937 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18938 // Fail-before-pass-after byte-parity pin on the lifted
18939 // `impl AsRef<str> for DepList` — asserts the standard-
18940 // library trait impl and the substrate-primitive
18941 // [`super::DepList::as_str`] `pub const fn` accessor resolve
18942 // to the same `&str` per instance across the two-arm closed
18943 // set, so any future silent detour that routes the impl
18944 // through a divergent projection (a per-arm inline
18945 // `match self { DepList::Prod => ":deps", … }` re-inlining
18946 // that opens a compile-time link to the un-lifted arm-literal,
18947 // a swap onto a second projection axis) trips at caixa-core
18948 // test time under `PartialEq` rather than at a downstream
18949 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18950 // every one of the two arms [`super::DepList::ALL`] carries
18951 // so no arm's projection is covered only by the sibling
18952 // `Display` path. Peer of the sibling
18953 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18954 // (1723611) on the top-level dialect-classification closed-
18955 // set typed enum, and the peer
18956 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18957 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18958 // typed enum — the pins together close the substrate
18959 // primitive's `AsRef<str>` projection axis onto the seventh
18960 // (and last unlifted) closed-set typed enum on the caixa
18961 // surface.
18962 for &list in super::DepList::ALL {
18963 assert_eq!(
18964 <super::DepList as AsRef<str>>::as_ref(&list),
18965 list.as_str(),
18966 "AsRef<str> impl on DepList::{list:?} must byte-equal \
18967 DepList::as_str on the same instance — divergence \
18968 signals a silent detour off the substrate-primitive \
18969 accessor"
18970 );
18971 }
18972 }
18973
18974 #[test]
18975 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18976 // Fail-before-pass-after byte-parity pin on the three-path
18977 // convergence discipline the [`super::DepList`] two-list
18978 // dep-graph closed-set typed enum now carries on the `&str`-
18979 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18980 // newly lifted impl), `format!("{v}")` (the pre-existing
18981 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18982 // primitive `pub const fn` accessor both trait impls delegate
18983 // through) must resolve to the same byte-string on every
18984 // instance across the two-arm closed set. Refuses any future
18985 // divergence between the two trait impls (a stray
18986 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18987 // rather than delegating through the shared accessor; a
18988 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18989 // literal cascade) that would silently split the two
18990 // projection paths of the same closed-set typed enum. Mirrors
18991 // the sibling three-path-convergence discipline the peer
18992 // [`crate::CaixaDialeto`] typed enum carries
18993 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18994 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18995 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18996 // d8136db), the peer [`crate::CaixaKind`] triple
18997 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18998 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18999 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
19000 // 16d5c7e).
19001 for &list in super::DepList::ALL {
19002 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
19003 let via_display: String = format!("{list}");
19004 let via_accessor: &str = list.as_str();
19005 assert_eq!(via_as_ref, via_accessor);
19006 assert_eq!(via_display, via_accessor);
19007 assert_eq!(via_as_ref, via_display.as_str());
19008 }
19009 }
19010
19011 #[test]
19012 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
19013 // Fail-before-pass-after byte-parity pin on the newly lifted
19014 // `impl TryFrom<&str> for DepList` — asserts the standard-
19015 // library trait impl and the substrate-primitive
19016 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
19017 // to the same two-arm accept-set across every arm the
19018 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
19019 // the sibling
19020 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
19021 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
19022 // and the 12 other substrate-wide trait-idiomatic reverse-
19023 // projection routes-through pins — closes the campaign's
19024 // completeness gap on the two-list dep-graph closed-set enum.
19025 for &list in super::DepList::ALL {
19026 let wire = list.as_str();
19027 assert_eq!(
19028 <super::DepList as TryFrom<&str>>::try_from(wire),
19029 Ok(list),
19030 "TryFrom<&str> impl on DepList must round-trip \
19031 DepList::{list:?}.as_str() = {wire:?} back to \
19032 Ok(DepList::{list:?}) — divergence from \
19033 DepList::from_wire signals a silent detour off the \
19034 substrate-primitive accessor"
19035 );
19036 assert_eq!(
19037 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
19038 super::DepList::from_wire(wire),
19039 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
19040 DepList::from_wire on the same input"
19041 );
19042 }
19043 }
19044
19045 #[test]
19046 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
19047 // Rejection witness on the `impl TryFrom<&str> for DepList` —
19048 // sweeps candidate byte-strings outside the two-arm accept-set
19049 // the sibling [`super::DepList::as_str`] emits (`:deps` /
19050 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
19051 // future accidental widening of the trait impl's accept-set (a
19052 // stray case-fold path, a silent inclusion of a rebrand alias
19053 // like `":packages"`, an English rebrand `":dev-deps"` in
19054 // reverse arm-order that would silently swap the two arms) trips
19055 // at caixa-core test time. Peer of the sibling
19056 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
19057 // (5b828ed) rejection witness.
19058 let rejected: &[&str] = &[
19059 "",
19060 " ",
19061 "\t",
19062 "\n",
19063 ":deps ",
19064 " :deps",
19065 ":DEPS",
19066 ":Deps",
19067 ":Deps-Dev",
19068 ":deps_dev",
19069 ":deps-development",
19070 ":dev-deps",
19071 ":packages",
19072 ":packages-dev",
19073 "deps",
19074 "deps-dev",
19075 "Prod",
19076 "Dev",
19077 "prod",
19078 "dev",
19079 "\":deps\"",
19080 "\":deps-dev\"",
19081 ":deps\n",
19082 ":deps-dev\n",
19083 ];
19084 for &input in rejected {
19085 assert_eq!(
19086 <super::DepList as TryFrom<&str>>::try_from(input),
19087 Err(()),
19088 "TryFrom<&str> impl on DepList must reject unknown \
19089 byte-string {input:?} — divergence from \
19090 DepList::from_wire on the same input signals a silent \
19091 accept-set widening past the two lifted \
19092 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
19093 );
19094 assert_eq!(
19095 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
19096 super::DepList::from_wire(input),
19097 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
19098 DepList::from_wire on the same input — divergence signals \
19099 the two reverse-projection paths have drifted onto \
19100 different accept-sets"
19101 );
19102 }
19103 }
19104
19105 #[test]
19106 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
19107 // Fail-before-pass-after byte-parity pin on the newly lifted
19108 // `impl From<DepList> for &'static str` — asserts the standard-
19109 // library trait impl and the substrate-primitive
19110 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19111 // the same two-arm emit-set across every arm the exhaustive
19112 // [`super::DepList::ALL`] slice enumerates. Materializes the
19113 // `<&'static str as From<DepList>>::from` output in a
19114 // `const`-shape binding to make the `'static` lifetime promise
19115 // a build-time invariant — a future accidental downgrade of
19116 // either arm to a non-`&'static str` (a `String::leak()`-
19117 // produced return, a `Box::leak`-cast) trips at caixa-core
19118 // build time rather than at a downstream `'static`-bound
19119 // consumer. Peer of the sibling
19120 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
19121 // (523157d) and the 13 other substrate-wide forward-projection
19122 // routes-through pins.
19123 const PROD: &str = super::DepList::Prod.as_str();
19124 const DEV: &str = super::DepList::Dev.as_str();
19125 for &list in super::DepList::ALL {
19126 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
19127 let via_method: &'static str = list.as_str();
19128 assert_eq!(
19129 via_trait, via_method,
19130 "From<DepList> for &'static str impl must round-trip \
19131 DepList::{list:?} to the same lifted \
19132 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19133 DepList::as_str returns — divergence signals a silent \
19134 detour off the substrate-primitive accessor"
19135 );
19136 let via_into: &'static str = list.into();
19137 assert_eq!(
19138 via_into, via_method,
19139 "Into<&'static str>::into on DepList::{list:?} must \
19140 byte-equal DepList::as_str on the same input — the \
19141 blanket-derived Into shape must resolve to the same \
19142 as_str dispatch as the explicit From impl"
19143 );
19144 }
19145 assert_eq!(
19146 [PROD, DEV],
19147 [
19148 crate::render::DEP_AUTHOR_KEY_DEPS,
19149 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19150 ],
19151 "const-context DepList::as_str must resolve to the two lifted \
19152 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
19153 of either arm to a non-const or non-static byte-string breaks \
19154 the `&'static str`-lifetime promise the paired \
19155 From<DepList> for &'static str impl carries by construction"
19156 );
19157 }
19158
19159 #[test]
19160 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
19161 // Cross-axis partition pin: the paired trait-idiomatic
19162 // `From<DepList> for &'static str` forward projection and the
19163 // method-named [`super::DepList::as_str`] forward projection
19164 // must resolve identically on every arm, locking the two paths
19165 // together so any future detour trips at caixa-core test time.
19166 // Then a round-trip witness: every arm's forward `From` output
19167 // re-parses through the paired trait-idiomatic reverse
19168 // `TryFrom<&str>` back to the original variant, closing the
19169 // two-way `DepList ↔ &'static str` round-trip on the trait-
19170 // idiomatic axis pair, mirroring the pre-existing method-named
19171 // `as_str` + `from_wire` round-trip. Peer of the sibling
19172 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
19173 // (523157d).
19174 for &list in super::DepList::ALL {
19175 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
19176 let via_method: &'static str = list.as_str();
19177 assert_eq!(
19178 via_trait, via_method,
19179 "From<DepList> for &'static str and DepList::as_str must \
19180 resolve identically on DepList::{list:?} — divergence \
19181 signals the two forward-projection paths have drifted \
19182 onto different emit-sets"
19183 );
19184 }
19185 for &list in super::DepList::ALL {
19186 let emitted: &'static str = list.into();
19187 let re_parsed: Result<super::DepList, ()> =
19188 <super::DepList as TryFrom<&str>>::try_from(emitted);
19189 assert_eq!(
19190 re_parsed,
19191 Ok(list),
19192 "trait-idiomatic axis pair must round-trip \
19193 DepList::{list:?} through `.into::<&'static str>()` and \
19194 back through `TryFrom<&str>` — a break signals the \
19195 forward-emit and reverse-parse axes have drifted onto \
19196 different vocabularies"
19197 );
19198 }
19199 }
19200
19201 #[test]
19202 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
19203 // Fail-before-pass-after byte-parity pin on the newly lifted
19204 // `impl From<&DepList> for &'static str` — asserts the borrowed-
19205 // input standard-library trait impl and the substrate-primitive
19206 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19207 // the same two-arm emit-set across every arm the exhaustive
19208 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
19209 // does not auto-derive the borrowed-input sibling from a paired
19210 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
19211 // U: From<T>` blanket in `core`), so the borrowed-input axis is
19212 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
19213 // shape over [`super::DepList::ALL`] (whose iterator yields
19214 // `&DepList`, not `DepList`) reaches through this impl and no
19215 // other — the paired owned-input [`From<DepList>`] impl requires
19216 // an explicit `.copied()` / dereference before the trait fires.
19217 // Materializes the `<&'static str as From<&DepList>>::from`
19218 // output in a `const`-shape binding to make the `'static`
19219 // lifetime promise a build-time invariant.
19220 const PROD: &str = super::DepList::Prod.as_str();
19221 const DEV: &str = super::DepList::Dev.as_str();
19222 for list in super::DepList::ALL {
19223 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
19224 let via_method: &'static str = list.as_str();
19225 assert_eq!(
19226 via_trait, via_method,
19227 "From<&DepList> for &'static str impl must round-trip \
19228 &DepList::{list:?} to the same lifted \
19229 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19230 DepList::as_str returns — divergence signals a silent \
19231 detour off the substrate-primitive accessor"
19232 );
19233 let via_into: &'static str = list.into();
19234 assert_eq!(
19235 via_into, via_method,
19236 "Into<&'static str>::into on &DepList::{list:?} must \
19237 byte-equal DepList::as_str on the same input — the \
19238 blanket-derived Into shape must resolve to the same \
19239 as_str dispatch as the explicit From impl"
19240 );
19241 }
19242 assert_eq!(
19243 [PROD, DEV],
19244 [
19245 crate::render::DEP_AUTHOR_KEY_DEPS,
19246 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19247 ],
19248 "const-context DepList::as_str must resolve to the two lifted \
19249 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
19250 From<&DepList> for &'static str impl inherits its `'static` \
19251 lifetime promise from the same accessor the owned-input \
19252 sibling routes through"
19253 );
19254 }
19255
19256 #[test]
19257 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
19258 // Cross-axis partition pin: the paired trait-idiomatic
19259 // owned-input `From<DepList> for &'static str` (523157d
19260 // campaign-shape) and borrowed-input `From<&DepList> for
19261 // &'static str` (this lift) forward projections must resolve
19262 // identically on every arm, locking the two input-shape paths
19263 // together so any future detour trips at caixa-core test time.
19264 // Then a witness that a `.iter().map(Into::into)` pipe over
19265 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
19266 // materializes the two-arm accept-set through the borrowed-
19267 // input axis alone — the exact shape a future M4 admission-
19268 // webhook rejection body composer, a future substrate-wide
19269 // per-arm diagnostic column, or a
19270 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
19271 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
19272 // through — closing the two-way owned/borrowed input-shape
19273 // symmetry on the forward-projection trait-idiomatic axis.
19274 for &list in super::DepList::ALL {
19275 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
19276 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
19277 assert_eq!(
19278 owned, borrowed,
19279 "From<DepList> and From<&DepList> for &'static str must \
19280 resolve identically on DepList::{list:?} — divergence \
19281 signals the owned-input and borrowed-input forward-\
19282 projection paths have drifted onto different emit-sets"
19283 );
19284 }
19285 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
19286 let via_method: Vec<&'static str> =
19287 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19288 assert_eq!(
19289 via_iter, via_method,
19290 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
19291 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
19292 input `From<&DepList> for &'static str` axis is what makes \
19293 the `.iter().map(Into::into)` shape route through the \
19294 substrate-primitive `DepList::as_str` accessor rather than \
19295 through a per-call-site `.copied()` / dereference detour"
19296 );
19297 }
19298
19299 #[test]
19300 fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
19301 // Fail-before-pass-after byte-parity pin on the newly lifted
19302 // `impl From<DepList> for String` — asserts the owned-`String`
19303 // -returning standard-library trait impl and the substrate-
19304 // primitive [`super::DepList::as_str`] `pub const fn` accessor
19305 // resolve to the same two-arm emit-set across every arm the
19306 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19307 // standard library does not carry a blanket
19308 // `impl<T: AsRef<str>> From<T> for String` (nor an
19309 // `impl<T: fmt::Display> From<T> for String`), so the
19310 // owned-`String` forward-projection axis is a distinct trait-
19311 // idiomatic surface that a `let key: String = list.into();`-
19312 // shaped call site reaches through this impl and no other — the
19313 // paired sibling `From<DepList> for &'static str` impl forces
19314 // every owned-`String` call site through an explicit
19315 // `.to_owned()` / `String::from` restatement. Peer of the
19316 // first-mover
19317 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
19318 // (7baa18a), the second-peer
19319 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
19320 // (7851725), the third-peer
19321 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
19322 // (231a18c), and the fourth-peer
19323 // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
19324 // (88942cd) — extends the trait-idiomatic owned-`String`
19325 // forward-projection axis onto the fifth closed-set fieldless
19326 // typed enum on the caixa surface (the two-list dep-graph axis).
19327 for &variant in super::DepList::ALL {
19328 let via_trait: String = <String as From<super::DepList>>::from(variant);
19329 let via_method: &'static str = variant.as_str();
19330 assert_eq!(
19331 via_trait.as_str(),
19332 via_method,
19333 "From<DepList> for String impl must round-trip \
19334 DepList::{variant:?} to the same lifted \
19335 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19336 DepList::as_str returns — divergence signals a silent \
19337 detour off the substrate-primitive accessor"
19338 );
19339 let via_into: String = variant.into();
19340 assert_eq!(
19341 via_into.as_str(),
19342 via_method,
19343 "Into<String>::into on DepList::{variant:?} must \
19344 byte-equal DepList::as_str on the same input — the \
19345 blanket-derived Into shape must resolve to the same \
19346 as_str dispatch as the explicit From impl"
19347 );
19348 }
19349 }
19350
19351 #[test]
19352 fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
19353 // Cross-axis partition pin: the paired trait-idiomatic
19354 // owned-`String` `From<DepList> for String` (this lift) and
19355 // owned-`&'static str` `From<DepList> for &'static str`
19356 // (523157d campaign-shape) forward projections must resolve
19357 // identically on every arm, locking the two return-type-shape
19358 // paths together so any future detour trips at caixa-core test
19359 // time. Also byte-parity witness against the sibling
19360 // [`ToString::to_string`] surface routed through
19361 // [`std::fmt::Display`] — the three owned-heap-string paths
19362 // (`.into::<String>()`, `String::from`, `.to_string()`) must
19363 // resolve identically on every arm so a future consumer that
19364 // picks any of the three lands on the same two-arm lifted
19365 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19366 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
19367 // Then a `.iter().copied().map(String::from)` pipe witness
19368 // over [`super::DepList::ALL`] that materializes the two-arm
19369 // accept-set through the owned-`String` axis alone — the exact
19370 // shape a future M4 admission-webhook rejection body composer
19371 // or a
19372 // `HashMap::<String, DepList>::from_iter(
19373 // DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
19374 // style owned-key per-list lookup reaches through — closing the
19375 // owned-`String` forward-projection axis's iterator-pipe shape.
19376 // Then a direct round-trip witness through the paired
19377 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
19378 // owned-`String`'s [`String::as_str`] borrow that closes the
19379 // two-way `Self → String → Self` round-trip on the trait-
19380 // idiomatic owned-`String` forward + reverse axis pair.
19381 //
19382 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19383 // `From` emit lands on the lowercase Portuguese `as_str`
19384 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19385 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19386 // forcing the round-trip through an intermediate
19387 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19388 // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
19389 // parse resolve through the same lifted
19390 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19391 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19392 // construction (there is no wire/diagnostic axis split on this
19393 // enum), so the owned-`String` forward axis and the reverse
19394 // axis compose directly — matching the peer
19395 // [`crate::supervisor::RestartStrategy`] /
19396 // [`crate::supervisor::RestartPolicy`] /
19397 // [`crate::CaixaDialeto`] owned-`String` axis pairs.
19398 for &list in super::DepList::ALL {
19399 let owned_string: String = <String as From<super::DepList>>::from(list);
19400 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19401 assert_eq!(
19402 owned_string.as_str(),
19403 owned_static,
19404 "From<DepList> for String and From<DepList> for \
19405 &'static str must resolve identically on \
19406 DepList::{list:?} — divergence signals the owned-\
19407 `String` and owned-`&'static str` forward-projection \
19408 return-type-shape paths have drifted onto different \
19409 emit-sets"
19410 );
19411 let via_to_string: String = list.to_string();
19412 assert_eq!(
19413 owned_string, via_to_string,
19414 "From<DepList> for String must byte-equal \
19415 DepList::to_string on DepList::{list:?} — divergence \
19416 signals the trait-idiomatic owned-`String` forward-\
19417 projection axis and the ToString-through-Display axis \
19418 have drifted onto different emit-sets"
19419 );
19420 }
19421 let via_iter: Vec<String> = super::DepList::ALL
19422 .iter()
19423 .copied()
19424 .map(String::from)
19425 .collect();
19426 let via_method: Vec<String> = super::DepList::ALL
19427 .iter()
19428 .map(|l| l.as_str().to_owned())
19429 .collect();
19430 assert_eq!(
19431 via_iter, via_method,
19432 "`.iter().copied().map(String::from)` over DepList::ALL must \
19433 byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
19434 every arm — the owned-`String` `From<DepList> for String` \
19435 axis is what makes the `String::from` composition route \
19436 through the substrate-primitive `DepList::as_str` accessor \
19437 rather than through a per-call-site `.to_owned()` / \
19438 `String::from(list.as_str())` detour"
19439 );
19440 for &variant in super::DepList::ALL {
19441 let emitted: String = variant.into();
19442 let re_parsed: Result<super::DepList, ()> =
19443 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19444 assert_eq!(
19445 re_parsed,
19446 Ok(variant),
19447 "trait-idiomatic owned-`String` forward-projection + \
19448 reverse-projection axis pair must round-trip \
19449 DepList::{variant:?} through `.into::<String>()` and \
19450 back through `TryFrom<&str>` on the owned-`String`'s \
19451 String::as_str borrow — a break signals the owned-\
19452 `String` forward-emit and reverse-parse axes have \
19453 drifted onto different vocabularies (unlike the peer \
19454 CaixaKind axis pair, DepList's forward emit and \
19455 reverse parse share the same lifted \
19456 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
19457 round-trip composes directly)"
19458 );
19459 }
19460 }
19461
19462 #[test]
19463 fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
19464 // Fail-before-pass-after byte-parity pin on the newly lifted
19465 // `impl From<&DepList> for String` — asserts the borrowed-input
19466 // owned-`String`-returning standard-library trait impl and the
19467 // substrate-primitive [`super::DepList::as_str`] `pub const fn`
19468 // accessor resolve to the same two-arm emit-set across every
19469 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
19470 // Rust's standard library does not carry a blanket
19471 // `impl<T: AsRef<str>> From<&T> for String` (nor an
19472 // `impl<T: fmt::Display> From<&T> for String`), so the
19473 // borrowed-input owned-`String` forward-projection axis is a
19474 // distinct trait-idiomatic surface that a
19475 // `let key: String = (&list).into();`-shaped call site reaches
19476 // through this impl and no other — the paired sibling
19477 // `From<DepList> for String` impl forces every borrowed-input
19478 // call site through an explicit `Copy` deref
19479 // (`String::from(*list)`) or an `.as_str().to_owned()` /
19480 // `.to_string()` detour. Peer of the first-mover
19481 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19482 // (579385f) and the second-peer
19483 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19484 // (8465740) — extends the trait-idiomatic borrowed-input owned-
19485 // `String` forward-projection axis off the M2 OTP-shape sibling
19486 // axis pair onto the first non-M2 closed-set fieldless typed
19487 // enum peer (the two-list dep-graph axis).
19488 for &variant in super::DepList::ALL {
19489 let via_trait: String = <String as From<&super::DepList>>::from(&variant);
19490 let via_method: &'static str = variant.as_str();
19491 assert_eq!(
19492 via_trait.as_str(),
19493 via_method,
19494 "From<&DepList> for String impl must round-trip \
19495 &DepList::{variant:?} to the same lifted \
19496 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19497 DepList::as_str returns — divergence signals a silent \
19498 detour off the substrate-primitive accessor"
19499 );
19500 let via_into: String = (&variant).into();
19501 assert_eq!(
19502 via_into.as_str(),
19503 via_method,
19504 "Into<String>::into on &DepList::{variant:?} must \
19505 byte-equal DepList::as_str on the same input — the \
19506 blanket-derived Into shape must resolve to the same \
19507 as_str dispatch as the explicit From impl"
19508 );
19509 }
19510 }
19511
19512 #[test]
19513 fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
19514 // Cross-axis partition pin: the newly lifted trait-idiomatic
19515 // borrowed-input owned-`String` `From<&DepList> for String`
19516 // (this lift), the paired owned-input owned-`String`
19517 // `From<DepList> for String` (32b0ee8), the paired borrowed-
19518 // input owned-`&'static str` `From<&DepList> for &'static str`
19519 // (64aa742), and the paired owned-input owned-`&'static str`
19520 // `From<DepList> for &'static str` (3455cbf) — every corner of
19521 // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
19522 // idiomatic projection family — must resolve identically on
19523 // every arm, locking the four return-shape × input-shape paths
19524 // together so any future detour trips at caixa-core test time.
19525 // Also byte-parity witness against the sibling
19526 // [`ToString::to_string`] surface routed through
19527 // [`std::fmt::Display`] and a direct round-trip witness through
19528 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
19529 // the owned-`String`'s [`String::as_str`] borrow that closes
19530 // the two-way `&Self → String → Self` round-trip on the trait-
19531 // idiomatic borrowed-input owned-`String` forward + reverse
19532 // axis pair. Peer of the first-mover
19533 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19534 // (579385f) and the second-peer
19535 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19536 // (8465740) — closes the whole `{Self, &Self} × {&'static str,
19537 // String}` 2×2 projection corner on the third substrate-wide
19538 // closed-set fieldless typed enum peer (the two-list dep-graph
19539 // axis, first outside the M2 OTP-shape sibling pair).
19540 //
19541 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19542 // `From` emit lands on the lowercase Portuguese `as_str`
19543 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19544 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19545 // forcing the round-trip through an intermediate
19546 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19547 // [`super::DepList::as_str`] emit and
19548 // [`super::DepList::from_wire`] parse resolve through the same
19549 // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19550 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19551 // construction (there is no wire/diagnostic axis split on this
19552 // enum), so the borrowed-input owned-`String` forward axis and
19553 // the reverse axis compose directly — matching the peer
19554 // [`crate::supervisor::RestartStrategy`] /
19555 // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
19556 // `String` axis pairs.
19557 for &list in super::DepList::ALL {
19558 let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
19559 let owned_string: String = <String as From<super::DepList>>::from(list);
19560 let borrowed_static: &'static str =
19561 <&'static str as From<&super::DepList>>::from(&list);
19562 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19563 assert_eq!(
19564 borrowed_string, owned_string,
19565 "From<&DepList> for String and From<DepList> for String \
19566 must resolve identically on DepList::{list:?} — \
19567 divergence signals the borrowed-input and owned-input \
19568 owned-`String` forward-projection input-shape paths \
19569 have drifted onto different emit-sets"
19570 );
19571 assert_eq!(
19572 borrowed_string.as_str(),
19573 borrowed_static,
19574 "From<&DepList> for String and From<&DepList> for \
19575 &'static str must resolve identically on \
19576 DepList::{list:?} — divergence signals the borrowed-\
19577 input `&'static str` and owned-`String` return-shape \
19578 paths have drifted onto different emit-sets"
19579 );
19580 assert_eq!(
19581 borrowed_string.as_str(),
19582 owned_static,
19583 "From<&DepList> for String and From<DepList> for \
19584 &'static str must resolve identically on \
19585 DepList::{list:?} — divergence signals a break in the \
19586 diagonal corner of the {{Self, &Self}} × {{&'static \
19587 str, String}} 2×2 trait-idiomatic projection family"
19588 );
19589 let via_to_string: String = list.to_string();
19590 assert_eq!(
19591 borrowed_string, via_to_string,
19592 "From<&DepList> for String must byte-equal \
19593 DepList::to_string on DepList::{list:?} — divergence \
19594 signals the trait-idiomatic borrowed-input owned-\
19595 `String` forward-projection axis and the ToString-\
19596 through-Display axis have drifted onto different \
19597 emit-sets"
19598 );
19599 }
19600 let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
19601 let via_method: Vec<String> = super::DepList::ALL
19602 .iter()
19603 .map(|l| l.as_str().to_owned())
19604 .collect();
19605 assert_eq!(
19606 via_iter, via_method,
19607 "`.iter().map(String::from)` over DepList::ALL — a call \
19608 site whose iteration axis holds `&DepList` by construction \
19609 — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
19610 on every arm — the borrowed-input owned-`String` \
19611 `From<&DepList> for String` axis is what makes the \
19612 `String::from` composition route through the substrate-\
19613 primitive `DepList::as_str` accessor without a spurious \
19614 `Copy` deref (which would only be reachable through the \
19615 owned-input `From<DepList> for String` axis by first \
19616 calling `.copied()` on the iterator)"
19617 );
19618 for &variant in super::DepList::ALL {
19619 let emitted: String = (&variant).into();
19620 let re_parsed: Result<super::DepList, ()> =
19621 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19622 assert_eq!(
19623 re_parsed,
19624 Ok(variant),
19625 "trait-idiomatic borrowed-input owned-`String` \
19626 forward-projection + reverse-projection axis pair must \
19627 round-trip &DepList::{variant:?} through \
19628 `.into::<String>()` on the borrowed-input surface and \
19629 back through `TryFrom<&str>` on the owned-`String`'s \
19630 String::as_str borrow — a break signals the \
19631 borrowed-input owned-`String` forward-emit and \
19632 reverse-parse axes have drifted onto different \
19633 vocabularies (unlike the peer CaixaKind axis pair, \
19634 DepList's forward emit and reverse parse share the \
19635 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
19636 construction, so the round-trip composes directly)"
19637 );
19638 }
19639 }
19640
19641 #[test]
19642 fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
19643 // Fail-before-pass-after byte-parity pin on the newly lifted
19644 // `impl From<DepList> for std::borrow::Cow<'static, str>` —
19645 // asserts the standard-library trait impl and the substrate-
19646 // primitive [`super::DepList::as_str`] `pub const fn`
19647 // accessor resolve to the same two-arm emit-set across every
19648 // arm the exhaustive [`super::DepList::ALL`] slice
19649 // enumerates. Rust's standard library does not carry a
19650 // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19651 // (nor an `impl<T: fmt::Display> From<T> for
19652 // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19653 // projection axis is a distinct trait-idiomatic surface that
19654 // a `let key: Cow<'static, str> = list.into();`-shaped call
19655 // site reaches through this impl and no other — the paired
19656 // sibling `From<DepList> for &'static str` and
19657 // `From<DepList> for String` impls force every
19658 // `Cow<'static, str>`-parameterized call site through a
19659 // `Cow::Borrowed(list.as_str())` /
19660 // `Cow::Owned(list.to_string())` composition whose type
19661 // bounds have no compile-time link back to the substrate
19662 // primitive.
19663 //
19664 // Also asserts the projection lands on the zero-alloc
19665 // [`std::borrow::Cow::Borrowed`] arm (not the
19666 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19667 // [`super::DepList::as_str`] accessor's `&'static str`
19668 // return lifetime by construction (each match arm resolves
19669 // to one of the two lifted
19670 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19671 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19672 // &str` values) makes the borrowed arm the type-correct
19673 // projection with no runtime allocation. Any future silent
19674 // detour that routes the impl through the owned arm trips
19675 // at caixa-core test time under the
19676 // [`std::borrow::Cow::Borrowed`] discriminator witness
19677 // rather than at a downstream `Cow<'static, str>`-bound
19678 // consumer's silent allocation.
19679 //
19680 // First-mover on the outside-M3 substrate-wide tier of the
19681 // substrate-wide trait-idiomatic
19682 // [`std::borrow::Cow<'static, str>`] forward-projection
19683 // campaign — extends the axis off the paired
19684 // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19685 // the paired M2 OTP-shape
19686 // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19687 // and [`crate::supervisor::RestartPolicy`] (0612398 +
19688 // ee577fd), and the paired M3-mesh-shape
19689 // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19690 // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19691 // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19692 // peers onto the first outside-M3 caixa-core peer (the two-
19693 // list dep-graph axis), opening the outside-M3 caixa-core
19694 // tier of the substrate-wide Cow<'static, str> forward-
19695 // projection campaign's owned-input corner.
19696 for &variant in super::DepList::ALL {
19697 let via_trait: std::borrow::Cow<'static, str> =
19698 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19699 let via_method: &'static str = variant.as_str();
19700 assert_eq!(
19701 via_trait.as_ref(),
19702 via_method,
19703 "From<DepList> for Cow<'static, str> impl must \
19704 round-trip DepList::{variant:?} to the same lifted \
19705 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19706 DepList::as_str returns — divergence signals a \
19707 silent detour off the substrate-primitive accessor"
19708 );
19709 assert!(
19710 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19711 "From<DepList> for Cow<'static, str> impl must land \
19712 on the zero-alloc Cow::Borrowed arm on \
19713 DepList::{variant:?} — a Cow::Owned outcome signals \
19714 the projection has silently allocated where the \
19715 substrate-primitive DepList::as_str `&'static str` \
19716 return makes the borrowed arm the type-correct \
19717 projection"
19718 );
19719 let via_into: std::borrow::Cow<'static, str> = variant.into();
19720 assert_eq!(
19721 via_into.as_ref(),
19722 via_method,
19723 "Into<Cow<'static, str>>::into on DepList::\
19724 {variant:?} must byte-equal DepList::as_str on the \
19725 same input — the blanket-derived Into shape must \
19726 resolve to the same as_str dispatch as the explicit \
19727 From impl"
19728 );
19729 assert!(
19730 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19731 "Into<Cow<'static, str>>::into on DepList::\
19732 {variant:?} must land on the zero-alloc \
19733 Cow::Borrowed arm — the blanket-derived Into shape \
19734 must resolve to the same Cow::Borrowed dispatch as \
19735 the explicit From impl"
19736 );
19737 }
19738 }
19739
19740 #[test]
19741 fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19742 // Cross-axis partition pin: the newly lifted trait-idiomatic
19743 // `From<DepList> for std::borrow::Cow<'static, str>` (this
19744 // lift), the paired owned-input `From<DepList> for
19745 // &'static str` (3455cbf), and the paired owned-input
19746 // `From<DepList> for String` (32b0ee8) forward projections
19747 // must resolve identically on every arm, locking the three
19748 // return-shape paths together by construction so any future
19749 // detour trips at caixa-core test time. Also byte-parity
19750 // witness against the sibling [`ToString::to_string`]
19751 // surface routed through [`std::fmt::Display`] — every
19752 // owned-heap-string path (the `Cow::Owned` promotion of
19753 // this axis's `.into_owned()`, `From<DepList> for String`,
19754 // and `.to_string()`) resolves to the same two-arm lifted
19755 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19756 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19757 // arm.
19758 //
19759 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19760 // witness over [`super::DepList::ALL`] that materializes the
19761 // two-arm accept-set through the
19762 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19763 // shape a future M4 admission-webhook rejection body's
19764 // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19765 // future substrate-wide per-arm diagnostic surface whose
19766 // typing rules out the sibling [`AsRef<str>`] borrowed
19767 // return, or a future per-arm dep-list emitter that binds
19768 // through a [`std::borrow::Cow<'static, str>`] boundary
19769 // reaches through — opening the composable-projection axis
19770 // on the first outside-M3 caixa-core closed-set fieldless
19771 // typed enum peer on the caixa surface. The pipe witness
19772 // also pins the zero-alloc discipline: every element in the
19773 // collected vector satisfies the
19774 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19775 // accidental silent-allocation regression on the pipe's
19776 // iteration axis is a caixa-core-test-time failure.
19777 for &variant in super::DepList::ALL {
19778 let via_cow: std::borrow::Cow<'static, str> =
19779 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19780 let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19781 let via_string: String = <String as From<super::DepList>>::from(variant);
19782 assert_eq!(
19783 via_cow.as_ref(),
19784 via_static,
19785 "From<DepList> for Cow<'static, str> and \
19786 From<DepList> for &'static str must resolve \
19787 identically on DepList::{variant:?} — divergence \
19788 signals the Cow<'static, str> and &'static str \
19789 return-shape paths have drifted onto different \
19790 emit-sets"
19791 );
19792 assert_eq!(
19793 via_cow.as_ref(),
19794 via_string.as_str(),
19795 "From<DepList> for Cow<'static, str> and \
19796 From<DepList> for String must resolve identically \
19797 on DepList::{variant:?} — divergence signals the \
19798 Cow<'static, str> and String return-shape paths \
19799 have drifted onto different emit-sets"
19800 );
19801 let via_to_string: String = variant.to_string();
19802 assert_eq!(
19803 via_cow.as_ref(),
19804 via_to_string.as_str(),
19805 "From<DepList> for Cow<'static, str> must byte-equal \
19806 DepList::to_string on DepList::{variant:?} — \
19807 divergence signals the trait-idiomatic \
19808 Cow<'static, str> forward-projection axis and the \
19809 ToString-through-Display axis have drifted onto \
19810 different emit-sets"
19811 );
19812 }
19813 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19814 .iter()
19815 .copied()
19816 .map(std::borrow::Cow::from)
19817 .collect();
19818 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19819 .iter()
19820 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19821 .collect();
19822 assert_eq!(
19823 via_iter, via_method,
19824 "`.iter().copied().map(Cow::from)` over DepList::ALL \
19825 must byte-equal `.iter().map(|l| \
19826 Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19827 idiomatic `From<DepList> for Cow<'static, str>` axis is \
19828 what makes the `Cow::from` composition route through \
19829 the substrate-primitive `DepList::as_str` accessor with \
19830 the zero-alloc Cow::Borrowed arm by construction, \
19831 rather than a per-call-site `Cow::Owned(list.to_string())` \
19832 allocation"
19833 );
19834 for cow in &via_iter {
19835 assert!(
19836 matches!(cow, std::borrow::Cow::Borrowed(_)),
19837 "every element of the .iter().copied().map(Cow::from) \
19838 pipe over DepList::ALL must land on the zero-alloc \
19839 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19840 signals the pipe's iteration axis has silently \
19841 allocated where the substrate-primitive \
19842 DepList::as_str `&'static str` return makes the \
19843 borrowed arm the type-correct projection"
19844 );
19845 }
19846 }
19847
19848 #[test]
19849 fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19850 // Fail-before-pass-after byte-parity pin on the newly lifted
19851 // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19852 // asserts the borrowed-input standard-library trait impl and
19853 // the substrate-primitive [`super::DepList::as_str`] `pub const
19854 // fn` accessor resolve to the same two-arm emit-set across
19855 // every arm the exhaustive [`super::DepList::ALL`] slice
19856 // enumerates. Rust's standard library does not carry a blanket
19857 // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19858 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19859 // the borrowed-input `Cow<'static, str>` forward-projection
19860 // axis is a distinct trait-idiomatic surface that a
19861 // `let key: Cow<'static, str> = (&list).into();`-shaped call
19862 // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19863 // reaches through this impl and no other — the paired owned-
19864 // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19865 // forces every borrowed-input call site through an explicit
19866 // `Copy` deref (`Cow::from(*list)`) or a
19867 // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19868 // have no compile-time link back to the substrate primitive.
19869 //
19870 // Also asserts the projection lands on the zero-alloc
19871 // [`std::borrow::Cow::Borrowed`] arm (not the
19872 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19873 // [`super::DepList::as_str`] accessor's `&'static str` return
19874 // lifetime by construction (each match arm resolves to one of
19875 // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19876 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19877 // values) makes the borrowed arm the type-correct projection
19878 // with no runtime allocation on the borrowed-input surface
19879 // just as on the paired owned-input surface.
19880 //
19881 // Closes the `{Self, &Self}` input-shape corner on the outside-
19882 // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19883 // on the first outside-M3 caixa-core closed-set fieldless typed
19884 // enum peer on the caixa surface, exactly as afdf0f4 closed it
19885 // on the second M3-mesh-primitive peer
19886 // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19887 // the owning half (eee504d) landed, as 25690ef closed it on
19888 // the first M3-mesh-primitive peer
19889 // ([`crate::aplicacao::WitShape`]) one commit after the owning
19890 // half (8634dec) landed, as d45c409 closed it on the top-level
19891 // [`crate::CaixaKind`] one commit after the owning half
19892 // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19893 // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19894 // [`crate::supervisor::RestartPolicy`] sibling peers one
19895 // commit after (7dd28b3 / 0612398) landed.
19896 for &variant in super::DepList::ALL {
19897 let via_trait: std::borrow::Cow<'static, str> =
19898 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19899 let via_method: &'static str = variant.as_str();
19900 assert_eq!(
19901 via_trait.as_ref(),
19902 via_method,
19903 "From<&DepList> for Cow<'static, str> impl must \
19904 round-trip &DepList::{variant:?} to the same lifted \
19905 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19906 DepList::as_str returns — divergence signals a silent \
19907 detour off the substrate-primitive accessor"
19908 );
19909 assert!(
19910 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19911 "From<&DepList> for Cow<'static, str> impl must land \
19912 on the zero-alloc Cow::Borrowed arm on \
19913 &DepList::{variant:?} — a Cow::Owned outcome signals \
19914 the projection has silently allocated where the \
19915 substrate-primitive DepList::as_str `&'static str` \
19916 return makes the borrowed arm the type-correct \
19917 projection"
19918 );
19919 let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19920 assert_eq!(
19921 via_into.as_ref(),
19922 via_method,
19923 "Into<Cow<'static, str>>::into on &DepList::\
19924 {variant:?} must byte-equal DepList::as_str on the \
19925 same input — the blanket-derived Into shape must \
19926 resolve to the same as_str dispatch as the explicit \
19927 From impl"
19928 );
19929 assert!(
19930 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19931 "Into<Cow<'static, str>>::into on &DepList::\
19932 {variant:?} must land on the zero-alloc \
19933 Cow::Borrowed arm — the blanket-derived Into shape \
19934 must resolve to the same Cow::Borrowed dispatch as \
19935 the explicit From impl"
19936 );
19937 }
19938 }
19939
19940 #[test]
19941 fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19942 // Cross-axis partition pin: the newly lifted trait-idiomatic
19943 // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19944 // str>` (this lift), the paired owned-input `From<DepList> for
19945 // std::borrow::Cow<'static, str>` (6858bac), the paired
19946 // borrowed-input owned-`&'static str` `From<&DepList> for
19947 // &'static str` (3455cbf), and the paired borrowed-input
19948 // owned-`String` `From<&DepList> for String` must resolve
19949 // identically on every arm, locking the four return-shape ×
19950 // input-shape paths together by construction so any future
19951 // detour trips at caixa-core test time. Also byte-parity
19952 // witness against the sibling [`ToString::to_string`] surface
19953 // routed through [`std::fmt::Display`] — every owned-heap-
19954 // string path (this axis's `.into_owned()` promotion, the
19955 // paired [`From<&DepList> for String`], and `.to_string()`)
19956 // resolves to the same two-arm lifted
19957 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19958 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19959 // arm.
19960 //
19961 // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19962 // over [`super::DepList::ALL`] — whose iterator yields
19963 // `&DepList` by construction, so the borrowed-input
19964 // [`Cow<'static, str>`] axis is what routes the pipe through
19965 // the substrate-primitive [`super::DepList::as_str`] accessor
19966 // without a spurious [`Copy`] deref (which would only be
19967 // reachable through the owned-input [`From<DepList> for
19968 // Cow<'static, str>`] axis by first calling `.copied()` on the
19969 // iterator). The pipe witness also pins the zero-alloc
19970 // discipline: every element in the collected vector satisfies
19971 // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19972 // future accidental silent-allocation regression on the pipe's
19973 // iteration axis is a caixa-core-test-time failure. Peer of
19974 // the sibling
19975 // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19976 // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19977 // axis — extends the whole borrowed-input `Cow<'static, str>`
19978 // + paired `{&'static str, String}` cross-axis-parity corner
19979 // onto the first outside-M3 caixa-core closed-set fieldless
19980 // typed enum peer on the caixa surface.
19981 for &variant in super::DepList::ALL {
19982 let borrowed_cow: std::borrow::Cow<'static, str> =
19983 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19984 let owned_cow: std::borrow::Cow<'static, str> =
19985 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19986 let borrowed_static: &'static str =
19987 <&'static str as From<&super::DepList>>::from(&variant);
19988 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19989 assert_eq!(
19990 borrowed_cow, owned_cow,
19991 "From<&DepList> for Cow<'static, str> and \
19992 From<DepList> for Cow<'static, str> must resolve \
19993 identically on DepList::{variant:?} — divergence \
19994 signals the borrowed-input and owned-input \
19995 Cow<'static, str> forward-projection input-shape \
19996 paths have drifted onto different emit-sets"
19997 );
19998 assert_eq!(
19999 borrowed_cow.as_ref(),
20000 borrowed_static,
20001 "From<&DepList> for Cow<'static, str> and \
20002 From<&DepList> for &'static str must resolve \
20003 identically on DepList::{variant:?} — divergence \
20004 signals the borrowed-input Cow<'static, str> and \
20005 &'static str return-shape paths have drifted onto \
20006 different emit-sets"
20007 );
20008 assert_eq!(
20009 borrowed_cow.as_ref(),
20010 borrowed_string.as_str(),
20011 "From<&DepList> for Cow<'static, str> and \
20012 From<&DepList> for String must resolve identically \
20013 on DepList::{variant:?} — divergence signals the \
20014 borrowed-input Cow<'static, str> and owned-`String` \
20015 return-shape paths have drifted onto different \
20016 emit-sets"
20017 );
20018 let via_to_string: String = variant.to_string();
20019 assert_eq!(
20020 borrowed_cow.as_ref(),
20021 via_to_string.as_str(),
20022 "From<&DepList> for Cow<'static, str> must byte-equal \
20023 DepList::to_string on DepList::{variant:?} — \
20024 divergence signals the trait-idiomatic borrowed-input \
20025 Cow<'static, str> forward-projection axis and the \
20026 ToString-through-Display axis have drifted onto \
20027 different emit-sets"
20028 );
20029 }
20030 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
20031 .iter()
20032 .map(std::borrow::Cow::from)
20033 .collect();
20034 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
20035 .iter()
20036 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
20037 .collect();
20038 assert_eq!(
20039 via_iter, via_method,
20040 "`.iter().map(Cow::from)` over DepList::ALL — a call site \
20041 whose iteration axis holds &DepList by construction — \
20042 must byte-equal `.iter().map(|l| \
20043 Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
20044 input Cow<'static, str> `From<&DepList> for Cow<'static, \
20045 str>` axis is what makes the `Cow::from` composition \
20046 route through the substrate-primitive `DepList::as_str` \
20047 accessor with the zero-alloc Cow::Borrowed arm by \
20048 construction and without a spurious `Copy` deref (which \
20049 would only be reachable through the owned-input \
20050 `From<DepList> for Cow<'static, str>` axis by first \
20051 calling `.copied()` on the iterator)"
20052 );
20053 for cow in &via_iter {
20054 assert!(
20055 matches!(cow, std::borrow::Cow::Borrowed(_)),
20056 "every element of the .iter().map(Cow::from) pipe \
20057 over DepList::ALL must land on the zero-alloc \
20058 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
20059 signals the pipe's iteration axis has silently \
20060 allocated where the substrate-primitive \
20061 DepList::as_str `&'static str` return makes the \
20062 borrowed arm the type-correct projection"
20063 );
20064 }
20065 }
20066
20067 #[test]
20068 fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
20069 // Fail-before-pass-after byte-parity pin on the newly lifted
20070 // `impl From<DepList> for Box<str>` — asserts the owned-input
20071 // standard-library trait impl and the substrate-primitive
20072 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
20073 // the same two-arm emit-set (the paired
20074 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20075 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20076 // byte-strings) across every arm the exhaustive
20077 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20078 // core-internal tier of the substrate-wide [`Box<str>`] forward-
20079 // projection campaign onto the second caixa-core-internal peer,
20080 // after the render-side path-shape-diagnostic
20081 // [`super::super::render::PathShapeViolation`] pair (0d87a72,
20082 // both corners in one axis) opened the tier. Rust's standard
20083 // library carries `impl From<&str> for Box<str>` and
20084 // `impl From<String> for Box<str>` but no blanket
20085 // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
20086 // distinct trait-idiomatic surface that a
20087 // `let key: Box<str> = list.into();`-shaped call site reaches
20088 // through this impl and no other — a paired
20089 // `Box::from(list.as_str())` open-code has no compile-time link
20090 // back to the substrate primitive.
20091 for &variant in super::DepList::ALL {
20092 let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20093 let via_method: &'static str = variant.as_str();
20094 assert_eq!(
20095 via_trait.as_ref(),
20096 via_method,
20097 "From<DepList> for Box<str> impl must round-trip \
20098 DepList::{variant:?} to the same lifted \
20099 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20100 DepList::as_str returns — divergence signals a silent \
20101 detour off the substrate-primitive accessor"
20102 );
20103 let via_into: Box<str> = variant.into();
20104 assert_eq!(
20105 via_into.as_ref(),
20106 via_method,
20107 "Into<Box<str>>::into on DepList::{variant:?} must \
20108 byte-equal DepList::as_str on the same input — the \
20109 blanket-derived Into shape must resolve to the same \
20110 as_str dispatch as the explicit From impl"
20111 );
20112 }
20113 }
20114
20115 #[test]
20116 fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
20117 // Fail-before-pass-after byte-parity pin on the newly lifted
20118 // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
20119 // standard-library trait impl and the substrate-primitive
20120 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
20121 // the same two-arm emit-set (the paired
20122 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20123 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20124 // byte-strings) across every arm the exhaustive
20125 // [`super::DepList::ALL`] slice enumerates. Rust's standard
20126 // library carries `impl From<&str> for Box<str>` and
20127 // `impl From<String> for Box<str>` but no blanket
20128 // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
20129 // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
20130 // input [`Box<str>`] forward-projection axis is a distinct
20131 // trait-idiomatic surface that a
20132 // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
20133 // iterator over `&'static [DepList]` yields `&DepList` by
20134 // construction) or a `let key: Box<str> = (&list).into();`-shaped
20135 // call site reaches through this impl and no other — the paired
20136 // owned-input `From<DepList> for Box<str>` impl alone would force
20137 // every borrowed-input call site through an explicit `Copy` deref
20138 // (`Box::<str>::from(*list)`) or a
20139 // `Box::<str>::from(list.as_str())` open-code whose type bounds
20140 // have no compile-time link back to the substrate primitive.
20141 //
20142 // Closes the `{Self, &Self}` input-shape corner on the second
20143 // caixa-core-internal closed-set fieldless typed enum peer of
20144 // the substrate-wide [`Box<str>`] forward-projection campaign —
20145 // one commit after the paired render-side path-shape-diagnostic
20146 // [`super::super::render::PathShapeViolation`] pair (0d87a72)
20147 // opened the caixa-core-internal tier — matching the trajectory
20148 // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
20149 // in one axis), the caixa-provedor `FerriteRuntime` pair
20150 // (14886a8, both corners in one axis), and the render-side
20151 // `PathShapeViolation` pair (0d87a72, both corners in one axis)
20152 // walked before it.
20153 for &variant in super::DepList::ALL {
20154 let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20155 let via_method: &'static str = variant.as_str();
20156 assert_eq!(
20157 via_trait.as_ref(),
20158 via_method,
20159 "From<&DepList> for Box<str> impl must round-trip \
20160 &DepList::{variant:?} to the same lifted \
20161 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20162 DepList::as_str returns — divergence signals a silent \
20163 detour off the substrate-primitive accessor"
20164 );
20165 let via_into: Box<str> = (&variant).into();
20166 assert_eq!(
20167 via_into.as_ref(),
20168 via_method,
20169 "Into<Box<str>>::into on &DepList::{variant:?} must \
20170 byte-equal DepList::as_str on the same input — the \
20171 blanket-derived Into shape on the borrowed-input \
20172 surface must resolve to the same as_str dispatch as \
20173 the explicit From impl"
20174 );
20175 }
20176
20177 // Pipe witness — the distinguishing shape that forces the
20178 // borrowed-input axis to be independent of the owned-input
20179 // peer. `DepList::ALL.iter()` yields `&DepList` by
20180 // construction, so `.map(Box::<str>::from)` resolves through
20181 // the borrowed-input `From<&DepList> for Box<str>` impl and
20182 // no other — without this axis, the same pipe would force an
20183 // explicit `.copied()` restatement whose type bounds bypass
20184 // the substrate primitive.
20185 let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
20186 let via_accessor: Vec<&'static str> =
20187 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
20188 assert_eq!(
20189 via_pipe.len(),
20190 via_accessor.len(),
20191 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
20192 preserve arity against the paired DepList::as_str \
20193 accessor — a length divergence signals the borrowed-input \
20194 axis has silently rejected an arm"
20195 );
20196 for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
20197 assert_eq!(
20198 pipe_arm.as_ref(),
20199 *accessor_arm,
20200 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
20201 byte-equal the paired \
20202 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
20203 arm — divergence signals the borrowed-input \
20204 `From<&DepList> for Box<str>` axis has silently \
20205 detoured off the substrate-primitive accessor"
20206 );
20207 }
20208 }
20209
20210 #[test]
20211 fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
20212 // Fail-before-pass-after byte-parity pin on the newly lifted
20213 // `impl From<DepList> for std::sync::Arc<str>` — asserts the
20214 // owned-input standard-library trait impl and the substrate-
20215 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20216 // resolve to the same two-arm emit-set (the paired
20217 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20218 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20219 // byte-strings) across every arm the exhaustive
20220 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20221 // core-internal tier of the substrate-wide
20222 // [`std::sync::Arc<str>`] forward-projection campaign onto the
20223 // second caixa-core-internal peer, after the top-level
20224 // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
20225 // opened the tier. Rust's standard library carries
20226 // `impl From<&str> for std::sync::Arc<str>` and
20227 // `impl From<String> for std::sync::Arc<str>` but no blanket
20228 // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
20229 // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
20230 // this axis is a distinct trait-idiomatic surface that a
20231 // `let key: std::sync::Arc<str> = list.into();`-shaped call site
20232 // reaches through this impl and no other — a paired
20233 // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
20234 // compile-time link back to the substrate primitive, and a two-
20235 // step `std::sync::Arc::<str>::from(String::from(list))`
20236 // composition through the owned-`String` axis allocates twice
20237 // (once into the intermediate `String`, once into the
20238 // [`std::sync::Arc<str>`] on the `From<String>` conversion)
20239 // where the single-step trait impl allocates once.
20240 //
20241 // Cross-axis byte-parity witness against the sibling owned-input
20242 // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
20243 // shape axes — locking the five return-shape paths on the owned-
20244 // input surface together by construction so any future detour
20245 // off the substrate-primitive [`super::DepList::as_str`] accessor
20246 // trips at caixa-core test time.
20247 for &variant in super::DepList::ALL {
20248 let via_trait: std::sync::Arc<str> =
20249 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20250 let via_method: &'static str = variant.as_str();
20251 assert_eq!(
20252 via_trait.as_ref(),
20253 via_method,
20254 "From<DepList> for std::sync::Arc<str> impl must round-\
20255 trip DepList::{variant:?} to the same lifted \
20256 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20257 DepList::as_str returns — divergence signals a silent \
20258 detour off the substrate-primitive accessor"
20259 );
20260 let via_into: std::sync::Arc<str> = variant.into();
20261 assert_eq!(
20262 via_into.as_ref(),
20263 via_method,
20264 "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
20265 must byte-equal DepList::as_str on the same input — \
20266 the blanket-derived Into shape must resolve to the same \
20267 as_str dispatch as the explicit From impl"
20268 );
20269 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20270 assert_eq!(
20271 via_trait.as_ref(),
20272 owned_static,
20273 "From<DepList> for std::sync::Arc<str> and \
20274 From<DepList> for &'static str must resolve identically \
20275 on DepList::{variant:?} — divergence signals the owned-\
20276 input std::sync::Arc<str> and &'static str return-shape \
20277 paths have drifted onto different emit-sets"
20278 );
20279 let owned_string: String = <String as From<super::DepList>>::from(variant);
20280 assert_eq!(
20281 via_trait.as_ref(),
20282 owned_string.as_str(),
20283 "From<DepList> for std::sync::Arc<str> and \
20284 From<DepList> for String must resolve identically on \
20285 DepList::{variant:?} — divergence signals the owned-\
20286 input std::sync::Arc<str> and owned-`String` return-shape \
20287 paths have drifted onto different emit-sets"
20288 );
20289 let owned_cow: std::borrow::Cow<'static, str> =
20290 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20291 assert_eq!(
20292 via_trait.as_ref(),
20293 owned_cow.as_ref(),
20294 "From<DepList> for std::sync::Arc<str> and \
20295 From<DepList> for Cow<'static, str> must resolve \
20296 identically on DepList::{variant:?} — divergence signals \
20297 the owned-input std::sync::Arc<str> and \
20298 Cow<'static, str> return-shape paths have drifted onto \
20299 different emit-sets"
20300 );
20301 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20302 assert_eq!(
20303 via_trait.as_ref(),
20304 owned_box.as_ref(),
20305 "From<DepList> for std::sync::Arc<str> and \
20306 From<DepList> for Box<str> must resolve identically on \
20307 DepList::{variant:?} — divergence signals the owned-\
20308 input std::sync::Arc<str> and Box<str> return-shape \
20309 paths have drifted onto different emit-sets"
20310 );
20311 }
20312 }
20313
20314 #[test]
20315 #[allow(
20316 clippy::too_many_lines,
20317 reason = "cross-axis partition pin folds four borrowed-input \
20318 return-shape paths (&'static str, String, Cow<'static, \
20319 str>, Box<str>) plus the paired owned-input Arc<str> \
20320 witness and the .iter().map(std::sync::Arc::<str>::from) \
20321 pipe witness into one exhaustive round-trip over \
20322 DepList::ALL — the accepted line-count cost of keying \
20323 the whole borrowed-input Arc<str> corner to the \
20324 substrate-primitive as_str accessor at the same test-site"
20325 )]
20326 fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
20327 // Fail-before-pass-after byte-parity pin on the newly lifted
20328 // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
20329 // borrowed-input standard-library trait impl and the substrate-
20330 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20331 // resolve to the same two-arm emit-set across every arm the
20332 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20333 // standard library does not carry a blanket
20334 // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
20335 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20336 // the borrowed-input `std::sync::Arc<str>` forward-projection
20337 // axis is a distinct trait-idiomatic surface that a
20338 // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
20339 // site or a
20340 // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
20341 // pipe reaches through this impl and no other — the paired
20342 // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
20343 // forces every borrowed-input call site through a spurious
20344 // `Copy` deref
20345 // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
20346 // `.copied()` restatement whose type bounds have no compile-time
20347 // link back to the substrate primitive.
20348 //
20349 // Closes the `{Self, &Self}` input-shape corner on the second
20350 // caixa-core-internal closed-set fieldless typed enum peer of
20351 // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
20352 // forward-projection campaign — one commit after the paired
20353 // top-level [`crate::CaixaKind`] pair (c17be64) opened the
20354 // caixa-core-internal tier — matching the
20355 // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
20356 // Box<str>}` 2×4 forward-projection matrix the peer projection
20357 // surfaces already close on this same enum.
20358 //
20359 // Cross-axis partition pin against the paired owned-input
20360 // [`From<DepList> for std::sync::Arc<str>`] and the sibling
20361 // borrowed-input `{&'static str, String, Cow<'static, str>,
20362 // Box<str>}` return-shape axes — locking the five return-shape
20363 // × input-shape paths on the borrowed-input surface together by
20364 // construction so any future detour off the substrate-primitive
20365 // accessor trips at caixa-core test time. Then a
20366 // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
20367 // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
20368 // construction, so the borrowed-input
20369 // [`std::sync::Arc<str>`] axis is what routes the pipe through
20370 // the substrate-primitive [`super::DepList::as_str`] accessor
20371 // without a spurious [`Copy`] deref (which would only be
20372 // reachable through the owned-input
20373 // [`From<DepList> for std::sync::Arc<str>`] axis by first
20374 // calling `.copied()` on the iterator).
20375 for &variant in super::DepList::ALL {
20376 let via_trait: std::sync::Arc<str> =
20377 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20378 let via_method: &'static str = variant.as_str();
20379 assert_eq!(
20380 via_trait.as_ref(),
20381 via_method,
20382 "From<&DepList> for std::sync::Arc<str> impl must round-\
20383 trip &DepList::{variant:?} to the same lifted \
20384 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20385 DepList::as_str returns — divergence signals a silent \
20386 detour off the substrate-primitive accessor"
20387 );
20388 let via_into: std::sync::Arc<str> = (&variant).into();
20389 assert_eq!(
20390 via_into.as_ref(),
20391 via_method,
20392 "Into<std::sync::Arc<str>>::into on &DepList::\
20393 {variant:?} must byte-equal DepList::as_str on the \
20394 same input — the blanket-derived Into shape on the \
20395 borrowed-input surface must resolve to the same as_str \
20396 dispatch as the explicit From impl"
20397 );
20398 let owned_arc: std::sync::Arc<str> =
20399 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20400 assert_eq!(
20401 via_trait, owned_arc,
20402 "From<&DepList> for std::sync::Arc<str> and \
20403 From<DepList> for std::sync::Arc<str> must resolve \
20404 identically on DepList::{variant:?} — divergence \
20405 signals the borrowed-input and owned-input \
20406 std::sync::Arc<str> forward-projection input-shape \
20407 paths have drifted onto different emit-sets"
20408 );
20409 let borrowed_static: &'static str =
20410 <&'static str as From<&super::DepList>>::from(&variant);
20411 assert_eq!(
20412 via_trait.as_ref(),
20413 borrowed_static,
20414 "From<&DepList> for std::sync::Arc<str> and \
20415 From<&DepList> for &'static str must resolve \
20416 identically on DepList::{variant:?} — divergence \
20417 signals the borrowed-input std::sync::Arc<str> and \
20418 &'static str return-shape paths have drifted onto \
20419 different emit-sets"
20420 );
20421 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20422 assert_eq!(
20423 via_trait.as_ref(),
20424 borrowed_string.as_str(),
20425 "From<&DepList> for std::sync::Arc<str> and \
20426 From<&DepList> for String must resolve identically on \
20427 DepList::{variant:?} — divergence signals the \
20428 borrowed-input std::sync::Arc<str> and owned-`String` \
20429 return-shape paths have drifted onto different emit-\
20430 sets"
20431 );
20432 let borrowed_cow: std::borrow::Cow<'static, str> =
20433 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20434 assert_eq!(
20435 via_trait.as_ref(),
20436 borrowed_cow.as_ref(),
20437 "From<&DepList> for std::sync::Arc<str> and \
20438 From<&DepList> for Cow<'static, str> must resolve \
20439 identically on DepList::{variant:?} — divergence \
20440 signals the borrowed-input std::sync::Arc<str> and \
20441 Cow<'static, str> return-shape paths have drifted onto \
20442 different emit-sets"
20443 );
20444 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20445 assert_eq!(
20446 via_trait.as_ref(),
20447 borrowed_box.as_ref(),
20448 "From<&DepList> for std::sync::Arc<str> and \
20449 From<&DepList> for Box<str> must resolve identically \
20450 on DepList::{variant:?} — divergence signals the \
20451 borrowed-input std::sync::Arc<str> and Box<str> \
20452 return-shape paths have drifted onto different emit-sets"
20453 );
20454 }
20455 let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
20456 .iter()
20457 .map(std::sync::Arc::<str>::from)
20458 .collect();
20459 let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
20460 .iter()
20461 .map(|l| std::sync::Arc::<str>::from(l.as_str()))
20462 .collect();
20463 assert_eq!(
20464 via_iter, via_method,
20465 "`.iter().map(std::sync::Arc::<str>::from)` over \
20466 DepList::ALL — a call site whose iteration axis holds \
20467 `&DepList` by construction — must byte-equal \
20468 `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
20469 on every arm — the borrowed-input std::sync::Arc<str> \
20470 `From<&DepList> for std::sync::Arc<str>` axis is what \
20471 makes the `std::sync::Arc::<str>::from` composition route \
20472 through the substrate-primitive `DepList::as_str` \
20473 accessor without a spurious `Copy` deref (which would \
20474 only be reachable through the owned-input \
20475 `From<DepList> for std::sync::Arc<str>` axis by first \
20476 calling `.copied()` on the iterator)"
20477 );
20478 }
20479
20480 #[test]
20481 fn dep_list_from_into_rc_str_routes_through_as_str_accessor() {
20482 // Fail-before-pass-after byte-parity pin on the newly lifted
20483 // `impl From<DepList> for std::rc::Rc<str>` — asserts the
20484 // owned-input standard-library trait impl and the substrate-
20485 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20486 // resolve to the same two-arm emit-set (the paired
20487 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20488 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20489 // byte-strings) across every arm the exhaustive
20490 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20491 // core-internal tier of the substrate-wide
20492 // [`std::rc::Rc<str>`] forward-projection campaign onto the
20493 // third caixa-core-internal peer, after the top-level
20494 // [`crate::CaixaKind`] (e04aff0), the second-peer
20495 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and the render-
20496 // side [`crate::render::PathShapeViolation`] (31fc43e) pairs
20497 // opened the tier. Rust's standard library carries
20498 // `impl From<&str> for std::rc::Rc<str>` and
20499 // `impl From<String> for std::rc::Rc<str>` but no blanket
20500 // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and the
20501 // [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait
20502 // tables are disjoint, so this axis is a distinct trait-
20503 // idiomatic surface that a
20504 // `let key: std::rc::Rc<str> = list.into();`-shaped call site
20505 // reaches through this impl and no other — a paired
20506 // `std::rc::Rc::<str>::from(list.as_str())` open-code has no
20507 // compile-time link back to the substrate primitive, and a
20508 // two-step `std::rc::Rc::<str>::from(String::from(list))`
20509 // composition through the owned-`String` axis allocates twice
20510 // (once into the intermediate `String`, once into the
20511 // [`std::rc::Rc<str>`] on the `From<String>` conversion) where
20512 // the single-step trait impl allocates once.
20513 //
20514 // Cross-axis byte-parity witness against the sibling owned-
20515 // input `{&'static str, String, Cow<'static, str>, Box<str>,
20516 // std::sync::Arc<str>}` return-shape axes — locking the six
20517 // return-shape paths on the owned-input surface together by
20518 // construction so any future detour off the substrate-
20519 // primitive [`super::DepList::as_str`] accessor trips at
20520 // caixa-core test time.
20521 for &variant in super::DepList::ALL {
20522 let via_trait: std::rc::Rc<str> =
20523 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20524 let via_method: &'static str = variant.as_str();
20525 assert_eq!(
20526 via_trait.as_ref(),
20527 via_method,
20528 "From<DepList> for std::rc::Rc<str> impl must round-\
20529 trip DepList::{variant:?} to the same lifted \
20530 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20531 DepList::as_str returns — divergence signals a silent \
20532 detour off the substrate-primitive accessor"
20533 );
20534 let via_into: std::rc::Rc<str> = variant.into();
20535 assert_eq!(
20536 via_into.as_ref(),
20537 via_method,
20538 "Into<std::rc::Rc<str>>::into on DepList::{variant:?} \
20539 must byte-equal DepList::as_str on the same input — \
20540 the blanket-derived Into shape must resolve to the \
20541 same as_str dispatch as the explicit From impl"
20542 );
20543 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20544 assert_eq!(
20545 via_trait.as_ref(),
20546 owned_static,
20547 "From<DepList> for std::rc::Rc<str> and \
20548 From<DepList> for &'static str must resolve identically \
20549 on DepList::{variant:?} — divergence signals the owned-\
20550 input std::rc::Rc<str> and &'static str return-shape \
20551 paths have drifted onto different emit-sets"
20552 );
20553 let owned_string: String = <String as From<super::DepList>>::from(variant);
20554 assert_eq!(
20555 via_trait.as_ref(),
20556 owned_string.as_str(),
20557 "From<DepList> for std::rc::Rc<str> and \
20558 From<DepList> for String must resolve identically on \
20559 DepList::{variant:?} — divergence signals the owned-\
20560 input std::rc::Rc<str> and owned-`String` return-shape \
20561 paths have drifted onto different emit-sets"
20562 );
20563 let owned_cow: std::borrow::Cow<'static, str> =
20564 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20565 assert_eq!(
20566 via_trait.as_ref(),
20567 owned_cow.as_ref(),
20568 "From<DepList> for std::rc::Rc<str> and \
20569 From<DepList> for Cow<'static, str> must resolve \
20570 identically on DepList::{variant:?} — divergence signals \
20571 the owned-input std::rc::Rc<str> and Cow<'static, str> \
20572 return-shape paths have drifted onto different emit-sets"
20573 );
20574 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20575 assert_eq!(
20576 via_trait.as_ref(),
20577 owned_box.as_ref(),
20578 "From<DepList> for std::rc::Rc<str> and \
20579 From<DepList> for Box<str> must resolve identically on \
20580 DepList::{variant:?} — divergence signals the owned-\
20581 input std::rc::Rc<str> and Box<str> return-shape paths \
20582 have drifted onto different emit-sets"
20583 );
20584 let owned_arc: std::sync::Arc<str> =
20585 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20586 assert_eq!(
20587 via_trait.as_ref(),
20588 owned_arc.as_ref(),
20589 "From<DepList> for std::rc::Rc<str> and \
20590 From<DepList> for std::sync::Arc<str> must resolve \
20591 identically on DepList::{variant:?} — divergence signals \
20592 the owned-input std::rc::Rc<str> and std::sync::Arc<str> \
20593 return-shape paths have drifted onto different emit-sets \
20594 (the two disjoint reference-counted trait tables have \
20595 desynchronized on the caixa-core two-list dep-graph axis)"
20596 );
20597 }
20598 }
20599
20600 #[test]
20601 #[allow(
20602 clippy::too_many_lines,
20603 reason = "cross-axis partition pin folds five borrowed-input \
20604 return-shape paths (&'static str, String, Cow<'static, \
20605 str>, Box<str>, std::sync::Arc<str>) plus the paired \
20606 owned-input Rc<str> witness and the \
20607 .iter().map(std::rc::Rc::<str>::from) pipe witness into \
20608 one exhaustive round-trip over DepList::ALL — the \
20609 accepted line-count cost of keying the whole borrowed-\
20610 input Rc<str> corner to the substrate-primitive as_str \
20611 accessor at the same test-site"
20612 )]
20613 fn dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
20614 // Fail-before-pass-after byte-parity pin on the newly lifted
20615 // `impl From<&DepList> for std::rc::Rc<str>` — asserts the
20616 // borrowed-input standard-library trait impl and the substrate-
20617 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20618 // resolve to the same two-arm emit-set across every arm the
20619 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20620 // standard library does not carry a blanket
20621 // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
20622 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20623 // the borrowed-input `std::rc::Rc<str>` forward-projection axis
20624 // is a distinct trait-idiomatic surface that a
20625 // `let key: std::rc::Rc<str> = (&list).into();`-shaped call
20626 // site or a
20627 // `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
20628 // pipe reaches through this impl and no other — the paired
20629 // owned-input `From<DepList> for std::rc::Rc<str>` impl alone
20630 // would force every borrowed-input call site through a spurious
20631 // `Copy` deref
20632 // (`std::rc::Rc::<str>::from((*list).as_str())`) or a
20633 // `.copied()` restatement whose type bounds have no compile-
20634 // time link back to the substrate primitive.
20635 //
20636 // Closes the `{Self, &Self}` input-shape corner on the third
20637 // caixa-core-internal closed-set fieldless typed enum peer of
20638 // the substrate-wide trait-idiomatic [`std::rc::Rc<str>`]
20639 // forward-projection campaign, matching the trajectory the
20640 // paired [`crate::CaixaKind`] (e04aff0),
20641 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and
20642 // [`crate::render::PathShapeViolation`] (31fc43e) pairs walked
20643 // before it on the same tier of the same axis.
20644 //
20645 // Cross-axis partition pin against the paired owned-input
20646 // [`From<DepList> for std::rc::Rc<str>`] and the sibling
20647 // borrowed-input `{&'static str, String, Cow<'static, str>,
20648 // Box<str>, std::sync::Arc<str>}` return-shape axes — locking
20649 // the six return-shape × input-shape paths on the borrowed-
20650 // input surface together by construction so any future detour
20651 // off the substrate-primitive accessor trips at caixa-core
20652 // test time. Then a `.iter().map(std::rc::Rc::<str>::from)`
20653 // pipe witness over [`super::DepList::ALL`] — whose iterator
20654 // yields `&DepList` by construction, so the borrowed-input
20655 // [`std::rc::Rc<str>`] axis is what routes the pipe through
20656 // the substrate-primitive [`super::DepList::as_str`] accessor
20657 // without a spurious [`Copy`] deref (which would only be
20658 // reachable through the owned-input
20659 // [`From<DepList> for std::rc::Rc<str>`] axis by first calling
20660 // `.copied()` on the iterator).
20661 for &variant in super::DepList::ALL {
20662 let via_trait: std::rc::Rc<str> =
20663 <std::rc::Rc<str> as From<&super::DepList>>::from(&variant);
20664 let via_method: &'static str = variant.as_str();
20665 assert_eq!(
20666 via_trait.as_ref(),
20667 via_method,
20668 "From<&DepList> for std::rc::Rc<str> impl must round-\
20669 trip &DepList::{variant:?} to the same lifted \
20670 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20671 DepList::as_str returns — divergence signals a silent \
20672 detour off the substrate-primitive accessor"
20673 );
20674 let via_into: std::rc::Rc<str> = (&variant).into();
20675 assert_eq!(
20676 via_into.as_ref(),
20677 via_method,
20678 "Into<std::rc::Rc<str>>::into on &DepList::\
20679 {variant:?} must byte-equal DepList::as_str on the \
20680 same input — the blanket-derived Into shape on the \
20681 borrowed-input surface must resolve to the same \
20682 as_str dispatch as the explicit From impl"
20683 );
20684 let owned_rc: std::rc::Rc<str> =
20685 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20686 assert_eq!(
20687 via_trait, owned_rc,
20688 "From<&DepList> for std::rc::Rc<str> and \
20689 From<DepList> for std::rc::Rc<str> must resolve \
20690 identically on DepList::{variant:?} — divergence \
20691 signals the borrowed-input and owned-input \
20692 std::rc::Rc<str> forward-projection input-shape \
20693 paths have drifted onto different emit-sets"
20694 );
20695 let borrowed_static: &'static str =
20696 <&'static str as From<&super::DepList>>::from(&variant);
20697 assert_eq!(
20698 via_trait.as_ref(),
20699 borrowed_static,
20700 "From<&DepList> for std::rc::Rc<str> and \
20701 From<&DepList> for &'static str must resolve \
20702 identically on DepList::{variant:?} — divergence \
20703 signals the borrowed-input std::rc::Rc<str> and \
20704 &'static str return-shape paths have drifted onto \
20705 different emit-sets"
20706 );
20707 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20708 assert_eq!(
20709 via_trait.as_ref(),
20710 borrowed_string.as_str(),
20711 "From<&DepList> for std::rc::Rc<str> and \
20712 From<&DepList> for String must resolve identically on \
20713 DepList::{variant:?} — divergence signals the \
20714 borrowed-input std::rc::Rc<str> and owned-`String` \
20715 return-shape paths have drifted onto different emit-\
20716 sets"
20717 );
20718 let borrowed_cow: std::borrow::Cow<'static, str> =
20719 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20720 assert_eq!(
20721 via_trait.as_ref(),
20722 borrowed_cow.as_ref(),
20723 "From<&DepList> for std::rc::Rc<str> and \
20724 From<&DepList> for Cow<'static, str> must resolve \
20725 identically on DepList::{variant:?} — divergence \
20726 signals the borrowed-input std::rc::Rc<str> and \
20727 Cow<'static, str> return-shape paths have drifted onto \
20728 different emit-sets"
20729 );
20730 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20731 assert_eq!(
20732 via_trait.as_ref(),
20733 borrowed_box.as_ref(),
20734 "From<&DepList> for std::rc::Rc<str> and \
20735 From<&DepList> for Box<str> must resolve identically \
20736 on DepList::{variant:?} — divergence signals the \
20737 borrowed-input std::rc::Rc<str> and Box<str> \
20738 return-shape paths have drifted onto different emit-sets"
20739 );
20740 let borrowed_arc: std::sync::Arc<str> =
20741 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20742 assert_eq!(
20743 via_trait.as_ref(),
20744 borrowed_arc.as_ref(),
20745 "From<&DepList> for std::rc::Rc<str> and \
20746 From<&DepList> for std::sync::Arc<str> must resolve \
20747 identically on DepList::{variant:?} — divergence \
20748 signals the borrowed-input std::rc::Rc<str> and \
20749 std::sync::Arc<str> return-shape paths have drifted \
20750 onto different emit-sets (the two disjoint reference-\
20751 counted trait tables have desynchronized on the \
20752 caixa-core two-list dep-graph axis)"
20753 );
20754 }
20755 let via_iter: Vec<std::rc::Rc<str>> = super::DepList::ALL
20756 .iter()
20757 .map(std::rc::Rc::<str>::from)
20758 .collect();
20759 let via_method: Vec<std::rc::Rc<str>> = super::DepList::ALL
20760 .iter()
20761 .map(|l| std::rc::Rc::<str>::from(l.as_str()))
20762 .collect();
20763 assert_eq!(
20764 via_iter, via_method,
20765 "`.iter().map(std::rc::Rc::<str>::from)` over \
20766 DepList::ALL — a call site whose iteration axis holds \
20767 `&DepList` by construction — must byte-equal \
20768 `.iter().map(|l| std::rc::Rc::<str>::from(l.as_str()))` \
20769 on every arm — the borrowed-input std::rc::Rc<str> \
20770 `From<&DepList> for std::rc::Rc<str>` axis is what makes \
20771 the `std::rc::Rc::<str>::from` composition route through \
20772 the substrate-primitive `DepList::as_str` accessor \
20773 without a spurious `Copy` deref (which would only be \
20774 reachable through the owned-input \
20775 `From<DepList> for std::rc::Rc<str>` axis by first \
20776 calling `.copied()` on the iterator)"
20777 );
20778 }
20779
20780 #[test]
20781 fn dep_list_author_keys_covers_every_arm() {
20782 // Load-bearing pin on the substrate-canonical
20783 // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
20784 // on the `:`-prefixed kebab-case tatara-lisp author-surface
20785 // key axis: every variant of the sibling
20786 // [`super::DepList::ALL`] exhaustive-iteration surface must
20787 // project through [`super::DepList::as_str`] onto an entry the
20788 // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
20789 // roster's length must byte-equal `super::DepList::ALL.len()`
20790 // so a silent skew between the [`super::DepList::as_str`]
20791 // match's arm-set and the roster's arm-set trips here at
20792 // caixa-core test time rather than at a downstream M4
20793 // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
20794 // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
20795 // a `feira dep --list …` "did you mean" hint drift / a
20796 // downstream [`super::DepError`] widening's typed `list:
20797 // DepList` carry that fans on the enum through a stale
20798 // accepted-set. A future arm addition (a `:build-dep` or
20799 // `:tool-dep` third list once the substrate grows Cargo-style
20800 // split-graphs — both trajectory items the sibling
20801 // [`super::DepList::from_wire`] doc block already names)
20802 // extends [`super::DepList::ALL`] as a single edit and this
20803 // pin sweeps the new arm by iteration; the paired
20804 // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
20805 // or this assertion trips. Every entry is further pinned to
20806 // open with the ASCII `:` byte (the tatara-lisp author-surface
20807 // keyword marker) so a silent collapse of the author-key axis
20808 // with any hypothetical peer un-prefixed wire-form axis (an
20809 // entry byte-identical to a sibling `deps` / `deps-dev`
20810 // bare-kebab byte-string that would let an author-key-axis
20811 // consumer accept the un-prefixed vocabulary) trips here
20812 // rather than at a downstream consumer's
20813 // vocabulary-collision miss.
20814 //
20815 // Peer of the sibling
20816 // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
20817 // (bd708bd) /
20818 // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
20819 // (427fe75) /
20820 // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
20821 // (3033f45) /
20822 // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
20823 // (ce9412b) /
20824 // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
20825 // (3e5b194) /
20826 // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
20827 // (9d9f585) /
20828 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20829 // (b553ec9) /
20830 // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
20831 // (1898d77) /
20832 // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
20833 // (cc42c0e) pins — the same closed-set exhaustive-roster
20834 // coverage discipline extended here onto the two-list dep-graph
20835 // closed-set typed enum, the ninth substrate-side closed-set
20836 // typed enum on the roster axis and the last unlifted
20837 // `&'static str`-carrying closed-set typed enum on the top-
20838 // level manifest surface to converge onto the discipline.
20839 //
20840 // Fail-before-pass-after locally verified by mutating one arm
20841 // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
20842 // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
20843 // `":deps-dev"` to `":deps_dev"`) — the length pin still
20844 // passes but the `contains` check fires on the mutated arm;
20845 // and by shortening the roster to one entry — the length pin
20846 // fires first.
20847 assert_eq!(
20848 super::DepList::AUTHOR_KEYS.len(),
20849 super::DepList::ALL.len(),
20850 "DepList::AUTHOR_KEYS.len() must byte-equal \
20851 DepList::ALL.len() — a mismatch means the roster and \
20852 the enum's arm-set have drifted; downstream consumers \
20853 that fan through both will silently disagree on the \
20854 accepted arm-set"
20855 );
20856 for &variant in super::DepList::ALL {
20857 let key = variant.as_str();
20858 assert!(
20859 super::DepList::AUTHOR_KEYS.contains(&key),
20860 "DepList::{variant:?}.as_str() = {key:?} must be a \
20861 member of DepList::AUTHOR_KEYS — the emitter and the \
20862 roster have drifted out of lockstep"
20863 );
20864 }
20865 for tag in super::DepList::AUTHOR_KEYS {
20866 let first = tag.chars().next().unwrap_or_else(|| {
20867 panic!(
20868 "DepList::AUTHOR_KEYS entry {tag:?} must be a \
20869 non-empty `:`-prefixed kebab-case tatara-lisp \
20870 author-surface key byte-string"
20871 )
20872 });
20873 assert_eq!(
20874 first, ':',
20875 "DepList::AUTHOR_KEYS entry {tag:?} must open with \
20876 the ASCII `:` byte (tatara-lisp author-surface \
20877 keyword marker) — an un-prefixed entry would \
20878 collide the roster with any hypothetical peer bare-\
20879 kebab wire-form axis a downstream consumer might \
20880 disambiguate against"
20881 );
20882 }
20883 // Pin the exact two-arm roster in declaration order so a
20884 // future arm-swap on either the roster or the paired
20885 // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
20886 // arm-key mapping that leaves both the length pin and the
20887 // membership pin passing on their own) trips at caixa-core
20888 // test time under `assert_eq!`. Order matches variant
20889 // declaration order verbatim (`Prod` → `Dev`) so the roster
20890 // is the canonical ordering every listing / rendering
20891 // consumer defers to. Same declaration-order pin the sibling
20892 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20893 // (b553ec9) closes on the M3 `:politicas :rate-limit`
20894 // canonical-suffix axis.
20895 assert_eq!(
20896 super::DepList::AUTHOR_KEYS,
20897 &[
20898 crate::render::DEP_AUTHOR_KEY_DEPS,
20899 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
20900 ],
20901 "DepList::AUTHOR_KEYS must enumerate every arm's \
20902 author-surface key exactly once, in variant declaration \
20903 order (Prod → Dev)"
20904 );
20905 }
20906
20907 #[test]
20908 fn dep_list_from_str_routes_through_try_from_str_impl() {
20909 // Fail-before-pass-after byte-parity pin on the newly lifted
20910 // `impl std::str::FromStr for DepList` — asserts the standard-
20911 // library `.parse()` parse-axis entry point and the paired
20912 // [`super::DepList::try_from`] `TryFrom<&str>` impl (which in
20913 // turn routes through the substrate-primitive
20914 // [`super::DepList::from_wire`] `Option<Self>` accessor)
20915 // resolve to the same two-arm accept-set across every arm the
20916 // exhaustive [`super::DepList::ALL`] slice enumerates. First-
20917 // mover on the substrate-wide `FromStr` parse-axis campaign —
20918 // the peer method-named `from_wire` accessor and the paired
20919 // `TryFrom<&str>` trait impl fix the two-arm accept set; this
20920 // pin locks the `FromStr::from_str` trait entry point onto the
20921 // same set so any future divergence (a stray per-arm `match s`
20922 // re-inlining that opens a compile-time link to an un-lifted
20923 // arm-literal, a swap onto a hand-rolled parser that widens
20924 // the accept-set past the two wire-format consts) trips at
20925 // caixa-core test time.
20926 use std::str::FromStr;
20927 for &list in super::DepList::ALL {
20928 let wire = list.as_str();
20929 assert_eq!(
20930 <super::DepList as FromStr>::from_str(wire),
20931 Ok(list),
20932 "FromStr impl on DepList must round-trip \
20933 DepList::{list:?}.as_str() = {wire:?} back to \
20934 Ok(DepList::{list:?}) — divergence from \
20935 DepList::try_from signals a silent detour off the \
20936 paired reverse-projection trait impl"
20937 );
20938 assert_eq!(
20939 <super::DepList as FromStr>::from_str(wire).ok(),
20940 super::DepList::from_wire(wire),
20941 "FromStr ok()-projection on {wire:?} must byte-equal \
20942 DepList::from_wire on the same input — divergence \
20943 signals the two reverse-projection trait paths have \
20944 drifted off the substrate-primitive accessor"
20945 );
20946 // `.parse::<DepList>()` short-form witness — the stdlib
20947 // consumer surface that reaches the enum through the
20948 // `T: FromStr` bound, not through `TryFrom<&str>`.
20949 let via_parse: Result<super::DepList, ()> = wire.parse();
20950 assert_eq!(
20951 via_parse,
20952 Ok(list),
20953 "`{wire:?}`.parse::<DepList>() must resolve to \
20954 Ok(DepList::{list:?}) — divergence signals the \
20955 stdlib `.parse()` short-form has drifted from the \
20956 lifted `FromStr::from_str` impl"
20957 );
20958 }
20959 }
20960
20961 #[test]
20962 fn dep_list_from_str_rejects_unknown_byte_strings() {
20963 // Rejection witness on the `impl FromStr for DepList` —
20964 // sweeps candidate byte-strings outside the two-arm accept-set
20965 // the sibling [`super::DepList::as_str`] emits (`:deps` /
20966 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
20967 // future accidental widening of the trait impl's accept-set (a
20968 // stray case-fold path, a silent inclusion of a rebrand alias
20969 // like `":packages"`, an English rebrand `":dev-deps"` in
20970 // reverse arm-order that would silently swap the two arms) trips
20971 // at caixa-core test time. Peer of the sibling
20972 // `dep_list_try_from_str_rejects_unknown_byte_strings` rejection
20973 // witness — the two pins together bracket both reverse-projection
20974 // trait impls against the same rejected set.
20975 use std::str::FromStr;
20976 let rejected: &[&str] = &[
20977 "",
20978 " ",
20979 "\t",
20980 "\n",
20981 ":deps ",
20982 " :deps",
20983 ":DEPS",
20984 ":Deps",
20985 ":Deps-Dev",
20986 ":deps_dev",
20987 ":deps-development",
20988 ":dev-deps",
20989 ":packages",
20990 ":packages-dev",
20991 "deps",
20992 "deps-dev",
20993 "Prod",
20994 "Dev",
20995 "prod",
20996 "dev",
20997 "\":deps\"",
20998 "\":deps-dev\"",
20999 ":deps\n",
21000 ":deps-dev\n",
21001 ];
21002 for &input in rejected {
21003 assert_eq!(
21004 <super::DepList as FromStr>::from_str(input),
21005 Err(()),
21006 "FromStr impl on DepList must reject unknown \
21007 byte-string {input:?} — divergence from \
21008 DepList::from_wire on the same input signals a silent \
21009 accept-set widening past the two lifted \
21010 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
21011 );
21012 assert_eq!(
21013 <super::DepList as FromStr>::from_str(input).ok(),
21014 super::DepList::from_wire(input),
21015 "FromStr ok()-projection on {input:?} must byte-equal \
21016 DepList::from_wire on the same input — divergence \
21017 signals the FromStr trait path has drifted off the \
21018 substrate-primitive accessor"
21019 );
21020 let via_parse: Result<super::DepList, ()> = input.parse();
21021 assert_eq!(
21022 via_parse,
21023 Err(()),
21024 "`{input:?}`.parse::<DepList>() must reject the \
21025 unknown byte-string — divergence signals the stdlib \
21026 `.parse()` short-form has drifted from the lifted \
21027 `FromStr::from_str` impl"
21028 );
21029 }
21030 }
21031
21032 #[test]
21033 #[allow(
21034 clippy::too_many_lines,
21035 reason = "cross-axis partition pin folds the substrate-primitive \
21036 as_str accessor's `.as_bytes()` byte-tail plus the \
21037 paired str-view (AsRef<str>, Display, as_str) and \
21038 reverse-projection ({&'static str, String, \
21039 Cow<'static, str>, Box<str>, std::sync::Arc<str>, \
21040 std::rc::Rc<str>}) return-shape axes' `.as_bytes()` \
21041 byte-tails plus a <T: AsRef<[u8]>>-bound-consumer \
21042 witness plus a blake3::Hasher::update-shape byte-\
21043 input surface witness into one exhaustive round-trip \
21044 over DepList::ALL — the accepted line-count cost of \
21045 opening the byte-view axis keyed to the substrate-\
21046 primitive as_str accessor at the same test-site"
21047 )]
21048 #[allow(
21049 clippy::needless_borrows_for_generic_args,
21050 reason = "the borrowed-input surface (&variant) is exercised \
21051 deliberately: the `<T: AsRef<[u8]>>`-bound consumer \
21052 and the `blake3::Hasher::update`-shape byte-input \
21053 surface both accept either owned or borrowed input \
21054 through the standard-library blanket \
21055 `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`, \
21056 and this pin round-trips both input shapes to lock \
21057 the borrowed-input path load-bearing against a \
21058 future silent regression"
21059 )]
21060 fn dep_list_as_ref_bytes_routes_through_as_str_accessor() {
21061 // `<T: AsRef<[u8]>>`-bound-consumer witness helper: a generic
21062 // byte-input function accepts a [`super::DepList`] directly
21063 // through the trait bound, without the caller open-coding the
21064 // two-hop `list.as_str().as_bytes()` composition. Lifted to
21065 // the top of the function per `clippy::items_after_statements`.
21066 fn generic_bytes_sink<T: AsRef<[u8]>>(t: T) -> Vec<u8> {
21067 t.as_ref().to_vec()
21068 }
21069 // `blake3::Hasher::update`-shape byte-input surface mock:
21070 // mirrors `blake3::Hasher::update` / `ring::digest::Context::
21071 // update` / `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound
21072 // `update` signature so a per-caixa BLAKE3 content-address
21073 // closure that composes `hasher.update(list)` on the
21074 // [`crate::Lacre`] closure builder reaches the substrate-
21075 // primitive `as_str` accessor through the [`super::DepList`]
21076 // `AsRef<[u8]>` axis and no other. Lifted to the top of the
21077 // function per `clippy::items_after_statements`.
21078 struct MockHasher(Vec<u8>);
21079 impl MockHasher {
21080 fn new() -> Self {
21081 Self(Vec::new())
21082 }
21083 fn update(&mut self, bytes: impl AsRef<[u8]>) -> &mut Self {
21084 self.0.extend_from_slice(bytes.as_ref());
21085 self
21086 }
21087 fn finalize(self) -> Vec<u8> {
21088 self.0
21089 }
21090 }
21091
21092 // Fail-before-pass-after byte-parity pin on the newly lifted
21093 // `impl AsRef<[u8]> for DepList` — asserts the trait-idiomatic
21094 // byte-view standard-library impl and the substrate-primitive
21095 // [`super::DepList::as_str`] `pub const fn` accessor's
21096 // `.as_bytes()` byte-tail resolve to the same two-arm
21097 // `:`-prefixed kebab-case byte-string emit-set across every
21098 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
21099 // Extends the substrate-wide trait-idiomatic byte-view axis
21100 // onto the third closed-set fieldless typed enum on the
21101 // caixa-core-internal tier — matching the trajectory the
21102 // sibling [`super::CaixaKind`] first-mover [`AsRef<[u8]>`]
21103 // impl (69d8d86) and [`super::CaixaDialeto`] second-mover
21104 // impl (8151347) walked before it.
21105 for &variant in super::DepList::ALL {
21106 let via_trait: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21107 let via_method_bytes: &[u8] = variant.as_str().as_bytes();
21108 assert_eq!(
21109 via_trait, via_method_bytes,
21110 "AsRef<[u8]> for DepList impl must byte-equal \
21111 DepList::as_str().as_bytes() on DepList::\
21112 {variant:?} — divergence signals a silent detour off \
21113 the substrate-primitive accessor"
21114 );
21115 // Cross-axis witness against the paired str-view axes'
21116 // `.as_bytes()` byte-tails: [`AsRef<str>`] /
21117 // [`std::fmt::Display`] / [`super::DepList::as_str`] all
21118 // resolve to the same lifted `render::DEP_AUTHOR_KEY_*`
21119 // const roster, and the byte-view axis must byte-equal
21120 // each of their `.as_bytes()` byte-tails by construction
21121 // — locking the str-view and byte-view axes together at
21122 // the substrate-primitive accessor.
21123 let str_view_ref: &str = <super::DepList as AsRef<str>>::as_ref(&variant);
21124 assert_eq!(
21125 via_trait,
21126 str_view_ref.as_bytes(),
21127 "AsRef<[u8]> for DepList and AsRef<str> for DepList \
21128 must resolve to byte-equal byte-tails on DepList::\
21129 {variant:?} — divergence signals the byte-view and \
21130 str-view axes have drifted off the same substrate-\
21131 primitive as_str accessor"
21132 );
21133 let display_bytes = variant.to_string();
21134 assert_eq!(
21135 via_trait,
21136 display_bytes.as_bytes(),
21137 "AsRef<[u8]> for DepList and \
21138 <DepList as std::fmt::Display>::to_string must \
21139 resolve to byte-equal byte-tails on DepList::\
21140 {variant:?} — divergence signals the byte-view axis \
21141 and the Display formatter axis have drifted off the \
21142 same substrate-primitive as_str accessor"
21143 );
21144 // Cross-axis witness against the paired reverse-
21145 // projection axes' `.as_bytes()` byte-tails: every one of
21146 // `{&'static str, String, Cow<'static, str>, Box<str>,
21147 // std::sync::Arc<str>, std::rc::Rc<str>}` allocates (or
21148 // borrows) the same `:`-prefixed kebab byte-string the
21149 // substrate-primitive accessor emits, so the byte-view
21150 // axis must byte-equal each of their `.as_bytes()` byte-
21151 // tails by construction.
21152 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
21153 assert_eq!(
21154 via_trait,
21155 owned_static.as_bytes(),
21156 "AsRef<[u8]> for DepList and From<DepList> for \
21157 &'static str must resolve to byte-equal byte-tails on \
21158 DepList::{variant:?}"
21159 );
21160 let owned_string: String = <String as From<super::DepList>>::from(variant);
21161 assert_eq!(
21162 via_trait,
21163 owned_string.as_bytes(),
21164 "AsRef<[u8]> for DepList and From<DepList> for \
21165 String must resolve to byte-equal byte-tails on \
21166 DepList::{variant:?}"
21167 );
21168 let owned_cow: std::borrow::Cow<'static, str> =
21169 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
21170 assert_eq!(
21171 via_trait,
21172 owned_cow.as_bytes(),
21173 "AsRef<[u8]> for DepList and From<DepList> for \
21174 Cow<'static, str> must resolve to byte-equal byte-\
21175 tails on DepList::{variant:?}"
21176 );
21177 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
21178 assert_eq!(
21179 via_trait,
21180 owned_box.as_bytes(),
21181 "AsRef<[u8]> for DepList and From<DepList> for \
21182 Box<str> must resolve to byte-equal byte-tails on \
21183 DepList::{variant:?}"
21184 );
21185 let owned_arc: std::sync::Arc<str> =
21186 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
21187 assert_eq!(
21188 via_trait,
21189 owned_arc.as_bytes(),
21190 "AsRef<[u8]> for DepList and From<DepList> for \
21191 std::sync::Arc<str> must resolve to byte-equal byte-\
21192 tails on DepList::{variant:?}"
21193 );
21194 let owned_rc_str: std::rc::Rc<str> =
21195 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
21196 assert_eq!(
21197 via_trait,
21198 owned_rc_str.as_bytes(),
21199 "AsRef<[u8]> for DepList and From<DepList> for \
21200 std::rc::Rc<str> must resolve to byte-equal byte-\
21201 tails on DepList::{variant:?}"
21202 );
21203 }
21204 // `<T: AsRef<[u8]>>`-bound-consumer witness: the generic byte-
21205 // input function `generic_bytes_sink` (lifted above per
21206 // `clippy::items_after_statements`) accepts a [`super::DepList`]
21207 // directly through the trait bound, without the caller open-
21208 // coding the two-hop `list.as_str().as_bytes()` composition.
21209 // This is the shape that reaches the caixa-lacre BLAKE3
21210 // content-address closure's
21211 // `blake3::Hasher::update(impl AsRef<[u8]>)` byte-input surface
21212 // through this impl and no other. Exercised on both owned and
21213 // borrowed input surfaces via the standard-library blanket
21214 // `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`.
21215 for &variant in super::DepList::ALL {
21216 let via_generic = generic_bytes_sink(variant);
21217 let via_borrowed_generic = generic_bytes_sink(&variant);
21218 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21219 assert_eq!(
21220 via_generic, via_method_bytes,
21221 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21222 DepList::{variant:?} must yield the same byte-tail \
21223 DepList::as_str().as_bytes() returns — divergence \
21224 signals the byte-view axis fails to bridge a generic \
21225 byte-input trait bound to the substrate-primitive \
21226 accessor"
21227 );
21228 assert_eq!(
21229 via_borrowed_generic, via_method_bytes,
21230 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21231 &DepList::{variant:?} must yield the same byte-tail \
21232 DepList::as_str().as_bytes() returns — the borrowed-\
21233 input surface must resolve to the same as_str dispatch"
21234 );
21235 }
21236 // `blake3::Hasher::update`-shape byte-input surface witness
21237 // on the caixa-lacre compounding target: the `MockHasher`
21238 // (lifted above per `clippy::items_after_statements`) mirrors
21239 // `blake3::Hasher::update` / `ring::digest::Context::update` /
21240 // `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound update
21241 // signature and accepts a [`super::DepList`] directly, routing
21242 // its byte-tail through the substrate-primitive `as_str`
21243 // accessor — the shape a future per-caixa BLAKE3 content-
21244 // address closure composes to fold a dep-list discriminator
21245 // byte-tag into the [`crate::Lacre`] closure body so a
21246 // downstream `Lacre` consumer can partition the runtime-
21247 // closure `:deps` from the dev-only-closure `:deps-dev` at
21248 // content-address time.
21249 for &variant in super::DepList::ALL {
21250 let mut owned_hasher = MockHasher::new();
21251 owned_hasher.update(variant);
21252 let owned_folded = owned_hasher.finalize();
21253 assert_eq!(
21254 owned_folded,
21255 variant.as_str().as_bytes(),
21256 "`hasher.update(list)`-shape composition on DepList::\
21257 {variant:?} must fold the same byte-tail DepList::\
21258 as_str().as_bytes() returns — the shape a future \
21259 per-caixa BLAKE3 content-address closure composes to \
21260 fold a dep-list discriminator byte-tag into the Lacre \
21261 closure body"
21262 );
21263 let mut borrowed_hasher = MockHasher::new();
21264 borrowed_hasher.update(&variant);
21265 let borrowed_folded = borrowed_hasher.finalize();
21266 assert_eq!(
21267 borrowed_folded,
21268 variant.as_str().as_bytes(),
21269 "`hasher.update(&list)`-shape composition on \
21270 &DepList::{variant:?} must fold the same byte-tail \
21271 DepList::as_str().as_bytes() returns — the borrowed-\
21272 input surface must resolve to the same as_str dispatch"
21273 );
21274 }
21275 }
21276
21277 #[test]
21278 #[expect(
21279 clippy::too_many_lines,
21280 reason = "the byte-owned reverse-projection axis is extended \
21281 onto DepList here as the third peer on the substrate-\
21282 wide byte-owned Vec<u8>-output projection family \
21283 (after the sibling first-mover CaixaKind, b245fd6, \
21284 and second-mover CaixaDialeto, 4cceaf5), so the pin \
21285 binds the new impl against every paired byte-view \
21286 and str-view axis on the same enum plus a generic \
21287 <T: Into<Vec<u8>>>-bound consumer witness and a \
21288 std::io::Write::write_all-shape owned-byte-sink \
21289 surface witness on both owned and borrowed input \
21290 shapes to lock the whole family against a future \
21291 silent regression"
21292 )]
21293 fn dep_list_from_into_owned_vec_bytes_routes_through_as_str_accessor() {
21294 // `<T: Into<Vec<u8>>>`-bound-consumer witness helper: a generic
21295 // owned-byte-input function accepts a [`super::DepList`]
21296 // directly through the trait bound, without the caller open-
21297 // coding the three-hop `list.as_str().as_bytes().to_vec()`
21298 // composition. Lifted to the top of the function per
21299 // `clippy::items_after_statements`.
21300 fn generic_owned_bytes_sink<T: Into<Vec<u8>>>(t: T) -> Vec<u8> {
21301 t.into()
21302 }
21303 // `std::io::Write::write_all`-shape owned-byte-sink surface
21304 // mock: mirrors `std::io::Write::write_all` /
21305 // `bytes::BytesMut::extend_from_slice` / any per-arm audit-log
21306 // byte-sink that consumes a `Vec<u8>` payload via
21307 // `Into<Vec<u8>>`, so a future per-caixa per-`:deps`/`:deps-dev`
21308 // audit-log emit reaches the substrate-primitive `as_str`
21309 // accessor through the byte-owned reverse-projection axis and
21310 // no other. Lifted to the top of the function per
21311 // `clippy::items_after_statements`.
21312 struct MockOwnedByteSink(Vec<u8>);
21313 impl MockOwnedByteSink {
21314 fn new() -> Self {
21315 Self(Vec::new())
21316 }
21317 fn write_all(&mut self, bytes: impl Into<Vec<u8>>) -> &mut Self {
21318 self.0.extend_from_slice(&bytes.into());
21319 self
21320 }
21321 fn finalize(self) -> Vec<u8> {
21322 self.0
21323 }
21324 }
21325
21326 // Fail-before-pass-after byte-parity pin on the newly lifted
21327 // `impl From<DepList> for Vec<u8>` and
21328 // `impl From<&DepList> for Vec<u8>` — asserts the trait-
21329 // idiomatic byte-owned reverse-projection standard-library
21330 // impls and the substrate-primitive
21331 // [`super::DepList::as_str`] `pub const fn` accessor's
21332 // `.as_bytes().to_vec()` byte-tail resolve to the same two-arm
21333 // `:`-prefixed kebab-case byte-string emit-set across every
21334 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
21335 // Extends the substrate-wide trait-idiomatic byte-owned
21336 // reverse-projection axis onto the third closed-set fieldless
21337 // typed enum on the caixa-core-internal tier — matching the
21338 // trajectory the sibling first-mover [`super::CaixaKind`]
21339 // `From<{Self, &Self}> for Vec<u8>` impls (b245fd6) and the
21340 // second-mover [`crate::dialeto::CaixaDialeto`] impls (4cceaf5)
21341 // walked before it on the caixa-core tier of the byte-owned
21342 // axis.
21343 for &variant in super::DepList::ALL {
21344 let via_owned_from: Vec<u8> = <Vec<u8> as From<super::DepList>>::from(variant);
21345 let via_borrowed_from: Vec<u8> = <Vec<u8> as From<&super::DepList>>::from(&variant);
21346 let via_method_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
21347 assert_eq!(
21348 via_owned_from, via_method_bytes,
21349 "From<DepList> for Vec<u8> impl must byte-equal \
21350 DepList::as_str().as_bytes().to_vec() on DepList::\
21351 {variant:?} — divergence signals a silent detour off \
21352 the substrate-primitive accessor"
21353 );
21354 assert_eq!(
21355 via_borrowed_from, via_method_bytes,
21356 "From<&DepList> for Vec<u8> impl must byte-equal \
21357 DepList::as_str().as_bytes().to_vec() on DepList::\
21358 {variant:?} — divergence signals a silent detour off \
21359 the substrate-primitive accessor"
21360 );
21361 assert_eq!(
21362 via_owned_from, via_borrowed_from,
21363 "From<DepList> for Vec<u8> and From<&DepList> for \
21364 Vec<u8> must byte-equal each other on DepList::\
21365 {variant:?} — divergence signals the owned-input and \
21366 borrowed-input paths have drifted off the same \
21367 substrate-primitive as_str accessor"
21368 );
21369 // Cross-axis witness against the paired [`AsRef<[u8]>`]
21370 // borrowed byte-view axis: the byte-owned reverse-
21371 // projection axis must byte-equal the paired borrowed
21372 // byte-view axis by construction — locking the byte-view
21373 // and byte-owned axes together at the substrate-primitive
21374 // accessor.
21375 let borrowed_bytes: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21376 assert_eq!(
21377 via_owned_from,
21378 borrowed_bytes.to_vec(),
21379 "From<DepList> for Vec<u8> and AsRef<[u8]> for DepList \
21380 must resolve to byte-equal byte-tails on DepList::\
21381 {variant:?} — divergence signals the byte-owned and \
21382 byte-view axes have drifted off the same substrate-\
21383 primitive as_str accessor"
21384 );
21385 // Cross-axis witness against the str-owned reverse-
21386 // projection family's `.into_bytes()` / `.as_bytes().to_vec()`
21387 // byte-tails: every one of `{String, Cow<'static, str>,
21388 // Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
21389 // allocates (or borrows) the same `:`-prefixed kebab byte-
21390 // string the substrate-primitive accessor emits, so the
21391 // byte-owned axis must byte-equal each of their owned
21392 // byte-tails by construction.
21393 let owned_string: String = <String as From<super::DepList>>::from(variant);
21394 assert_eq!(
21395 via_owned_from,
21396 owned_string.into_bytes(),
21397 "From<DepList> for Vec<u8> and \
21398 String::from(list).into_bytes() must resolve to byte-\
21399 equal byte-tails on DepList::{variant:?}"
21400 );
21401 let owned_cow: std::borrow::Cow<'static, str> =
21402 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
21403 assert_eq!(
21404 via_owned_from,
21405 owned_cow.as_bytes().to_vec(),
21406 "From<DepList> for Vec<u8> and From<DepList> for \
21407 Cow<'static, str> must resolve to byte-equal byte-\
21408 tails on DepList::{variant:?}"
21409 );
21410 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
21411 assert_eq!(
21412 via_owned_from,
21413 owned_box.as_bytes().to_vec(),
21414 "From<DepList> for Vec<u8> and From<DepList> for \
21415 Box<str> must resolve to byte-equal byte-tails on \
21416 DepList::{variant:?}"
21417 );
21418 let owned_arc: std::sync::Arc<str> =
21419 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
21420 assert_eq!(
21421 via_owned_from,
21422 owned_arc.as_bytes().to_vec(),
21423 "From<DepList> for Vec<u8> and From<DepList> for \
21424 std::sync::Arc<str> must resolve to byte-equal byte-\
21425 tails on DepList::{variant:?}"
21426 );
21427 let owned_rc_str: std::rc::Rc<str> =
21428 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
21429 assert_eq!(
21430 via_owned_from,
21431 owned_rc_str.as_bytes().to_vec(),
21432 "From<DepList> for Vec<u8> and From<DepList> for \
21433 std::rc::Rc<str> must resolve to byte-equal byte-\
21434 tails on DepList::{variant:?}"
21435 );
21436 }
21437 // `<T: Into<Vec<u8>>>`-bound-consumer witness on both owned
21438 // and borrowed input shapes: the generic owned-byte-input
21439 // function `generic_owned_bytes_sink` (lifted above per
21440 // `clippy::items_after_statements`) accepts a
21441 // [`super::DepList`] and a `&DepList` directly through the
21442 // trait bound, without the caller open-coding the three-hop
21443 // `list.as_str().as_bytes().to_vec()` composition.
21444 for &variant in super::DepList::ALL {
21445 let via_generic_owned = generic_owned_bytes_sink(variant);
21446 // Bind the borrowed-input path through an explicit
21447 // `&DepList` local so the generic-consumer witness routes
21448 // through `From<&DepList> for Vec<u8>` (T binds to
21449 // `&DepList`) rather than clippy-collapsing the borrow
21450 // onto the owned-input `From<DepList> for Vec<u8>` peer.
21451 let variant_ref: &super::DepList = &variant;
21452 let via_generic_borrowed = generic_owned_bytes_sink(variant_ref);
21453 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21454 assert_eq!(
21455 via_generic_owned, via_method_bytes,
21456 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21457 DepList::{variant:?} must yield the same byte-tail \
21458 DepList::as_str().as_bytes().to_vec() returns — \
21459 divergence signals the byte-owned axis fails to \
21460 bridge a generic owned-byte-input trait bound to the \
21461 substrate-primitive accessor"
21462 );
21463 assert_eq!(
21464 via_generic_borrowed, via_method_bytes,
21465 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21466 &DepList::{variant:?} must yield the same byte-tail \
21467 DepList::as_str().as_bytes().to_vec() returns — the \
21468 borrowed-input surface must resolve to the same \
21469 as_str dispatch"
21470 );
21471 }
21472 // `std::io::Write::write_all`-shape owned-byte-sink surface
21473 // witness: the `MockOwnedByteSink` (lifted above per
21474 // `clippy::items_after_statements`) mirrors
21475 // `std::io::Write::write_all` /
21476 // `bytes::BytesMut::extend_from_slice`'s `impl Into<Vec<u8>>`-
21477 // bound owned-byte input signature and accepts a
21478 // [`super::DepList`] directly on both owned and borrowed input
21479 // shapes, routing its byte-tail through the substrate-
21480 // primitive `as_str` accessor — the shape a future per-caixa
21481 // per-`:deps`/`:deps-dev` audit-log emit composes to fold a
21482 // dep-list discriminator byte-tag into a downstream owned-
21483 // byte-sink surface so a partition of the runtime-closure
21484 // `:deps` from the dev-only-closure `:deps-dev` reaches the
21485 // sink through this axis and no other.
21486 for &variant in super::DepList::ALL {
21487 let mut owned_sink = MockOwnedByteSink::new();
21488 owned_sink.write_all(variant);
21489 let owned_folded = owned_sink.finalize();
21490 assert_eq!(
21491 owned_folded,
21492 variant.as_str().as_bytes(),
21493 "`sink.write_all(list)`-shape composition on DepList::\
21494 {variant:?} must fold the same byte-tail DepList::\
21495 as_str().as_bytes() returns"
21496 );
21497 let mut borrowed_sink = MockOwnedByteSink::new();
21498 // Same explicit `&DepList` binding as the generic-consumer
21499 // witness above: routes the owned-byte-sink surface
21500 // through `From<&DepList> for Vec<u8>` (T binds to
21501 // `&DepList`) rather than clippy-collapsing the borrow
21502 // onto the owned-input peer.
21503 let variant_ref: &super::DepList = &variant;
21504 borrowed_sink.write_all(variant_ref);
21505 let borrowed_folded = borrowed_sink.finalize();
21506 assert_eq!(
21507 borrowed_folded,
21508 variant.as_str().as_bytes(),
21509 "`sink.write_all(&list)`-shape composition on \
21510 &DepList::{variant:?} must fold the same byte-tail \
21511 DepList::as_str().as_bytes() returns — the borrowed-\
21512 input surface must resolve to the same as_str dispatch"
21513 );
21514 }
21515 }
21516
21517 #[test]
21518 fn dep_list_try_from_bytes_routes_through_from_wire_accessor() {
21519 // Fail-before-pass-after byte-parity pin on the newly lifted
21520 // `impl TryFrom<&[u8]> for DepList` — asserts the trait-
21521 // idiomatic byte-view reverse-projection standard-library impl
21522 // and the substrate-primitive [`super::DepList::from_wire`]
21523 // `Option<Self>` accessor resolve to the same two-arm
21524 // `:`-prefixed kebab-case wire accept-set across every arm the
21525 // exhaustive [`super::DepList::ALL`] slice enumerates. Extends
21526 // the substrate-wide trait-idiomatic byte-view reverse-
21527 // projection axis onto the third caixa-core-internal closed-set
21528 // fieldless typed enum peer — mirror of the paired
21529 // [`TryFrom<&str> for DepList`] str-view reverse-projection
21530 // axis on the same enum, and the byte-view companion of the
21531 // pre-existing byte-owned reverse-projection family
21532 // ([`AsRef<[u8]>`], [`From<DepList> for Vec<u8>`],
21533 // [`From<&DepList> for Vec<u8>`]) on this same enum. Peer of
21534 // the sibling
21535 // [`crate::kind::tests::caixa_kind_try_from_bytes_routes_through_from_wire_accessor`]
21536 // (18d1940) on the first-mover [`crate::CaixaKind`] closed-set
21537 // typed-enum peer and the sibling
21538 // [`crate::dialeto::tests::caixa_dialeto_try_from_bytes_routes_through_from_wire_accessor`]
21539 // (d102cb8) on the second-mover [`crate::CaixaDialeto`] peer —
21540 // tracks the "route through `from_wire` via `std::str::from_utf8`"
21541 // discipline the first-mover established.
21542 //
21543 // Rust's standard library carries no blanket
21544 // `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so
21545 // a two-hop composition through [`std::str::from_utf8`] + the
21546 // paired [`TryFrom<&str>`] axis is reachable through the pre-
21547 // existing str-view reverse-projection axis alone. But that
21548 // two-hop shape has no compile-time link back to the byte-view
21549 // reverse-projection axis, forces every downstream
21550 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer to open-code
21551 // the composition at every call site, and admits a silent split
21552 // whenever a future call site takes a sibling byte-projection
21553 // axis whose parse arm-set carries no compile-time byte-view
21554 // surface. This impl closes the byte-view reverse-projection
21555 // axis at the substrate-primitive
21556 // [`super::DepList::from_wire`] accessor so every future
21557 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer reaches the
21558 // same two-arm `:`-prefixed kebab-case wire accept-set through
21559 // one trait dispatch.
21560 for &variant in super::DepList::ALL {
21561 let wire_bytes: &[u8] = variant.as_str().as_bytes();
21562 assert_eq!(
21563 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes),
21564 Ok(variant),
21565 "TryFrom<&[u8]> impl on DepList must round-trip \
21566 DepList::{variant:?}.as_str().as_bytes() back to \
21567 Ok(DepList::{variant:?}) — divergence from \
21568 DepList::from_wire signals a silent detour off the \
21569 substrate-primitive accessor"
21570 );
21571 assert_eq!(
21572 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes).ok(),
21573 super::DepList::from_wire(variant.as_str()),
21574 "TryFrom<&[u8]> ok()-projection on \
21575 DepList::{variant:?}.as_str().as_bytes() must \
21576 byte-equal DepList::from_wire on the paired &str input"
21577 );
21578 // Cross-axis witness: the byte-view reverse-projection axis
21579 // must agree with the paired str-view reverse-projection
21580 // axis ([`TryFrom<&str>`]) on every accepted arm — the two
21581 // reverse paths share one `:`-prefixed kebab accept-set
21582 // through the substrate-primitive `from_wire` accessor.
21583 let via_str: Result<super::DepList, ()> =
21584 <super::DepList as TryFrom<&str>>::try_from(variant.as_str());
21585 let via_bytes: Result<super::DepList, ()> =
21586 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes);
21587 assert_eq!(
21588 via_bytes, via_str,
21589 "TryFrom<&[u8]> and TryFrom<&str> reverse-projection \
21590 axes on DepList must agree on DepList::{variant:?} — \
21591 divergence signals the byte-view and str-view reverse \
21592 paths have drifted off the same substrate-primitive \
21593 from_wire accessor"
21594 );
21595 // Cross-axis witness against the paired [`AsRef<[u8]>`]
21596 // borrowed byte-view axis: feeding the same byte-tail the
21597 // forward byte-view axis emits back through the reverse
21598 // byte-view axis must round-trip to the originating arm —
21599 // locks the forward and reverse byte-view axes together at
21600 // the substrate-primitive accessor.
21601 let borrowed_bytes: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21602 assert_eq!(
21603 <super::DepList as TryFrom<&[u8]>>::try_from(borrowed_bytes),
21604 Ok(variant),
21605 "TryFrom<&[u8]> fed the AsRef<[u8]>-projected byte-tail \
21606 of DepList::{variant:?} must round-trip to \
21607 Ok(DepList::{variant:?}) — divergence signals the \
21608 forward and reverse byte-view axes have drifted off \
21609 the same substrate-primitive as_str/from_wire accessor \
21610 pair"
21611 );
21612 }
21613 }
21614
21615 #[test]
21616 fn dep_list_try_from_bytes_rejects_unknown_and_non_utf8_bytes() {
21617 // Rejection witness on the `impl TryFrom<&[u8]> for DepList` —
21618 // sweeps two rejection paths the byte-view reverse-projection
21619 // axis collapses onto the single unit-error `Err(())` return:
21620 // the invalid-UTF-8 rejection path ([`std::str::from_utf8`]
21621 // returns `Err` before [`super::DepList::from_wire`] runs) and
21622 // the valid-UTF-8-but-unknown-wire rejection path
21623 // ([`super::DepList::from_wire`] returns `None` on a byte-
21624 // string outside the two-arm `:`-prefixed kebab-case accept-
21625 // set). Both must reject, so a future accidental widening of
21626 // the trait impl's accept-set (a case-fold path, a silent
21627 // acceptance of a `":packages"` rebrand alias, a
21628 // `#[serde(rename_all = "…")]` attribute drift that widens the
21629 // parse arm-set silently, a stray fallback that maps invalid
21630 // UTF-8 onto a default arm rather than the trait-idiomatic
21631 // `Err(())`) trips at caixa-core test time. Peer of the sibling
21632 // [`crate::kind::tests::caixa_kind_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
21633 // (18d1940) on the first-mover [`crate::CaixaKind`] peer and
21634 // the sibling
21635 // [`crate::dialeto::tests::caixa_dialeto_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
21636 // (d102cb8) on the second-mover [`crate::CaixaDialeto`] peer.
21637 //
21638 // Non-UTF-8 candidates:
21639 // - a lone 0xFF byte (never valid as a UTF-8 leading byte)
21640 // - a lone 0x80 continuation byte with no leading byte
21641 // - a truncated multi-byte sequence (0xC3 without its continuation)
21642 // - a UTF-16 BOM-style byte pair the UTF-8 validator rejects
21643 // - a UTF-16 surrogate half rejected by UTF-8
21644 let non_utf8_rejected: &[&[u8]] = &[
21645 &[0xFF],
21646 &[0x80],
21647 &[0xC3],
21648 &[0xFF, 0xFE],
21649 &[0xED, 0xA0, 0x80],
21650 ];
21651 for &input in non_utf8_rejected {
21652 assert_eq!(
21653 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21654 Err(()),
21655 "TryFrom<&[u8]> impl on DepList must reject the non-\
21656 UTF-8 byte-sequence {input:?} with Err(()) — silent \
21657 acceptance signals the UTF-8 validation path collapsed \
21658 onto a default arm rather than the trait-idiomatic \
21659 unit-error"
21660 );
21661 }
21662 // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
21663 // string, whitespace-only forms, case-folded variants of
21664 // accepted arms, the un-`:`-prefixed bare-kebab
21665 // ("deps"/"deps-dev") the sibling
21666 // [`super::DepList::from_wire`] doc block flags as a
21667 // `:`-prefix-discipline hazard, plausible rebrand aliases the
21668 // sibling `dep_list_try_from_str_rejects_unknown_byte_strings`
21669 // rejection witness (5b828ed) already pins on the str-view
21670 // reverse axis, and whitespace-padded/quoted forms.
21671 let unknown_wire_rejected: &[&[u8]] = &[
21672 b"",
21673 b" ",
21674 b"\t",
21675 b"\n",
21676 b":deps ",
21677 b" :deps",
21678 b":DEPS",
21679 b":Deps",
21680 b":Deps-Dev",
21681 b":deps_dev",
21682 b":deps-development",
21683 b":dev-deps",
21684 b":packages",
21685 b":packages-dev",
21686 b"deps",
21687 b"deps-dev",
21688 b"Prod",
21689 b"Dev",
21690 b"prod",
21691 b"dev",
21692 b"\":deps\"",
21693 b"\":deps-dev\"",
21694 b":deps\n",
21695 b":deps-dev\n",
21696 ];
21697 for &input in unknown_wire_rejected {
21698 assert_eq!(
21699 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21700 Err(()),
21701 "TryFrom<&[u8]> impl on DepList must reject the valid-\
21702 UTF-8-but-unknown-wire byte-string {input:?} with \
21703 Err(()) — silent acceptance signals an accept-set \
21704 widening off the paired DepList::from_wire resolver"
21705 );
21706 // Cross-axis witness: on a byte-string that is valid UTF-8,
21707 // the byte-view reverse-projection axis must agree with the
21708 // paired str-view reverse-projection axis
21709 // ([`TryFrom<&str>`]) — both route through the same
21710 // [`super::DepList::from_wire`] resolver, so the two
21711 // rejection paths align by construction.
21712 if let Ok(s) = std::str::from_utf8(input) {
21713 assert_eq!(
21714 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21715 <super::DepList as TryFrom<&str>>::try_from(s),
21716 "TryFrom<&[u8]> and TryFrom<&str> reverse-\
21717 projection axes on DepList must agree on the \
21718 valid-UTF-8 input {input:?} — divergence signals \
21719 the two reverse paths have drifted off the same \
21720 substrate-primitive from_wire accessor"
21721 );
21722 }
21723 }
21724 }
21725
21726 #[test]
21727 fn dep_list_try_from_vec_bytes_routes_through_borrowed_byte_view_axis() {
21728 // Fail-before-pass-after byte-parity pin on the newly lifted
21729 // `impl TryFrom<Vec<u8>> for DepList` — asserts the trait-
21730 // idiomatic owned-byte-vec reverse-projection standard-library
21731 // impl and the sibling borrowed-input [`TryFrom<&[u8]>`] axis
21732 // resolve to the same two-arm `:`-prefixed kebab-case wire
21733 // accept-set across every arm the exhaustive
21734 // [`super::DepList::ALL`] slice enumerates. Extends the
21735 // substrate-wide trait-idiomatic byte-owned reverse-projection
21736 // axis onto the third caixa-core-internal closed-set fieldless
21737 // typed enum peer — owned-input mirror of the paired
21738 // [`TryFrom<&[u8]>`] byte-view reverse-projection axis
21739 // (b8f25d5), and byte-owned reverse companion of the pre-
21740 // existing byte-owned *forward*-projection pair
21741 // ([`From<super::DepList> for Vec<u8>`],
21742 // [`From<&super::DepList> for Vec<u8>`]) on this same enum.
21743 // Peer of the sibling first-mover
21744 // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
21745 // (99c2849) on the [`crate::CaixaKind`] closed-set typed-enum
21746 // peer and the sibling second-mover
21747 // [`crate::dialeto::tests::caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
21748 // (83a1526) on the [`crate::CaixaDialeto`] peer — tracks the
21749 // "delegate through `TryFrom<&[u8]>` on the `Vec<u8>::as_slice`
21750 // borrow" discipline the first-mover established.
21751 //
21752 // Rust's standard library carries no blanket
21753 // `impl<T: for<'a> TryFrom<&'a [u8]>> TryFrom<Vec<u8>> for T`,
21754 // so an owned-byte-vec caller otherwise picks between an
21755 // open-coded `<T as TryFrom<&[u8]>>::try_from(bytes.as_slice())`
21756 // at every call site whose type bounds have no compile-time
21757 // link back to the byte-owned reverse-projection axis, or a
21758 // `String::from_utf8(bytes)` two-hop shape whose error surface
21759 // leaks the standard-library `FromUtf8Error` type. This impl
21760 // closes the byte-owned reverse-projection axis at the
21761 // substrate-primitive [`super::DepList::from_wire`] accessor
21762 // so every future `<T: TryFrom<Vec<u8>>>`-bound owned-byte-vec
21763 // consumer reaches the same two-arm `:`-prefixed kebab-case
21764 // wire accept-set through one trait dispatch.
21765 for &variant in super::DepList::ALL {
21766 let wire_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
21767 assert_eq!(
21768 <super::DepList as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone()),
21769 Ok(variant),
21770 "TryFrom<Vec<u8>> impl on DepList must round-trip \
21771 DepList::{variant:?}.as_str().as_bytes().to_vec() \
21772 back to Ok(DepList::{variant:?}) — divergence from \
21773 the sibling TryFrom<&[u8]> axis signals a silent \
21774 detour off the substrate-primitive from_wire accessor"
21775 );
21776 // Cross-axis witness: the owned-byte-vec reverse-projection
21777 // axis must agree with the borrowed byte-slice reverse-
21778 // projection axis on every accepted arm — the two axes
21779 // share one `:`-prefixed kebab-case wire vocabulary
21780 // through the substrate-primitive `from_wire` accessor,
21781 // and the owned-input axis delegates to the borrowed peer
21782 // by design.
21783 let via_owned: Result<super::DepList, ()> =
21784 <super::DepList as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone());
21785 let via_borrowed: Result<super::DepList, ()> =
21786 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes.as_slice());
21787 assert_eq!(
21788 via_owned, via_borrowed,
21789 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
21790 axes on DepList must agree on DepList::{variant:?} — \
21791 divergence signals the owned-input and borrowed-input \
21792 byte-view reverse paths have drifted off the same \
21793 substrate-primitive from_wire accessor"
21794 );
21795 // Cross-axis witness against the paired str-view reverse
21796 // axis ([`TryFrom<&str>`]) — the three reverse paths (str-
21797 // view, byte-view borrowed, byte-view owned) share one
21798 // substrate primitive.
21799 let via_str: Result<super::DepList, ()> =
21800 <super::DepList as TryFrom<&str>>::try_from(variant.as_str());
21801 assert_eq!(
21802 via_owned, via_str,
21803 "TryFrom<Vec<u8>> and TryFrom<&str> reverse-projection \
21804 axes on DepList must agree on DepList::{variant:?} — \
21805 divergence signals the byte-owned and str-view \
21806 reverse paths have drifted off the same substrate-\
21807 primitive from_wire accessor"
21808 );
21809 // Four-corner witness: because [`super::DepList`] carries
21810 // no wire-vs-diagnostic split (as_str and from_wire share
21811 // one `:`-prefixed kebab-case byte-vocabulary), the byte-
21812 // owned reverse-projection axis on this enum *does* round-
21813 // trip against the paired byte-owned forward-projection
21814 // pair. Pin every corner of the {owned-input, borrowed-
21815 // input} × {From<Self> → Vec<u8>, From<&Self> → Vec<u8>}
21816 // square onto the same Ok(variant) return so a future
21817 // accident that drops one corner off the substrate-
21818 // primitive accessor trips here.
21819 let owned_forward: Vec<u8> = <Vec<u8> as From<super::DepList>>::from(variant);
21820 let borrowed_forward: Vec<u8> = <Vec<u8> as From<&super::DepList>>::from(&variant);
21821 assert_eq!(
21822 owned_forward, wire_bytes,
21823 "From<DepList> for Vec<u8> forward projection on \
21824 DepList::{variant:?} must byte-equal \
21825 variant.as_str().as_bytes().to_vec() — divergence \
21826 signals the paired forward pair drifted off the \
21827 substrate-primitive as_str accessor"
21828 );
21829 assert_eq!(
21830 borrowed_forward, wire_bytes,
21831 "From<&DepList> for Vec<u8> forward projection on \
21832 &DepList::{variant:?} must byte-equal \
21833 variant.as_str().as_bytes().to_vec() — divergence \
21834 signals the paired forward pair drifted off the \
21835 substrate-primitive as_str accessor"
21836 );
21837 assert_eq!(
21838 <super::DepList as TryFrom<Vec<u8>>>::try_from(owned_forward.clone()),
21839 Ok(variant),
21840 "Four-corner round-trip on DepList::{variant:?} \
21841 through From<DepList> for Vec<u8> then \
21842 TryFrom<Vec<u8>> for DepList must return \
21843 Ok(variant) — divergence signals the byte-owned \
21844 forward pair and the byte-owned reverse axis have \
21845 drifted apart"
21846 );
21847 assert_eq!(
21848 <super::DepList as TryFrom<Vec<u8>>>::try_from(borrowed_forward),
21849 Ok(variant),
21850 "Four-corner round-trip on DepList::{variant:?} \
21851 through From<&DepList> for Vec<u8> then \
21852 TryFrom<Vec<u8>> for DepList must return \
21853 Ok(variant) — divergence signals the borrowed-input \
21854 forward corner and the owned-input reverse corner \
21855 have drifted apart"
21856 );
21857 }
21858 }
21859
21860 #[test]
21861 fn dep_list_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes() {
21862 // Rejection witness on the `impl TryFrom<Vec<u8>> for DepList`
21863 // — sweeps the same two rejection paths the sibling borrowed
21864 // `TryFrom<&[u8]>` axis collapses onto the single unit-error
21865 // return: the invalid-UTF-8 rejection path (`std::str::from_utf8`
21866 // on the underlying byte-slice returns `Err` before
21867 // [`super::DepList::from_wire`] runs) and the valid-UTF-8-
21868 // but-unknown-wire rejection path
21869 // ([`super::DepList::from_wire`] returns `None` on a byte-
21870 // string outside the two-arm `:`-prefixed kebab-case accept-
21871 // set). Both must reject so a future accidental widening of
21872 // the trait impl's accept-set (a case-fold path, a silent
21873 // acceptance of a `":packages"` rebrand alias, a
21874 // `#[serde(rename_all = "…")]` attribute drift that widens
21875 // the parse arm-set silently, a stray `String::from_utf8_lossy`
21876 // detour that widens the input surface with the U+FFFD
21877 // replacement character, an `Option::unwrap_or_default`-shape
21878 // fallback that maps invalid UTF-8 onto a default arm rather
21879 // than the trait-idiomatic `Err(())`) trips at caixa-core test
21880 // time. Peer of the sibling first-mover
21881 // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
21882 // (99c2849) on the [`crate::CaixaKind`] peer and the sibling
21883 // second-mover
21884 // [`crate::dialeto::tests::caixa_dialeto_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
21885 // (83a1526) on the [`crate::CaixaDialeto`] peer.
21886 let non_utf8_rejected: &[&[u8]] = &[
21887 &[0xFF],
21888 &[0x80],
21889 &[0xC3],
21890 &[0xFF, 0xFE],
21891 &[0xED, 0xA0, 0x80], // UTF-16 surrogate half — rejected by UTF-8
21892 ];
21893 for &input in non_utf8_rejected {
21894 let owned: Vec<u8> = input.to_vec();
21895 assert_eq!(
21896 <super::DepList as TryFrom<Vec<u8>>>::try_from(owned),
21897 Err(()),
21898 "TryFrom<Vec<u8>> impl on DepList must reject the \
21899 non-UTF-8 byte-sequence {input:?} with Err(()) — \
21900 silent acceptance signals the UTF-8 validation path \
21901 collapsed onto a default arm rather than the trait-\
21902 idiomatic unit-error"
21903 );
21904 // Cross-axis witness: the owned-input axis must agree with
21905 // the borrowed-input axis on every rejected input.
21906 assert_eq!(
21907 <super::DepList as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
21908 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21909 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
21910 axes on DepList must agree on the non-UTF-8 input \
21911 {input:?} — divergence signals the owned-input and \
21912 borrowed-input byte-view reverse paths have drifted \
21913 off the same substrate-primitive from_wire accessor"
21914 );
21915 }
21916 // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
21917 // string, whitespace-only forms, case-folded variants of
21918 // accepted arms, the un-`:`-prefixed bare-kebab
21919 // ("deps"/"deps-dev") the sibling
21920 // [`super::DepList::from_wire`] doc block flags as a
21921 // `:`-prefix-discipline hazard, plausible rebrand aliases the
21922 // sibling `dep_list_try_from_str_rejects_unknown_byte_strings`
21923 // rejection witness already pins on the str-view reverse
21924 // axis, and whitespace-padded / quoted forms.
21925 let unknown_wire_rejected: &[&[u8]] = &[
21926 b"",
21927 b" ",
21928 b"\t",
21929 b"\n",
21930 b":deps ",
21931 b" :deps",
21932 b":DEPS",
21933 b":Deps",
21934 b":Deps-Dev",
21935 b":deps_dev",
21936 b":deps-development",
21937 b":dev-deps",
21938 b":packages",
21939 b":packages-dev",
21940 b"deps",
21941 b"deps-dev",
21942 b"Prod",
21943 b"Dev",
21944 b"prod",
21945 b"dev",
21946 b"\":deps\"",
21947 b"\":deps-dev\"",
21948 b":deps\n",
21949 b":deps-dev\n",
21950 ];
21951 for &input in unknown_wire_rejected {
21952 let owned: Vec<u8> = input.to_vec();
21953 assert_eq!(
21954 <super::DepList as TryFrom<Vec<u8>>>::try_from(owned),
21955 Err(()),
21956 "TryFrom<Vec<u8>> impl on DepList must reject the \
21957 valid-UTF-8-but-unknown-wire byte-string {input:?} \
21958 with Err(()) — silent acceptance signals an accept-\
21959 set widening off the paired DepList::from_wire \
21960 resolver"
21961 );
21962 // Cross-axis witness against the borrowed byte-view axis:
21963 // the two paths must agree by construction, since the owned
21964 // axis delegates to the borrowed peer.
21965 assert_eq!(
21966 <super::DepList as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
21967 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21968 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
21969 axes on DepList must agree on the valid-UTF-8-but-\
21970 unknown-wire input {input:?} — divergence signals \
21971 the owned-input and borrowed-input byte-view reverse \
21972 paths have drifted off the same substrate-primitive \
21973 from_wire accessor"
21974 );
21975 }
21976 }
21977}
21978
21979#[cfg(test)]
21980mod dep_source_is_variant_tests {
21981 use super::*;
21982
21983 fn all_variants() -> Vec<(DepSource, &'static str)> {
21984 vec![
21985 (
21986 DepSource::Git {
21987 repo: "github:pleme-io/caixa-teia".into(),
21988 tag: Some("v0.1.0".into()),
21989 rev: None,
21990 branch: None,
21991 },
21992 "Git",
21993 ),
21994 (
21995 DepSource::Path {
21996 caminho: "../caixa-teia".into(),
21997 },
21998 "Path",
21999 ),
22000 ]
22001 }
22002
22003 fn predicate_row(s: &DepSource) -> [bool; 2] {
22004 [s.is_git(), s.is_path()]
22005 }
22006
22007 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
22008 // derive-generated per-arm predicate partition — for every variant
22009 // in `all_variants()`, the observed 2-slot predicate row must equal
22010 // a one-hot row with the `true` at exactly the same index as the
22011 // variant's declaration order. Expected rows are generated live
22012 // from the enumeration rather than transcribed by hand, so a
22013 // copy-paste flip that reroutes one arm through the wrong predicate
22014 // lane trips at the identity-diagonal assertion the way every peer
22015 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
22016 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
22017 // / [`crate::upgrade::UpgradeInstruction`] /
22018 // [`crate::aplicacao::PlacementStrategy`] /
22019 // [`crate::aplicacao::RateLimitUnit`] /
22020 // [`crate::aplicacao::WitTarget`] /
22021 // [`crate::render::PathShapeViolation`] partition pin already does.
22022 #[test]
22023 fn dep_source_is_variant_predicates_partition_the_arm_set() {
22024 let variants = all_variants();
22025 for (idx, (variant, name)) in variants.iter().enumerate() {
22026 let observed = predicate_row(variant);
22027 let mut expected = [false; 2];
22028 expected[idx] = true;
22029 assert_eq!(
22030 observed, expected,
22031 "DepSource::{name} at declaration-order slot {idx} must \
22032 satisfy exactly one is_* predicate (its own); observed \
22033 row must equal the one-hot expected row — a drift \
22034 would silently reroute one `:fonte`-arm consumer \
22035 through the wrong predicate lane"
22036 );
22037 }
22038 }
22039
22040 // Byte-parity pin on the two field-agnostic `matches!` shapes the
22041 // per-arm arm-discriminator predicates replace at any future
22042 // consumer site (a `:fonte`-shape-only lint rule that flags path
22043 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
22044 // a future admission-webhook that rejects `:fonte` shapes outside
22045 // the `is_git()` accept-set, a caixa-lacre indexing pass that
22046 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
22047 // Refuses a future accidental split between the derived predicate
22048 // and its `matches!` shape — a hand-rolled shadow impl that
22049 // overrides one path, an accidental rebrand that leaves one
22050 // consumer on the raw `matches!` form — on the two load-bearing
22051 // `:fonte`-arm-discriminator axes every downstream substrate
22052 // consumer of the dep-source axis keys off.
22053 #[test]
22054 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
22055 for (variant, name) in all_variants() {
22056 let via_matches_git = matches!(variant, DepSource::Git { .. });
22057 let via_predicate_git = variant.is_git();
22058 assert_eq!(
22059 via_predicate_git, via_matches_git,
22060 "DepSource::{name}.is_git() must byte-equal \
22061 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
22062 future converged consumer site would silently \
22063 disagree with its pre-lift shape"
22064 );
22065 let via_matches_path = matches!(variant, DepSource::Path { .. });
22066 let via_predicate_path = variant.is_path();
22067 assert_eq!(
22068 via_predicate_path, via_matches_path,
22069 "DepSource::{name}.is_path() must byte-equal \
22070 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
22071 future converged consumer site would silently \
22072 disagree with its pre-lift shape"
22073 );
22074 }
22075 }
22076
22077 // Cross-pin against every constructor path that materializes a
22078 // [`DepSource`] shape today (the [`DepSource::default_github`]
22079 // resolver-side fallback that materializes an unpinned
22080 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
22081 // surface constructor that materializes a pinned `:tag`-carrying
22082 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
22083 // fixture family builds inline). Every constructor's return must
22084 // satisfy the arm-discriminator predicate the constructor's
22085 // variant name matches — a future constructor addition (an
22086 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
22087 // enclosing docstring already names as a trajectory item) surfaces
22088 // as a build-time failure that names the offending drift when its
22089 // return arm doesn't route through the paired predicate.
22090 #[test]
22091 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
22092 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
22093 assert!(
22094 via_default_github.is_git(),
22095 "DepSource::default_github must materialize a Git-arm shape — \
22096 a future constructor that routed through a non-Git arm \
22097 (a registry-fetch pin, a `DepSource::Feira` promotion) \
22098 would silently split the resolver's unpinned-shorthand \
22099 materializer from the sole_pin() precedence cascade"
22100 );
22101 assert!(
22102 !via_default_github.is_path(),
22103 "DepSource::default_github must NOT materialize a Path-arm \
22104 shape — the paired negation pin"
22105 );
22106
22107 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
22108 .fonte
22109 .expect("Dep::git materializes a Some(fonte)");
22110 assert!(
22111 via_dep_git.is_git(),
22112 "Dep::git's `:fonte` materialization must land on the Git \
22113 arm — the author-surface pinned-git constructor's return \
22114 must route through the paired predicate"
22115 );
22116 assert!(!via_dep_git.is_path(), "paired negation pin");
22117
22118 let via_path = DepSource::Path {
22119 caminho: "../caixa-teia".into(),
22120 };
22121 assert!(
22122 via_path.is_path(),
22123 "the dev-mode Path-arm materialization must satisfy is_path()"
22124 );
22125 assert!(!via_path.is_git(), "paired negation pin");
22126 }
22127
22128 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
22129 // String, reason: String }` three-slot envelope on `DepError`,
22130 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
22131 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
22132 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
22133 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
22134 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
22135 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
22136
22137 #[test]
22138 fn versao_invalid_ctor_matches_struct_literal_wrap() {
22139 assert_eq!(
22140 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
22141 DepError::VersaoInvalid {
22142 nome: "caixa-teia".to_string(),
22143 versao: "^0..1".to_string(),
22144 reason: "invalid comparator".to_string(),
22145 },
22146 "versao_invalid ctor must produce byte-equal \
22147 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
22148 );
22149 }
22150
22151 #[test]
22152 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
22153 assert_eq!(
22154 DepError::fonte_repo_shape(
22155 "caixa-teia",
22156 "-upload-pack=evil",
22157 "leading dash rejected".to_string(),
22158 ),
22159 DepError::FonteRepoShape {
22160 nome: "caixa-teia".to_string(),
22161 repo: "-upload-pack=evil".to_string(),
22162 reason: "leading dash rejected".to_string(),
22163 },
22164 "fonte_repo_shape ctor must produce byte-equal \
22165 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
22166 );
22167 }
22168
22169 #[test]
22170 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
22171 assert_eq!(
22172 DepError::caracteristica_invalid(
22173 "caixa-teia",
22174 "bad feature!",
22175 "embedded space rejected".to_string(),
22176 ),
22177 DepError::CaracteristicaInvalid {
22178 nome: "caixa-teia".to_string(),
22179 caracteristica: "bad feature!".to_string(),
22180 reason: "embedded space rejected".to_string(),
22181 },
22182 "caracteristica_invalid ctor must produce byte-equal \
22183 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
22184 );
22185 }
22186
22187 #[test]
22188 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
22189 // Cross-axis routing pin: sweep the three constructor input axes
22190 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
22191 // distinct-per-axis fixtures against every generated arm in the
22192 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
22193 // lowercase / trim / truncate on the two `&str` axes — a silent
22194 // field swap between `nome`, the middle `<axis>` field, and
22195 // `reason`, or a `reason` axis silently rerouted through
22196 // `.to_string()` instead of forwarded owned — surfaces here rather
22197 // than at a downstream diagnostic-shape mismatch. Peer of the
22198 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
22199 // through_to_string` (0e35793) cross-axis routing pin on the same
22200 // envelope's `{ nome, caminho, byte }` three-slot family and of
22201 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
22202 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
22203 // — extended here onto the `{ nome, <axis>: String, reason:
22204 // String }` three-slot envelope so every substrate-primitive ctor
22205 // family in caixa-core's `DepError` envelope guarantees each field
22206 // routes the caller's value verbatim through `.to_string()` (or
22207 // owned-forward for `reason: String`) in declared field order.
22208 // Distinct-per-axis fixtures rule out any two-axis swap
22209 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
22210 // same-fixture-per-axis pin.
22211 let nome = "sibling-teia";
22212 let axis = "distinct-axis-value";
22213 let reason = "distinct rejection sentence".to_string();
22214 assert_eq!(
22215 DepError::versao_invalid(nome, axis, reason.clone()),
22216 DepError::VersaoInvalid {
22217 nome: nome.to_string(),
22218 versao: axis.to_string(),
22219 reason: reason.clone(),
22220 },
22221 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
22222 `reason` → `reason` in declared field order",
22223 );
22224 assert_eq!(
22225 DepError::fonte_repo_shape(nome, axis, reason.clone()),
22226 DepError::FonteRepoShape {
22227 nome: nome.to_string(),
22228 repo: axis.to_string(),
22229 reason: reason.clone(),
22230 },
22231 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
22232 `reason` → `reason` in declared field order",
22233 );
22234 assert_eq!(
22235 DepError::caracteristica_invalid(nome, axis, reason.clone()),
22236 DepError::CaracteristicaInvalid {
22237 nome: nome.to_string(),
22238 caracteristica: axis.to_string(),
22239 reason: reason.clone(),
22240 },
22241 "caracteristica_invalid must route `nome` → `nome`, \
22242 `axis` → `caracteristica`, `reason` → `reason` in declared \
22243 field order",
22244 );
22245 }
22246
22247 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
22248 // two-slot envelope on `DepError`, missing rung between
22249 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
22250 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
22251 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
22252 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
22253 // two-slot `{ nome, list: &'static str }` envelope (same slot
22254 // count, `&'static str` axis instead of owned `String` axis).
22255
22256 #[test]
22257 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
22258 assert_eq!(
22259 DepError::fonte_pin_empty("caixa-teia", ":tag"),
22260 DepError::FontePinEmpty {
22261 nome: "caixa-teia".to_string(),
22262 pin: ":tag".to_string(),
22263 },
22264 "fonte_pin_empty ctor must produce byte-equal \
22265 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
22266 on the same `(&str, &str)` fixture",
22267 );
22268 }
22269
22270 #[test]
22271 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
22272 assert_eq!(
22273 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
22274 DepError::FontePinAmbiguous {
22275 nome: "caixa-teia".to_string(),
22276 pins: ":tag, :rev".to_string(),
22277 },
22278 "fonte_pin_ambiguous ctor must produce byte-equal \
22279 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
22280 wrap on the same `(&str, &str)` fixture",
22281 );
22282 }
22283
22284 #[test]
22285 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
22286 assert_eq!(
22287 DepError::caracteristica_duplicate("caixa-teia", "http"),
22288 DepError::CaracteristicaDuplicate {
22289 nome: "caixa-teia".to_string(),
22290 caracteristica: "http".to_string(),
22291 },
22292 "caracteristica_duplicate ctor must produce byte-equal \
22293 `DepError::CaracteristicaDuplicate` to the pre-lift \
22294 struct-literal wrap on the same `(&str, &str)` fixture",
22295 );
22296 }
22297
22298 #[test]
22299 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
22300 // Owned-`String` routing pin: thread the real
22301 // `set.join(", ")` `String` carrier through the ctor's
22302 // `&str`-parameter Deref coercion, so the ambiguity-arm
22303 // wire-up site's actual `&set.join(", ")` shape stays
22304 // byte-equal to a direct `":tag, :rev"` literal. A future
22305 // parameter-shape change silently dropping the Deref
22306 // coercion route (e.g., a switch to `impl Into<String>`)
22307 // surfaces here rather than at the wire-up's compile
22308 // error far from the ctor definition.
22309 let set: Vec<&'static str> = vec![":tag", ":rev"];
22310 let joined: String = set.join(", ");
22311 assert_eq!(
22312 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
22313 DepError::FontePinAmbiguous {
22314 nome: "caixa-teia".to_string(),
22315 pins: ":tag, :rev".to_string(),
22316 },
22317 "fonte_pin_ambiguous ctor must accept an owned-`String` \
22318 `&set.join(\", \")` carrier via Deref coercion — the exact \
22319 shape the ambiguity-arm wire-up site passes into it",
22320 );
22321 }
22322
22323 #[test]
22324 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
22325 // Cross-axis routing pin: sweep the two constructor input axes
22326 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
22327 // fixtures against every generated arm in the
22328 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
22329 // trim / truncate at codegen time — a silent field swap between
22330 // `nome` and the middle `<axis>` field, or a `<axis>` axis
22331 // silently rerouted through the wrong field on any one variant
22332 // — surfaces here rather than at a downstream diagnostic-shape
22333 // mismatch. Peer of the sibling
22334 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
22335 // (6f5e0cd) pin on the same envelope's peer two-slot family
22336 // (`{ nome, list: &'static str }`) and of the sibling
22337 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
22338 // (5621f8a) pin on the same envelope's three-slot `{ nome,
22339 // <axis>: String, reason: String }` family — extended here onto
22340 // the `{ nome, <axis>: String }` two-slot envelope so the last
22341 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
22342 // ladder guarantees each field routes the caller's value
22343 // verbatim through `.to_string()` in declared field order.
22344 // Distinct-per-axis fixtures rule out any two-axis swap
22345 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
22346 // per-axis pin.
22347 let nome = "sibling-teia";
22348 let axis = "distinct-axis-value";
22349 assert_eq!(
22350 DepError::fonte_pin_empty(nome, axis),
22351 DepError::FontePinEmpty {
22352 nome: nome.to_string(),
22353 pin: axis.to_string(),
22354 },
22355 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
22356 in declared field order",
22357 );
22358 assert_eq!(
22359 DepError::fonte_pin_ambiguous(nome, axis),
22360 DepError::FontePinAmbiguous {
22361 nome: nome.to_string(),
22362 pins: axis.to_string(),
22363 },
22364 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
22365 in declared field order",
22366 );
22367 assert_eq!(
22368 DepError::caracteristica_duplicate(nome, axis),
22369 DepError::CaracteristicaDuplicate {
22370 nome: nome.to_string(),
22371 caracteristica: axis.to_string(),
22372 },
22373 "caracteristica_duplicate must route `nome` → `nome`, \
22374 `axis` → `caracteristica` in declared field order",
22375 );
22376 }
22377
22378 #[test]
22379 fn nome_invalid_ctor_matches_struct_literal_wrap() {
22380 // Equivalence pin: the ctor produces byte-equal
22381 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
22382 // literal that cloned the offending `:deps :nome` verbatim and
22383 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
22384 // owned `reason` payload at the caller site inside
22385 // [`Dep::validate`]. Guards any future field-addition /
22386 // reordering / accessor-return tweak on the variant. Sibling of
22387 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
22388 // (below) and the sibling three-slot
22389 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
22390 // pin on the same envelope's three-slot `{ nome, <axis>: String,
22391 // reason: String }` family.
22392 let nome = "Caixa-Teia";
22393 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
22394 let via_ctor = DepError::nome_invalid(nome, reason.clone());
22395 let via_literal = DepError::NomeInvalid {
22396 nome: nome.to_string(),
22397 reason,
22398 };
22399 assert_eq!(
22400 via_ctor, via_literal,
22401 "nome_invalid(nome, reason) must byte-equal the open-coded \
22402 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
22403 );
22404 assert_eq!(
22405 via_ctor.to_string(),
22406 via_literal.to_string(),
22407 "Display byte-string must byte-equal the open-coded struct-literal"
22408 );
22409 }
22410
22411 #[test]
22412 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
22413 // Boundary-sweep pin on the ctor's two-slot projection: sweep
22414 // the two ctor input axes (`nome: &str`, `reason: String`)
22415 // through distinct-per-axis fixtures against a representative
22416 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
22417 // wrapper-side silent lowercase / trim / truncate at codegen
22418 // time — a silent field swap between `nome` and `reason`, an
22419 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
22420 // divergence on the `reason` axis — surfaces at caixa-core
22421 // build time rather than at a downstream diagnostic consumer
22422 // that reads `err.nome` / `err.reason` back and gets a different
22423 // value than the one it stored. Peer of the sibling
22424 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
22425 // (7f7c950) pin on the same envelope's peer two-slot family
22426 // (`{ nome, <axis>: String }`) — extended here onto the
22427 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
22428 // variant carries. Distinct-per-axis fixtures rule out any
22429 // two-axis swap (`nome` ↔ `reason`) that would still pass a
22430 // same-fixture-per-axis pin. The sweep list carries a mixed
22431 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
22432 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
22433 // over-63-byte) so a future silent per-input normalization
22434 // surfaces on the arm that diverges.
22435 for nome in [
22436 "Caixa-Teia",
22437 "caixa_teia",
22438 "caixa.teia",
22439 "-caixa-teia",
22440 "caixa-teia-",
22441 "caixa/teia",
22442 &"a".repeat(64),
22443 ] {
22444 let reason = crate::render::is_dns_1123_label(nome)
22445 .expect_err("fixture must be a DNS-1123-refused label");
22446 let via_ctor = DepError::nome_invalid(nome, reason.clone());
22447 let DepError::NomeInvalid {
22448 nome: stored_nome,
22449 reason: stored_reason,
22450 } = via_ctor
22451 else {
22452 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
22453 };
22454 assert_eq!(
22455 stored_nome, nome,
22456 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
22457 );
22458 assert_eq!(
22459 stored_reason, reason,
22460 "reason slot must forward the owned `String` verbatim for {nome:?}"
22461 );
22462 }
22463 }
22464
22465 #[test]
22466 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
22467 // End-to-end pin: the sole in-crate wire-up site
22468 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
22469 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
22470 // the ctor's output on the same DNS-1123-refused `:deps :nome`
22471 // fixture, with identical `Display` rendering. A future silent
22472 // de-lift of the wire-up back to the open-coded struct-literal
22473 // trips this test at caixa-core build time rather than at a
22474 // downstream diagnostic consumer far from the wire-up commit.
22475 // Sibling of the peer
22476 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
22477 // pin on the same wire-up — extended here from a `matches!`
22478 // shape check to a byte-identity + Display parity route through
22479 // the ctor.
22480 let d = Dep::simple("Caixa_Teia", "^0.1");
22481 let observed = d.validate().unwrap_err();
22482 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
22483 .expect_err("fixture must be DNS-1123-refused");
22484 let expected = DepError::nome_invalid("Caixa_Teia", reason);
22485 assert_eq!(
22486 observed, expected,
22487 "Dep::validate's DNS-1123 refusal arm must byte-equal \
22488 nome_invalid(nome, reason)"
22489 );
22490 assert_eq!(
22491 observed.to_string(),
22492 expected.to_string(),
22493 "Display byte-string parity"
22494 );
22495 }
22496}