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/// Trait-idiomatic *owned-`String` input, `Result<Self, ()>` output*
4959/// string-owned reverse projection on the third caixa-core-internal
4960/// closed-set fieldless typed enum peer ([`DepList`]) — the owned-
4961/// input peer of the paired [`TryFrom<&str> for DepList`] str-view
4962/// reverse-projection axis (which routes through the substrate-
4963/// primitive [`DepList::from_wire`] `Option<Self>` accessor on the
4964/// two-arm `:`-prefixed kebab-case accept-set the sibling
4965/// [`DepList::as_str`] emitter returns), and the string-owned reverse
4966/// companion of the pre-existing string-owned *forward*-projection
4967/// pair ([`From<DepList> for String`] / [`From<&DepList> for String`])
4968/// already lifted on this same enum. Routes owned [`String`] input
4969/// byte-for-byte through the paired borrowed-input [`TryFrom<&str>`]
4970/// axis via [`String::as_str`], so every consumer that holds an owned
4971/// [`String`] and needs a typed [`DepList`] — a future M4
4972/// `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook body reader
4973/// that hands a per-manifest `spec.deps`/`spec.deps-dev` scalar off as
4974/// an owned [`String`] after UTF-8 validation commits allocation, a
4975/// `serde_yaml::from_str` / `serde_json::from_str` de-serialize
4976/// composer that surfaces the two-list dep-graph author-surface
4977/// scalar as an owned [`String`] typed field, a future
4978/// `feira dep --list <deps|deps-dev>` `clap`-derived arg-parse whose
4979/// owned-`String` positional lands the canonical arm at the typed
4980/// dispatch, a per-caixa overlay resolver reading an owned [`String`]
4981/// out of a `ConfigMap` `data.dep-list` scalar, an
4982/// `<T: TryFrom<String>>`-bound generic loader over any of the
4983/// substrate's closed-set typed enums — reaches the same two-arm
4984/// `:`-prefixed kebab-case wire accept-set through one trait
4985/// dispatch off the shared [`DepList::from_wire`] substrate primitive.
4986///
4987/// Closes the substrate-wide trait-idiomatic *string-owned reverse-
4988/// projection* family on the caixa-core-internal closed-set peer
4989/// census — opened on the compound M3-mesh `:politicas :rate-limit`
4990/// primitive [`crate::aplicacao::RateLimit`] (a2e6f02), lifted onto
4991/// the first closed-set fieldless typed-enum peer
4992/// [`crate::aplicacao::WitShape`] (e6aac29), extended onto the second
4993/// closed-set fieldless typed-enum peer
4994/// [`crate::aplicacao::RateLimitUnit`] (94a9c5e), extended onto the
4995/// third closed-set fieldless typed-enum peer
4996/// [`crate::aplicacao::PlacementStrategy`] (d81a70a), extended onto
4997/// the first M2-OTP-shape supervisor-slot closed-set fieldless typed-
4998/// enum peer [`crate::supervisor::RestartStrategy`] (78fe8c8), closed
4999/// on the M2-OTP-shape supervisor-slot pair by
5000/// [`crate::supervisor::RestartPolicy`] (35dea5a), extended onto the
5001/// structurally most fundamental caixa-core enum peer
5002/// [`crate::CaixaKind`] (e7df24f), and extended onto the second
5003/// caixa-core-internal closed-set fieldless typed-enum peer
5004/// [`crate::CaixaDialeto`] (9e07f5c) — onto the third and last
5005/// caixa-core-internal closed-set fieldless typed-enum peer, the
5006/// outer-`Caixa` two-list dep-graph discriminator. This mirrors the
5007/// trajectory the byte-view (b8f25d5) / byte-owned (42091cb) / str-
5008/// view reverse-projection families already walked on this same enum.
5009///
5010/// Rust's standard library carries no blanket
5011/// `impl<T: for<'a> TryFrom<&'a str>> TryFrom<String> for T`, so a
5012/// consumer that holds an owned [`String`] and needs a typed
5013/// [`DepList`] otherwise picks between (a) an open-coded
5014/// `<DepList as TryFrom<&str>>::try_from(s.as_str())` at every call
5015/// site whose type bounds have no compile-time link back to the
5016/// string-owned reverse-projection axis, (b) a `let s: &str = &s;
5017/// DepList::try_from(s)` two-step whose borrow arithmetic leaks a
5018/// per-call-site lifetime dance rather than a single trait dispatch,
5019/// or (c) a `String::into_bytes` + [`TryFrom<Vec<u8>>`] detour that
5020/// reaches the substrate-primitive `from_wire` accessor through a
5021/// UTF-8 re-validation hop the owned-`String` axis already knows to
5022/// skip. This impl closes the string-owned reverse-projection axis
5023/// at the substrate-primitive [`DepList::from_wire`] accessor so
5024/// every future `<T: TryFrom<String>>`-bound owned-string consumer
5025/// reaches the same two-arm `:`-prefixed kebab-case accept-set
5026/// through one trait dispatch.
5027///
5028/// `type Error = ()` matches the sibling [`TryFrom<&str> for DepList`],
5029/// [`TryFrom<&[u8]> for DepList`], and [`TryFrom<Vec<u8>> for DepList`]
5030/// unit-error shapes, preserving the trait-family consistency across
5031/// the {str-view, byte-view, byte-owned, string-owned} reverse-
5032/// projection square. The owned [`String`] input is dropped on the
5033/// error path (the standard-library `String::from_utf8` convention of
5034/// returning the input in the error deliberately declined — a caller
5035/// that needs the string back holds a clone before the call, and the
5036/// closed-set-enum use site rarely wants the raw string back past a
5037/// "did you mean" diagnostic that operates on the wire vocabulary
5038/// rather than the input).
5039///
5040/// Unlike the peer [`crate::CaixaKind`] axis (whose paired string-
5041/// owned *forward* projection ([`From<crate::CaixaKind> for String`])
5042/// emits lowercase Portuguese diagnostic bytes while its reverse axis
5043/// parses `PascalCase` wire bytes — the two-axis wire/diagnostic
5044/// split forces the closed-cycle round-trip witness to cross through
5045/// [`crate::CaixaKind::wire_name`]), [`DepList`] carries exactly one
5046/// author-facing `:`-prefixed kebab-case axis (the [`DepList::as_str`]
5047/// and [`DepList::from_wire`] resolvers share one byte-vocabulary, as
5048/// the sibling `dep_list_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`
5049/// four-corner witness makes explicit on the byte-owned axis), so the
5050/// string-owned forward and reverse axes here round-trip directly
5051/// through the shared `:`-prefixed kebab-case vocabulary — a four-
5052/// corner witness the pinned load-bearing test makes explicit,
5053/// mirroring the peer four-corner witness the sibling
5054/// [`crate::CaixaDialeto`] axis (9e07f5c) pins on the same string-
5055/// owned reverse-projection surface.
5056///
5057/// Pinned load-bearing by
5058/// [`tests::dep_list_try_from_owned_string_routes_through_borrowed_str_view_axis`]
5059/// (byte-parity pin against the paired borrowed [`TryFrom<&str>`]
5060/// axis across the two-arm [`DepList::ALL`] accept-set on the owned-
5061/// `String` surface, cross-axis witness that the string-owned reverse
5062/// projection agrees with the sibling byte-view and byte-owned
5063/// reverse-projection axes on every accepted arm through the shared
5064/// substrate-primitive [`DepList::from_wire`] accessor, plus a four-
5065/// corner {owned-input, borrowed-input} × {`From<Self> → String`,
5066/// `From<&Self> → String`} round-trip witness against the paired
5067/// [`From<{Self, &Self}> for String`] string-owned forward-projection
5068/// pair) and
5069/// [`tests::dep_list_try_from_owned_string_rejects_unknown_wire_strings`]
5070/// (rejection witness against silent accept-set widening — mirrors
5071/// the corpus the paired [`TryFrom<&str>`] and [`TryFrom<Vec<u8>>`]
5072/// rejection witnesses already pin, including empty / whitespace-
5073/// only inputs, case-fold variants of accepted arms, un-`:`-prefixed
5074/// bare-kebab forms, rebrand candidates, English-rebrand candidates,
5075/// and whitespace-padded / trailing-newline / quote-wrapped forms,
5076/// with per-input cross-axis parity against the borrowed
5077/// [`TryFrom<&str>`] reverse-projection axis).
5078impl TryFrom<String> for DepList {
5079 type Error = ();
5080
5081 fn try_from(s: String) -> Result<Self, Self::Error> {
5082 <Self as TryFrom<&str>>::try_from(s.as_str())
5083 }
5084}
5085
5086/// Errors raised by [`Dep::validate`].
5087///
5088/// Mirrors the per-axis error families the other `:versao`-carrying
5089/// typed surfaces expose
5090/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
5091/// [`crate::AplicacaoError::MembroVersaoInvalid`],
5092/// [`crate::SupervisorError::EmptyChildVersion`] /
5093/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
5094/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
5095#[derive(Debug, Error, PartialEq, Eq)]
5096pub enum DepError {
5097 #[error(
5098 ":deps entry has empty :nome (every dep must name a target caixa; \
5099 omit the entry instead of carrying an empty name)"
5100 )]
5101 NomeEmpty,
5102 #[error(
5103 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
5104 (the value flows verbatim as the target caixa's `:nome`, the rendered \
5105 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
5106 value, and the resolver's checkout-directory leaf — each apiserver-side \
5107 schema rejects non-DNS-1123 names at admission time; use a lowercase \
5108 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
5109 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
5110 )]
5111 NomeInvalid { nome: String, reason: String },
5112 #[error(
5113 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
5114 constraint that resolves through the lacre pipeline)"
5115 )]
5116 VersaoEmpty { nome: String },
5117 #[error(
5118 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
5119 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
5120 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
5121 and `:children :versao` carry; the lacre pipeline resolves all three \
5122 through the same parser)"
5123 )]
5124 VersaoInvalid {
5125 nome: String,
5126 versao: String,
5127 reason: String,
5128 },
5129 #[error(
5130 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
5131 (every git source must name a repo — use a `github:org/repo` \
5132 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
5133 entire :fonte block to fall back to the default-host resolver \
5134 convention)"
5135 )]
5136 FonteRepoEmpty { nome: String },
5137 #[error(
5138 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
5139 invalid value-shape: {reason} (the value flows verbatim into the \
5140 caixa-resolver's `git clone <repo>` subprocess invocation; every \
5141 documented form carries a `:` separator and no whitespace / \
5142 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
5143 an `https://host/path` / `ssh://[user@]host/path` / \
5144 `git://host/path` / `file:///path` URL, or the `git@host:path` \
5145 scp-style SSH form)"
5146 )]
5147 FonteRepoShape {
5148 nome: String,
5149 repo: String,
5150 reason: String,
5151 },
5152 #[error(
5153 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
5154 (set exactly one of :tag, :rev, or :branch so the resolver \
5155 can pick a reproducible commit; omit the entire :fonte block \
5156 to fall back to the default-host resolver convention, which \
5157 resolves the latest tag matching :versao)"
5158 )]
5159 FontePinMissing { nome: String },
5160 #[error(
5161 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
5162 set ({pins}); exactly one of :tag, :rev, or :branch must be \
5163 set so the resolver's checkout target is unambiguous (the \
5164 resolver's silent precedence is :rev > :tag > :branch — if \
5165 you intended one specifically, drop the others)"
5166 )]
5167 FontePinAmbiguous { nome: String, pins: String },
5168 #[error(
5169 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
5170 (a set pin must name a non-empty git ref; drop the {pin} key \
5171 entirely to fall through to another pin axis)"
5172 )]
5173 FontePinEmpty { nome: String, pin: String },
5174 #[error(
5175 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
5176 value-shape: {reason} (the git porcelain enforces the same shape at \
5177 `git fetch` / `git checkout` time on every pin; use a leaf refname \
5178 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
5179 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
5180 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
5181 prepends at clone time, and avoid abbreviated SHAs which are \
5182 ambiguous across repository history)"
5183 )]
5184 FontePinShape {
5185 nome: String,
5186 pin: String,
5187 value: String,
5188 reason: String,
5189 },
5190 #[error(
5191 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
5192 (every path source must name a non-empty filesystem path; \
5193 omit the entire :fonte block to fall back to the default-host \
5194 resolver convention)"
5195 )]
5196 FonteCaminhoEmpty { nome: String },
5197 #[error(
5198 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
5199 absolute (the lacre pipeline embeds the value verbatim in its \
5200 per-dep content-address `path:{caminho}` at \
5201 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
5202 BLAKE3 closure differ across machines — defeating the \
5203 reproducibility contract that's load-bearing for CSE; express \
5204 the path relative to the caixa.lisp location, e.g. \
5205 \"../caixa-teia\" for a sibling workspace dep)"
5206 )]
5207 FonteCaminhoAbsolute { nome: String, caminho: String },
5208 #[error(
5209 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5210 with `~` (the leading-tilde is a shell-expansion convention, not a \
5211 POSIX path component — `Path::is_absolute` returns false on it, so \
5212 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
5213 pipeline embeds the value verbatim in its per-dep content-address \
5214 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
5215 caixa-resolver folds it through `Path::join` without `~`-expansion, \
5216 so the build looks for a literal `./{caminho}` subdirectory and \
5217 fails at resolve time far from the source caixa.lisp; even worse, a \
5218 future caixa-resolver pass that *does* expand `~` would silently \
5219 re-open the host-layout-leak the b94fd83 absolute gate closes — \
5220 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
5221 runners with different `$HOME` layouts resolve to two distinct paths \
5222 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
5223 determinism contract; express the path relative to the caixa.lisp \
5224 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
5225 spell out the full relative path explicitly if a workstation-rooted \
5226 dep is genuinely intended)"
5227 )]
5228 FonteCaminhoTildeExpansion { nome: String, caminho: String },
5229 #[error(
5230 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5231 with `$` (the leading-`$` is a shell-variable-expansion convention, \
5232 not a POSIX path component — `Path::is_absolute` returns false on it \
5233 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
5234 embeds the value verbatim in its per-dep content-address \
5235 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
5236 caixa-resolver folds it through `Path::join` without `$`-expansion, \
5237 so the build looks for a literal `./{caminho}` subdirectory and \
5238 fails at resolve time far from the source caixa.lisp; even worse, a \
5239 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
5240 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
5241 invites) would silently re-open the host-layout-leak the b94fd83 \
5242 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
5243 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
5244 layouts resolve to two distinct paths for the byte-identical caixa, \
5245 defeating the THEORY.md §V.2 render-determinism contract; express \
5246 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
5247 for a sibling workspace dep, or spell out the full relative path \
5248 explicitly if a workstation-rooted dep is genuinely intended)"
5249 )]
5250 FonteCaminhoVarExpansion { nome: String, caminho: String },
5251 #[error(
5252 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5253 with a space (the leading ASCII space `0x20` is the orthogonal \
5254 paste-from-aligned-doc footgun that silently passes \
5255 `Path::is_absolute` and every prior leading-byte arm — \
5256 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
5257 `./ ../caixa-teia` subdirectory the resolver fails to find at \
5258 resolve time with a non-self-locating `No such file or directory` \
5259 error far from the source caixa.lisp; the lacre pipeline embeds \
5260 the value verbatim in its per-dep content-address `path:{caminho}` \
5261 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
5262 semantic-identical caixa values (` ../caixa-teia` vs \
5263 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
5264 workstations whose authors differ only in paste-from-aligned- \
5265 caixa.lisp-doc whitespace habits — the most insidious failure \
5266 mode the typed slot can carry (no error surfaces; the divergence \
5267 is invisible until two machines compare lacres), defeating the \
5268 THEORY.md §V.2 render-determinism contract. The canonical \
5269 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
5270 a multi-entry `:deps` block sits at the same column — an author \
5271 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
5272 the rendered alignment into a fresh entry preserves the leading \
5273 whitespace verbatim); peer `:fonte :repo` axis already rejects \
5274 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
5275 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
5276 `is_chart_description_shape`, `:licenca` via \
5277 `is_spdx_expression_shape`. Drop the leading space; express the \
5278 path as a bare relative single-token like \"../caixa-teia\")"
5279 )]
5280 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
5281 #[error(
5282 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5283 with `-` (the canonical CLI-argument-injection footgun on the \
5284 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
5285 its per-dep content-address `path:{caminho}` at \
5286 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
5287 through `Path::join` looking for a literal `./{caminho}` \
5288 subdirectory. Every downstream subprocess that consumes the resolved \
5289 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
5290 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
5291 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
5292 value as a CLI flag rather than a positional path when the invocation \
5293 does not carry a `--` argument-list terminator between the flag block \
5294 and the path (the common case at every porcelain entry point). The \
5295 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
5296 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
5297 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
5298 CLI-arg-injection vector at every git porcelain entry point that \
5299 consumes a path or URL argument, peer with is_git_repo_url's \
5300 leading-`-` arm on the sibling `:fonte :repo` axis), \
5301 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
5302 POSIX `std::path::Path` treats a leading `-` as a literal filename \
5303 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
5304 for a literal `./-rf` subdirectory that fails at resolve time with a \
5305 non-self-locating `No such file or directory` error far from the \
5306 source caixa.lisp — but on any downstream shell-out without `--` the \
5307 reinterpretation is silent and the failure mode is arbitrary-\
5308 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
5309 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
5310 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
5311 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
5312 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
5313 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
5314 `:children :caixa`, `:deps :nome`, cluster names); \
5315 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
5316 the feira `init` / `add <nome>` positional gate (868c191) rejects \
5317 leading `-` on the CLI positional itself. Express the path as a bare \
5318 relative single-token like \"../caixa-teia\" — the sibling-workspace \
5319 directory name carries no leading-hyphen semantic, and `./` / `../` \
5320 prefixes structurally partition the leading-byte set to safe values.)"
5321 )]
5322 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
5323 #[error(
5324 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
5325 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
5326 every `std::fs` syscall routes the path through `CString::new` which \
5327 fails with `NulError` at resolve time; the lacre pipeline embeds the \
5328 value verbatim in its per-dep content-address `path:{caminho}` at \
5329 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
5330 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
5331 determinism contract — the canonical paste-from-multiline-doc \
5332 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
5333 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
5334 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
5335 already gates against. Express the path as a relative single-line ASCII \
5336 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
5337 )]
5338 FonteCaminhoControlChar {
5339 nome: String,
5340 caminho: String,
5341 byte: u8,
5342 },
5343 #[error(
5344 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
5345 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
5346 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
5347 not the parent's sibling — and the caixa-resolver folds the value through \
5348 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
5349 resolve time with a non-self-locating `No such file or directory` error far \
5350 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
5351 primary path separator equal to `/`, so byte-identical caixa.lisp values \
5352 resolve to two distinct directories across runner OSes — the lacre pipeline \
5353 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5354 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
5355 determinism contract via the cross-host-OS-separator divergence vector. The \
5356 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
5357 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
5358 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
5359 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
5360 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
5361 \"../caixa-teia\" for a sibling workspace dep)"
5362 )]
5363 FonteCaminhoBackslash { nome: String, caminho: String },
5364 #[error(
5365 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5366 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
5367 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
5368 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
5369 paste-from-shell-pipeline footgun where an author copies a `command > log` \
5370 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
5371 as literal path-component bytes, so the resolver folds the value through \
5372 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5373 subdirectory and fails at resolve time with a non-self-locating `No such \
5374 file or directory` error far from the source caixa.lisp. The lacre pipeline \
5375 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5376 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
5377 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5378 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5379 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
5380 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
5381 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
5382 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
5383 RFC-3986-reserved set. Express the path as a bare relative single-token like \
5384 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5385 redirection semantic.",
5386 ch = *byte as char
5387 )]
5388 FonteCaminhoShellRedirection {
5389 nome: String,
5390 caminho: String,
5391 byte: u8,
5392 },
5393 #[error(
5394 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
5395 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
5396 `|` as the pipe operator that wires one command's stdout to the next command's \
5397 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
5398 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
5399 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
5400 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
5401 treats `|` as a literal path-component byte, so the resolver folds the value \
5402 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5403 subdirectory and fails at resolve time with a non-self-locating `No such file or \
5404 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
5405 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
5406 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
5407 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
5408 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
5409 subprocess-argument / shell-metachar injection surface every peer single-token-\
5410 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
5411 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5412 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5413 workspace directory name carries no shell-pipe semantic."
5414 )]
5415 FonteCaminhoShellPipe { nome: String, caminho: String },
5416 #[error(
5417 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5418 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
5419 / nushell — lexes `;` as the sequential-command terminator that fires the next \
5420 command regardless of the prior command's exit status, so `:caminho \
5421 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
5422 footgun where an author copies a `cd path; do-thing` chain without trimming \
5423 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
5424 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
5425 literal path-component byte, so the resolver folds the value through \
5426 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5427 subdirectory and fails at resolve time with a non-self-locating `No such file \
5428 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5429 the value verbatim in its per-dep content-address `path:{caminho}` at \
5430 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5431 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5432 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5433 canonical shell-metachar injection surface every peer single-token-shaped \
5434 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
5435 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5436 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5437 workspace directory name carries no shell-command-separator semantic."
5438 )]
5439 FonteCaminhoShellSemicolon { nome: String, caminho: String },
5440 #[error(
5441 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5442 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
5443 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
5444 terminator detaching the prior command and returning control immediately to \
5445 the prompt, double `&&` as the logical-AND list operator firing the next \
5446 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
5447 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
5448 sleep 1` background-launch one-liner or a `cd path && make install` build-\
5449 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
5450 05c358e closed the sequential-command-separator vector, this arm closes the \
5451 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
5452 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
5453 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5454 byte lands in the BLAKE3 closure and rides into every shell-spawned \
5455 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5456 future operator-side `nix` spawn) as the canonical shell-metachar injection \
5457 surface every peer single-token-shaped typed slot already closes. The peer \
5458 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
5459 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
5460 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
5461 shell-background / logical-AND semantic."
5462 )]
5463 FonteCaminhoShellBackground { nome: String, caminho: String },
5464 #[error(
5465 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5466 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
5467 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
5468 wrapper that runs the enclosed command and substitutes its standard-output \
5469 verbatim into the surrounding word, so a backticked `whoami` expands to the \
5470 current user's name and a backticked `cat /etc/passwd` expands to the file's \
5471 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
5472 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
5473 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
5474 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
5475 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
5476 background / logical-AND vector, this arm closes the orthogonal command-\
5477 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
5478 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
5479 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
5480 value verbatim in its per-dep content-address `path:{caminho}` at \
5481 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5482 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
5483 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5484 shell-metachar injection surface every peer single-token-shaped typed slot \
5485 already closes. The peer `:entrada :paths` axis rejects the byte via \
5486 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
5487 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5488 directory name carries no shell-command-substitution semantic."
5489 )]
5490 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
5491 #[error(
5492 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5493 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
5494 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
5495 expansion wildcards: `*` matches any sequence of characters in a path component \
5496 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
5497 canonical paste-from-shell-listing footgun where an author copies a \
5498 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
5499 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
5500 `std::path::Path` treats both bytes as literal path-component bytes, so the \
5501 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
5502 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
5503 locating `No such file or directory` error far from the source caixa.lisp. The \
5504 lacre pipeline embeds the value verbatim in its per-dep content-address \
5505 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
5506 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
5507 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
5508 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
5509 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
5510 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
5511 reserved set. Express the path as a bare relative single-token like \
5512 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
5513 / pathname-expansion semantic.",
5514 ch = *byte as char
5515 )]
5516 FonteCaminhoShellGlob {
5517 nome: String,
5518 caminho: String,
5519 byte: u8,
5520 },
5521 #[error(
5522 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5523 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
5524 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
5525 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
5526 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
5527 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
5528 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
5529 arm closes the leading byte of — together the two arms now structurally exclude the \
5530 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
5531 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5532 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
5533 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
5534 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
5535 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
5536 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
5537 self-locating `No such file or directory` error far from the source caixa.lisp. The \
5538 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
5539 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
5540 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5541 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5542 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
5543 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
5544 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
5545 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
5546 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
5547 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5548 subshell-grouping semantic.",
5549 ch = *byte as char
5550 )]
5551 FonteCaminhoShellSubshellGrouping {
5552 nome: String,
5553 caminho: String,
5554 byte: u8,
5555 },
5556 #[error(
5557 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5558 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
5559 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
5560 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
5561 comma-separated members and `{{1..10}}` expands to the integer range — the \
5562 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
5563 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
5564 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
5565 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
5566 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
5567 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
5568 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
5569 `std::path::Path` treats the byte as a literal path-component byte, so a \
5570 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
5571 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
5572 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
5573 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
5574 silently passes every prior arm and the resolver folds the value through \
5575 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5576 resolve time with a non-self-locating `No such file or directory` error far from \
5577 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
5578 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5579 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5580 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5581 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
5582 expansion / URI-Template-placeholder surface every peer single-token-shaped \
5583 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
5584 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
5585 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
5586 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5587 directory name carries no shell-brace-expansion / URI-Template-placeholder \
5588 semantic; if two siblings actually need pinning, author two separate `:deps` \
5589 entries rather than one brace-expanded `:caminho` value.",
5590 ch = *byte as char
5591 )]
5592 FonteCaminhoShellBraceExpansion {
5593 nome: String,
5594 caminho: String,
5595 byte: u8,
5596 },
5597 #[error(
5598 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5599 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
5600 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
5601 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
5602 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
5603 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
5604 glob every shell-history block carries; the bracket pair additionally carries the \
5605 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
5606 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
5607 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
5608 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
5609 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
5610 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
5611 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5612 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
5613 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
5614 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
5615 leak) silently passes every prior arm and the resolver folds the value through \
5616 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5617 resolve time with a non-self-locating `No such file or directory` error far from \
5618 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5619 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5620 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5621 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5622 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
5623 surface every peer single-token-shaped typed slot already closes. Express the path \
5624 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5625 directory name carries no shell-bracket-expansion / glob-character-class / array-\
5626 literal semantic; if a family of sibling caixas actually needs pinning, author \
5627 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
5628 ch = *byte as char
5629 )]
5630 FonteCaminhoShellBracketExpansion {
5631 nome: String,
5632 caminho: String,
5633 byte: u8,
5634 },
5635 #[error(
5636 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5637 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
5638 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5639 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
5640 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
5641 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
5642 every path-with-embedded-whitespace paste block carries and the symmetric \
5643 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
5644 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
5645 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
5646 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
5647 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
5648 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
5649 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
5650 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
5651 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
5652 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
5653 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
5654 production. POSIX `std::path::Path` treats the byte as a literal path-component \
5655 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
5656 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
5657 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
5658 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
5659 shape) silently passes every prior arm and the resolver folds the value through \
5660 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5661 resolve time with a non-self-locating `No such file or directory` error far from \
5662 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5663 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5664 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5665 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5666 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
5667 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5668 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
5669 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
5670 `is_git_repo_url`). Express the path as a bare relative single-token like \
5671 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
5672 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
5673 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
5674 quoting on the outer syntactic layer, so an inner quote pair would nest and \
5675 desugar to a broken layer).",
5676 ch = *byte as char
5677 )]
5678 FonteCaminhoShellQuoteGrouping {
5679 nome: String,
5680 caminho: String,
5681 byte: u8,
5682 },
5683 #[error(
5684 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5685 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
5686 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5687 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
5688 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
5689 discarding the byte and everything after it to the end of the physical line \
5690 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
5691 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
5692 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
5693 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
5694 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
5695 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
5696 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
5697 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
5698 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
5699 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
5700 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
5701 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
5702 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
5703 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
5704 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
5705 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
5706 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
5707 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
5708 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
5709 fails at resolve time with a non-self-locating `No such file or directory` \
5710 error far from the source caixa.lisp — while every downstream shell / YAML / \
5711 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
5712 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
5713 scalar disagree with the resolver on which directory the value names. The \
5714 lacre pipeline embeds the value verbatim in its per-dep content-address \
5715 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
5716 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5717 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
5718 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
5719 fragment-delimiter surface every peer single-token-shaped typed slot already \
5720 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
5721 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
5722 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5723 workspace directory name carries no shell-comment / URL-fragment / YAML-\
5724 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
5725 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
5726 and drop any `#fragment` tail entirely (fragment identifiers select \
5727 renderings, not directories, and `:caminho` names a directory).",
5728 ch = *byte as char
5729 )]
5730 FonteCaminhoShellComment {
5731 nome: String,
5732 caminho: String,
5733 byte: u8,
5734 },
5735 #[error(
5736 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
5737 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
5738 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
5739 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
5740 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
5741 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
5742 literally inside a URL value. The canonical paste-from-browser-address-bar \
5743 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
5744 encoded README hyperlink / browser address bar / percent-encoded permalink \
5745 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
5746 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
5747 what the author intended as the byte-identical sibling-workspace dep. POSIX \
5748 `std::path::Path` treats the byte as a literal path-component byte, so \
5749 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
5750 resolve time with a non-self-locating `No such file or directory` error far \
5751 from the source caixa.lisp — while every downstream URL parser / shell printf \
5752 builtin / YAML directive parser silently reinterprets the byte to a different \
5753 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
5754 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
5755 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
5756 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
5757 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
5758 recent job whose command started with `foo`\" — a future `kill %1` invocation \
5759 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
5760 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
5761 directive block cross-idiom leak); and the Windows-shell env-var-reference \
5762 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
5763 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
5764 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5765 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
5766 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5767 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
5768 printf-format-specifier / job-control-specifier surface every peer single-\
5769 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
5770 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
5771 `is_git_repo_url`). Express the path as a bare relative single-token like \
5772 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
5773 percent-encoding-escape / format-specifier / job-control semantic; substitute \
5774 any `%20` percent-encoded-space with a literal space then reject the whole \
5775 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5776 directory name never carries an embedded space in practice); drop any \
5777 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5778 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5779 ch = *byte as char
5780 )]
5781 FonteCaminhoUrlPercentEncoding {
5782 nome: String,
5783 caminho: String,
5784 byte: u8,
5785 },
5786 #[error(
5787 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5788 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5789 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5790 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5791 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5792 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5793 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5794 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5795 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5796 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5797 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5798 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5799 the byte is a first-class parser byte in nearly every config / templating / \
5800 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5801 `std::path::Path` treats the byte as a literal path-component byte, so the \
5802 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5803 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5804 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5805 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5806 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5807 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5808 subdirectory that fails at resolve time with a non-self-locating `No such file \
5809 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5810 the value verbatim in its per-dep content-address `path:{caminho}` at \
5811 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5812 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5813 time lock to two distinct BLAKE3 closures across two workstations whose \
5814 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5815 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5816 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5817 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5818 is the canonical CWE-78 shell-command-injection surface every peer single-\
5819 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5820 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5821 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5822 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5823 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5824 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5825 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5826 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5827 so every position — leading and embedded — is structurally rejected. Substitute \
5828 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5829 time, or express the path as a bare relative single-token like \
5830 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5831 variable-expansion / command-substitution / arithmetic-expansion semantic.",
5832 ch = *byte as char
5833 )]
5834 FonteCaminhoShellVariableExpansion {
5835 nome: String,
5836 caminho: String,
5837 byte: u8,
5838 },
5839 #[error(
5840 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5841 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5842 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5843 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5844 reference §9.3: `!command` re-runs the most recent history entry beginning with \
5845 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5846 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5847 and the substitution fires at every history-expansion-enabled shell context — \
5848 `set -o histexpand` is bash's default for interactive sessions and the layer \
5849 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5850 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5851 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5852 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5853 encodes it inside a query component via the 'special-query percent-encode set' \
5854 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5855 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5856 prefix — the paste-from-source-code idiom where an author copies \
5857 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5858 the string-literal boundary); the canonical English-typography emphasis / \
5859 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5860 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5861 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5862 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5863 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5864 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5865 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5866 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5867 repeat-prior-command paste idiom), the English-typography `:caminho \
5868 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5869 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5870 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5871 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5872 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5873 subdirectory that fails at resolve time with a non-self-locating `No such file \
5874 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5875 the value verbatim in its per-dep content-address `path:{caminho}` at \
5876 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5877 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5878 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5879 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5880 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5881 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5882 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5883 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5884 name carries no shell-history-expansion / bang-operator semantic; drop any \
5885 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5886 idiom; and drop any trailing English-typography exclamation mark that pasted \
5887 from prose.",
5888 ch = *byte as char
5889 )]
5890 FonteCaminhoShellHistoryExpansion {
5891 nome: String,
5892 caminho: String,
5893 byte: u8,
5894 },
5895 #[error(
5896 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5897 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5898 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5899 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5900 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5901 substitution' history operator that rewrites the prior command's `old` string to \
5902 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5903 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5904 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5905 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5906 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5907 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5908 literal value diverges from every downstream `feira tofu` curl-invocation / \
5909 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5910 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5911 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5912 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5913 `std::path::Path` treats `^` as a literal path-component byte, so \
5914 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5915 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5916 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5917 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5918 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5919 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5920 that fails at resolve time with a non-self-locating `No such file or directory` \
5921 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5922 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5923 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5924 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5925 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5926 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5927 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5928 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5929 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5930 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5931 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5932 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5933 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5934 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5935 drop any trailing `^` history-substitution-open fragment.",
5936 ch = *byte as char
5937 )]
5938 FonteCaminhoShellHistorySubstitution {
5939 nome: String,
5940 caminho: String,
5941 byte: u8,
5942 },
5943 #[error(
5944 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5945 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5946 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5947 value verbatim in its per-dep content-address `path:{caminho}` at \
5948 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5949 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5950 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5951 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5952 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5953 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5954 trailing `/`; every `:caminho` value names a sibling-workspace directory \
5955 already, so the trailing separator carries no information. Use \
5956 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5957 )]
5958 FonteCaminhoTrailingSlash { nome: String, caminho: String },
5959 #[error(
5960 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5961 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5962 apply the same set-not-multiset discipline; one package per table), and \
5963 two entries naming the same caixa carry two version constraints / source \
5964 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5965 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5966 silently overwrites the first at the resolver-side `concrete_versao` step, \
5967 and the dropped entry's pin / features never reach the closure — far from \
5968 the source caixa.lisp, with no field naming which `:deps` entry was the \
5969 silent loser. If two version constraints are genuinely needed (the rare \
5970 multi-version closure case the lacre pipeline doesn't yet support), the \
5971 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5972 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5973 )]
5974 DuplicateNome { nome: String, list: &'static str },
5975 #[error(
5976 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5977 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5978 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5979 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5980 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5981 with the canonical kebab-case feature name the target caixa declares."
5982 )]
5983 CaracteristicaEmpty { nome: String },
5984 #[error(
5985 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5986 feature name: {reason} (the value flows verbatim into Cargo's \
5987 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5988 parser enforces the same shape at `cargo metadata` time; use a single-token \
5989 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5990 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5991 an ASCII alphanumeric or `_`)"
5992 )]
5993 CaracteristicaInvalid {
5994 nome: String,
5995 caracteristica: String,
5996 reason: String,
5997 },
5998 #[error(
5999 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
6000 every feature-flag list keys its entries by name (Cargo's \
6001 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
6002 per feature per dep), and two entries naming the same feature are a redundant \
6003 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
6004 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
6005 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
6006 feature once regardless of declaration count, so the duplicate's pin / position never \
6007 reaches the closure with no field naming the silent loser. One entry per feature per \
6008 dep; if two distinct features are intended, name each verbatim."
6009 )]
6010 CaracteristicaDuplicate {
6011 nome: String,
6012 caracteristica: String,
6013 },
6014 #[error(
6015 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
6016 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
6017 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
6018 rejects mid-traversal far from the source caixa.lisp or recurses on until \
6019 it exhausts its stack). Every :nome is globally-unique substrate identity, \
6020 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
6021 *is* the parent itself, not a coincidentally-named peer. Drop the \
6022 self-referential dep entry — to reference code from this caixa, use \
6023 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
6024 referencing the caixa's own code surface) instead."
6025 )]
6026 DepIsSelf { nome: String, list: &'static str },
6027}
6028
6029// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
6030// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
6031// [`DepSource::validate_caminho`] onto one substrate primitive per typed
6032// variant — the paired `{ nome: String, caminho: String }` two-slot family
6033// on [`DepError`], sibling of the peer
6034// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
6035// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
6036// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
6037// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
6038// (981060b, 7 variants on `{ <field>: String, reason: String }`),
6039// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
6040// `{ de, para, wit, expected }`), and
6041// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
6042// variants on `{ de, para, <field>: String, reason: String }`) on the
6043// `AplicacaoError` envelopes, the peer
6044// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
6045// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
6046// (0419438, 4 variants on `{ caixa, kind, slots }`),
6047// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
6048// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
6049// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
6050// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
6051// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
6052// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
6053// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
6054// `UpgradeError` envelope. First fold family on this `DepError` envelope.
6055//
6056// Each of the eleven wire-up sites on this shape (the leading-byte cascade
6057// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
6058// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
6059// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
6060// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
6061// CommandSubstitution}` on the four single-byte shell operators; and the
6062// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
6063// opened the identical `DepError::FonteCaminho<Variant> { nome:
6064// nome.to_string(), caminho: caminho.to_string() }` four-line
6065// struct-literal against the same `(nome: &str, caminho: &str)` local pair
6066// — the exact "same block re-inlined at every consumer" shape the PRIME
6067// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
6068// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
6069// families each closed on their sibling envelopes. The eleven variants
6070// share one `{ nome: String, caminho: String }` shape, so the fold routes
6071// each wire-up site through one dispatch per typed variant.
6072//
6073// The macro below generates one `#[must_use]` inherent constructor per
6074// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
6075// wire-up site collapses onto one dispatch:
6076// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
6077// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
6078// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
6079// once — inside the macro — rather than at every wire-up site.
6080//
6081// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
6082// shapes at the per-byte-classification arms — the
6083// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
6084// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
6085// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
6086// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
6087// cluster — carry an additional `byte: u8` naming the offending byte and
6088// so would break the uniform-two-field routing this macro promises. They
6089// instead fold onto the sibling three-field envelope through
6090// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
6091// `{ nome, caminho, byte }` shape), whose sole additional axis over this
6092// two-slot family is the `byte: u8` classification the arms carry. The
6093// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
6094// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
6095// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
6096// envelope.
6097//
6098// Every future consumer that wants to construct one of these eleven
6099// variants outside the current in-crate [`DepSource::validate_caminho`]
6100// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
6101// at lacre-resolve time re-checking the same value-shape axes the resolver
6102// consumes, a future `feira validate --deps` per-caixa admission verb
6103// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
6104// rejecting a `:caminho` value against a cluster-local snapshot) now
6105// reaches each variant through one call rather than re-inlining the
6106// four-line struct-literal in lockstep with the eleven in-crate wire-up
6107// sites.
6108macro_rules! fonte_caminho_ctors {
6109 ($($ctor:ident => $variant:ident),* $(,)?) => {
6110 impl DepError {
6111 $(
6112 #[doc = concat!(
6113 "Construct a [`DepError::",
6114 stringify!($variant),
6115 "`] naming the offending `:deps :nome` + `:fonte ",
6116 "(:tipo path …) :caminho` pair. Folds the uniform ",
6117 "`Self::",
6118 stringify!($variant),
6119 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
6120 "two-slot struct-literal onto one substrate primitive so ",
6121 "every [`DepSource::validate_caminho`] wire-up on this ",
6122 "variant reads through one dispatch rather than the ",
6123 "pre-lift four-line open-coded block."
6124 )]
6125 #[must_use]
6126 pub fn $ctor(nome: &str, caminho: &str) -> Self {
6127 Self::$variant {
6128 nome: nome.to_string(),
6129 caminho: caminho.to_string(),
6130 }
6131 }
6132 )*
6133 }
6134 };
6135}
6136
6137fonte_caminho_ctors! {
6138 fonte_caminho_absolute => FonteCaminhoAbsolute,
6139 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
6140 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
6141 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
6142 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
6143 fonte_caminho_backslash => FonteCaminhoBackslash,
6144 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
6145 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
6146 fonte_caminho_shell_background => FonteCaminhoShellBackground,
6147 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
6148 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
6149}
6150
6151// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
6152// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
6153// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
6154// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
6155// three-slot family on [`DepError`], strict sibling of the peer
6156// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
6157// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
6158// that fold onto the `byte`-classifying arms whose additional `byte: u8`
6159// axis broke its uniform-two-field routing — the exact "future compounding
6160// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
6161// here. Third fold family on this `DepError` envelope, sibling of the peer
6162// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
6163// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
6164// same enum.
6165//
6166// Each of the twelve wire-up sites on this shape (the control-byte arm
6167// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
6168// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
6169// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
6170// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
6171// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
6172// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
6173// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
6174// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
6175// `FonteCaminhoShellHistoryExpansion` on `!`, and
6176// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
6177// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
6178// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
6179// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
6180// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
6181// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
6182// closed on the sibling two-field envelope of this same enum. The twelve
6183// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
6184// the fold routes each wire-up site through one dispatch per typed variant.
6185//
6186// The macro below generates one `#[must_use]` inherent constructor per
6187// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
6188// so every wire-up site collapses onto one dispatch:
6189// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
6190// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
6191// three-field construction (`nome.to_string()` / `caminho.to_string()` /
6192// `byte`) is spelled once — inside the macro — rather than at every wire-up
6193// site.
6194//
6195// Every future consumer that wants to construct one of these twelve
6196// variants outside the current in-crate [`DepSource::validate_caminho`]
6197// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
6198// at lacre-resolve time re-checking the same value-shape axes the resolver
6199// consumes, a future `feira validate --deps` per-caixa admission verb
6200// re-checking the `:fonte :caminho` axis against the shell-metachar
6201// classification bytes this cluster catches, a per-lacre overlay resolver
6202// rejecting a `:caminho` value against a cluster-local snapshot) now
6203// reaches each variant through one call rather than re-inlining the
6204// five-line struct-literal in lockstep with the twelve in-crate wire-up
6205// sites.
6206macro_rules! fonte_caminho_byte_ctors {
6207 ($($ctor:ident => $variant:ident),* $(,)?) => {
6208 impl DepError {
6209 $(
6210 #[doc = concat!(
6211 "Construct a [`DepError::",
6212 stringify!($variant),
6213 "`] naming the offending `:deps :nome` + `:fonte ",
6214 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
6215 "classification. Folds the uniform `Self::",
6216 stringify!($variant),
6217 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
6218 "byte }` three-slot struct-literal onto one substrate ",
6219 "primitive so every [`DepSource::validate_caminho`] wire-up ",
6220 "on this variant reads through one dispatch rather than ",
6221 "the pre-lift five-line open-coded block."
6222 )]
6223 #[must_use]
6224 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
6225 Self::$variant {
6226 nome: nome.to_string(),
6227 caminho: caminho.to_string(),
6228 byte,
6229 }
6230 }
6231 )*
6232 }
6233 };
6234}
6235
6236fonte_caminho_byte_ctors! {
6237 fonte_caminho_control_char => FonteCaminhoControlChar,
6238 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
6239 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
6240 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
6241 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
6242 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
6243 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
6244 fonte_caminho_shell_comment => FonteCaminhoShellComment,
6245 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
6246 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
6247 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
6248 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
6249}
6250
6251// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
6252// single-slot struct-variant wire-up sites scattered across
6253// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
6254// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
6255// substrate primitive per typed variant — the paired `{ nome: String }`
6256// single-slot family on [`DepError`], sibling of the peer
6257// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
6258// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
6259// the same enum, and of the peer
6260// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
6261// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
6262// axis. Second fold family on this `DepError` envelope, and the first on
6263// the single-`{ nome }` shape.
6264//
6265// The five wire-up sites this fold closes each opened the identical
6266// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
6267// struct-literal against the same `nome: &str` (or `self.nome: &String`)
6268// local — the exact "same block re-inlined at every consumer" shape the
6269// PRIME DIRECTIVE names as a bug. The five variants share one
6270// `{ nome: String }` shape, so the fold routes each wire-up site through
6271// one dispatch per typed variant.
6272//
6273// The macro below generates one `#[must_use]` inherent constructor per
6274// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
6275// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
6276// pre-lift struct-literal on the same `&str` fixture. The uniform
6277// one-field construction (`nome.to_string()`) is spelled once — inside
6278// the macro — rather than at every wire-up site. Callers that hold a
6279// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
6280// and lets the macro-owned `.to_string()` produce the fresh owning copy
6281// the enum variant needs; the semantics collapse onto the same
6282// `.clone()`-equivalent one this fold replaces at every site.
6283//
6284// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
6285// on the same envelope stays on its pre-lift open-coded wire-up shape —
6286// it carries no `nome` field (the offending `:nome` value *is* the empty
6287// string this variant catches) so the uniform `fn(nome: &str) -> Self`
6288// signature this macro promises does not apply. Every future consumer
6289// that wants to construct one of these five variants outside the current
6290// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
6291// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
6292// re-validator at lacre-resolve time, a future `feira validate --deps`
6293// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
6294// these empty-value shapes against a cluster-local snapshot) now reaches
6295// each variant through one call rather than re-inlining the three-line
6296// struct-literal in lockstep with the five in-crate wire-up sites.
6297macro_rules! dep_nome_only_ctors {
6298 ($($ctor:ident => $variant:ident),* $(,)?) => {
6299 impl DepError {
6300 $(
6301 #[doc = concat!(
6302 "Construct a [`DepError::",
6303 stringify!($variant),
6304 "`] naming the offending `:deps :nome`. Folds the ",
6305 "uniform `Self::",
6306 stringify!($variant),
6307 " { nome: nome.to_string() }` one-field ",
6308 "struct-literal onto one substrate primitive so every ",
6309 "in-crate wire-up on this variant reads through one ",
6310 "dispatch rather than the pre-lift three-line ",
6311 "open-coded block."
6312 )]
6313 #[must_use]
6314 pub fn $ctor(nome: &str) -> Self {
6315 Self::$variant { nome: nome.to_string() }
6316 }
6317 )*
6318 }
6319 };
6320}
6321
6322dep_nome_only_ctors! {
6323 versao_empty => VersaoEmpty,
6324 fonte_repo_empty => FonteRepoEmpty,
6325 fonte_pin_missing => FontePinMissing,
6326 fonte_caminho_empty => FonteCaminhoEmpty,
6327 caracteristica_empty => CaracteristicaEmpty,
6328}
6329
6330// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
6331// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
6332// [`crate::manifest::Caixa::validate_deps`] +
6333// [`validate_no_self_dep`] onto one substrate-primitive family per
6334// typed variant — the `DepError`-side siblings of the peer
6335// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
6336// on the `SupervisorError { caixa: String }` one-slot envelope and of
6337// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
6338// `DepError { nome: String }` one-slot envelope. The two variants
6339// carry the same `{ nome: String, list: &'static str }` two-slot
6340// shape: the `nome` field names the offending dep the diagnostic
6341// points the author back at, and the `list` field carries the
6342// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
6343// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
6344// [`validate_deps`] arms, and via the paired
6345// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
6346// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
6347// canonicals on the [`validate_no_self_dep`] arm) so the author can
6348// grep their caixa.lisp for the offending list block in one edit.
6349//
6350// Each of the four wire-up sites opened the same struct-literal
6351// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
6352// two-line block — the exact "same block re-inlined at every
6353// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
6354// altitude the peer `DepError` / `SupervisorError` /
6355// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
6356// already closed on their sibling envelopes. The two `#[must_use]`
6357// inherent constructors below fold each wire-up onto one dispatch:
6358// `DepError::duplicate_nome(<nome>, <list>)` and
6359// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
6360// pre-lift struct-literal on the same scalar fixtures. The `list:
6361// &'static str` parameter (not `impl Into<String>`) preserves the
6362// exact wire tag every consumer already passes verbatim — no
6363// downstream diagnostic reshaping at the lift, matching the peer
6364// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
6365// contract each wire-up site already keys off.
6366macro_rules! dep_nome_list_ctors {
6367 ($($ctor:ident => $variant:ident),* $(,)?) => {
6368 impl DepError {
6369 $(
6370 #[doc = concat!(
6371 "Construct a [`DepError::",
6372 stringify!($variant),
6373 "`] naming the offending `:deps :nome` and the ",
6374 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
6375 "the diagnostic points the author back at. Folds ",
6376 "the uniform `Self::",
6377 stringify!($variant),
6378 " { nome: nome.to_string(), list }` two-field ",
6379 "struct-literal onto one substrate primitive so ",
6380 "every in-crate wire-up on this variant reads ",
6381 "through one dispatch rather than the pre-lift ",
6382 "open-coded struct-literal block."
6383 )]
6384 #[must_use]
6385 pub fn $ctor(nome: &str, list: &'static str) -> Self {
6386 Self::$variant { nome: nome.to_string(), list }
6387 }
6388 )*
6389 }
6390 };
6391}
6392
6393dep_nome_list_ctors! {
6394 duplicate_nome => DuplicateNome,
6395 dep_is_self => DepIsSelf,
6396}
6397
6398// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
6399// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
6400// <value>.to_string(), reason }` struct-variant wire-up sites at
6401// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
6402// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
6403// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
6404// primitive family per typed variant — the `DepError`-side siblings of the
6405// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
6406// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
6407// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
6408// the two-slot `{ nome, caminho }` envelope, and
6409// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
6410// caminho, byte }` envelope. The three variants share the same
6411// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
6412// the `nome` field names the offending dep the diagnostic points the
6413// author back at, the middle `<axis>: String` field carries the offending
6414// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
6415// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
6416// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
6417// field carries the parser-shaped rejection sentence the paired
6418// [`crate::render::require_valid_versao_requirement`] /
6419// [`crate::render::is_git_repo_url`] /
6420// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
6421// axis-field name differs across variants (`versao` / `repo` /
6422// `caracteristica`) so the ctor family below takes the axis field name as
6423// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
6424// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
6425// -> Self` inherent constructor per typed variant that spells the uniform
6426// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
6427// `reason` forwarded owned) exactly once. Peer of the sibling
6428// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
6429// family on the `AplicacaoError` envelope's mirror-symmetric
6430// `{ <field>: String, reason: String }` two-slot shape — same
6431// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
6432// one `nome`-axis added at the per-dep-owned altitude the `DepError`
6433// envelope keys off (every `DepError` variant carries the offending
6434// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
6435// offending block in one edit).
6436//
6437// The three wire-up sites this fold closes are:
6438// - [`DepSource::validate`]'s `:repo` value-shape arm
6439// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
6440// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
6441// rejects the offending URL);
6442// - [`Dep::validate`]'s `:versao` requirement-shape arm
6443// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
6444// self.versao_requirement().to_string(), reason }` inside the
6445// [`crate::render::require_valid_versao_requirement`] callback pair);
6446// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
6447// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
6448// caracteristica: c.clone(), reason })` after
6449// [`crate::render::is_cargo_feature_name`] rejects the offending
6450// feature-name).
6451//
6452// Each opened the identical five-line struct-literal against the same
6453// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
6454// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6455// same altitude the peer four already-lifted `DepError` ctor families
6456// closed on their sibling shape-envelopes. The three variant / axis-field
6457// discriminators are the only things that vary between them; the rest of
6458// the struct-literal is a byte-for-byte re-inline.
6459//
6460// Every future consumer wanting to raise one of these three diagnostics
6461// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
6462// time re-checking each declared dep against the same requirement +
6463// git-URL + feature-name value-shape cascade, a future `feira validate
6464// --deps` per-caixa admission verb re-running the shape gates on demand,
6465// a per-lacre overlay resolver rejecting an author-supplied dep against a
6466// cluster-local snapshot) now reaches one dispatch rather than re-inlining
6467// the five-line struct-literal in lockstep with the three in-crate
6468// wire-up sites.
6469macro_rules! dep_nome_axis_reason_ctors {
6470 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6471 impl DepError {
6472 $(
6473 #[doc = concat!(
6474 "Construct a [`DepError::",
6475 stringify!($variant),
6476 "`] naming the offending `:deps :nome`, the offending ",
6477 "`:", stringify!($axis), "` axis value, and the ",
6478 "parser-shaped rejection `reason`. Folds the uniform ",
6479 "`Self::",
6480 stringify!($variant),
6481 " { nome: nome.to_string(), ",
6482 stringify!($axis),
6483 ": ",
6484 stringify!($axis),
6485 ".to_string(), reason }` three-field struct-literal ",
6486 "onto one substrate primitive so every in-crate ",
6487 "wire-up on this variant reads through one dispatch ",
6488 "rather than the pre-lift five-line open-coded block. ",
6489 "The `nome: &str` and `",
6490 stringify!($axis),
6491 ": &str` parameters accept `&str` literals and ",
6492 "`&String` (via Deref coercion) so every existing ",
6493 "wire-up threads through the ctor without a ",
6494 "pre-conversion; the `reason: String` parameter takes ",
6495 "an owned `String` (not `impl Into<String>`) matching ",
6496 "the paired `crate::render::*` predicate's ",
6497 "`Result<(), String>` return shape every wire-up ",
6498 "already holds owned at the call site."
6499 )]
6500 #[must_use]
6501 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
6502 Self::$variant {
6503 nome: nome.to_string(),
6504 $axis: $axis.to_string(),
6505 reason,
6506 }
6507 }
6508 )*
6509 }
6510 };
6511}
6512
6513dep_nome_axis_reason_ctors! {
6514 versao_invalid => VersaoInvalid { versao },
6515 fonte_repo_shape => FonteRepoShape { repo },
6516 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
6517}
6518
6519// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
6520// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
6521// <value>.to_string() }` struct-variant wire-up sites at
6522// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
6523// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
6524// per-entry set-not-multiset dedup closure onto one substrate-primitive
6525// family per typed variant — the missing two-slot rung on the
6526// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
6527// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
6528// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
6529// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
6530// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
6531// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
6532// symmetric sibling of the peer
6533// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
6534// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
6535// envelope — same `<axis>: <value>.to_string()` owned-forward payload
6536// shape, `reason` axis removed and `nome`-axis added at the per-dep-
6537// owned altitude the `DepError` envelope keys off (every `DepError`
6538// variant carries the offending `:deps :nome` verbatim so the author
6539// can grep their caixa.lisp for the offending block in one edit). The
6540// three variants share the same `{ nome: String, <axis>: String }`
6541// two-slot shape: the `nome` field names the offending dep the
6542// diagnostic points the author back at, and the middle `<axis>:
6543// String` field carries the offending per-envelope axis value verbatim
6544// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
6545// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
6546// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
6547// The middle axis-field name differs across variants (`pin` / `pins` /
6548// `caracteristica`) so the ctor family below takes the axis field name
6549// as a macro parameter (`$axis:ident`) alongside the ctor + variant
6550// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
6551// Self` inherent constructor per typed variant that spells the
6552// uniform two-field construction (`nome.to_string()` /
6553// `<axis>.to_string()`) exactly once.
6554//
6555// The three wire-up sites this fold closes are:
6556// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
6557// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
6558// pin.to_string() });` inside the `set.len() == 1` branch after the
6559// `is_some_and(String::is_empty)` iterator);
6560// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
6561// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
6562// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
6563// - [`Dep::validate_caracteristicas`]'s per-entry
6564// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
6565// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
6566// [`crate::render::insert_first_seen`]).
6567//
6568// Each opened the identical four-line struct-literal against the same
6569// `(nome, <axis>)` local pair — the exact "same block re-inlined at
6570// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6571// same altitude the peer four already-lifted `DepError` ctor families
6572// closed on their sibling shape-envelopes. The three variant / axis-
6573// field discriminators are the only things that vary between them;
6574// the rest of the struct-literal is a byte-for-byte re-inline.
6575//
6576// Every future consumer wanting to raise one of these three
6577// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
6578// at lacre-resolve time re-checking each declared dep against the
6579// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
6580// set-not-multiset cascade, a future `feira validate --deps` per-
6581// caixa admission verb re-running the shape gates on demand, a
6582// per-lacre overlay resolver rejecting an author-supplied dep against
6583// a cluster-local snapshot the M4 CR materializer projects) now
6584// reaches one dispatch rather than re-inlining the four-line struct-
6585// literal in lockstep with the three in-crate wire-up sites.
6586macro_rules! dep_nome_axis_ctors {
6587 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6588 impl DepError {
6589 $(
6590 #[doc = concat!(
6591 "Construct a [`DepError::",
6592 stringify!($variant),
6593 "`] naming the offending `:deps :nome` and the ",
6594 "offending `:", stringify!($axis), "` axis value. ",
6595 "Folds the uniform `Self::",
6596 stringify!($variant),
6597 " { nome: nome.to_string(), ",
6598 stringify!($axis),
6599 ": ",
6600 stringify!($axis),
6601 ".to_string() }` two-field struct-literal onto one ",
6602 "substrate primitive so every in-crate wire-up on ",
6603 "this variant reads through one dispatch rather than ",
6604 "the pre-lift four-line open-coded block. Both `nome: ",
6605 "&str` and `",
6606 stringify!($axis),
6607 ": &str` parameters accept `&str` literals and ",
6608 "`&String` (via Deref coercion) so every existing ",
6609 "wire-up threads through the ctor without a pre-",
6610 "conversion."
6611 )]
6612 #[must_use]
6613 pub fn $ctor(nome: &str, $axis: &str) -> Self {
6614 Self::$variant {
6615 nome: nome.to_string(),
6616 $axis: $axis.to_string(),
6617 }
6618 }
6619 )*
6620 }
6621 };
6622}
6623
6624dep_nome_axis_ctors! {
6625 fonte_pin_empty => FontePinEmpty { pin },
6626 fonte_pin_ambiguous => FontePinAmbiguous { pins },
6627 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
6628}
6629
6630// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
6631// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
6632// struct-variant wire-up sites at [`DepSource::validate`]'s
6633// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
6634// the `DepError` envelope — the last open-coded ctor site remaining on
6635// the `:fonte (:tipo git …)` value-shape trajectory this envelope
6636// carries, and the single-variant sibling of the peer four already-
6637// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
6638// on the two-slot `{ nome, caminho }` envelope,
6639// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
6640// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
6641// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
6642// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
6643// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
6644// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
6645// `{ …, value: String, reason: String }` payload shape, one axis
6646// removed at the `nome`-only-owner altitude the `DepError` envelope
6647// keys off (no `edge_pair()` de/para pair).
6648//
6649// The two wire-up sites this fold closes are the paired refname-pin
6650// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
6651// pin: pin.to_string(), value: v.clone(), reason }` inside the
6652// `[(":tag", tag), (":branch", branch)]` iterator against
6653// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
6654// (`|| DepError::FontePinShape { nome: nome.to_string(),
6655// pin: ":rev".to_string(), value: v.clone(), reason }` against
6656// [`crate::render::is_git_oid`]) — each opened the identical
6657// `DepError::FontePinShape { … }` six-line struct-literal against the
6658// same `(nome: &str, pin: &str, v: &String, reason: String)` local
6659// tuple, the exact "same block re-inlined at every consumer" shape
6660// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
6661// the only thing that varies between them (`":tag"`/`":branch"` on
6662// the refname arm, `":rev"` on the hex-OID arm); the rest of the
6663// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
6664// route through the same ctor because their `pin` field carries the
6665// author-surface tag verbatim (matching the `FontePinEmpty` /
6666// `FontePinAmbiguous` sibling variants' `pin: String` axis
6667// convention), so the offending author can grep their caixa.lisp for
6668// the offending `:tag "<value>"` / `:branch "<value>"` /
6669// `:rev "<value>"` literal in one edit.
6670//
6671// The single ctor below folds each wire-up onto one dispatch:
6672// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
6673// the pre-lift struct-literal on the same `(&str, &str, &str,
6674// String)` fixture. The uniform four-field construction
6675// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
6676// `reason` forwarded owned) is spelled once here rather than at every
6677// wire-up site. The `reason: String` field takes an owned `String`
6678// (not `impl Into<String>`) matching the two call sites' pre-existing
6679// `let Err(reason) = crate::render::is_git_ref_name(v)` /
6680// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
6681// predicates return `Result<(), String>`, so the caller always holds
6682// an owned `String` at the wire-up site and threading it through the
6683// ctor without a `.into()` shim keeps the routing shape byte-equal to
6684// the pre-lift block. The `value: &str` parameter accepts both `&str`
6685// literals (unused today) and `&String` (from the caller-held
6686// `v: &String` on each arm, via Deref coercion), so every existing
6687// wire-up threads through the ctor without a pre-conversion.
6688//
6689// Every future consumer that wants to construct this variant outside
6690// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
6691// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
6692// re-checking the same value-shape axes the resolver consumes, a
6693// future `feira validate --deps` per-caixa admission verb re-checking
6694// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
6695// resolver rejecting a git-pin value against a cluster-local
6696// snapshot) now reaches this variant through one call rather than
6697// re-inlining the six-line struct-literal in lockstep with the two
6698// in-crate wire-up sites.
6699impl DepError {
6700 /// Construct a [`DepError::FontePinShape`] naming the offending
6701 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
6702 /// axis tag, the offending value, and the parser-shaped `reason`.
6703 /// Folds the uniform
6704 /// `Self::FontePinShape { nome: nome.to_string(),
6705 /// pin: pin.to_string(), value: value.to_string(), reason }`
6706 /// four-field struct-literal onto one substrate primitive so
6707 /// every [`DepSource::validate`] wire-up on this variant reads
6708 /// through one dispatch rather than the pre-lift six-line
6709 /// open-coded block. The `nome` string threads verbatim from
6710 /// [`Dep::nome`] at the call site; the `pin` string carries the
6711 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
6712 /// `value` string carries the offending refname / hex-OID
6713 /// verbatim; and `reason` forwards the owned `String` returned
6714 /// by [`crate::render::is_git_ref_name`] /
6715 /// [`crate::render::is_git_oid`] without a `.into()` shim.
6716 #[must_use]
6717 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
6718 Self::FontePinShape {
6719 nome: nome.to_string(),
6720 pin: pin.to_string(),
6721 value: value.to_string(),
6722 reason,
6723 }
6724 }
6725
6726 /// Construct a [`DepError::NomeInvalid`] naming the offending
6727 /// `:deps :nome` byte-string and the parser-shaped rejection
6728 /// `reason` returned by [`crate::render::is_dns_1123_label`].
6729 ///
6730 /// Folds the uniform
6731 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
6732 /// struct-literal onto one substrate primitive so every wire-up on
6733 /// this variant reads through one dispatch rather than the pre-lift
6734 /// four-line open-coded `DepError::NomeInvalid { nome:
6735 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
6736 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
6737 /// ctor-family ladder (`{ nome }` one-slot →
6738 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
6739 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
6740 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
6741 /// `{ nome, <axis>: String, reason: String }` three-slot →
6742 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
6743 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
6744 /// — the sole variant on the envelope carrying the
6745 /// `{ nome: String, reason: String }` two-slot shape without a
6746 /// middle axis, matching the peer
6747 /// [`crate::manifest::ManifestError::NomeInvalid`] +
6748 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
6749 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
6750 /// four-axis DNS-1123 caixa-identifier diagnostic family the
6751 /// existing `nome_invalid_diagnostic_carries_offending_name` test
6752 /// pins on this envelope.
6753 ///
6754 /// The `nome: &str` parameter accepts `&str` literals and `&String`
6755 /// (via Deref coercion) so the sole in-crate wire-up threads through
6756 /// the ctor without a pre-conversion; the `reason: String`
6757 /// parameter takes an owned `String` (not `impl Into<String>`)
6758 /// matching the [`crate::render::is_dns_1123_label`] predicate's
6759 /// `Result<(), String>` return shape the sole wire-up site already
6760 /// holds owned at the call site, keeping the routing byte-equal to
6761 /// the pre-lift block. Same owned-`String`-forward `reason` payload
6762 /// discipline as the sibling three-slot family
6763 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
6764 /// and the four-slot [`DepError::fonte_pin_shape`] on
6765 /// `{ nome, pin, value, reason }`.
6766 ///
6767 /// Every future consumer that raises the same diagnostic outside
6768 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
6769 /// re-validator at lacre-resolve time re-checking each declared
6770 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
6771 /// side schema uses (the `:nome` value flows verbatim as the target
6772 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
6773 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
6774 /// checkout-directory leaf), a future `feira validate --deps`
6775 /// per-caixa admission verb re-running the shape gate on demand, a
6776 /// per-lacre overlay resolver rejecting an author-supplied dep's
6777 /// `:nome` against a cluster-local snapshot the M4 CR materializer
6778 /// projects, a future authoring-surface widening the field into a
6779 /// `(String, Vec<Suggestion>)` pair carrying a
6780 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6781 /// variant through one call rather than re-inlining the four-line
6782 /// struct-literal in lockstep with the one in-crate wire-up site.
6783 #[must_use]
6784 pub fn nome_invalid(nome: &str, reason: String) -> Self {
6785 Self::NomeInvalid {
6786 nome: nome.to_string(),
6787 reason,
6788 }
6789 }
6790}
6791
6792#[allow(clippy::trivially_copy_pass_by_ref)]
6793fn is_false(b: &bool) -> bool {
6794 !*b
6795}
6796
6797#[cfg(test)]
6798mod tests {
6799 use super::*;
6800
6801 #[test]
6802 fn registry_dep_is_minimal() {
6803 let d = Dep::simple("caixa-teia", "^0.1");
6804 assert_eq!(d.nome, "caixa-teia");
6805 assert_eq!(d.versao, "^0.1");
6806 assert!(d.fonte.is_none());
6807 assert!(!d.opcional());
6808 assert!(d.caracteristicas().is_empty());
6809 }
6810
6811 #[test]
6812 fn dep_string_scalar_accessor_pair_is_const_fn() {
6813 // Fail-before-pass-after pin on [`Dep::nome`] +
6814 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6815 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6816 // entry's [`String`] storage through the `pub const fn`
6817 // [`String::as_str`] (const-stable since Rust 1.87, well
6818 // within the workspace MSRV) — any future accidental
6819 // downgrade to non-`const` fails the corresponding
6820 // `<name>_via_const_fn` wrapper at caixa-core build time with
6821 // E0015 (`cannot call non-const method`), strictly stronger
6822 // than a runtime `assert!`. Sibling of the peer
6823 // per-M2/M3/universal-axis `String → &str` scalar-accessor
6824 // family pins on the sibling `const`-eval-surface passes
6825 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6826 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6827 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6828 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6829 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6830 // [`crate::aplicacao::Entrada::destination`] at the M3
6831 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6832 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6833 // M2 supervisor-tree axis,
6834 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6835 // M2 upgrade axis, and the per-`:contratos`
6836 // [`crate::aplicacao::WitContract::source`] /
6837 // [`crate::aplicacao::WitContract::destination`] /
6838 // [`crate::aplicacao::WitContract::world_ref`] trio the
6839 // sibling pin at 279823b already anchors).
6840 const fn nome_via_const_fn(d: &Dep) -> &str {
6841 d.nome()
6842 }
6843 const fn versao_via_const_fn(d: &Dep) -> &str {
6844 d.versao_requirement()
6845 }
6846 for (nome, versao) in [
6847 ("caixa-teia", "^0.1"),
6848 ("caixa-mesh", "~0.2.3"),
6849 ("caixa-helm", "*"),
6850 ] {
6851 let d = Dep::simple(nome, versao);
6852 assert_eq!(nome_via_const_fn(&d), d.nome());
6853 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6854 assert_eq!(d.nome(), nome);
6855 assert_eq!(d.versao_requirement(), versao);
6856 }
6857 }
6858
6859 #[test]
6860 fn dep_outer_accessor_family_is_const_fn() {
6861 // Fail-before-pass-after pin on [`Dep::fonte`] +
6862 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6863 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6864 // entry's composite / list storage through a `pub const fn`
6865 // stdlib method (`Option::<DepSource>::as_ref` /
6866 // `Vec::<String>::as_slice`, both const-stable since Rust
6867 // 1.83, well within the workspace MSRV). Any future
6868 // accidental downgrade to non-`const` fails the corresponding
6869 // `<name>_via_const_fn` wrapper at caixa-core build time with
6870 // E0015 (`cannot call non-const method`), strictly stronger
6871 // than a runtime `assert!` and side-stepping the destructor-
6872 // in-const restriction the `Dep` fixture's `String` /
6873 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6874 // direct-`const _: () = assert!(...)` residence.
6875 //
6876 // Peer of the sibling per-`Dep` scalar-accessor pair pin
6877 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6878 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6879 // the `const`-eval-surface discipline onto the composite-
6880 // reference and slice-return arms of the outer-`Dep` accessor
6881 // family, closing the four-slot outer surface (`:nome` +
6882 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6883 // posture. The `:opcional` `bool` arm already carries the
6884 // posture through [`Dep::opcional`]'s prior `pub const fn`
6885 // declaration, so this pin lands the last two unlifted
6886 // outer-`Dep` accessors and closes the family.
6887 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6888 d.fonte()
6889 }
6890 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6891 d.caracteristicas()
6892 }
6893 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6894 let empty = Dep::simple("caixa-teia", "^0.1");
6895 assert!(fonte_via_const_fn(&empty).is_none());
6896 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6897 assert!(caracteristicas_via_const_fn(&empty).is_empty());
6898 assert_eq!(
6899 caracteristicas_via_const_fn(&empty),
6900 empty.caracteristicas()
6901 );
6902 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6903 // still empty.
6904 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6905 assert!(fonte_via_const_fn(&git).is_some());
6906 assert_eq!(fonte_via_const_fn(&git), git.fonte());
6907 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6908 // Populated `:caracteristicas` — exercise the non-empty
6909 // slice-view arm to pin the accessor's borrow shape against
6910 // both a `Vec::new()` empty backing buffer and a populated one.
6911 let mut with_features = Dep::simple("caixa-teia", "^0.1");
6912 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6913 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6914 assert_eq!(
6915 caracteristicas_via_const_fn(&with_features),
6916 with_features.caracteristicas()
6917 );
6918 }
6919
6920 #[test]
6921 fn git_dep_carries_tag() {
6922 let d = Dep::git("t", "*", "github:o/r", "v1");
6923 match d.fonte {
6924 Some(DepSource::Git {
6925 ref repo, ref tag, ..
6926 }) => {
6927 assert_eq!(repo, "github:o/r");
6928 assert_eq!(tag.as_deref(), Some("v1"));
6929 }
6930 _ => panic!("expected Git source"),
6931 }
6932 }
6933
6934 #[test]
6935 fn validate_accepts_simple_dep() {
6936 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6937 }
6938
6939 #[test]
6940 fn validate_rejects_empty_nome() {
6941 // The fail-before-pass-after pin for `:nome ""`: the empty-name
6942 // arm fires first so the per-entry parse-side diagnostic doesn't
6943 // emit a useless `nome: ""` reference.
6944 let mut d = Dep::simple("placeholder", "^0.1");
6945 d.nome = String::new();
6946 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6947 }
6948
6949 #[test]
6950 fn validate_rejects_empty_versao() {
6951 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6952 // semver crate accepts the empty string as a wildcard match),
6953 // so the empty-`:versao` arm is structurally necessary even
6954 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6955 // `EmptyChildVersion` ordering on the other two `:versao` axes.
6956 let mut d = Dep::simple("caixa-teia", "ignored");
6957 d.versao = String::new();
6958 let err = d.validate().unwrap_err();
6959 assert!(
6960 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6961 "got {err:?}"
6962 );
6963 }
6964
6965 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6966
6967 #[test]
6968 fn validate_rejects_nome_with_uppercase() {
6969 // The fail-before-pass-after pin: a non-empty but uppercase
6970 // `:nome` silently passed `validate()` on every pre-gate
6971 // codebase because the prior shape only refused the empty
6972 // string. The DNS-1123 violation surfaced far downstream at
6973 // lacre-resolve time when the *target* caixa's `:nome` failed
6974 // its own gate — far from the `:deps` entry, with a diagnostic
6975 // naming the target rather than the dep entry that referenced
6976 // it. Same fail-before-pass-after fixture pinned for
6977 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6978 // and Caixa `:nome` (6c992f8).
6979 let d = Dep::simple("Caixa-Teia", "^0.1");
6980 let err = d.validate().unwrap_err();
6981 assert!(
6982 matches!(
6983 err,
6984 DepError::NomeInvalid { ref nome, ref reason }
6985 if nome == "Caixa-Teia" && reason.contains("uppercase")
6986 ),
6987 "got {err:?}"
6988 );
6989 }
6990
6991 #[test]
6992 fn validate_rejects_nome_with_underscore() {
6993 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6994 // "I'm thinking of Go module names / Python identifiers" leak.
6995 // Same fixture pinned for the peer caixa-identifier axes.
6996 let d = Dep::simple("caixa_teia", "^0.1");
6997 let err = d.validate().unwrap_err();
6998 assert!(
6999 matches!(
7000 err,
7001 DepError::NomeInvalid { ref nome, ref reason }
7002 if nome == "caixa_teia" && reason.contains('_')
7003 ),
7004 "got {err:?}"
7005 );
7006 }
7007
7008 #[test]
7009 fn validate_rejects_nome_with_dot() {
7010 // A `:deps :nome` is a single DNS-1123 *label*, not a
7011 // subdomain — dots are rejected. The `"caixa.teia"` shape is
7012 // the canonical "I confused the dep name with the FQDN /
7013 // namespace" footgun, distinct from the legitimate
7014 // `:fonte :repo "github:org/caixa-teia"` axis.
7015 let d = Dep::simple("caixa.teia", "^0.1");
7016 let err = d.validate().unwrap_err();
7017 assert!(
7018 matches!(
7019 err,
7020 DepError::NomeInvalid { ref nome, ref reason }
7021 if nome == "caixa.teia" && reason.contains('.')
7022 ),
7023 "got {err:?}"
7024 );
7025 }
7026
7027 #[test]
7028 fn validate_rejects_nome_with_leading_hyphen() {
7029 // RFC 1123 requires alphanumeric at both label boundaries.
7030 // Pinned in parity with the peer DNS-1123 fixtures.
7031 let d = Dep::simple("-caixa-teia", "^0.1");
7032 let err = d.validate().unwrap_err();
7033 assert!(
7034 matches!(
7035 err,
7036 DepError::NomeInvalid { ref nome, ref reason }
7037 if nome == "-caixa-teia" && reason.contains("alphanumeric")
7038 ),
7039 "got {err:?}"
7040 );
7041 }
7042
7043 #[test]
7044 fn validate_rejects_nome_with_trailing_hyphen() {
7045 let d = Dep::simple("caixa-teia-", "^0.1");
7046 let err = d.validate().unwrap_err();
7047 assert!(
7048 matches!(
7049 err,
7050 DepError::NomeInvalid { ref nome, ref reason }
7051 if nome == "caixa-teia-" && reason.contains("alphanumeric")
7052 ),
7053 "got {err:?}"
7054 );
7055 }
7056
7057 #[test]
7058 fn validate_rejects_nome_with_slash() {
7059 // The canonical "I copied the GitHub repo path into `:nome`
7060 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
7061 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
7062 // the local-name slot. Same fixture pinned for `:membros
7063 // :caixa` (3f9d7a0).
7064 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
7065 let err = d.validate().unwrap_err();
7066 assert!(
7067 matches!(
7068 err,
7069 DepError::NomeInvalid { ref nome, ref reason }
7070 if nome == "pleme-io/caixa-teia" && reason.contains('/')
7071 ),
7072 "got {err:?}"
7073 );
7074 }
7075
7076 #[test]
7077 fn validate_rejects_nome_too_long() {
7078 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
7079 // Built from a valid character set so the length-bound
7080 // diagnostic surfaces before any per-character check (the
7081 // order pin parallel to the per-character predicates inside
7082 // [`crate::render::is_dns_1123_label`]).
7083 let long = "a".repeat(64);
7084 let d = Dep::simple(&long, "^0.1");
7085 let err = d.validate().unwrap_err();
7086 assert!(
7087 matches!(
7088 err,
7089 DepError::NomeInvalid { ref nome, ref reason }
7090 if nome.len() == 64 && reason.contains("max length of 63")
7091 ),
7092 "got {err:?}"
7093 );
7094 }
7095
7096 #[test]
7097 fn validate_accepts_canonical_nome_labels() {
7098 // Positive-control sweep — every form the K8s apiserver
7099 // accepts as a DNS-1123 label must round-trip through
7100 // validate. Covers a hyphen-bearing label, a numeric-suffix
7101 // label, a leading-digit label, a single-character label, and
7102 // a 63-byte (exactly the cap) label — the same fixture set
7103 // the peer `:membros :caixa` / `:children :caixa` positive
7104 // controls pin.
7105 for nome in [
7106 "caixa-teia",
7107 "caixa-resolver2",
7108 "2nd-tier-cache",
7109 "x",
7110 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
7111 ] {
7112 Dep::simple(nome, "^0.1")
7113 .validate()
7114 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
7115 }
7116 }
7117
7118 #[test]
7119 fn nome_empty_takes_precedence_over_nome_invalid() {
7120 // Ordering pin: `NomeEmpty` is the more self-locating
7121 // diagnostic on `""` and must lead — `is_dns_1123_label` is
7122 // only reached after the empty-check fires at the call site.
7123 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
7124 // (3f9d7a0) on the peer caixa-identifier axis.
7125 let mut d = Dep::simple("placeholder", "^0.1");
7126 d.nome = String::new();
7127 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
7128 }
7129
7130 #[test]
7131 fn nome_invalid_fires_before_versao_empty() {
7132 // Ordering pin: a malformed `:nome` fires before any `:versao`
7133 // axis check on the *same* entry — the per-entry shape gates
7134 // run top-to-bottom (nome empty → nome shape → versao empty →
7135 // versao parse → fonte shape), so a one-entry caixa.lisp with
7136 // both wrong sees the name-side diagnostic first (the name is
7137 // the self-locating axis — without a valid name, the parse
7138 // diagnostic can't quote `:nome "<bad>"`). Same ordering
7139 // discipline as `membro_caixa_invalid_fires_before_versao_check`
7140 // (3f9d7a0).
7141 let mut d = Dep::simple("Caixa-Teia", "^0.1");
7142 d.versao = String::new();
7143 let err = d.validate().unwrap_err();
7144 assert!(
7145 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
7146 "got {err:?}"
7147 );
7148 }
7149
7150 #[test]
7151 fn nome_invalid_fires_before_versao_invalid() {
7152 // Ordering pin: a malformed `:nome` fires before the `:versao`
7153 // parse-side check on the *same* entry. Pin separately from
7154 // the empty-versao ordering so a future re-ordering surfaces
7155 // here, parallel to the b0c8389 / c4213a4 trajectory.
7156 let d = Dep::simple("Caixa-Teia", "^^0.1");
7157 let err = d.validate().unwrap_err();
7158 assert!(
7159 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
7160 "got {err:?}"
7161 );
7162 }
7163
7164 #[test]
7165 fn nome_invalid_fires_before_fonte_invalid() {
7166 // Ordering pin: a malformed `:nome` fires before the `:fonte`
7167 // shape check on the *same* entry. The `:fonte` diagnostic
7168 // names the offending dep's `:nome` verbatim (via
7169 // `DepSource::validate(&self.nome)`), so a non-self-locating
7170 // name would taint the downstream diagnostic too — the gate
7171 // ordering keeps both diagnostics individually self-locating.
7172 let mut d = Dep::simple("Caixa-Teia", "^0.1");
7173 d.fonte = Some(DepSource::Git {
7174 repo: String::new(),
7175 tag: None,
7176 rev: None,
7177 branch: None,
7178 });
7179 let err = d.validate().unwrap_err();
7180 assert!(
7181 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
7182 "got {err:?}"
7183 );
7184 }
7185
7186 #[test]
7187 fn nome_invalid_diagnostic_carries_offending_name() {
7188 // The diagnostic-shape pin: the error names the offending
7189 // `:nome` value verbatim so the author can grep their
7190 // caixa.lisp without re-running the build, and carries a
7191 // non-empty `reason` from `is_dns_1123_label` so the
7192 // predicate's own wording flows through to the diagnostic.
7193 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
7194 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
7195 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
7196 // share a structurally-equivalent diagnostic family.
7197 let d = Dep::simple("Caixa_Teia", "^0.1");
7198 let err = d.validate().unwrap_err();
7199 let DepError::NomeInvalid { nome, reason } = err else {
7200 panic!("expected NomeInvalid, got other variant");
7201 };
7202 assert_eq!(nome, "Caixa_Teia");
7203 assert!(
7204 !reason.is_empty(),
7205 "NomeInvalid `reason` must carry the predicate's wording verbatim"
7206 );
7207 }
7208
7209 #[test]
7210 fn validate_rejects_invalid_versao_requirement() {
7211 // The fail-before-pass-after pin: a non-empty but malformed
7212 // requirement (`"^bad-version"`) silently passed every pre-gate
7213 // codebase because `:deps :versao` wasn't validated. The parse
7214 // failure surfaced far downstream at lacre-resolve time with a
7215 // `semver::Error` that didn't name which `:deps` entry carried
7216 // the typo. The new gate moves the check to caixa-build time
7217 // at the source caixa.lisp.
7218 let d = Dep::simple("caixa-teia", "^bad-version");
7219 let err = d.validate().unwrap_err();
7220 assert!(
7221 matches!(
7222 err,
7223 DepError::VersaoInvalid { ref nome, ref versao, .. }
7224 if nome == "caixa-teia" && versao == "^bad-version"
7225 ),
7226 "got {err:?}"
7227 );
7228 }
7229
7230 #[test]
7231 fn validate_rejects_versao_with_double_caret_typo() {
7232 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
7233 // Cargo-shaped requirement on first glance but fails the parser
7234 // because semver doesn't accept stacked operators. Pin this
7235 // adjacent-shape footgun explicitly so a future relaxation that
7236 // accepts "looks-canonical-but-isn't" forms surfaces here, in
7237 // parity with the `:membros` / `:children` fixtures.
7238 let d = Dep::simple("caixa-teia", "^^0.1");
7239 let err = d.validate().unwrap_err();
7240 assert!(
7241 matches!(
7242 err,
7243 DepError::VersaoInvalid { ref nome, ref versao, .. }
7244 if nome == "caixa-teia" && versao == "^^0.1"
7245 ),
7246 "got {err:?}"
7247 );
7248 }
7249
7250 #[test]
7251 fn validate_rejects_versao_with_v_prefixed_tag() {
7252 // `"v0.1"` is the canonical "git-tag-shape leaking into the
7253 // semver requirement slot" typo — an author copies the
7254 // publish-side git-tag string verbatim into `:versao`, but
7255 // Cargo's semver parser rejects the leading `v`. Same fixture
7256 // pinned for `:membros :versao` (9888b13) and `:children
7257 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
7258 // are *accepted* by the semver crate as an `*` wildcard on the
7259 // patch axis — they're a Cargo-side valid shape, not a typo.)
7260 let d = Dep::simple("caixa-teia", "v0.1");
7261 let err = d.validate().unwrap_err();
7262 assert!(
7263 matches!(
7264 err,
7265 DepError::VersaoInvalid { ref nome, ref versao, .. }
7266 if nome == "caixa-teia" && versao == "v0.1"
7267 ),
7268 "got {err:?}"
7269 );
7270 }
7271
7272 #[test]
7273 fn validate_accepts_canonical_versao_forms() {
7274 // The five Cargo-shaped requirement forms `:membros :versao`
7275 // and `:children :versao` already accept via
7276 // `crate::parse_requirement` must pass the deps gate without
7277 // re-validating at the resolver layer. Pin every leg so a
7278 // future tightening of the canonical set surfaces here as a
7279 // test failure.
7280 for form in [
7281 "^0.1", // caret — minor-range pin (the most common shape)
7282 "~0.1.2", // tilde — patch-range pin
7283 "0.1.0", // exact — single-version pin
7284 "*", // wildcard — explicitly any-version
7285 ">=0.1, <2", // multi-range — comma-separated comparators
7286 ] {
7287 Dep::simple("caixa-teia", form)
7288 .validate()
7289 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
7290 }
7291 }
7292
7293 #[test]
7294 fn versao_empty_takes_precedence_over_invalid() {
7295 // Order pin: the existing `VersaoEmpty` diagnostic (which
7296 // doesn't try to parse) fires before the new `VersaoInvalid`
7297 // parse-side diagnostic, so an empty `:versao` keeps its
7298 // narrower error message — `parse_requirement("")` would
7299 // otherwise return `Ok(STAR)` and silently pass, but the empty
7300 // arm catches it first.
7301 let mut d = Dep::simple("caixa-teia", "ignored");
7302 d.versao = String::new();
7303 let err = d.validate().unwrap_err();
7304 assert!(
7305 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
7306 "got {err:?}"
7307 );
7308 }
7309
7310 #[test]
7311 fn nome_empty_takes_precedence_over_versao_invalid() {
7312 // Order pin: even when `:versao` is malformed and would raise
7313 // its own diagnostic, `:nome ""` fires first because the
7314 // per-entry parse diagnostic needs a non-empty name to be
7315 // self-locating. Mirrors the
7316 // `membros_validation_runs_before_contratos_membership_check`
7317 // ordering on the typed-graph layer.
7318 let mut d = Dep::simple("placeholder", "^bad");
7319 d.nome = String::new();
7320 let err = d.validate().unwrap_err();
7321 assert_eq!(err, DepError::NomeEmpty);
7322 }
7323
7324 #[test]
7325 fn versao_invalid_diagnostic_carries_offending_versao() {
7326 // The diagnostic-shape pin: the error names the offending
7327 // `:versao` value verbatim so the author can grep their
7328 // caixa.lisp without re-running the build, and carries a
7329 // non-empty `reason` from `semver::VersionReq::parse` so the
7330 // parser's own wording flows through to the diagnostic.
7331 let d = Dep::simple("caixa-teia", "not-a-req");
7332 let err = d.validate().unwrap_err();
7333 let DepError::VersaoInvalid {
7334 nome,
7335 versao,
7336 reason,
7337 } = err
7338 else {
7339 panic!("expected VersaoInvalid, got other variant");
7340 };
7341 assert_eq!(nome, "caixa-teia");
7342 assert_eq!(versao, "not-a-req");
7343 assert!(
7344 !reason.is_empty(),
7345 "VersaoInvalid `reason` must carry the parser's wording verbatim"
7346 );
7347 }
7348
7349 // -- :fonte value-shape gate ------------------------------------------
7350
7351 fn dep_with_fonte(fonte: DepSource) -> Dep {
7352 let mut d = Dep::simple("caixa-teia", "^0.1");
7353 d.fonte = Some(fonte);
7354 d
7355 }
7356
7357 #[test]
7358 fn validate_accepts_git_fonte_with_tag() {
7359 // The positive-control pin on the canonical git source — exactly
7360 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
7361 // shape every existing caixa-resolver integration test uses.
7362 let d = dep_with_fonte(DepSource::Git {
7363 repo: "github:pleme-io/caixa-teia".into(),
7364 tag: Some("v0.1.0".into()),
7365 rev: None,
7366 branch: None,
7367 });
7368 d.validate().unwrap();
7369 }
7370
7371 #[test]
7372 fn validate_accepts_git_fonte_with_rev() {
7373 // Each of the three pin axes is independently a valid single-pin
7374 // shape; pin the :rev arm so a future relaxation that only
7375 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
7376 // OID — the canonical `git rev-parse HEAD` emission shape the
7377 // `crate::render::is_git_oid` value-shape gate now requires;
7378 // abbreviated OIDs are ambiguous across repo history and
7379 // rejected at this gate (pinned separately by
7380 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
7381 let d = dep_with_fonte(DepSource::Git {
7382 repo: "github:pleme-io/caixa-teia".into(),
7383 tag: None,
7384 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
7385 branch: None,
7386 });
7387 d.validate().unwrap();
7388 }
7389
7390 #[test]
7391 fn validate_accepts_git_fonte_with_branch() {
7392 // The :branch arm is the third valid single-pin shape — pinned
7393 // separately so the gate-accepts-all-three-pin-axes contract is
7394 // a build-error to relax.
7395 let d = dep_with_fonte(DepSource::Git {
7396 repo: "github:pleme-io/caixa-teia".into(),
7397 tag: None,
7398 rev: None,
7399 branch: Some("main".into()),
7400 });
7401 d.validate().unwrap();
7402 }
7403
7404 #[test]
7405 fn validate_accepts_path_fonte() {
7406 // The positive-control pin on the path source — non-empty
7407 // :caminho, no pin axes (paths have no commit identity). Pinned
7408 // so a future "paths must also pin a rev" tightening surfaces
7409 // here as a structural decision, not a silent break.
7410 let d = dep_with_fonte(DepSource::Path {
7411 caminho: "../caixa-teia".into(),
7412 });
7413 d.validate().unwrap();
7414 }
7415
7416 #[test]
7417 fn validate_rejects_git_fonte_with_empty_repo() {
7418 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
7419 // "v1")`: the empty-repo shape silently passed every pre-gate
7420 // codebase because `:fonte` wasn't validated. The git-clone
7421 // failure surfaced far downstream at lacre-resolve time with no
7422 // field naming which `:deps` entry carried the typo. The new
7423 // gate moves the check to caixa-build time at the source
7424 // caixa.lisp.
7425 let d = dep_with_fonte(DepSource::Git {
7426 repo: String::new(),
7427 tag: Some("v0.1.0".into()),
7428 rev: None,
7429 branch: None,
7430 });
7431 let err = d.validate().unwrap_err();
7432 assert!(
7433 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
7434 "got {err:?}"
7435 );
7436 }
7437
7438 // -- :repo value-shape gate -------------------------------------------
7439 //
7440 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
7441 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
7442 // codebase admitted any non-empty string; the new
7443 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
7444 // URL intersection-floor at validate time, peer with the three pin
7445 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
7446 // `is_git_oid`). Every test in this section is a fail-before /
7447 // pass-after pin on a specific authoring footgun.
7448
7449 #[test]
7450 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
7451 // The canonical paste-from-doc footgun on `:repo` — an author
7452 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
7453 // a doc paragraph. Until this gate landed the empty-repo arm
7454 // passed (the string isn't empty), the resolver issued
7455 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
7456 // surfaced at clone time with a quoting-confused error far from
7457 // the source caixa.lisp. Same paste-from-doc footgun the
7458 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
7459 // axis — now closed on the `:repo` URL axis too.
7460 let d = dep_with_fonte(DepSource::Git {
7461 repo: "github:pleme-io/caixa-teia ".into(),
7462 tag: Some("v0.1.0".into()),
7463 rev: None,
7464 branch: None,
7465 });
7466 let err = d.validate().unwrap_err();
7467 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7468 panic!("expected FonteRepoShape, got other variant");
7469 };
7470 assert_eq!(nome, "caixa-teia");
7471 assert_eq!(repo, "github:pleme-io/caixa-teia ");
7472 assert!(
7473 reason.contains("whitespace"),
7474 "reason must surface the whitespace arm, got {reason:?}"
7475 );
7476 }
7477
7478 #[test]
7479 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
7480 // The canonical CLI-argument-injection footgun at the `git clone`
7481 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
7482 // argv parser read the value as a CLI flag, escaping the
7483 // subprocess argument boundary. The `--` separator workaround
7484 // does not fix the typed slot's accepted set; the gate rejects
7485 // the shape upstream at validate time so the resolver never
7486 // invokes a `git clone -…` subprocess.
7487 let d = dep_with_fonte(DepSource::Git {
7488 repo: "-upload-pack=evil".into(),
7489 tag: Some("v0.1.0".into()),
7490 rev: None,
7491 branch: None,
7492 });
7493 let err = d.validate().unwrap_err();
7494 let DepError::FonteRepoShape { repo, reason, .. } = err else {
7495 panic!("expected FonteRepoShape, got other variant");
7496 };
7497 assert_eq!(repo, "-upload-pack=evil");
7498 assert!(
7499 reason.contains("must not start with `-`"),
7500 "reason must surface the leading-`-` arm, got {reason:?}"
7501 );
7502 }
7503
7504 #[test]
7505 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
7506 // The canonical paste-from-multiline-doc footgun — a `:repo`
7507 // string with an embedded `\n` silently breaks git's URL parser
7508 // and is a class of CRLF-injection at the subprocess-argument
7509 // boundary. Caught by the control-char arm (0x0A < 0x20).
7510 let d = dep_with_fonte(DepSource::Git {
7511 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
7512 tag: Some("v0.1.0".into()),
7513 rev: None,
7514 branch: None,
7515 });
7516 let err = d.validate().unwrap_err();
7517 let DepError::FonteRepoShape { reason, .. } = err else {
7518 panic!("expected FonteRepoShape, got other variant");
7519 };
7520 assert!(
7521 reason.contains("control character"),
7522 "reason must surface the control-char arm, got {reason:?}"
7523 );
7524 }
7525
7526 #[test]
7527 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
7528 // Tab is the sibling whitespace footgun (the canonical
7529 // copy-from-aligned-table paste); pinned separately from the
7530 // space arm so a future relaxation that only catches one
7531 // surfaces here.
7532 let d = dep_with_fonte(DepSource::Git {
7533 repo: "github:pleme-io/caixa-teia\t".into(),
7534 tag: Some("v0.1.0".into()),
7535 rev: None,
7536 branch: None,
7537 });
7538 let err = d.validate().unwrap_err();
7539 assert!(
7540 matches!(
7541 err,
7542 DepError::FonteRepoShape { ref reason, .. }
7543 if reason.contains("whitespace")
7544 ),
7545 "got {err:?}"
7546 );
7547 }
7548
7549 #[test]
7550 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
7551 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
7552 // non-ASCII silently breaks at git's URL parser and round-trips
7553 // inconsistently across NFC/NFD normalization on APFS /
7554 // case-folding filesystems. Same intersection-floor
7555 // [`is_git_ref_name`] enforces on the refname axes.
7556 let d = dep_with_fonte(DepSource::Git {
7557 repo: "https://github.com/pleme-io/café".into(),
7558 tag: Some("v0.1.0".into()),
7559 rev: None,
7560 branch: None,
7561 });
7562 let err = d.validate().unwrap_err();
7563 assert!(
7564 matches!(
7565 err,
7566 DepError::FonteRepoShape { ref reason, .. }
7567 if reason.contains("non-ASCII")
7568 ),
7569 "got {err:?}"
7570 );
7571 }
7572
7573 #[test]
7574 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
7575 // The fail-before-pass-after pin for the canonical paste-from-
7576 // browser-address-bar footgun on `:repo`: an author copies a
7577 // GitHub permalink to a README anchor / line-permalink and
7578 // forgets to trim the `#fragment` tail. Until this arm landed
7579 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
7580 // silently passed every prior arm (no whitespace, no control
7581 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
7582 // or `:`), libcurl's URL parser stripped the `#readme` tail
7583 // before opening the HTTPS transport, and the lacre embedded
7584 // the value verbatim in its per-dep BLAKE3 closure — two
7585 // authors whose values differ only in their fragment anchor
7586 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
7587 // `git clone` but lock to two distinct lacres, defeating the
7588 // THEORY.md §V.2 render-determinism contract. Same value-shape
7589 // axis-floor every peer typed surface enforces; peer `:fonte
7590 // :tag` / `:fonte :branch` already reject the byte-class through
7591 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
7592 // URL grammar admitted) and `:entrada :paths` rejects `#` as
7593 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
7594 let d = dep_with_fonte(DepSource::Git {
7595 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
7596 tag: Some("v0.1.0".into()),
7597 rev: None,
7598 branch: None,
7599 });
7600 let err = d.validate().unwrap_err();
7601 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7602 panic!("expected FonteRepoShape, got other variant");
7603 };
7604 assert_eq!(nome, "caixa-teia");
7605 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
7606 assert!(
7607 reason.contains("must not contain `#`"),
7608 "reason must surface the fragment-`#` arm, got {reason:?}"
7609 );
7610 assert!(
7611 reason.contains("fragment"),
7612 "reason must name the URL fragment grammar, got {reason:?}"
7613 );
7614 }
7615
7616 #[test]
7617 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
7618 // The symmetric paste-from-Nix-flake-ref footgun — an author
7619 // confuses the Nix flake-reference idiom (`github:foo/
7620 // bar#packageName`, where `#packageName` selects a flake
7621 // output) with the bare git `:repo` shape. The pleme-io
7622 // substrate authors compose flakes downstream of caixa
7623 // (caixa-flake renders a flake.nix), so the cross-idiom leak
7624 // is the canonical near-miss: the author writes the
7625 // flake-ref shape into a git `:repo` slot. Pinned separately
7626 // from the HTTPS-anchor arm so a future relaxation that
7627 // narrows to one URL scheme surfaces here.
7628 let d = dep_with_fonte(DepSource::Git {
7629 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
7630 tag: Some("v0.1.0".into()),
7631 rev: None,
7632 branch: None,
7633 });
7634 let err = d.validate().unwrap_err();
7635 let DepError::FonteRepoShape { reason, .. } = err else {
7636 panic!("expected FonteRepoShape, got other variant");
7637 };
7638 assert!(
7639 reason.contains("must not contain `#`"),
7640 "reason must surface the fragment-`#` arm, got {reason:?}"
7641 );
7642 assert!(
7643 reason.contains("Nix flake"),
7644 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
7645 );
7646 }
7647
7648 #[test]
7649 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
7650 // The fail-before-pass-after pin for the canonical paste-from-
7651 // browser-address-bar footgun on `:repo` (peer with the
7652 // a68f818 fragment-`#` arm on the same axis). An author
7653 // copies a GitHub tab deep-link out of the address bar and
7654 // forgets to trim the `?tab=…` query tail. Until this arm
7655 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
7656 // silently passed every prior arm (no whitespace, no control
7657 // chars, no non-ASCII, no `#` fragment, contains a `:`,
7658 // doesn't start with `-` or `:`); GitHub silently ignored
7659 // the `?query` tail and served the same repo regardless;
7660 // the lacre embedded the value verbatim in its per-dep
7661 // BLAKE3 closure — two authors whose values differ only in
7662 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
7663 // `?utm_source=twitter`) resolve to the byte-identical
7664 // upstream `git clone` but lock to two distinct lacres,
7665 // defeating the THEORY.md §V.2 render-determinism contract
7666 // on the same axis the `#` fragment arm closes. Same value-
7667 // shape axis-floor every peer typed surface enforces; peer
7668 // `:fonte :tag` / `:fonte :branch` already reject the byte-
7669 // class through `is_git_ref_name`'s alphabet (refspec glob
7670 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
7671 // :paths` rejects `?` as the query separator in
7672 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
7673 let d = dep_with_fonte(DepSource::Git {
7674 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
7675 tag: Some("v0.1.0".into()),
7676 rev: None,
7677 branch: None,
7678 });
7679 let err = d.validate().unwrap_err();
7680 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7681 panic!("expected FonteRepoShape, got other variant");
7682 };
7683 assert_eq!(nome, "caixa-teia");
7684 assert_eq!(
7685 repo,
7686 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
7687 );
7688 assert!(
7689 reason.contains("must not contain `?`"),
7690 "reason must surface the query-`?` arm, got {reason:?}"
7691 );
7692 assert!(
7693 reason.contains("query"),
7694 "reason must name the URL query grammar, got {reason:?}"
7695 );
7696 }
7697
7698 #[test]
7699 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
7700 // The symmetric paste-from-social-share footgun — an author
7701 // copies a repo URL out of a Slack unfurl / Twitter share /
7702 // newsletter link / Discord embed and forgets to trim the
7703 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
7704 // campaign-tracker tail. Every major social-share / unfurl /
7705 // newsletter platform appends these UTM parameters; the
7706 // canonical near-miss on the `:repo` axis. Pinned separately
7707 // from the GitHub-tab-deep-link arm so a future relaxation
7708 // that narrows to one query-parameter class surfaces here.
7709 let d = dep_with_fonte(DepSource::Git {
7710 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
7711 .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 query-`?` arm, got {reason:?}"
7723 );
7724 assert!(
7725 reason.contains("campaign-tracker"),
7726 "reason must name the campaign-tracker paste footgun, got {reason:?}"
7727 );
7728 }
7729
7730 #[test]
7731 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
7732 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
7733 // 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
7735 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
7736 // (fragment before query — unusual URL-grammar but value-
7737 // disjoint at byte level) carries both `#` and `?`; the `#`
7738 // byte appears first, so the fragment-`#` arm fires, surfacing
7739 // the more self-locating diagnostic on the byte the author
7740 // pasted earliest in the URL. Mirrors the peer cascade
7741 // discipline `fonte_repo_control_char_fires_before_fragment`
7742 // pins on the prior `:repo` byte-class arm.
7743 let d = dep_with_fonte(DepSource::Git {
7744 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
7745 tag: Some("v0.1.0".into()),
7746 rev: None,
7747 branch: None,
7748 });
7749 let err = d.validate().unwrap_err();
7750 let DepError::FonteRepoShape { reason, .. } = err else {
7751 panic!("expected FonteRepoShape, got other variant");
7752 };
7753 assert!(
7754 reason.contains("must not contain `#`"),
7755 "reason must surface the fragment-`#` arm (fires before query-`?` when \
7756 `#` byte appears first in value), got {reason:?}"
7757 );
7758 }
7759
7760 #[test]
7761 fn fonte_repo_control_char_fires_before_fragment() {
7762 // Cascade pin: the control-char arm structurally precedes the
7763 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
7764 // positive on both arms (contains LF and `#`), but the narrower
7765 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
7766 // (`control character`) wins so the author sees the more
7767 // self-locating arm first. Mirrors the peer cascade discipline
7768 // every prior `:repo` byte-class arm establishes.
7769 let d = dep_with_fonte(DepSource::Git {
7770 repo: "github:pleme-io/caixa-teia\n#readme".into(),
7771 tag: Some("v0.1.0".into()),
7772 rev: None,
7773 branch: None,
7774 });
7775 let err = d.validate().unwrap_err();
7776 let DepError::FonteRepoShape { reason, .. } = err else {
7777 panic!("expected FonteRepoShape, got other variant");
7778 };
7779 assert!(
7780 reason.contains("control character"),
7781 "reason must surface the control-char arm, got {reason:?}"
7782 );
7783 }
7784
7785 #[test]
7786 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7787 // The fail-before-pass-after pin for the canonical Windows-
7788 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7789 // backslash arm on the sibling `:caminho` path-fonte axis).
7790 // An author pastes a Windows Explorer address-bar / PowerShell
7791 // `Get-Location` output into a `file://` URL slot, producing
7792 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7793 // value silently passed every prior arm (no whitespace, no
7794 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7795 // with `-` or `:`); libcurl's URL parser silently translates
7796 // `\` → `/` on some platforms and refuses it on others, so
7797 // the byte rides verbatim into the lacre's per-dep content-
7798 // address but is silently rewritten / rejected at the wire —
7799 // two authors whose `:repo` values differ only in backslash-
7800 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7801 // resolve to the byte-identical local clone but lock to two
7802 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7803 // render-determinism contract on the same axis the `#`
7804 // fragment and `?` query arms close. Same value-shape axis-
7805 // floor every peer typed surface enforces; the `:caminho`
7806 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7807 let d = dep_with_fonte(DepSource::Git {
7808 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7809 tag: Some("v0.1.0".into()),
7810 rev: None,
7811 branch: None,
7812 });
7813 let err = d.validate().unwrap_err();
7814 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7815 panic!("expected FonteRepoShape, got other variant");
7816 };
7817 assert_eq!(nome, "caixa-teia");
7818 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7819 assert!(
7820 reason.contains("must not contain `\\`"),
7821 "reason must surface the backslash-`\\` arm, got {reason:?}"
7822 );
7823 assert!(
7824 reason.contains("Windows"),
7825 "reason must name the Windows-path-confusion footgun, got {reason:?}"
7826 );
7827 }
7828
7829 #[test]
7830 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7831 // The symmetric Win32-shell-mangled-slashes footgun — an author
7832 // copies `https://github.com/foo/bar` into a Win32 shell that
7833 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7834 // separator-coercion bug), pastes the result into a `:repo`
7835 // slot, and produces `https:\\github.com\foo\bar`. Pinned
7836 // separately from the `file://` Explorer-paste arm so a future
7837 // relaxation that narrows to one URL scheme surfaces here.
7838 let d = dep_with_fonte(DepSource::Git {
7839 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7840 tag: Some("v0.1.0".into()),
7841 rev: None,
7842 branch: None,
7843 });
7844 let err = d.validate().unwrap_err();
7845 let DepError::FonteRepoShape { reason, .. } = err else {
7846 panic!("expected FonteRepoShape, got other variant");
7847 };
7848 assert!(
7849 reason.contains("must not contain `\\`"),
7850 "reason must surface the backslash-`\\` arm, got {reason:?}"
7851 );
7852 assert!(
7853 reason.contains("path separator") || reason.contains("path-segment separator"),
7854 "reason must name the URL path-segment separator grammar, got {reason:?}"
7855 );
7856 }
7857
7858 #[test]
7859 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7860 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7861 // are both per-byte arms inside the same `for &b in s.as_bytes()`
7862 // loop, so the byte that appears first in the value's byte order
7863 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7864 // both `#` and `\`; the `#` byte appears first, so the fragment-
7865 // `#` arm fires, surfacing the more self-locating diagnostic on
7866 // the byte the author pasted earliest in the URL. Mirrors the
7867 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7868 // pins on the prior `:repo` byte-class arm.
7869 let d = dep_with_fonte(DepSource::Git {
7870 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7871 tag: Some("v0.1.0".into()),
7872 rev: None,
7873 branch: None,
7874 });
7875 let err = d.validate().unwrap_err();
7876 let DepError::FonteRepoShape { reason, .. } = err else {
7877 panic!("expected FonteRepoShape, got other variant");
7878 };
7879 assert!(
7880 reason.contains("must not contain `#`"),
7881 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7882 `#` byte appears first in value), got {reason:?}"
7883 );
7884 }
7885
7886 #[test]
7887 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7888 // The fail-before-pass-after pin for the canonical URI Template
7889 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7890 // README quick-start snippet / OpenAPI `servers:` URL / Helm
7891 // chart `home:` template that carries unresolved
7892 // `{org}` / `{repo}` placeholders and pastes the raw template
7893 // into the `:repo` slot, expecting the substrate to resolve the
7894 // placeholder downstream. Until this arm landed the value
7895 // silently passed every prior arm (no whitespace, no control
7896 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7897 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7898 // / `%7D` on the wire, so the byte rides verbatim into the
7899 // lacre's per-dep content-address but round-trips inconsistently
7900 // between the lacre's per-dep content-address and the
7901 // resolver's `git clone <repo>` invocation, defeating the
7902 // THEORY.md §V.2 render-determinism contract on the same axis
7903 // the `#` fragment, `?` query, and `\` backslash arms close;
7904 // every git porcelain entry-point additionally fetches a
7905 // nonexistent literal-`{placeholder}`-named path far from the
7906 // source caixa.lisp.
7907 let d = dep_with_fonte(DepSource::Git {
7908 repo: "https://github.com/{org}/caixa-teia".into(),
7909 tag: Some("v0.1.0".into()),
7910 rev: None,
7911 branch: None,
7912 });
7913 let err = d.validate().unwrap_err();
7914 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7915 panic!("expected FonteRepoShape, got other variant");
7916 };
7917 assert_eq!(nome, "caixa-teia");
7918 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7919 assert!(
7920 reason.contains("must not contain `{`"),
7921 "reason must surface the open-brace `{{` arm, got {reason:?}"
7922 );
7923 assert!(
7924 reason.contains("URI Template") || reason.contains("RFC 6570"),
7925 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7926 );
7927 }
7928
7929 #[test]
7930 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7931 // The symmetric Mustache / Handlebars doubled-brace
7932 // substitution-form footgun every CI / IaC templating engine
7933 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7934 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7935 // chart README quick-start snippet emits. Pinned separately
7936 // from the single-`{` `{org}` arm so a future relaxation that
7937 // narrows to one substitution-form surfaces here.
7938 let d = dep_with_fonte(DepSource::Git {
7939 repo: "https://github.com/{{org}}/caixa-teia".into(),
7940 tag: Some("v0.1.0".into()),
7941 rev: None,
7942 branch: None,
7943 });
7944 let err = d.validate().unwrap_err();
7945 let DepError::FonteRepoShape { reason, .. } = err else {
7946 panic!("expected FonteRepoShape, got other variant");
7947 };
7948 assert!(
7949 reason.contains("must not contain `{`"),
7950 "reason must surface the open-brace `{{` arm, got {reason:?}"
7951 );
7952 }
7953
7954 #[test]
7955 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7956 // Asymmetric `}`-only shape — covers the closing-brace-by-
7957 // itself footgun (an author truncated `{org}/{repo}` mid-edit
7958 // and left a trailing `}` from the prior template fragment,
7959 // or pasted a value that included a closing brace from a
7960 // surrounding shell context). Pinned to ensure the predicate
7961 // refuses each brace independently rather than only when both
7962 // appear — a future regression that ANDs the two byte tests
7963 // surfaces here.
7964 let d = dep_with_fonte(DepSource::Git {
7965 repo: "https://github.com/pleme-io/caixa-teia}".into(),
7966 tag: Some("v0.1.0".into()),
7967 rev: None,
7968 branch: None,
7969 });
7970 let err = d.validate().unwrap_err();
7971 let DepError::FonteRepoShape { reason, .. } = err else {
7972 panic!("expected FonteRepoShape, got other variant");
7973 };
7974 assert!(
7975 reason.contains("must not contain `}`"),
7976 "reason must surface the close-brace `}}` arm, got {reason:?}"
7977 );
7978 }
7979
7980 #[test]
7981 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7982 // Cascade pin: the fragment-`#` arm and the template-`{` /
7983 // `}` arm are both per-byte arms inside the same
7984 // `for &b in s.as_bytes()` loop, so the byte that appears
7985 // first in the value's byte order wins. A `:repo
7986 // "https://github.com/p/x#readme{org}"` carries both `#` and
7987 // `{`; the `#` byte appears first, so the fragment-`#` arm
7988 // fires, surfacing the more self-locating diagnostic on the
7989 // byte the author pasted earliest in the URL. Mirrors the
7990 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7991 // pins on the prior `:repo` byte-class arm.
7992 let d = dep_with_fonte(DepSource::Git {
7993 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7994 tag: Some("v0.1.0".into()),
7995 rev: None,
7996 branch: None,
7997 });
7998 let err = d.validate().unwrap_err();
7999 let DepError::FonteRepoShape { reason, .. } = err else {
8000 panic!("expected FonteRepoShape, got other variant");
8001 };
8002 assert!(
8003 reason.contains("must not contain `#`"),
8004 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
8005 `#` byte appears first in value), got {reason:?}"
8006 );
8007 }
8008
8009 #[test]
8010 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
8011 // The fail-before-pass-after pin for the canonical
8012 // shell-output-redirection footgun on `:repo`: an author
8013 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
8014 // / `… >output.txt`) into the `:repo` slot without trimming
8015 // the redirect. Until this arm landed the value silently
8016 // passed every prior arm (no whitespace, no control chars,
8017 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
8018 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
8019 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
8020 // percent-encode set maps `>` → `%3E` on the wire, so the
8021 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
8022 // but is silently rewritten or rejected at libcurl's URL-
8023 // parser layer — two authors whose values differ only in
8024 // their redirect tail (`>build.log` vs nothing) resolve to
8025 // the byte-identical upstream `git clone` but lock to two
8026 // distinct lacres, defeating the THEORY.md §V.2 render-
8027 // determinism contract. Peer with the `:caminho` axis's
8028 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
8029 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8030 // byte RFC-3986-reserved set on `:entrada :paths`.
8031 let d = dep_with_fonte(DepSource::Git {
8032 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
8033 tag: Some("v0.1.0".into()),
8034 rev: None,
8035 branch: None,
8036 });
8037 let err = d.validate().unwrap_err();
8038 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8039 panic!("expected FonteRepoShape, got other variant");
8040 };
8041 assert_eq!(nome, "caixa-teia");
8042 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
8043 assert!(
8044 reason.contains("must not contain `>`"),
8045 "reason must surface the output-redirection `>` arm, got {reason:?}"
8046 );
8047 assert!(
8048 reason.contains("redirection") || reason.contains("'delims'"),
8049 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
8050 );
8051 }
8052
8053 #[test]
8054 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
8055 // The symmetric shell-input-redirection footgun — an author
8056 // pastes a shell-pipeline head (`git clone <input.url` /
8057 // `cat <README.md`) into the `:repo` slot. Pinned separately
8058 // from the `>`-output arm so a future relaxation that only
8059 // catches one of the two redirect bytes surfaces here. Peer
8060 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
8061 // arm which closes both `<` and `>` under the same banner.
8062 let d = dep_with_fonte(DepSource::Git {
8063 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
8064 tag: Some("v0.1.0".into()),
8065 rev: None,
8066 branch: None,
8067 });
8068 let err = d.validate().unwrap_err();
8069 let DepError::FonteRepoShape { reason, .. } = err else {
8070 panic!("expected FonteRepoShape, got other variant");
8071 };
8072 assert!(
8073 reason.contains("must not contain `<`"),
8074 "reason must surface the input-redirection `<` arm, got {reason:?}"
8075 );
8076 assert!(
8077 reason.contains("RFC 3986") || reason.contains("'unwise'"),
8078 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
8079 );
8080 }
8081
8082 #[test]
8083 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
8084 // The fail-before-pass-after pin for the canonical
8085 // paste-from-shell-prompt-with-backticked-substitution footgun
8086 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
8087 // `:caminho` path-fonte axis). An author pastes a URL whose
8088 // segment carries a backticked command-substitution wrapper
8089 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
8090 // from a doc / README quick-start snippet that expected the
8091 // substrate to substitute the value downstream. Until this arm
8092 // landed the value silently passed every prior arm (no
8093 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8094 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
8095 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
8096 // 'unwise' set and the WHATWG URL spec's fragment percent-
8097 // encode set maps `` ` `` → `%60` on the wire, so the byte
8098 // rides verbatim into the lacre's per-dep BLAKE3 closure but
8099 // is silently rewritten or rejected at libcurl's URL-parser
8100 // layer — two authors whose values differ only in their
8101 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
8102 // byte-identical upstream `git clone` but lock to two distinct
8103 // lacres, defeating the THEORY.md §V.2 render-determinism
8104 // contract. Peer with the `:caminho` axis's
8105 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
8106 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
8107 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
8108 let d = dep_with_fonte(DepSource::Git {
8109 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
8110 tag: Some("v0.1.0".into()),
8111 rev: None,
8112 branch: None,
8113 });
8114 let err = d.validate().unwrap_err();
8115 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8116 panic!("expected FonteRepoShape, got other variant");
8117 };
8118 assert_eq!(nome, "caixa-teia");
8119 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
8120 assert!(
8121 reason.contains("must not contain `` ` ``"),
8122 "reason must surface the backtick command-substitution arm, got {reason:?}"
8123 );
8124 assert!(
8125 reason.contains("command-substitution") || reason.contains("'unwise'"),
8126 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
8127 got {reason:?}"
8128 );
8129 }
8130
8131 #[test]
8132 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
8133 // Cascade pin: the fragment-`#` arm and the backtick command-
8134 // substitution arm are both per-byte arms inside the same
8135 // `for &b in s.as_bytes()` loop, so the byte that appears first
8136 // in the value's byte order wins. A `:repo
8137 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
8138 // and backtick; the `#` byte appears first, so the fragment-
8139 // `#` arm fires, surfacing the more self-locating diagnostic
8140 // on the byte the author pasted earliest in the URL. Mirrors
8141 // the peer cascade discipline
8142 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
8143 // pins on the prior `:repo` byte-class arm.
8144 let d = dep_with_fonte(DepSource::Git {
8145 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
8146 tag: Some("v0.1.0".into()),
8147 rev: None,
8148 branch: None,
8149 });
8150 let err = d.validate().unwrap_err();
8151 let DepError::FonteRepoShape { reason, .. } = err else {
8152 panic!("expected FonteRepoShape, got other variant");
8153 };
8154 assert!(
8155 reason.contains("must not contain `#`"),
8156 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
8157 appears first in value), got {reason:?}"
8158 );
8159 }
8160
8161 #[test]
8162 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
8163 // Cascade pin: the shell-redirection `<` / `>` arm and the
8164 // backtick command-substitution arm are both per-byte arms
8165 // inside the same `for &b in s.as_bytes()` loop, so the byte
8166 // that appears first in the value's byte order wins. A `:repo
8167 // "https://github.com/p/x>build.log/`whoami`"` carries both
8168 // `>` and backtick; the `>` byte appears first, so the
8169 // shell-redirection arm fires, surfacing the more self-
8170 // locating diagnostic on the byte the author pasted earliest
8171 // in the URL. Pins the natural-order cascade so a future
8172 // reorder of the per-byte arms surfaces here.
8173 let d = dep_with_fonte(DepSource::Git {
8174 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
8175 tag: Some("v0.1.0".into()),
8176 rev: None,
8177 branch: None,
8178 });
8179 let err = d.validate().unwrap_err();
8180 let DepError::FonteRepoShape { reason, .. } = err else {
8181 panic!("expected FonteRepoShape, got other variant");
8182 };
8183 assert!(
8184 reason.contains("must not contain `>`"),
8185 "reason must surface the shell-redirection `>` arm (fires before backtick when \
8186 `>` byte appears first in value), got {reason:?}"
8187 );
8188 }
8189
8190 #[test]
8191 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
8192 // Cascade pin: the fragment-`#` arm and the shell-redirection
8193 // `<` / `>` arm are both per-byte arms inside the same
8194 // `for &b in s.as_bytes()` loop, so the byte that appears
8195 // first in the value's byte order wins. A `:repo
8196 // "https://github.com/p/x#readme>build.log"` carries both
8197 // `#` and `>`; the `#` byte appears first, so the fragment-
8198 // `#` arm fires, surfacing the more self-locating diagnostic
8199 // on the byte the author pasted earliest in the URL. Mirrors
8200 // the peer cascade discipline
8201 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
8202 // pins on the prior `:repo` byte-class arm.
8203 let d = dep_with_fonte(DepSource::Git {
8204 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
8205 tag: Some("v0.1.0".into()),
8206 rev: None,
8207 branch: None,
8208 });
8209 let err = d.validate().unwrap_err();
8210 let DepError::FonteRepoShape { reason, .. } = err else {
8211 panic!("expected FonteRepoShape, got other variant");
8212 };
8213 assert!(
8214 reason.contains("must not contain `#`"),
8215 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
8216 `#` byte appears first in value), got {reason:?}"
8217 );
8218 }
8219
8220 #[test]
8221 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
8222 // The fail-before-pass-after pin for the canonical
8223 // paste-from-shell-prompt-with-piped-pipeline footgun on
8224 // `:repo` (peer with the 124106f pipe arm on the sibling
8225 // `:caminho` path-fonte axis). An author pastes a shell
8226 // pipeline (`git clone <url> | tee build.log`,
8227 // `git ls-remote <url> | head`) into the `:repo` slot,
8228 // forgetting to trim the `| <consumer>` tail. Until this arm
8229 // landed the value silently passed every prior arm (no
8230 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8231 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
8232 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
8233 // 'unwise' set and the WHATWG URL spec's fragment percent-
8234 // encode set maps `|` → `%7C` on the wire, so the byte rides
8235 // verbatim into the lacre's per-dep BLAKE3 closure but is
8236 // silently rewritten or rejected at libcurl's URL-parser
8237 // layer — two authors whose values differ only in their pipe
8238 // tail (`|tee build.log` vs nothing) resolve to the byte-
8239 // identical upstream `git clone` but lock to two distinct
8240 // lacres, defeating the THEORY.md §V.2 render-determinism
8241 // contract. Peer with the `:caminho` axis's
8242 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
8243 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
8244 // RFC-3986-reserved set on `:entrada :paths`.
8245 let d = dep_with_fonte(DepSource::Git {
8246 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
8247 tag: Some("v0.1.0".into()),
8248 rev: None,
8249 branch: None,
8250 });
8251 let err = d.validate().unwrap_err();
8252 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8253 panic!("expected FonteRepoShape, got other variant");
8254 };
8255 assert_eq!(nome, "caixa-teia");
8256 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
8257 assert!(
8258 reason.contains("must not contain `|`"),
8259 "reason must surface the shell-pipe arm, got {reason:?}"
8260 );
8261 assert!(
8262 reason.contains("pipe") || reason.contains("'unwise'"),
8263 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
8264 );
8265 }
8266
8267 #[test]
8268 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
8269 // Cascade pin: the fragment-`#` arm and the pipe arm are both
8270 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8271 // so the byte that appears first in the value's byte order
8272 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
8273 // both `#` and `|`; the `#` byte appears first, so the
8274 // fragment-`#` arm fires, surfacing the more self-locating
8275 // diagnostic on the byte the author pasted earliest in the
8276 // URL. Mirrors the peer cascade discipline
8277 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
8278 // pins on the prior `:repo` byte-class arm.
8279 let d = dep_with_fonte(DepSource::Git {
8280 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
8281 tag: Some("v0.1.0".into()),
8282 rev: None,
8283 branch: None,
8284 });
8285 let err = d.validate().unwrap_err();
8286 let DepError::FonteRepoShape { reason, .. } = err else {
8287 panic!("expected FonteRepoShape, got other variant");
8288 };
8289 assert!(
8290 reason.contains("must not contain `#`"),
8291 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
8292 appears first in value), got {reason:?}"
8293 );
8294 }
8295
8296 #[test]
8297 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
8298 // Cascade pin: the backtick arm and the pipe arm are both per-
8299 // byte arms inside the same `for &b in s.as_bytes()` loop, so
8300 // the byte that appears first in the value's byte order wins.
8301 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
8302 // `` ` `` and `|`; the backtick byte appears first, so the
8303 // backtick arm fires, surfacing the more self-locating
8304 // diagnostic on the byte the author pasted earliest in the
8305 // URL. Pins the natural-order cascade so a future reorder of
8306 // the per-byte arms surfaces here.
8307 let d = dep_with_fonte(DepSource::Git {
8308 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
8309 tag: Some("v0.1.0".into()),
8310 rev: None,
8311 branch: None,
8312 });
8313 let err = d.validate().unwrap_err();
8314 let DepError::FonteRepoShape { reason, .. } = err else {
8315 panic!("expected FonteRepoShape, got other variant");
8316 };
8317 assert!(
8318 reason.contains("must not contain `` ` ``"),
8319 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
8320 appears first in value), got {reason:?}"
8321 );
8322 }
8323
8324 #[test]
8325 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
8326 // The fail-before-pass-after pin for the canonical
8327 // paste-from-shell-prompt-with-sequential-command-tail footgun
8328 // on `:repo` (peer with the 05c358e `;` arm on the sibling
8329 // `:caminho` path-fonte axis). An author pastes a shell
8330 // one-liner that chained a cleanup tail after the URL
8331 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
8332 // echo done`) into the `:repo` slot, forgetting to trim the
8333 // `; <cmd>` tail. Until this arm landed the value silently
8334 // passed every prior `is_git_repo_url` arm (no whitespace, no
8335 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
8336 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
8337 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
8338 // reserved set and the WHATWG URL spec's fragment percent-
8339 // encode set maps `;` → `%3B` on the wire, so the byte rides
8340 // verbatim into the lacre's per-dep BLAKE3 closure but is
8341 // silently rewritten at libcurl's URL-parser layer — two
8342 // authors whose values differ only in their sequential-command
8343 // tail (`; rm -rf build` vs nothing) resolve to the byte-
8344 // identical upstream `git clone` but lock to two distinct
8345 // lacres, defeating the THEORY.md §V.2 render-determinism
8346 // contract. Peer with the `:caminho` axis's
8347 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
8348 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8349 // byte RFC-3986-reserved set on `:entrada :paths`.
8350 let d = dep_with_fonte(DepSource::Git {
8351 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
8352 tag: Some("v0.1.0".into()),
8353 rev: None,
8354 branch: None,
8355 });
8356 let err = d.validate().unwrap_err();
8357 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8358 panic!("expected FonteRepoShape, got other variant");
8359 };
8360 assert_eq!(nome, "caixa-teia");
8361 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
8362 assert!(
8363 reason.contains("must not contain `;`"),
8364 "reason must surface the shell-command-separator arm, got {reason:?}"
8365 );
8366 assert!(
8367 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
8368 "reason must name the shell-command-separator / RFC-3986-sub-delims \
8369 rationale, got {reason:?}"
8370 );
8371 }
8372
8373 #[test]
8374 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
8375 // Cascade pin: the fragment-`#` arm and the semicolon arm are
8376 // both per-byte arms inside the same `for &b in s.as_bytes()`
8377 // loop, so the byte that appears first in the value's byte
8378 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
8379 // carries both `#` and `;`; the `#` byte appears first, so the
8380 // fragment-`#` arm fires, surfacing the more self-locating
8381 // diagnostic on the byte the author pasted earliest in the URL.
8382 // Mirrors the peer cascade discipline
8383 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
8384 // pins on the prior `:repo` byte-class arm.
8385 let d = dep_with_fonte(DepSource::Git {
8386 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
8387 tag: Some("v0.1.0".into()),
8388 rev: None,
8389 branch: None,
8390 });
8391 let err = d.validate().unwrap_err();
8392 let DepError::FonteRepoShape { reason, .. } = err else {
8393 panic!("expected FonteRepoShape, got other variant");
8394 };
8395 assert!(
8396 reason.contains("must not contain `#`"),
8397 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
8398 byte appears first in value), got {reason:?}"
8399 );
8400 }
8401
8402 #[test]
8403 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
8404 // Cascade pin: the pipe arm and the semicolon arm are both
8405 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8406 // so the byte that appears first in the value's byte order
8407 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
8408 // both `|` and `;`; the `|` byte appears first, so the
8409 // pipe arm fires, surfacing the more self-locating diagnostic
8410 // on the byte the author pasted earliest in the URL. Pins the
8411 // natural-order cascade so a future reorder of the per-byte
8412 // arms surfaces here.
8413 let d = dep_with_fonte(DepSource::Git {
8414 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
8415 tag: Some("v0.1.0".into()),
8416 rev: None,
8417 branch: None,
8418 });
8419 let err = d.validate().unwrap_err();
8420 let DepError::FonteRepoShape { reason, .. } = err else {
8421 panic!("expected FonteRepoShape, got other variant");
8422 };
8423 assert!(
8424 reason.contains("must not contain `|`"),
8425 "reason must surface the pipe arm (fires before semicolon when `|` byte \
8426 appears first in value), got {reason:?}"
8427 );
8428 }
8429
8430 #[test]
8431 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
8432 // The fail-before-pass-after pin for the canonical
8433 // paste-from-shell-prompt-with-background-launch-tail footgun
8434 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
8435 // `:caminho` path-fonte axis). An author pastes a shell one-
8436 // liner that detached the clone into the background
8437 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
8438 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
8439 // `&& <cmd>` tail. Until this arm landed the value silently
8440 // passed every prior `is_git_repo_url` arm (no whitespace,
8441 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
8442 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8443 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
8444 // the 'sub-delims' / reserved set and the WHATWG URL spec's
8445 // fragment percent-encode set maps `&` → `%26` on the wire,
8446 // so the byte rides verbatim into the lacre's per-dep
8447 // BLAKE3 closure but is silently rewritten at libcurl's
8448 // URL-parser layer — two authors whose values differ only
8449 // in their background-launch tail (`& sleep 1` vs nothing)
8450 // resolve to the byte-identical upstream `git clone` but
8451 // lock to two distinct lacres, defeating the THEORY.md
8452 // §V.2 render-determinism contract. Peer with the
8453 // `:caminho` axis's `FonteCaminhoShellBackground` arm
8454 // (e12e4f3) on the sibling path-fonte axis, and
8455 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
8456 // reserved set on `:entrada :paths`.
8457 let d = dep_with_fonte(DepSource::Git {
8458 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
8459 tag: Some("v0.1.0".into()),
8460 rev: None,
8461 branch: None,
8462 });
8463 let err = d.validate().unwrap_err();
8464 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8465 panic!("expected FonteRepoShape, got other variant");
8466 };
8467 assert_eq!(nome, "caixa-teia");
8468 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
8469 assert!(
8470 reason.contains("must not contain `&`"),
8471 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
8472 );
8473 assert!(
8474 reason.contains("background-task") || reason.contains("'sub-delims'"),
8475 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
8476 got {reason:?}"
8477 );
8478 }
8479
8480 #[test]
8481 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
8482 // The fail-before-pass-after pin for the symmetric `&&`
8483 // logical-AND build-chain paste footgun: an author pastes
8484 // a `git clone <url> && cd <repo>` build-chain one-liner
8485 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
8486 // is the same `&` byte twice in a row; the per-byte arm
8487 // fires on the first `&` it sees. Pinned separately from
8488 // the single-`&` background-launch shape so a future
8489 // diagnostic-surface change that special-cased the
8490 // doubled-byte form surfaces here.
8491 let d = dep_with_fonte(DepSource::Git {
8492 repo: "github:pleme-io/caixa-teia&&echo".into(),
8493 tag: Some("v0.1.0".into()),
8494 rev: None,
8495 branch: None,
8496 });
8497 let err = d.validate().unwrap_err();
8498 let DepError::FonteRepoShape { reason, .. } = err else {
8499 panic!("expected FonteRepoShape, got other variant");
8500 };
8501 assert!(
8502 reason.contains("must not contain `&`"),
8503 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
8504 shape too, got {reason:?}"
8505 );
8506 }
8507
8508 #[test]
8509 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
8510 // Cascade pin: the fragment-`#` arm and the background-`&`
8511 // arm are both per-byte arms inside the same `for &b in
8512 // s.as_bytes()` loop, so the byte that appears first in the
8513 // value's byte order wins. A `:repo
8514 // "https://github.com/p/x#readme & sleep"` carries both `#`
8515 // and `&`; the `#` byte appears first, so the fragment-`#`
8516 // arm fires, surfacing the more self-locating diagnostic on
8517 // the byte the author pasted earliest in the URL. Mirrors
8518 // the peer cascade discipline
8519 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
8520 // on the prior `:repo` byte-class arm.
8521 let d = dep_with_fonte(DepSource::Git {
8522 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
8523 tag: Some("v0.1.0".into()),
8524 rev: None,
8525 branch: None,
8526 });
8527 let err = d.validate().unwrap_err();
8528 let DepError::FonteRepoShape { reason, .. } = err else {
8529 panic!("expected FonteRepoShape, got other variant");
8530 };
8531 assert!(
8532 reason.contains("must not contain `#`"),
8533 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
8534 byte appears first in value), got {reason:?}"
8535 );
8536 }
8537
8538 #[test]
8539 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
8540 // Cascade pin: the semicolon arm and the background-`&` arm
8541 // are both per-byte arms inside the same `for &b in
8542 // s.as_bytes()` loop, so the byte that appears first in the
8543 // value's byte order wins. A `:repo
8544 // "https://github.com/p/x; rm & sleep"` carries both `;` and
8545 // `&`; the `;` byte appears first, so the semicolon arm
8546 // fires, surfacing the more self-locating diagnostic on the
8547 // byte the author pasted earliest in the URL. Pins the
8548 // natural-order cascade so a future reorder of the per-byte
8549 // arms surfaces here.
8550 let d = dep_with_fonte(DepSource::Git {
8551 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
8552 tag: Some("v0.1.0".into()),
8553 rev: None,
8554 branch: None,
8555 });
8556 let err = d.validate().unwrap_err();
8557 let DepError::FonteRepoShape { reason, .. } = err else {
8558 panic!("expected FonteRepoShape, got other variant");
8559 };
8560 assert!(
8561 reason.contains("must not contain `;`"),
8562 "reason must surface the semicolon arm (fires before background-`&` when `;` \
8563 byte appears first in value), got {reason:?}"
8564 );
8565 }
8566
8567 #[test]
8568 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
8569 // The fail-before-pass-after pin for the canonical
8570 // paste-from-shell-prompt-with-unsubstituted-variable footgun
8571 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
8572 // `:caminho` path-fonte axis). An author pastes a shell one-
8573 // liner that referenced an environment variable
8574 // (`git clone https://github.com/$ORG/x`, `git clone
8575 // github:$USER/repo`) into the `:repo` slot, forgetting to
8576 // substitute the literal value at author time. Until this arm
8577 // landed the value silently passed every prior
8578 // `is_git_repo_url` arm (no whitespace, no control chars, no
8579 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8580 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
8581 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
8582 // reserved set and the WHATWG URL spec's fragment percent-
8583 // encode set maps `$` → `%24` on the wire, so the byte rides
8584 // verbatim into the lacre's per-dep BLAKE3 closure but is
8585 // silently rewritten at libcurl's URL-parser layer — two
8586 // authors whose values differ only in their `$VAR` /
8587 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
8588 // identical upstream `git clone` but lock to two distinct
8589 // lacres, defeating the THEORY.md §V.2 render-determinism
8590 // contract. Beyond determinism, the value is a structural
8591 // host-layout leak: two authors with the same `:repo` slot
8592 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
8593 // different upstreams. Peer with the `:caminho` axis's
8594 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
8595 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8596 // byte RFC-3986-reserved set on `:entrada :paths`.
8597 let d = dep_with_fonte(DepSource::Git {
8598 repo: "https://github.com/$ORG/caixa-teia".into(),
8599 tag: Some("v0.1.0".into()),
8600 rev: None,
8601 branch: None,
8602 });
8603 let err = d.validate().unwrap_err();
8604 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8605 panic!("expected FonteRepoShape, got other variant");
8606 };
8607 assert_eq!(nome, "caixa-teia");
8608 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
8609 assert!(
8610 reason.contains("must not contain `$`"),
8611 "reason must surface the shell-variable-expansion arm, got {reason:?}"
8612 );
8613 assert!(
8614 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
8615 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
8616 rationale, got {reason:?}"
8617 );
8618 }
8619
8620 #[test]
8621 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
8622 // The fail-before-pass-after pin for the symmetric POSIX-
8623 // shell braced `${VAR}` expansion paste footgun: an author
8624 // pastes a CI-manifest line `git clone
8625 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
8626 // Actions / GitLab CI / Drone shape) and forgets to
8627 // substitute the literal value. The `${...}` shape is the
8628 // same `$` byte at the leading position of the expansion;
8629 // the per-byte arm fires on the `$`. Pinned separately from
8630 // the bare-`$VAR` shape so a future diagnostic-surface
8631 // change that special-cased the braced form surfaces here.
8632 let d = dep_with_fonte(DepSource::Git {
8633 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
8634 tag: Some("v0.1.0".into()),
8635 rev: None,
8636 branch: None,
8637 });
8638 let err = d.validate().unwrap_err();
8639 let DepError::FonteRepoShape { reason, .. } = err else {
8640 panic!("expected FonteRepoShape, got other variant");
8641 };
8642 assert!(
8643 reason.contains("must not contain `$`"),
8644 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
8645 shape too, got {reason:?}"
8646 );
8647 }
8648
8649 #[test]
8650 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
8651 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
8652 // arm are both per-byte arms inside the same `for &b in
8653 // s.as_bytes()` loop, so the byte that appears first in the
8654 // value's byte order wins. A `:repo
8655 // "https://github.com/p/x#readme$HOME"` carries both `#` and
8656 // `$`; the `#` byte appears first, so the fragment-`#` arm
8657 // fires, surfacing the more self-locating diagnostic on the
8658 // byte the author pasted earliest in the URL. Mirrors the
8659 // peer cascade discipline
8660 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
8661 // on the prior `:repo` byte-class arm.
8662 let d = dep_with_fonte(DepSource::Git {
8663 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
8664 tag: Some("v0.1.0".into()),
8665 rev: None,
8666 branch: None,
8667 });
8668 let err = d.validate().unwrap_err();
8669 let DepError::FonteRepoShape { reason, .. } = err else {
8670 panic!("expected FonteRepoShape, got other variant");
8671 };
8672 assert!(
8673 reason.contains("must not contain `#`"),
8674 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
8675 `#` byte appears first in value), got {reason:?}"
8676 );
8677 }
8678
8679 #[test]
8680 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
8681 // Cascade pin: the background-`&` arm and the
8682 // var-expansion-`$` arm are both per-byte arms inside the
8683 // same `for &b in s.as_bytes()` loop, so the byte that
8684 // appears first in the value's byte order wins. A `:repo
8685 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
8686 // `$`; the `&` byte appears first, so the background arm
8687 // fires, surfacing the more self-locating diagnostic on the
8688 // byte the author pasted earliest in the URL. Pins the
8689 // natural-order cascade so a future reorder of the per-byte
8690 // arms surfaces here — `$` is the most recent byte-class arm,
8691 // so the cascade-pin sweep extends to cover every immediately
8692 // prior byte arm (`#`, `&`) firing first when ordered ahead
8693 // of `$` in the value.
8694 let d = dep_with_fonte(DepSource::Git {
8695 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
8696 tag: Some("v0.1.0".into()),
8697 rev: None,
8698 branch: None,
8699 });
8700 let err = d.validate().unwrap_err();
8701 let DepError::FonteRepoShape { reason, .. } = err else {
8702 panic!("expected FonteRepoShape, got other variant");
8703 };
8704 assert!(
8705 reason.contains("must not contain `&`"),
8706 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
8707 `&` byte appears first in value), got {reason:?}"
8708 );
8709 }
8710
8711 #[test]
8712 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
8713 // The fail-before-pass-after pin for the canonical
8714 // paste-from-shell-prompt glob footgun on `:repo` (peer with
8715 // the cf9034b `*` / `?` arm on the sibling `:caminho`
8716 // path-fonte axis). An author pastes a shell one-liner that
8717 // referenced a glob expansion (`ls
8718 // github.com/pleme-io/caixa-*`, `git clone
8719 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
8720 // to substitute the literal repo name. Until this arm landed
8721 // the `*` byte silently passed every prior `is_git_repo_url`
8722 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
8723 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
8724 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
8725 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
8726 // the WHATWG URL spec's special-query percent-encode set maps
8727 // `*` → `%2A` on the wire, so the byte rides verbatim into
8728 // the lacre's per-dep BLAKE3 closure but is silently
8729 // rewritten at libcurl's URL-parser layer — two authors
8730 // whose values differ only in their asterisk presence
8731 // resolve to the byte-identical upstream `git clone` but
8732 // lock to two distinct lacres, defeating the THEORY.md §V.2
8733 // render-determinism contract. Peer with the `:caminho`
8734 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
8735 // sibling path-fonte axis, and the `is_git_ref_name`
8736 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
8737 // axes.
8738 let d = dep_with_fonte(DepSource::Git {
8739 repo: "https://github.com/pleme-io/caixa-*".into(),
8740 tag: Some("v0.1.0".into()),
8741 rev: None,
8742 branch: None,
8743 });
8744 let err = d.validate().unwrap_err();
8745 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8746 panic!("expected FonteRepoShape, got other variant");
8747 };
8748 assert_eq!(nome, "caixa-teia");
8749 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
8750 assert!(
8751 reason.contains("must not contain `*`"),
8752 "reason must surface the shell-glob arm, got {reason:?}"
8753 );
8754 assert!(
8755 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
8756 "reason must name the shell-glob / pathname-expansion / \
8757 RFC-3986-sub-delims rationale, got {reason:?}"
8758 );
8759 }
8760
8761 #[test]
8762 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
8763 // The fail-before-pass-after pin for the symmetric bash
8764 // `globstar` recursive-glob paste footgun: an author pastes
8765 // a `ls github.com/pleme-io/**/x` (the canonical
8766 // `globstar`-shopt-enabled recursive-listing tail) into the
8767 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
8768 // the per-byte arm fires on the first `*`. Pinned
8769 // separately from the single-`*` shape so a future
8770 // diagnostic-surface change that special-cased the
8771 // double-`*` form surfaces here.
8772 let d = dep_with_fonte(DepSource::Git {
8773 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
8774 tag: Some("v0.1.0".into()),
8775 rev: None,
8776 branch: None,
8777 });
8778 let err = d.validate().unwrap_err();
8779 let DepError::FonteRepoShape { reason, .. } = err else {
8780 panic!("expected FonteRepoShape, got other variant");
8781 };
8782 assert!(
8783 reason.contains("must not contain `*`"),
8784 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8785 got {reason:?}"
8786 );
8787 }
8788
8789 #[test]
8790 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8791 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8792 // both per-byte arms inside the same `for &b in s.as_bytes()`
8793 // loop, so the byte that appears first in the value's byte
8794 // order wins. A `:repo
8795 // "https://github.com/p/x#readme*tail"` carries both `#` and
8796 // `*`; the `#` byte appears first, so the fragment-`#` arm
8797 // fires, surfacing the more self-locating diagnostic on the
8798 // byte the author pasted earliest in the URL. Mirrors the
8799 // peer cascade discipline
8800 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8801 // on the prior `:repo` byte-class arm.
8802 let d = dep_with_fonte(DepSource::Git {
8803 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8804 tag: Some("v0.1.0".into()),
8805 rev: None,
8806 branch: None,
8807 });
8808 let err = d.validate().unwrap_err();
8809 let DepError::FonteRepoShape { reason, .. } = err else {
8810 panic!("expected FonteRepoShape, got other variant");
8811 };
8812 assert!(
8813 reason.contains("must not contain `#`"),
8814 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8815 appears first in value), got {reason:?}"
8816 );
8817 }
8818
8819 #[test]
8820 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8821 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8822 // arm are both per-byte arms inside the same `for &b in
8823 // s.as_bytes()` loop, so the byte that appears first in the
8824 // value's byte order wins. A `:repo
8825 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8826 // the `$` byte appears first, so the var-expansion arm
8827 // fires, surfacing the more self-locating diagnostic on the
8828 // byte the author pasted earliest in the URL. Pins the
8829 // natural-order cascade so a future reorder of the per-byte
8830 // arms surfaces here — `*` is the most recent byte-class
8831 // arm, so the cascade-pin sweep extends to cover the
8832 // immediately prior `$` byte arm firing first when ordered
8833 // ahead of `*` in the value.
8834 let d = dep_with_fonte(DepSource::Git {
8835 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
8836 tag: Some("v0.1.0".into()),
8837 rev: None,
8838 branch: None,
8839 });
8840 let err = d.validate().unwrap_err();
8841 let DepError::FonteRepoShape { reason, .. } = err else {
8842 panic!("expected FonteRepoShape, got other variant");
8843 };
8844 assert!(
8845 reason.contains("must not contain `$`"),
8846 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8847 byte appears first in value), got {reason:?}"
8848 );
8849 }
8850
8851 #[test]
8852 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8853 // The fail-before-pass-after pin for the canonical paste-from-
8854 // shell-prompt subshell-grouping footgun on `:repo`. An author
8855 // pastes a doc / README snippet carrying a regex-alternation
8856 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8857 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8858 // `:repo` slot, forgetting to substitute one literal org name.
8859 // Until this arm landed the `(` byte silently passed every
8860 // prior `is_git_repo_url` arm (no whitespace, no control
8861 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8862 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8863 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8864 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8865 // URL spec's special-query percent-encode set maps `(` →
8866 // `%28` and `)` → `%29` on the wire, so the byte rides
8867 // verbatim into the lacre's per-dep BLAKE3 closure but is
8868 // silently rewritten at libcurl's URL-parser layer —
8869 // defeating the THEORY.md §V.2 render-determinism contract on
8870 // the same axis the prior twelve byte-class arms close.
8871 let d = dep_with_fonte(DepSource::Git {
8872 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8873 tag: Some("v0.1.0".into()),
8874 rev: None,
8875 branch: None,
8876 });
8877 let err = d.validate().unwrap_err();
8878 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8879 panic!("expected FonteRepoShape, got other variant");
8880 };
8881 assert_eq!(nome, "caixa-teia");
8882 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8883 assert!(
8884 reason.contains("must not contain `(`"),
8885 "reason must surface the subshell-open-paren arm, got {reason:?}"
8886 );
8887 assert!(
8888 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8889 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8890 got {reason:?}"
8891 );
8892 }
8893
8894 #[test]
8895 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8896 // The symmetric arm pin on the closing `)` byte: an author
8897 // pastes a `$(date)` command-substitution wrapper or a
8898 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8899 // Pinned separately from the opening `(` shape so a future
8900 // diagnostic-surface change that only checked one boundary
8901 // surfaces here. The `(` byte appears earlier in the
8902 // canonical regex / subshell wrapper so the per-byte loop
8903 // fires on `(` first; this test exercises a `:repo` value
8904 // carrying only the closing `)` byte (no opening paren) so
8905 // the `)` arm fires directly — pinning the byte-class arm
8906 // independent of order.
8907 let d = dep_with_fonte(DepSource::Git {
8908 repo: "github:pleme-io/caixa-teia)tail".into(),
8909 tag: Some("v0.1.0".into()),
8910 rev: None,
8911 branch: None,
8912 });
8913 let err = d.validate().unwrap_err();
8914 let DepError::FonteRepoShape { reason, .. } = err else {
8915 panic!("expected FonteRepoShape, got other variant");
8916 };
8917 assert!(
8918 reason.contains("must not contain `)`"),
8919 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8920 got {reason:?}"
8921 );
8922 }
8923
8924 #[test]
8925 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8926 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8927 // are both per-byte arms inside the same `for &b in
8928 // s.as_bytes()` loop, so the byte that appears first in the
8929 // value's byte order wins. A `:repo
8930 // "https://github.com/p/x#readme(tail)"` carries both `#` and
8931 // `(`; the `#` byte appears first, so the fragment-`#` arm
8932 // fires, surfacing the more self-locating diagnostic on the
8933 // byte the author pasted earliest in the URL. Mirrors the
8934 // peer cascade discipline
8935 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8936 // on the prior `:repo` byte-class arm.
8937 let d = dep_with_fonte(DepSource::Git {
8938 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8939 tag: Some("v0.1.0".into()),
8940 rev: None,
8941 branch: None,
8942 });
8943 let err = d.validate().unwrap_err();
8944 let DepError::FonteRepoShape { reason, .. } = err else {
8945 panic!("expected FonteRepoShape, got other variant");
8946 };
8947 assert!(
8948 reason.contains("must not contain `#`"),
8949 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8950 byte appears first in value), got {reason:?}"
8951 );
8952 }
8953
8954 #[test]
8955 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8956 // Cascade pin: the glob-`*` arm (the immediate-predecessor
8957 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8958 // per-byte arms inside the same `for &b in s.as_bytes()`
8959 // loop, so the byte that appears first in the value's byte
8960 // order wins. A `:repo
8961 // "https://github.com/p/x-*-(date)"` carries both `*` and
8962 // `(`; the `*` byte appears first, so the glob arm fires,
8963 // surfacing the more self-locating diagnostic on the byte
8964 // the author pasted earliest in the URL. Pins the natural-
8965 // order cascade so a future reorder of the per-byte arms
8966 // surfaces here — `(` is the most recent byte-class arm,
8967 // so the cascade-pin sweep extends to cover the immediately
8968 // prior `*` byte arm firing first when ordered ahead of `(`
8969 // in the value.
8970 let d = dep_with_fonte(DepSource::Git {
8971 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8972 tag: Some("v0.1.0".into()),
8973 rev: None,
8974 branch: None,
8975 });
8976 let err = d.validate().unwrap_err();
8977 let DepError::FonteRepoShape { reason, .. } = err else {
8978 panic!("expected FonteRepoShape, got other variant");
8979 };
8980 assert!(
8981 reason.contains("must not contain `*`"),
8982 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8983 appears first in value), got {reason:?}"
8984 );
8985 }
8986
8987 #[test]
8988 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8989 // The fail-before-pass-after pin for the canonical paste-from-
8990 // doc-shell-quoting footgun on `:repo`. An author copies a
8991 // README quick-start snippet (`$ git clone "https://github.com/
8992 // foo/bar"`) and keeps the surrounding double-quote bytes when
8993 // pasting into the `:repo` slot — the doc wraps the URL in
8994 // double quotes so the shell doesn't re-lex metachars inside,
8995 // but the typed slot is itself a byte-level string parser, not
8996 // a shell context, so the quote bytes ride into the value
8997 // verbatim. Until this arm landed the `"` byte silently passed
8998 // every prior `is_git_repo_url` arm (no whitespace, no control
8999 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
9000 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
9001 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
9002 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
9003 // `` ` ``) every URL parser is required to refuse or percent-
9004 // encode, and the WHATWG URL spec's 'C0 control percent-encode
9005 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
9006 // into the lacre's per-dep BLAKE3 closure but is silently
9007 // rewritten at libcurl's URL-parser layer, defeating the
9008 // THEORY.md §V.2 render-determinism contract.
9009 let d = dep_with_fonte(DepSource::Git {
9010 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
9011 tag: Some("v0.1.0".into()),
9012 rev: None,
9013 branch: None,
9014 });
9015 let err = d.validate().unwrap_err();
9016 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9017 panic!("expected FonteRepoShape, got other variant");
9018 };
9019 assert_eq!(nome, "caixa-teia");
9020 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
9021 assert!(
9022 reason.contains("must not contain `\"`"),
9023 "reason must surface the shell-double-quote arm, got {reason:?}"
9024 );
9025 assert!(
9026 reason.contains("double-quote") || reason.contains("'delims'"),
9027 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
9028 got {reason:?}"
9029 );
9030 }
9031
9032 #[test]
9033 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
9034 // The symmetric stray-quote tail pin: an author pastes only a
9035 // closing `"` from a shell-history line like `git clone
9036 // "https://github.com/foo/bar" && cd …` (the trim went too
9037 // far in one direction but not the other) into the `:repo`
9038 // slot. Pinned separately from the wrapped-quote shape so a
9039 // future diagnostic-surface change that only checked one
9040 // boundary (only leading, only trailing, only paired) surfaces
9041 // here — the per-byte arm fires anywhere `"` appears.
9042 let d = dep_with_fonte(DepSource::Git {
9043 repo: "github:pleme-io/caixa-teia\"".into(),
9044 tag: Some("v0.1.0".into()),
9045 rev: None,
9046 branch: None,
9047 });
9048 let err = d.validate().unwrap_err();
9049 let DepError::FonteRepoShape { reason, .. } = err else {
9050 panic!("expected FonteRepoShape, got other variant");
9051 };
9052 assert!(
9053 reason.contains("must not contain `\"`"),
9054 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
9055 got {reason:?}"
9056 );
9057 }
9058
9059 #[test]
9060 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
9061 // Cascade pin: the fragment-`#` arm and the double-quote arm
9062 // are both per-byte arms inside the same `for &b in
9063 // s.as_bytes()` loop, so the byte that appears first in the
9064 // value's byte order wins. A `:repo
9065 // "https://github.com/p/x#readme\"tail"` carries both `#` and
9066 // `"`; the `#` byte appears first, so the fragment-`#` arm
9067 // fires, surfacing the more self-locating diagnostic on the
9068 // byte the author pasted earliest in the URL.
9069 let d = dep_with_fonte(DepSource::Git {
9070 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
9071 tag: Some("v0.1.0".into()),
9072 rev: None,
9073 branch: None,
9074 });
9075 let err = d.validate().unwrap_err();
9076 let DepError::FonteRepoShape { reason, .. } = err else {
9077 panic!("expected FonteRepoShape, got other variant");
9078 };
9079 assert!(
9080 reason.contains("must not contain `#`"),
9081 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
9082 byte appears first in value), got {reason:?}"
9083 );
9084 }
9085
9086 #[test]
9087 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
9088 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
9089 // byte-class arm, 3b99147) and the double-quote arm are both
9090 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9091 // so the byte that appears first in the value's byte order
9092 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
9093 // and `"`; the `(` byte appears first, so the subshell arm
9094 // fires, surfacing the more self-locating diagnostic on the
9095 // byte the author pasted earliest in the URL. Pins the natural-
9096 // order cascade so a future reorder of the per-byte arms
9097 // surfaces here — `"` is the most recent byte-class arm, so
9098 // the cascade-pin sweep extends to cover the immediately prior
9099 // `(` byte arm firing first when ordered ahead of `"` in the
9100 // value.
9101 let d = dep_with_fonte(DepSource::Git {
9102 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
9103 tag: Some("v0.1.0".into()),
9104 rev: None,
9105 branch: None,
9106 });
9107 let err = d.validate().unwrap_err();
9108 let DepError::FonteRepoShape { reason, .. } = err else {
9109 panic!("expected FonteRepoShape, got other variant");
9110 };
9111 assert!(
9112 reason.contains("must not contain `(`"),
9113 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
9114 byte appears first in value), got {reason:?}"
9115 );
9116 }
9117
9118 #[test]
9119 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
9120 // The fail-before-pass-after pin for the canonical paste-from-
9121 // doc-strong-quoting footgun on `:repo`. An author copies a
9122 // security-conscious README quick-start snippet (`$ git clone
9123 // 'https://github.com/foo/bar'`) and keeps the surrounding
9124 // single-quote bytes when pasting into the `:repo` slot — the
9125 // doc strong-quotes the URL so the shell suppresses every form
9126 // of expansion on the bytes inside (no `$`, no backtick, no
9127 // glob, no word-splitting), but the typed slot is itself a
9128 // byte-level string parser, not a shell context, so the quote
9129 // bytes ride into the value verbatim. Until this arm landed the
9130 // `'` byte silently passed every prior `is_git_repo_url` arm
9131 // (no whitespace, no control chars, no non-ASCII, no `#`, no
9132 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
9133 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
9134 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
9135 // set, peer with the `\"` 'delims' double-quote arm and the
9136 // partner ASCII shell-string-delimiter byte every byte-level
9137 // string parser sharing a value-shape with a shell argument
9138 // must refuse on a URL-shaped slot.
9139 let d = dep_with_fonte(DepSource::Git {
9140 repo: "'https://github.com/pleme-io/caixa-teia'".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'");
9151 assert!(
9152 reason.contains("must not contain `'`"),
9153 "reason must surface the shell-single-quote arm, got {reason:?}"
9154 );
9155 assert!(
9156 reason.contains("single-quote") || reason.contains("strong-quote"),
9157 "reason must name the shell-single-quote / strong-quote rationale, \
9158 got {reason:?}"
9159 );
9160 }
9161
9162 #[test]
9163 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
9164 // The symmetric English-typography pin: an author writes
9165 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
9166 // from-prose idiom every README / commit-message / chat-thread
9167 // reference to a repo carries) expecting the substrate to
9168 // coerce it to a kebab-case slug — but the byte rides into the
9169 // lacre verbatim. Pinned separately from the wrapped-quote
9170 // shape so a future diagnostic-surface change that only checked
9171 // the boundary positions (only leading, only trailing, only
9172 // paired) surfaces here — the per-byte arm fires anywhere `'`
9173 // appears in the value.
9174 let d = dep_with_fonte(DepSource::Git {
9175 repo: "github:pleme-io/repo's-fork".into(),
9176 tag: Some("v0.1.0".into()),
9177 rev: None,
9178 branch: None,
9179 });
9180 let err = d.validate().unwrap_err();
9181 let DepError::FonteRepoShape { reason, .. } = err else {
9182 panic!("expected FonteRepoShape, got other variant");
9183 };
9184 assert!(
9185 reason.contains("must not contain `'`"),
9186 "reason must surface the shell-single-quote arm on the mid-string \
9187 apostrophe shape, got {reason:?}"
9188 );
9189 }
9190
9191 #[test]
9192 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
9193 // Cascade pin: the fragment-`#` arm and the single-quote arm
9194 // are both per-byte arms inside the same `for &b in
9195 // s.as_bytes()` loop, so the byte that appears first in the
9196 // value's byte order wins. A `:repo
9197 // "https://github.com/p/x#readme'tail"` carries both `#` and
9198 // `'`; the `#` byte appears first, so the fragment-`#` arm
9199 // fires, surfacing the more self-locating diagnostic on the
9200 // byte the author pasted earliest in the URL.
9201 let d = dep_with_fonte(DepSource::Git {
9202 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
9203 tag: Some("v0.1.0".into()),
9204 rev: None,
9205 branch: None,
9206 });
9207 let err = d.validate().unwrap_err();
9208 let DepError::FonteRepoShape { reason, .. } = err else {
9209 panic!("expected FonteRepoShape, got other variant");
9210 };
9211 assert!(
9212 reason.contains("must not contain `#`"),
9213 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
9214 byte appears first in value), got {reason:?}"
9215 );
9216 }
9217
9218 #[test]
9219 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
9220 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
9221 // byte-class arm, 4267d8b) and the single-quote arm are both
9222 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9223 // so the byte that appears first in the value's byte order
9224 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
9225 // `'`; the `"` byte appears first, so the double-quote arm
9226 // fires, surfacing the more self-locating diagnostic on the
9227 // byte the author pasted earliest in the URL. Pins the natural-
9228 // order cascade so a future reorder of the per-byte arms
9229 // surfaces here — `'` is the most recent byte-class arm, so
9230 // the cascade-pin sweep extends to cover the immediately prior
9231 // `"` byte arm firing first when ordered ahead of `'` in the
9232 // value.
9233 let d = dep_with_fonte(DepSource::Git {
9234 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
9235 tag: Some("v0.1.0".into()),
9236 rev: None,
9237 branch: None,
9238 });
9239 let err = d.validate().unwrap_err();
9240 let DepError::FonteRepoShape { reason, .. } = err else {
9241 panic!("expected FonteRepoShape, got other variant");
9242 };
9243 assert!(
9244 reason.contains("must not contain `\"`"),
9245 "reason must surface the double-quote arm (fires before single-quote when `\"` \
9246 byte appears first in value), got {reason:?}"
9247 );
9248 }
9249
9250 #[test]
9251 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
9252 // The fail-before-pass-after pin for the canonical paste-from-
9253 // shell-history footgun on `:repo`. An author copies a `git
9254 // clone <url>!sudo make install` one-liner from a README's
9255 // quick-start snippet, intending the trailing `!sudo` as a
9256 // shell-history-expansion reference but the typed slot is itself
9257 // a byte-level string parser, not a shell context, so the byte
9258 // rides into the value verbatim. Until this arm landed the `!`
9259 // byte silently passed every prior `is_git_repo_url` arm (no
9260 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
9261 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
9262 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
9263 // start with `-` or `:`); bash with the default `histexpand`
9264 // mode rewrites `!command` to the most recent history entry
9265 // beginning with `command`, the canonical RCE-class injection
9266 // vector when the byte rides into a shell argument.
9267 let d = dep_with_fonte(DepSource::Git {
9268 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
9269 tag: Some("v0.1.0".into()),
9270 rev: None,
9271 branch: None,
9272 });
9273 let err = d.validate().unwrap_err();
9274 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9275 panic!("expected FonteRepoShape, got other variant");
9276 };
9277 assert_eq!(nome, "caixa-teia");
9278 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
9279 assert!(
9280 reason.contains("must not contain `!`"),
9281 "reason must surface the shell-history-expansion arm, got {reason:?}"
9282 );
9283 assert!(
9284 reason.contains("history-expansion") || reason.contains("bang"),
9285 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
9286 );
9287 }
9288
9289 #[test]
9290 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
9291 // The symmetric `!!` repeat-prior-command pin: an author paste-
9292 // trims a `git clone <url>` retry idiom from shell history that
9293 // expands to the previous command via `!!`. Pinned separately
9294 // from the wrapped `!command` shape so a future diagnostic-
9295 // surface change that only checked the leading or paired-bang
9296 // position surfaces here — the per-byte arm fires anywhere `!`
9297 // appears in the value.
9298 let d = dep_with_fonte(DepSource::Git {
9299 repo: "github:pleme-io/caixa-teia!!".into(),
9300 tag: Some("v0.1.0".into()),
9301 rev: None,
9302 branch: None,
9303 });
9304 let err = d.validate().unwrap_err();
9305 let DepError::FonteRepoShape { reason, .. } = err else {
9306 panic!("expected FonteRepoShape, got other variant");
9307 };
9308 assert!(
9309 reason.contains("must not contain `!`"),
9310 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
9311 got {reason:?}"
9312 );
9313 }
9314
9315 #[test]
9316 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
9317 // Cascade pin: the fragment-`#` arm and the bang arm are both
9318 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9319 // so the byte that appears first in the value's byte order
9320 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
9321 // both `#` and `!`; the `#` byte appears first, so the
9322 // fragment-`#` arm fires, surfacing the more self-locating
9323 // diagnostic on the byte the author pasted earliest in the URL.
9324 let d = dep_with_fonte(DepSource::Git {
9325 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
9326 tag: Some("v0.1.0".into()),
9327 rev: None,
9328 branch: None,
9329 });
9330 let err = d.validate().unwrap_err();
9331 let DepError::FonteRepoShape { reason, .. } = err else {
9332 panic!("expected FonteRepoShape, got other variant");
9333 };
9334 assert!(
9335 reason.contains("must not contain `#`"),
9336 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
9337 appears first in value), got {reason:?}"
9338 );
9339 }
9340
9341 #[test]
9342 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
9343 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
9344 // byte-class arm, e7a109f) and the bang arm are both per-byte
9345 // arms inside the same `for &b in s.as_bytes()` loop, so the
9346 // byte that appears first in the value's byte order wins. A
9347 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
9348 // `'` byte appears first, so the single-quote arm fires,
9349 // surfacing the more self-locating diagnostic on the byte the
9350 // author pasted earliest in the URL. Pins the natural-order
9351 // cascade so a future reorder of the per-byte arms surfaces
9352 // here — `!` is the most recent byte-class arm, so the
9353 // cascade-pin sweep extends to cover the immediately prior `'`
9354 // byte arm firing first when ordered ahead of `!` in the value.
9355 let d = dep_with_fonte(DepSource::Git {
9356 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
9357 tag: Some("v0.1.0".into()),
9358 rev: None,
9359 branch: None,
9360 });
9361 let err = d.validate().unwrap_err();
9362 let DepError::FonteRepoShape { reason, .. } = err else {
9363 panic!("expected FonteRepoShape, got other variant");
9364 };
9365 assert!(
9366 reason.contains("must not contain `'`"),
9367 "reason must surface the single-quote arm (fires before bang when `'` byte \
9368 appears first in value), got {reason:?}"
9369 );
9370 }
9371
9372 #[test]
9373 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
9374 // The fail-before-pass-after pin for the canonical
9375 // list-separator-belongs-to-list-grammar footgun on `:repo`.
9376 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
9377 // one-liner from a multi-repo bootstrap doc, intending the
9378 // comma to separate multiple repo entries but the typed
9379 // `:repo` slot names *one* repo (the list-separator belongs
9380 // to the `:deps` list grammar, not to the value). Until this
9381 // arm landed the `,` byte silently passed every prior
9382 // `is_git_repo_url` arm (no whitespace, no control chars, no
9383 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
9384 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
9385 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
9386 // `:`); the byte rode into the lacre's per-dep content-
9387 // address and the resolver's `git clone <repo>` subprocess
9388 // invocation, where no host's repo registry resolved the
9389 // comma-bearing slug.
9390 let d = dep_with_fonte(DepSource::Git {
9391 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
9392 tag: Some("v0.1.0".into()),
9393 rev: None,
9394 branch: None,
9395 });
9396 let err = d.validate().unwrap_err();
9397 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9398 panic!("expected FonteRepoShape, got other variant");
9399 };
9400 assert_eq!(nome, "caixa-teia");
9401 assert_eq!(
9402 repo,
9403 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
9404 );
9405 assert!(
9406 reason.contains("must not contain `,`"),
9407 "reason must surface the list-separator-comma arm, got {reason:?}"
9408 );
9409 assert!(
9410 reason.contains("list-separator") || reason.contains("sub-delims"),
9411 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
9412 got {reason:?}"
9413 );
9414 }
9415
9416 #[test]
9417 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
9418 // The symmetric trailing-`,` paste-from-prose pin: an author
9419 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
9420 // comma every README-prose list-of-projects sentence carries,
9421 // mistakenly retained when the slug is pasted mid-sentence)
9422 // expecting the substrate to coerce it to a kebab-case slug.
9423 // Pinned separately from the wrapped mid-token shape so a
9424 // future diagnostic-surface change that only checked the
9425 // leading or paired-comma position surfaces here — the
9426 // per-byte arm fires anywhere `,` appears in the value.
9427 let d = dep_with_fonte(DepSource::Git {
9428 repo: "github:pleme-io/caixa-feira,".into(),
9429 tag: Some("v0.1.0".into()),
9430 rev: None,
9431 branch: None,
9432 });
9433 let err = d.validate().unwrap_err();
9434 let DepError::FonteRepoShape { reason, .. } = err else {
9435 panic!("expected FonteRepoShape, got other variant");
9436 };
9437 assert!(
9438 reason.contains("must not contain `,`"),
9439 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
9440 got {reason:?}"
9441 );
9442 }
9443
9444 #[test]
9445 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
9446 // Cascade pin: the fragment-`#` arm and the comma arm are
9447 // both per-byte arms inside the same `for &b in s.as_bytes()`
9448 // loop, so the byte that appears first in the value's byte
9449 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
9450 // carries both `#` and `,`; the `#` byte appears first, so
9451 // the fragment-`#` arm fires, surfacing the more self-
9452 // locating diagnostic on the byte the author pasted earliest
9453 // in the URL.
9454 let d = dep_with_fonte(DepSource::Git {
9455 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
9456 tag: Some("v0.1.0".into()),
9457 rev: None,
9458 branch: None,
9459 });
9460 let err = d.validate().unwrap_err();
9461 let DepError::FonteRepoShape { reason, .. } = err else {
9462 panic!("expected FonteRepoShape, got other variant");
9463 };
9464 assert!(
9465 reason.contains("must not contain `#`"),
9466 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
9467 appears first in value), got {reason:?}"
9468 );
9469 }
9470
9471 #[test]
9472 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
9473 // Cascade pin: the bang-`!` arm (the immediate-predecessor
9474 // byte-class arm, 7d53c68) and the comma arm are both
9475 // per-byte arms inside the same `for &b in s.as_bytes()`
9476 // loop, so the byte that appears first in the value's byte
9477 // order wins. A `:repo "github:p/x!mid,tail"` carries both
9478 // `!` and `,`; the `!` byte appears first, so the bang arm
9479 // fires, surfacing the more self-locating diagnostic on the
9480 // byte the author pasted earliest in the URL. Pins the
9481 // natural-order cascade so a future reorder of the per-byte
9482 // arms surfaces here — `,` is the most recent byte-class
9483 // arm, so the cascade-pin sweep extends to cover the
9484 // immediately prior `!` byte arm firing first when ordered
9485 // ahead of `,` in the value.
9486 let d = dep_with_fonte(DepSource::Git {
9487 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
9488 tag: Some("v0.1.0".into()),
9489 rev: None,
9490 branch: None,
9491 });
9492 let err = d.validate().unwrap_err();
9493 let DepError::FonteRepoShape { reason, .. } = err else {
9494 panic!("expected FonteRepoShape, got other variant");
9495 };
9496 assert!(
9497 reason.contains("must not contain `!`"),
9498 "reason must surface the bang arm (fires before comma when `!` byte \
9499 appears first in value), got {reason:?}"
9500 );
9501 }
9502
9503 #[test]
9504 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
9505 // The fail-before-pass-after pin for the canonical
9506 // shell-env-var-assignment-belongs-to-shell-grammar footgun
9507 // on `:repo`. An author copies
9508 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
9509 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
9510 // git clone <url>`, etc. — the canonical
9511 // git-troubleshooting README idiom for a one-shot env-var
9512 // scoped to the `git clone` invocation) from a shell-prompt
9513 // one-liner, intending the `KEY=VALUE` prefix as a shell-
9514 // grammar env-var assignment but the typed `:repo` slot is
9515 // a value parser, not a shell context, so the bytes ride
9516 // into the value verbatim. Until this arm landed the `=`
9517 // byte silently passed every prior `is_git_repo_url` arm
9518 // (no whitespace, no control chars, no non-ASCII, no `#`,
9519 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
9520 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
9521 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
9522 // the byte rode into the lacre's per-dep content-address
9523 // and the resolver's `git clone <repo>` subprocess
9524 // invocation, where the upstream host's git porcelain
9525 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
9526 // path that no host's repo registry resolves.
9527 let d = dep_with_fonte(DepSource::Git {
9528 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
9529 tag: Some("v0.1.0".into()),
9530 rev: None,
9531 branch: None,
9532 });
9533 let err = d.validate().unwrap_err();
9534 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9535 panic!("expected FonteRepoShape, got other variant");
9536 };
9537 assert_eq!(nome, "caixa-teia");
9538 assert_eq!(
9539 repo,
9540 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
9541 );
9542 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
9543 // appears before the ` ` byte at position 21, so the `=`
9544 // arm fires (not the whitespace arm) — both arms guard
9545 // the slot, but the per-byte for-loop scans left-to-right
9546 // and the first matching byte wins.
9547 assert!(
9548 reason.contains("must not contain `=`"),
9549 "reason must surface the equals-`=` arm on the env-var-assignment \
9550 paste shape, got {reason:?}"
9551 );
9552 assert!(
9553 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
9554 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
9555 );
9556 }
9557
9558 #[test]
9559 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
9560 // The symmetric paste-from-gitconfig pin: an author copies
9561 // `url=https://github.com/p/x` from `git config --get-all
9562 // remote.origin.url` output, a `.gitconfig` `[remote
9563 // "origin"] url = https://…` ini-stanza paste, or a
9564 // `git config remote.origin.url <value>` doc snippet,
9565 // intending the `url=` prefix as the ini-key but the typed
9566 // `:repo` slot is a URL value parser, not a gitconfig
9567 // grammar. With no leading whitespace and no earlier-arm
9568 // bytes in the value, the `=` arm itself fires (rather
9569 // than cascading to the whitespace arm as in the env-var
9570 // paste shape). Pinned separately so a future diagnostic-
9571 // surface change that only checked the whitespace-leading
9572 // shape surfaces here — the per-byte arm fires anywhere
9573 // `=` appears in the value.
9574 let d = dep_with_fonte(DepSource::Git {
9575 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
9576 tag: Some("v0.1.0".into()),
9577 rev: None,
9578 branch: None,
9579 });
9580 let err = d.validate().unwrap_err();
9581 let DepError::FonteRepoShape { reason, .. } = err else {
9582 panic!("expected FonteRepoShape, got other variant");
9583 };
9584 assert!(
9585 reason.contains("must not contain `=`"),
9586 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
9587 paste shape, got {reason:?}"
9588 );
9589 assert!(
9590 reason.contains("key-value-separator") || reason.contains("sub-delims"),
9591 "reason must name the key-value-separator / RFC-3986-sub-delims \
9592 rationale, got {reason:?}"
9593 );
9594 }
9595
9596 #[test]
9597 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
9598 // Cascade pin: the fragment-`#` arm and the `=` arm are
9599 // both per-byte arms inside the same `for &b in s.as_bytes()`
9600 // loop, so the byte that appears first in the value's byte
9601 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
9602 // carries both `#` and `=`; the `#` byte appears first, so
9603 // the fragment-`#` arm fires, surfacing the more self-
9604 // locating diagnostic on the byte the author pasted earliest
9605 // in the URL.
9606 let d = dep_with_fonte(DepSource::Git {
9607 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
9608 tag: Some("v0.1.0".into()),
9609 rev: None,
9610 branch: None,
9611 });
9612 let err = d.validate().unwrap_err();
9613 let DepError::FonteRepoShape { reason, .. } = err else {
9614 panic!("expected FonteRepoShape, got other variant");
9615 };
9616 assert!(
9617 reason.contains("must not contain `#`"),
9618 "reason must surface the fragment-`#` arm (fires before equals when \
9619 `#` byte appears first in value), got {reason:?}"
9620 );
9621 }
9622
9623 #[test]
9624 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
9625 // Cascade pin: the comma-`,` arm (the immediate-predecessor
9626 // byte-class arm, 775b80e) and the `=` arm are both per-byte
9627 // arms inside the same `for &b in s.as_bytes()` loop, so
9628 // the byte that appears first in the value's byte order
9629 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
9630 // and `=`; the `,` byte appears first, so the comma arm
9631 // fires, surfacing the more self-locating diagnostic on
9632 // the byte the author pasted earliest in the URL. Pins the
9633 // natural-order cascade so a future reorder of the per-byte
9634 // arms surfaces here — `=` is the most recent byte-class
9635 // arm, so the cascade-pin sweep extends to cover the
9636 // immediately prior `,` byte arm firing first when ordered
9637 // ahead of `=` in the value.
9638 let d = dep_with_fonte(DepSource::Git {
9639 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
9640 tag: Some("v0.1.0".into()),
9641 rev: None,
9642 branch: None,
9643 });
9644 let err = d.validate().unwrap_err();
9645 let DepError::FonteRepoShape { reason, .. } = err else {
9646 panic!("expected FonteRepoShape, got other variant");
9647 };
9648 assert!(
9649 reason.contains("must not contain `,`"),
9650 "reason must surface the comma arm (fires before equals when `,` byte \
9651 appears first in value), got {reason:?}"
9652 );
9653 }
9654
9655 #[test]
9656 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
9657 // The fail-before-pass-after pin for the canonical paste-from-
9658 // browser-address-bar percent-encoded-space footgun on `:repo`.
9659 // An author copies `https://github.com/p/x%20test` from a
9660 // browser address bar (or a percent-encoded README hyperlink,
9661 // or a `curl --data-urlencode` shell-pipeline output)
9662 // intending `%20` as the URL encoding of a literal space; the
9663 // typed `:repo` slot already rejects the literal space byte
9664 // (the whitespace arm at the top of `is_git_repo_url`), so an
9665 // author trying to express "I really meant a space" reaches
9666 // for percent-encoding. Until this arm landed the `%` byte
9667 // silently passed every prior `is_git_repo_url` arm and rode
9668 // verbatim into the lacre's per-dep content-address — but
9669 // libcurl re-percent-encodes `%` to `%25` on the wire (since
9670 // `%` is reserved as the escape-sequence lead-in), so the
9671 // wire request becomes `https://github.com/p/x%2520test`, a
9672 // path the lacre's content-address never names. The classic
9673 // render-determinism violation on the encoding-mechanism axis
9674 // itself.
9675 let d = dep_with_fonte(DepSource::Git {
9676 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
9677 tag: Some("v0.1.0".into()),
9678 rev: None,
9679 branch: None,
9680 });
9681 let err = d.validate().unwrap_err();
9682 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9683 panic!("expected FonteRepoShape, got other variant");
9684 };
9685 assert_eq!(nome, "caixa-teia");
9686 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
9687 assert!(
9688 reason.contains("must not contain `%`"),
9689 "reason must surface the percent-`%` arm on the percent-encoded-space \
9690 paste shape, got {reason:?}"
9691 );
9692 assert!(
9693 reason.contains("percent-encoding") || reason.contains("%25"),
9694 "reason must name the percent-encoding / `%25` re-encoding rationale, \
9695 got {reason:?}"
9696 );
9697 }
9698
9699 #[test]
9700 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
9701 // The symmetric over-encoded-path-separator pin: an author
9702 // writes `:repo "https://github.com/p%2Fx"` intending the
9703 // `%2F` as the URL encoding of `/` (the canonical
9704 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
9705 // footgun every API client library and OAuth redirect-URI
9706 // documentation surfaces — the `/` is the URL-path-separator
9707 // and some templates percent-encode it to escape interpretation
9708 // as a path separator). The GitHub Smart-HTTP transport
9709 // resolves the URL's path-segment grammar before the
9710 // percent-decoding pass, so the value identifies a different
9711 // resource on the wire than the literal-`/` form the lacre's
9712 // content-address must agree with — two authors whose `:repo`
9713 // values differ only in their `/` vs `%2F` presence lock to
9714 // two distinct BLAKE3 closures for the byte-identical upstream
9715 // `git clone`. Pinned separately so a future diagnostic
9716 // surface that only catches the `%20` shape surfaces here too.
9717 let d = dep_with_fonte(DepSource::Git {
9718 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
9719 tag: Some("v0.1.0".into()),
9720 rev: None,
9721 branch: None,
9722 });
9723 let err = d.validate().unwrap_err();
9724 let DepError::FonteRepoShape { reason, .. } = err else {
9725 panic!("expected FonteRepoShape, got other variant");
9726 };
9727 assert!(
9728 reason.contains("must not contain `%`"),
9729 "reason must surface the percent-`%` arm on the over-encoded-path \
9730 shape, got {reason:?}"
9731 );
9732 assert!(
9733 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9734 "reason must name the render-determinism / BLAKE3-closure rationale, \
9735 got {reason:?}"
9736 );
9737 }
9738
9739 #[test]
9740 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
9741 // Cascade pin: the fragment-`#` arm and the `%` arm are both
9742 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9743 // so the byte that appears first in the value's byte order
9744 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
9745 // both `#` and `%`; the `#` byte appears first, so the
9746 // fragment-`#` arm fires, surfacing the more self-locating
9747 // diagnostic on the byte the author pasted earliest in the URL.
9748 let d = dep_with_fonte(DepSource::Git {
9749 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
9750 tag: Some("v0.1.0".into()),
9751 rev: None,
9752 branch: None,
9753 });
9754 let err = d.validate().unwrap_err();
9755 let DepError::FonteRepoShape { reason, .. } = err else {
9756 panic!("expected FonteRepoShape, got other variant");
9757 };
9758 assert!(
9759 reason.contains("must not contain `#`"),
9760 "reason must surface the fragment-`#` arm (fires before percent when \
9761 `#` byte appears first in value), got {reason:?}"
9762 );
9763 }
9764
9765 #[test]
9766 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
9767 // Cascade pin: the equals-`=` arm (the immediate-predecessor
9768 // byte-class arm, acf99af) and the `%` arm are both per-byte
9769 // arms inside the same `for &b in s.as_bytes()` loop, so the
9770 // byte that appears first in the value's byte order wins.
9771 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
9772 // the `=` byte appears first, so the equals arm fires,
9773 // surfacing the more self-locating diagnostic on the byte the
9774 // author pasted earliest in the URL. Pins the natural-order
9775 // cascade so a future reorder of the per-byte arms surfaces
9776 // here — `%` is the most recent byte-class arm, so the
9777 // cascade-pin sweep extends to cover the immediately prior
9778 // `=` byte arm firing first when ordered ahead of `%` in the
9779 // value.
9780 let d = dep_with_fonte(DepSource::Git {
9781 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9782 tag: Some("v0.1.0".into()),
9783 rev: None,
9784 branch: None,
9785 });
9786 let err = d.validate().unwrap_err();
9787 let DepError::FonteRepoShape { reason, .. } = err else {
9788 panic!("expected FonteRepoShape, got other variant");
9789 };
9790 assert!(
9791 reason.contains("must not contain `=`"),
9792 "reason must surface the equals arm (fires before percent when `=` byte \
9793 appears first in value), got {reason:?}"
9794 );
9795 }
9796
9797 #[test]
9798 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9799 // The fail-before-pass-after pin for the canonical paste-from-
9800 // shell-history footgun on `:repo`. An author copies a
9801 // `git clone <url>` line from their terminal followed by a
9802 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9803 // history shorthand (the `^old^new^` form re-runs the prior
9804 // history entry with the first `old` substituted by `new`,
9805 // bash's default behavior on interactive sessions with
9806 // `set -o histexpand`), forgetting to trim the trailing
9807 // `^...^...` shell-history fragment from the URL value. The
9808 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9809 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9810 // classes), the WHATWG URL spec's 'fragment percent-encode
9811 // set' maps `^` → `%5E` on the wire, so the byte rides
9812 // verbatim into the lacre's per-dep content-address but
9813 // libcurl re-encodes it to `%5E` at `git clone` time — the
9814 // classic render-determinism violation on the same axis the
9815 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9816 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9817 // `#` arms close.
9818 let d = dep_with_fonte(DepSource::Git {
9819 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9820 tag: Some("v0.1.0".into()),
9821 rev: None,
9822 branch: None,
9823 });
9824 let err = d.validate().unwrap_err();
9825 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9826 panic!("expected FonteRepoShape, got other variant");
9827 };
9828 assert_eq!(nome, "caixa-teia");
9829 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9830 assert!(
9831 reason.contains("must not contain `^`"),
9832 "reason must surface the caret-`^` arm on the paste-from-shell-history \
9833 shape, got {reason:?}"
9834 );
9835 assert!(
9836 reason.contains("history-substitution") || reason.contains("%5E"),
9837 "reason must name the shell-history-substitution / `%5E` wire-encoding \
9838 rationale, got {reason:?}"
9839 );
9840 }
9841
9842 #[test]
9843 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9844 // The symmetric paste-from-doc-grep-pipeline footgun: an
9845 // author writes `:repo "github:p/^archived"` after copying a
9846 // `grep '^archived'` regex-anchor / negation idiom from a
9847 // doc / README quick-listing snippet, expecting the substrate
9848 // to coerce it to a literal repo name. The byte rides
9849 // verbatim into the lacre's per-dep content-address and
9850 // diverges from the byte-identical literal `archived` form
9851 // every other author authored — the canonical render-
9852 // determinism violation pin on the second footgun shape the
9853 // caret-`^` arm closes.
9854 let d = dep_with_fonte(DepSource::Git {
9855 repo: "github:pleme-io/^archived".into(),
9856 tag: Some("v0.1.0".into()),
9857 rev: None,
9858 branch: None,
9859 });
9860 let err = d.validate().unwrap_err();
9861 let DepError::FonteRepoShape { reason, .. } = err else {
9862 panic!("expected FonteRepoShape, got other variant");
9863 };
9864 assert!(
9865 reason.contains("must not contain `^`"),
9866 "reason must surface the caret-`^` arm on the regex-anchor shape, \
9867 got {reason:?}"
9868 );
9869 assert!(
9870 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9871 "reason must name the render-determinism / BLAKE3-closure rationale, \
9872 got {reason:?}"
9873 );
9874 }
9875
9876 #[test]
9877 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9878 // Cascade pin: the `%` arm (the immediate-predecessor byte-
9879 // class arm, a323db8) and the `^` arm are both per-byte arms
9880 // inside the same `for &b in s.as_bytes()` loop, so the byte
9881 // that appears first in the value's byte order wins. A
9882 // `:repo "https://github.com/p/x%20mid^tail"` carries both
9883 // `%` and `^`; the `%` byte appears first, so the percent
9884 // arm fires, surfacing the more self-locating diagnostic on
9885 // the byte the author pasted earliest in the URL. Pins the
9886 // natural-order cascade so a future reorder of the per-byte
9887 // arms surfaces here — `^` is the most recent byte-class arm,
9888 // so the cascade-pin sweep extends to cover the immediately
9889 // prior `%` byte arm firing first when ordered ahead of `^`
9890 // in the value.
9891 let d = dep_with_fonte(DepSource::Git {
9892 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9893 tag: Some("v0.1.0".into()),
9894 rev: None,
9895 branch: None,
9896 });
9897 let err = d.validate().unwrap_err();
9898 let DepError::FonteRepoShape { reason, .. } = err else {
9899 panic!("expected FonteRepoShape, got other variant");
9900 };
9901 assert!(
9902 reason.contains("must not contain `%`"),
9903 "reason must surface the percent arm (fires before caret when `%` byte \
9904 appears first in value), got {reason:?}"
9905 );
9906 }
9907
9908 #[test]
9909 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9910 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9911 // (no `github:` prefix, no scheme). Every documented form
9912 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9913 // `file://`, or `git@host:path`); a bare `org/repo` is
9914 // ambiguous (`git clone` reads as a relative filesystem path
9915 // rather than the GitHub-shorthand expansion the author
9916 // probably intended) and the gate rejects the shape upstream.
9917 let d = dep_with_fonte(DepSource::Git {
9918 repo: "pleme-io/caixa-teia".into(),
9919 tag: Some("v0.1.0".into()),
9920 rev: None,
9921 branch: None,
9922 });
9923 let err = d.validate().unwrap_err();
9924 let DepError::FonteRepoShape { reason, .. } = err else {
9925 panic!("expected FonteRepoShape, got other variant");
9926 };
9927 assert!(
9928 reason.contains("must contain a `:`"),
9929 "reason must surface the missing-`:` arm, got {reason:?}"
9930 );
9931 assert!(
9932 reason.contains("github:"),
9933 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9934 );
9935 }
9936
9937 #[test]
9938 fn validate_rejects_git_fonte_with_repo_leading_colon() {
9939 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9940 // scheme that no git porcelain entry-point accepts. Pinned
9941 // separately from the missing-`:` arm because a value with a
9942 // leading `:` does technically contain a `:` separator; the
9943 // shape gate rejects on a dedicated arm so the diagnostic
9944 // names the specific footgun.
9945 let d = dep_with_fonte(DepSource::Git {
9946 repo: ":pleme-io/caixa-teia".into(),
9947 tag: Some("v0.1.0".into()),
9948 rev: None,
9949 branch: None,
9950 });
9951 let err = d.validate().unwrap_err();
9952 let DepError::FonteRepoShape { reason, .. } = err else {
9953 panic!("expected FonteRepoShape, got other variant");
9954 };
9955 assert!(
9956 reason.contains("must not start with `:`"),
9957 "reason must surface the leading-`:` arm, got {reason:?}"
9958 );
9959 }
9960
9961 #[test]
9962 fn validate_rejects_git_fonte_with_repo_too_long() {
9963 // The cap arm — a `:repo` value longer than
9964 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9965 // structurally untenable on every realistic landing site (the
9966 // resolver's `git clone` invocation, the future M4 CR
9967 // materializer's per-dep `repo:` axis); a value of that length
9968 // is almost certainly a paste-from-binary slug.
9969 let too_long = format!(
9970 "github:pleme-io/{}",
9971 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9972 );
9973 let d = dep_with_fonte(DepSource::Git {
9974 repo: too_long.clone(),
9975 tag: Some("v0.1.0".into()),
9976 rev: None,
9977 branch: None,
9978 });
9979 let err = d.validate().unwrap_err();
9980 let DepError::FonteRepoShape { reason, .. } = err else {
9981 panic!("expected FonteRepoShape, got other variant");
9982 };
9983 assert!(
9984 reason.contains("2048"),
9985 "reason must name the cap, got {reason:?}"
9986 );
9987 }
9988
9989 #[test]
9990 fn validate_accepts_canonical_git_fonte_repo_shapes() {
9991 // The positive-control sweep: every documented author shape on
9992 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9993 // must pass the value-shape gate. Pinned so a future tightening
9994 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9995 // here as a structural decision. Each form is exercised with the
9996 // same canonical `:tag` pin so only the `:repo` axis varies.
9997 for repo in [
9998 // The pleme-io registry-shorthand convention — `github:org/repo`.
9999 "github:pleme-io/caixa-teia",
10000 // Other host-aliased shorthands (the resolver's pluggable
10001 // host-prefix table).
10002 "gitlab:pleme-io/caixa-teia",
10003 "codeberg:pleme-io/caixa-teia",
10004 "sourcehut:~pleme-io/caixa-teia",
10005 // Full HTTPS URL with and without `.git` suffix.
10006 "https://github.com/pleme-io/caixa-teia",
10007 "https://github.com/pleme-io/caixa-teia.git",
10008 // HTTP (rare; dev / mirror).
10009 "http://example.com/pleme-io/caixa-teia.git",
10010 // SSH URL.
10011 "ssh://git@github.com/pleme-io/caixa-teia.git",
10012 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
10013 // Scp-style SSH — the canonical `git@host:path` short form.
10014 "git@github.com:pleme-io/caixa-teia.git",
10015 "git@git.example.com:team/private.git",
10016 // Anonymous git protocol.
10017 "git://git.example.com/pleme-io/caixa-teia.git",
10018 // Local file URL (dev path).
10019 "file:///tmp/caixa-teia",
10020 ] {
10021 let d = dep_with_fonte(DepSource::Git {
10022 repo: repo.into(),
10023 tag: Some("v0.1.0".into()),
10024 rev: None,
10025 branch: None,
10026 });
10027 d.validate()
10028 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
10029 }
10030 }
10031
10032 #[test]
10033 fn fonte_repo_empty_takes_precedence_over_shape() {
10034 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
10035 // diagnostic; doesn't try to parse the URL shape) fires before
10036 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
10037 // keeps its narrower error message. Mirrors
10038 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
10039 // on the ordering layer.
10040 let d = dep_with_fonte(DepSource::Git {
10041 repo: String::new(),
10042 tag: Some("v0.1.0".into()),
10043 rev: None,
10044 branch: None,
10045 });
10046 let err = d.validate().unwrap_err();
10047 assert!(
10048 matches!(err, DepError::FonteRepoEmpty { .. }),
10049 "got {err:?}"
10050 );
10051 }
10052
10053 #[test]
10054 fn fonte_repo_shape_fires_before_pin_missing() {
10055 // Order pin: a malformed `:repo` value on a dep with no pin set
10056 // surfaces the `:repo` shape diagnostic (the more self-locating
10057 // axis — the `:repo` is the load-bearing identity of the source;
10058 // a missing pin is downstream from "do we even know the repo")
10059 // rather than collapsing onto the pin-missing diagnostic. The
10060 // shape gate runs inline before the pin enumeration in
10061 // `DepSource::validate`.
10062 let d = dep_with_fonte(DepSource::Git {
10063 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
10064 tag: None,
10065 rev: None,
10066 branch: None,
10067 });
10068 let err = d.validate().unwrap_err();
10069 assert!(
10070 matches!(err, DepError::FonteRepoShape { .. }),
10071 "got {err:?}"
10072 );
10073 }
10074
10075 #[test]
10076 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
10077 // The diagnostic-shape pin: the error names the offending
10078 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
10079 // so the author can grep their caixa.lisp without re-running
10080 // the build. Mirrors the diagnostic-shape sweep on every prior
10081 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
10082 let d = dep_with_fonte(DepSource::Git {
10083 repo: "pleme-io/caixa-teia".into(),
10084 tag: Some("v0.1.0".into()),
10085 rev: None,
10086 branch: None,
10087 });
10088 let err = d.validate().unwrap_err();
10089 let DepError::FonteRepoShape { nome, repo, reason } = err else {
10090 panic!("expected FonteRepoShape, got other variant");
10091 };
10092 assert_eq!(nome, "caixa-teia");
10093 assert_eq!(repo, "pleme-io/caixa-teia");
10094 assert!(
10095 !reason.is_empty(),
10096 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
10097 );
10098 }
10099
10100 #[test]
10101 fn validate_rejects_git_fonte_with_no_pin() {
10102 // The fail-before-pass-after pin for the canonical
10103 // `(:tipo git :repo "github:pleme-io/x")` shape with no
10104 // :tag/:rev/:branch — until this gate landed the resolver's
10105 // ResolveError::MissingPin surfaced at fetch time, far from the
10106 // source caixa.lisp. The new gate moves the check to validate
10107 // time and names the offending dep.
10108 let d = dep_with_fonte(DepSource::Git {
10109 repo: "github:pleme-io/caixa-teia".into(),
10110 tag: None,
10111 rev: None,
10112 branch: None,
10113 });
10114 let err = d.validate().unwrap_err();
10115 assert!(
10116 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
10117 "got {err:?}"
10118 );
10119 }
10120
10121 #[test]
10122 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
10123 // The canonical "pin drift" footgun: an author writes
10124 // `:tag "v1"` and later adds `:branch "main"` without removing
10125 // the :tag, and the resolver silently picks :tag (precedence
10126 // :rev > :tag > :branch). The :branch was dropped with no
10127 // diagnostic. The gate now rejects multi-pin shapes so the
10128 // author makes the precedence explicit at the source.
10129 let d = dep_with_fonte(DepSource::Git {
10130 repo: "github:pleme-io/caixa-teia".into(),
10131 tag: Some("v0.1.0".into()),
10132 rev: None,
10133 branch: Some("main".into()),
10134 });
10135 let err = d.validate().unwrap_err();
10136 let DepError::FontePinAmbiguous { nome, pins } = err else {
10137 panic!("expected FontePinAmbiguous");
10138 };
10139 assert_eq!(nome, "caixa-teia");
10140 assert!(pins.contains(":tag"));
10141 assert!(pins.contains(":branch"));
10142 assert!(!pins.contains(":rev"));
10143 }
10144
10145 #[test]
10146 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
10147 // Sibling arm of the pin-drift footgun: :tag + :rev set
10148 // simultaneously. Pinned separately so a future relaxation
10149 // that only catches the (:tag, :branch) pair surfaces here.
10150 let d = dep_with_fonte(DepSource::Git {
10151 repo: "github:pleme-io/caixa-teia".into(),
10152 tag: Some("v0.1.0".into()),
10153 rev: Some("c0ffee".into()),
10154 branch: None,
10155 });
10156 let err = d.validate().unwrap_err();
10157 let DepError::FontePinAmbiguous { nome, pins } = err else {
10158 panic!("expected FontePinAmbiguous");
10159 };
10160 assert_eq!(nome, "caixa-teia");
10161 assert!(pins.contains(":tag"));
10162 assert!(pins.contains(":rev"));
10163 }
10164
10165 #[test]
10166 fn validate_rejects_git_fonte_with_all_three_pins() {
10167 // The maximal ambiguity case — every pin axis set. Pinned so a
10168 // future relaxation that only catches pairs surfaces here. The
10169 // diagnostic must enumerate every offending axis so the author
10170 // sees the full set, not just the first match.
10171 let d = dep_with_fonte(DepSource::Git {
10172 repo: "github:pleme-io/caixa-teia".into(),
10173 tag: Some("v0.1.0".into()),
10174 rev: Some("c0ffee".into()),
10175 branch: Some("main".into()),
10176 });
10177 let err = d.validate().unwrap_err();
10178 let DepError::FontePinAmbiguous { nome, pins } = err else {
10179 panic!("expected FontePinAmbiguous");
10180 };
10181 assert_eq!(nome, "caixa-teia");
10182 assert!(pins.contains(":tag"));
10183 assert!(pins.contains(":rev"));
10184 assert!(pins.contains(":branch"));
10185 }
10186
10187 #[test]
10188 fn validate_rejects_git_fonte_with_empty_tag_pin() {
10189 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
10190 // inner string is empty. Distinct from FontePinMissing (where
10191 // every axis is None) — pinned separately so a future
10192 // tightening collapsing them surfaces here as a structural
10193 // decision.
10194 let d = dep_with_fonte(DepSource::Git {
10195 repo: "github:pleme-io/caixa-teia".into(),
10196 tag: Some(String::new()),
10197 rev: None,
10198 branch: None,
10199 });
10200 let err = d.validate().unwrap_err();
10201 let DepError::FontePinEmpty { nome, pin } = err else {
10202 panic!("expected FontePinEmpty");
10203 };
10204 assert_eq!(nome, "caixa-teia");
10205 assert_eq!(pin, ":tag");
10206 }
10207
10208 #[test]
10209 fn validate_rejects_git_fonte_with_empty_rev_pin() {
10210 // Sibling arm — the empty-pin diagnostic names which axis
10211 // carries the empty value, so the author's grep target is
10212 // unambiguous.
10213 let d = dep_with_fonte(DepSource::Git {
10214 repo: "github:pleme-io/caixa-teia".into(),
10215 tag: None,
10216 rev: Some(String::new()),
10217 branch: None,
10218 });
10219 let err = d.validate().unwrap_err();
10220 let DepError::FontePinEmpty { nome, pin } = err else {
10221 panic!("expected FontePinEmpty");
10222 };
10223 assert_eq!(nome, "caixa-teia");
10224 assert_eq!(pin, ":rev");
10225 }
10226
10227 #[test]
10228 fn validate_rejects_path_fonte_with_empty_caminho() {
10229 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
10230 // until this gate landed the resolver's
10231 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
10232 // fetch time — not actionable. The new gate moves the check to
10233 // validate time and names the offending dep.
10234 let d = dep_with_fonte(DepSource::Path {
10235 caminho: String::new(),
10236 });
10237 let err = d.validate().unwrap_err();
10238 assert!(
10239 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
10240 "got {err:?}"
10241 );
10242 }
10243
10244 #[test]
10245 fn validate_rejects_path_fonte_with_absolute_caminho() {
10246 // The fail-before-pass-after pin for the absolute-`:caminho`
10247 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
10248 // Until this gate landed an absolute `:caminho` silently
10249 // passed validate; the lacre pipeline embedded the
10250 // host-specific filesystem path verbatim in its
10251 // content-address (`conteudo: format!("path:{caminho}")`,
10252 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
10253 // differed per machine — the build succeeded but two CI
10254 // runners with different `${HOME}` layouts emitted two
10255 // distinct lacres for the byte-identical caixa, silently
10256 // breaking the THEORY.md §V.2 render-determinism contract
10257 // far from the source caixa.lisp. The new gate moves the
10258 // check to validate time and names the offending dep +
10259 // caminho verbatim.
10260 let d = dep_with_fonte(DepSource::Path {
10261 caminho: "/home/me/work/caixa-teia".into(),
10262 });
10263 let err = d.validate().unwrap_err();
10264 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
10265 panic!("expected FonteCaminhoAbsolute, got other variant");
10266 };
10267 assert_eq!(nome, "caixa-teia");
10268 assert_eq!(caminho, "/home/me/work/caixa-teia");
10269 }
10270
10271 #[test]
10272 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
10273 // The canonical sibling-workspace dep form
10274 // (`:caminho "../caixa-teia"`) remains accepted. The
10275 // absolute-path gate above is specifically narrower than the
10276 // shared [`crate::render::is_sandboxed_relative_path`]
10277 // predicate (which additionally forbids `..` traversal): a
10278 // local-path dep's canonical author surface is the in-tree
10279 // sibling-workspace path, so a full sandboxed-relative-path
10280 // lift would structurally reject every legitimate path-fonte
10281 // dep. Pinned so a future tightening to the full predicate
10282 // surfaces here as a structural decision, not a silent break.
10283 let d = dep_with_fonte(DepSource::Path {
10284 caminho: "../caixa-teia".into(),
10285 });
10286 d.validate().unwrap();
10287 }
10288
10289 #[test]
10290 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
10291 // A multi-segment relative `:caminho`
10292 // (`"vendor/forks/caixa-teia"`) remains accepted — the
10293 // absolute-path gate brackets the host-layout-leaking shape
10294 // at the leading-`/` boundary only; every relative shape past
10295 // the empty arm continues to pass. Pinned alongside the
10296 // `..`-traversal positive control so a future tightening
10297 // surfaces the full set of legitimate relative forms here
10298 // rather than at a downstream consumer.
10299 let d = dep_with_fonte(DepSource::Path {
10300 caminho: "vendor/forks/caixa-teia".into(),
10301 });
10302 d.validate().unwrap();
10303 }
10304
10305 #[test]
10306 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
10307 // The fail-before-pass-after pin for the tilde-expansion
10308 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
10309 // Until this gate landed the b94fd83 absolute arm let `~/foo`
10310 // through (`Path::is_absolute` returns false on a leading `~`
10311 // — the tilde is a shell-expansion convention, not a POSIX
10312 // path component), so the lacre embedded the value verbatim
10313 // and the resolver folded it through `Path::join` without
10314 // expansion, looking for a literal `./~/work/caixa-teia`
10315 // subdirectory and failing at resolve time with a
10316 // `No such file or directory` error far from the source
10317 // caixa.lisp. The new gate moves the check to validate time
10318 // and names the offending dep + caminho verbatim.
10319 let d = dep_with_fonte(DepSource::Path {
10320 caminho: "~/work/caixa-teia".into(),
10321 });
10322 let err = d.validate().unwrap_err();
10323 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
10324 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
10325 };
10326 assert_eq!(nome, "caixa-teia");
10327 assert_eq!(caminho, "~/work/caixa-teia");
10328 }
10329
10330 #[test]
10331 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
10332 // The bare `~` form (canonical "I meant `$HOME` and forgot
10333 // the rest"): both the leading-tilde arm catches it and the
10334 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
10335 // sweeps through the same arm. Pinned both to ensure the
10336 // gate doesn't narrow to `~/` only.
10337 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
10338 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10339 let err = d.validate().unwrap_err();
10340 assert!(
10341 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10342 "{s:?} → {err:?}",
10343 );
10344 }
10345 }
10346
10347 #[test]
10348 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
10349 // The leading-`~` is the canonical shell-expansion footgun —
10350 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
10351 // backup-file-suffix idiom) is a legitimate POSIX path byte
10352 // with no shell-expansion semantic at the leading position.
10353 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
10354 // sweep that would break every legitimate-shape backup-file
10355 // path.
10356 let d = dep_with_fonte(DepSource::Path {
10357 caminho: "../foo~bar/caixa-teia".into(),
10358 });
10359 d.validate().unwrap();
10360 }
10361
10362 #[test]
10363 fn fonte_caminho_empty_fires_before_tilde_expansion() {
10364 // Cascade pin: the empty arm structurally precedes the
10365 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
10366 // pin establishes the precedence at the diagnostic-shape
10367 // level should a future codec round-trip ever produce a
10368 // probe-as-both value. Mirrors the peer
10369 // `fonte_repo_empty_fires_before_pin_missing` cascade
10370 // discipline.
10371 let d = dep_with_fonte(DepSource::Path {
10372 caminho: String::new(),
10373 });
10374 let err = d.validate().unwrap_err();
10375 assert!(
10376 matches!(err, DepError::FonteCaminhoEmpty { .. }),
10377 "got {err:?}",
10378 );
10379 }
10380
10381 #[test]
10382 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
10383 // Diagnostic-shape pin (peer with
10384 // `validate_rejects_path_fonte_with_absolute_caminho`'s
10385 // payload assertion): the error's Display surfaces both the
10386 // offending `:nome` and the offending `:caminho` verbatim
10387 // so a `feira lint` run can render the diagnostic without
10388 // re-parsing.
10389 let d = dep_with_fonte(DepSource::Path {
10390 caminho: "~alice/dev/caixa-teia".into(),
10391 });
10392 let rendered = d.validate().unwrap_err().to_string();
10393 assert!(
10394 rendered.contains("caixa-teia"),
10395 "diagnostic must name the offending dep: {rendered}",
10396 );
10397 assert!(
10398 rendered.contains("~alice/dev/caixa-teia"),
10399 "diagnostic must quote the offending caminho: {rendered}",
10400 );
10401 assert!(
10402 rendered.contains('~'),
10403 "diagnostic must reference the tilde footgun: {rendered}",
10404 );
10405 }
10406
10407 #[test]
10408 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
10409 // The fail-before-pass-after pin for the shell-variable-
10410 // expansion `:caminho` shape: `(:tipo path :caminho
10411 // "$HOME/work/caixa-teia")`. Until this gate landed the
10412 // b94fd83 absolute arm + the a5c248e tilde arm both let
10413 // `$HOME/foo` through (`Path::is_absolute` returns false on
10414 // a leading `$` — the `$` is a shell convention, not a POSIX
10415 // path component; `starts_with('~')` returns false too), so
10416 // the lacre embedded the value verbatim and the resolver
10417 // folded it through `Path::join` without `$`-expansion,
10418 // looking for a literal `./$HOME/work/caixa-teia`
10419 // subdirectory and failing at resolve time with a
10420 // `No such file or directory` error far from the source
10421 // caixa.lisp. The new gate moves the check to validate time
10422 // and names the offending dep + caminho verbatim.
10423 let d = dep_with_fonte(DepSource::Path {
10424 caminho: "$HOME/work/caixa-teia".into(),
10425 });
10426 let err = d.validate().unwrap_err();
10427 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
10428 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
10429 };
10430 assert_eq!(nome, "caixa-teia");
10431 assert_eq!(caminho, "$HOME/work/caixa-teia");
10432 }
10433
10434 #[test]
10435 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
10436 // Sweep over every leading-`$` shape: the `${VAR}`-braced
10437 // form (canonical "paste-from-CI-manifest" footgun every
10438 // GitHub Actions / GitLab CI / Drone manifest carries on
10439 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
10440 // canonical "I'm referencing a per-user config dir"),
10441 // and the bare `$` (canonical "I meant `$HOME` and forgot
10442 // the rest"). All shapes route through the same gate's
10443 // byte check. Pinned so the gate doesn't narrow to a
10444 // single shape (e.g. `$HOME/` only).
10445 for s in [
10446 "${HOME}/work/caixa-teia",
10447 "${WORKSPACE}/caixa-teia",
10448 "$XDG_CONFIG_HOME/caixa",
10449 "$",
10450 ] {
10451 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10452 let err = d.validate().unwrap_err();
10453 assert!(
10454 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10455 "{s:?} → {err:?}",
10456 );
10457 }
10458 }
10459
10460 #[test]
10461 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
10462 // The `$` byte is the canonical shell-variable-expansion /
10463 // command-substitution / arithmetic-expansion sentinel and
10464 // is rejected at *every* position on the `:caminho` axis: the
10465 // leading arm surfaces `FonteCaminhoVarExpansion`, the
10466 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
10467 // (6620f39). Pinned so a future arm doesn't narrow the gate
10468 // back to the leading position and re-open the paste-from-
10469 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
10470 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
10471 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
10472 // the lacre content-address (`path:{caminho}`,
10473 // caixa-resolver/src/resolve.rs:189).
10474 let d = dep_with_fonte(DepSource::Path {
10475 caminho: "../foo$bar/caixa-teia".into(),
10476 });
10477 let err = d.validate().unwrap_err();
10478 assert!(
10479 matches!(
10480 err,
10481 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
10482 ),
10483 "got {err:?}",
10484 );
10485 }
10486
10487 #[test]
10488 fn fonte_caminho_tilde_fires_before_var_expansion() {
10489 // Cascade pin: the tilde arm structurally precedes the var
10490 // arm (the bytes `~` and `$` don't overlap at the leading
10491 // position), but the pin establishes the precedence at the
10492 // diagnostic-shape level should a future codec round-trip
10493 // ever produce a probe-as-both value. Mirrors the peer
10494 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
10495 // discipline on the immediate-predecessor arm.
10496 let d = dep_with_fonte(DepSource::Path {
10497 caminho: "~/work/caixa-teia".into(),
10498 });
10499 let err = d.validate().unwrap_err();
10500 assert!(
10501 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10502 "got {err:?}",
10503 );
10504 }
10505
10506 #[test]
10507 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
10508 // Diagnostic-shape pin (peer with
10509 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
10510 // payload assertion on the immediate-predecessor arm): the
10511 // error's Display surfaces both the offending `:nome` and
10512 // the offending `:caminho` verbatim plus the `$` footgun
10513 // character itself so a `feira lint` run can render the
10514 // diagnostic without re-parsing.
10515 let d = dep_with_fonte(DepSource::Path {
10516 caminho: "${WORKSPACE}/caixa-teia".into(),
10517 });
10518 let rendered = d.validate().unwrap_err().to_string();
10519 assert!(
10520 rendered.contains("caixa-teia"),
10521 "diagnostic must name the offending dep: {rendered}",
10522 );
10523 assert!(
10524 rendered.contains("${WORKSPACE}/caixa-teia"),
10525 "diagnostic must quote the offending caminho: {rendered}",
10526 );
10527 assert!(
10528 rendered.contains('$'),
10529 "diagnostic must reference the dollar footgun: {rendered}",
10530 );
10531 }
10532
10533 #[test]
10534 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
10535 // The fail-before-pass-after pin for the load-bearing NUL byte:
10536 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
10537 // routes the path through `CString::new` which fails with
10538 // `NulError`); until this gate landed a `:caminho
10539 // "../caixa\0teia"` silently passed validate, the lacre
10540 // pipeline embedded the value verbatim, and the failure
10541 // surfaced at the resolver's `Path::join` → `CString::new`
10542 // boundary with a non-self-locating `NulError` far from the
10543 // source caixa.lisp. The new gate moves the check to validate
10544 // time and names the offending dep + caminho + offending byte
10545 // verbatim.
10546 let d = dep_with_fonte(DepSource::Path {
10547 caminho: "../caixa\0teia".into(),
10548 });
10549 let err = d.validate().unwrap_err();
10550 let DepError::FonteCaminhoControlChar {
10551 nome,
10552 caminho,
10553 byte,
10554 } = err
10555 else {
10556 panic!("expected FonteCaminhoControlChar, got {err:?}");
10557 };
10558 assert_eq!(nome, "caixa-teia");
10559 assert_eq!(caminho, "../caixa\0teia");
10560 assert_eq!(byte, 0x00);
10561 }
10562
10563 #[test]
10564 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
10565 // The canonical paste-from-multiline-doc footgun on `:caminho`
10566 // — author copies `"../caixa-teia\n"` (trailing newline) out
10567 // of a multi-line code-fence or, worse, a `:caminho
10568 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
10569 // injection sibling on the path axis the `is_git_repo_url`
10570 // control-char arm already closes on `:repo`). Pinned
10571 // separately from the NUL arm so a future relaxation that
10572 // catches one but not the other surfaces here.
10573 let d = dep_with_fonte(DepSource::Path {
10574 caminho: "../caixa-teia\n".into(),
10575 });
10576 let err = d.validate().unwrap_err();
10577 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10578 panic!("expected FonteCaminhoControlChar, got {err:?}");
10579 };
10580 assert_eq!(byte, 0x0A);
10581 }
10582
10583 #[test]
10584 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
10585 // The CRLF sibling of the LF arm — Windows-line-ending
10586 // paste-from-multiline-doc on a `\r\n`-terminated buffer
10587 // leaves a stray `\r` mid-string after the LF strip. Pinned
10588 // separately from the LF arm so a future relaxation that
10589 // only catches LF surfaces here.
10590 let d = dep_with_fonte(DepSource::Path {
10591 caminho: "../caixa-teia\r".into(),
10592 });
10593 let err = d.validate().unwrap_err();
10594 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10595 panic!("expected FonteCaminhoControlChar, got {err:?}");
10596 };
10597 assert_eq!(byte, 0x0D);
10598 }
10599
10600 #[test]
10601 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
10602 // The canonical paste-from-aligned-table footgun — a `\t`
10603 // mid-`:caminho` is invisible in most editors but rides
10604 // through the lacre's content-address verbatim, so two
10605 // paste-from-distinct-tables (one editor strips tabs, one
10606 // preserves them) yield divergent lacres for the byte-
10607 // identical-looking caixa. Pinned separately from the
10608 // whitespace-shaped LF/CR arms so a future relaxation that
10609 // narrows to line-terminator-only surfaces here.
10610 let d = dep_with_fonte(DepSource::Path {
10611 caminho: "../caixa\tteia".into(),
10612 });
10613 let err = d.validate().unwrap_err();
10614 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10615 panic!("expected FonteCaminhoControlChar, got {err:?}");
10616 };
10617 assert_eq!(byte, 0x09);
10618 }
10619
10620 #[test]
10621 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
10622 // The DEL byte (`0x7F`) closes the upper-end paste-from-
10623 // binary-blob footgun — the gate's contract is `b < 0x20 ||
10624 // b == 0x7F`, matching the `is_git_repo_url` /
10625 // `is_git_ref_name` predicates' control-char arms. Pinned
10626 // separately from the lower-range arms so a future narrowing
10627 // to `< 0x20` only surfaces here.
10628 let d = dep_with_fonte(DepSource::Path {
10629 caminho: "../caixa\x7fteia".into(),
10630 });
10631 let err = d.validate().unwrap_err();
10632 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10633 panic!("expected FonteCaminhoControlChar, got {err:?}");
10634 };
10635 assert_eq!(byte, 0x7F);
10636 }
10637
10638 #[test]
10639 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
10640 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
10641 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
10642 // are opaque byte sequences and UTF-8 multi-byte sequences
10643 // are a legitimate filename shape (the `café-teia/foo` idiom).
10644 // Pinned so the gate doesn't widen to a full ASCII-only sweep
10645 // that would break every legitimate-shape UTF-8 path.
10646 let d = dep_with_fonte(DepSource::Path {
10647 caminho: "../café-teia/foo".into(),
10648 });
10649 d.validate().unwrap();
10650 }
10651
10652 #[test]
10653 fn fonte_caminho_var_fires_before_control_char() {
10654 // Cascade pin: the var-expansion arm structurally precedes the
10655 // control-char arm. A value like `"$\n"` probes positive on
10656 // both arms (`starts_with('$')` and contains LF), but the
10657 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
10658 // wins so the author sees the more self-locating shell-
10659 // expansion arm first. Mirrors the
10660 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10661 // discipline on the immediate-predecessor arm.
10662 let d = dep_with_fonte(DepSource::Path {
10663 caminho: "$HOME\n".into(),
10664 });
10665 let err = d.validate().unwrap_err();
10666 assert!(
10667 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10668 "got {err:?}",
10669 );
10670 }
10671
10672 #[test]
10673 fn validate_rejects_path_fonte_with_leading_space_caminho() {
10674 // The fail-before-pass-after pin for the leading ASCII space
10675 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
10676 // Until this gate landed the b94fd83 absolute arm + the a5c248e
10677 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
10678 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
10679 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
10680 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
10681 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
10682 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
10683 // are caught, but the most common whitespace `0x20` space is
10684 // not). The lacre embedded the value verbatim and the resolver
10685 // folded it through `Path::join` looking for a literal `./ ../
10686 // caixa-teia` subdirectory and failing at resolve time with a
10687 // non-self-locating `No such file or directory` error far from
10688 // the source caixa.lisp. The new gate moves the check to
10689 // validate time and names the offending dep + caminho verbatim.
10690 let d = dep_with_fonte(DepSource::Path {
10691 caminho: " ../caixa-teia".into(),
10692 });
10693 let err = d.validate().unwrap_err();
10694 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
10695 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
10696 };
10697 assert_eq!(nome, "caixa-teia");
10698 assert_eq!(caminho, " ../caixa-teia");
10699 }
10700
10701 #[test]
10702 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
10703 // The aligned-doc paste footgun sweep: more than one leading
10704 // space (`" ../caixa-teia"` — the canonical "I selected the
10705 // aligned column from a four-`:fonte`-entry `:deps` block"
10706 // paste) routes through the same gate's `starts_with(' ')`
10707 // byte check. Pinned so the gate doesn't narrow to a
10708 // single-space prefix.
10709 let d = dep_with_fonte(DepSource::Path {
10710 caminho: " ../caixa-teia".into(),
10711 });
10712 let err = d.validate().unwrap_err();
10713 assert!(
10714 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10715 "got {err:?}",
10716 );
10717 }
10718
10719 #[test]
10720 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
10721 // The leading-space is the canonical paste-from-aligned-doc
10722 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
10723 // canonical "I have a directory with a space in its name"
10724 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
10725 // legitimate path with no whitespace-leak semantic at the
10726 // non-leading position. Pinned so the gate doesn't widen to a
10727 // full no-space-anywhere sweep that would break every
10728 // legitimate-shape space-in-filename path.
10729 let d = dep_with_fonte(DepSource::Path {
10730 caminho: "../my dir/caixa-teia".into(),
10731 });
10732 d.validate().unwrap();
10733 }
10734
10735 #[test]
10736 fn fonte_caminho_var_fires_before_leading_whitespace() {
10737 // Cascade pin: the var-expansion arm structurally precedes the
10738 // leading-whitespace arm. A value like `"$ "` would probe positive
10739 // on var (`starts_with('$')`) but the leading-byte arms walk
10740 // left-to-right so the var arm fires on the leading `$` before
10741 // the leading-whitespace arm probes. Mirrors the
10742 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10743 // discipline on the immediate-predecessor arms.
10744 let d = dep_with_fonte(DepSource::Path {
10745 caminho: "$VAR".into(),
10746 });
10747 let err = d.validate().unwrap_err();
10748 assert!(
10749 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10750 "got {err:?}",
10751 );
10752 }
10753
10754 #[test]
10755 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
10756 // Cascade pin: the leading-whitespace arm structurally precedes
10757 // the control-char arm. A value like `" ../foo\n"` probes
10758 // positive on both (starts with space AND contains LF), but
10759 // the narrower leading-byte diagnostic
10760 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
10761 // more self-locating paste-from-aligned-doc arm first. Mirrors
10762 // the `fonte_caminho_var_fires_before_control_char` cascade
10763 // discipline on the immediate-predecessor arm.
10764 let d = dep_with_fonte(DepSource::Path {
10765 caminho: " ../foo\n".into(),
10766 });
10767 let err = d.validate().unwrap_err();
10768 assert!(
10769 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10770 "got {err:?}",
10771 );
10772 }
10773
10774 #[test]
10775 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10776 // Diagnostic-shape pin (peer with
10777 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10778 // payload assertion on the immediate-predecessor arm): the
10779 // error's Display surfaces both the offending `:nome` and the
10780 // offending `:caminho` verbatim, so a `feira lint` run can
10781 // render the diagnostic without re-parsing and the author can
10782 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10783 // one edit.
10784 let d = dep_with_fonte(DepSource::Path {
10785 caminho: " ../caixa-teia".into(),
10786 });
10787 let rendered = d.validate().unwrap_err().to_string();
10788 assert!(
10789 rendered.contains("caixa-teia"),
10790 "diagnostic must name the offending dep: {rendered}",
10791 );
10792 assert!(
10793 rendered.contains(" ../caixa-teia"),
10794 "diagnostic must quote the offending caminho: {rendered}",
10795 );
10796 assert!(
10797 rendered.contains("space"),
10798 "diagnostic must name the space footgun: {rendered}",
10799 );
10800 }
10801
10802 #[test]
10803 fn fonte_caminho_absolute_fires_before_control_char() {
10804 // Cascade pin on the sibling leading-byte arm: a leading `/`
10805 // value with embedded control byte (`"/etc/passwd\n"`) routes
10806 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10807 // — the host-layout-leak diagnostic is the load-bearing axis,
10808 // the control byte is the secondary observation. Same precedence
10809 // logic on every prior leading-byte arm.
10810 let d = dep_with_fonte(DepSource::Path {
10811 caminho: "/etc/passwd\n".into(),
10812 });
10813 let err = d.validate().unwrap_err();
10814 assert!(
10815 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10816 "got {err:?}",
10817 );
10818 }
10819
10820 #[test]
10821 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10822 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10823 // injection `:caminho` shape sweep. Until this gate landed
10824 // every prior leading-byte arm passed a leading-`-` value
10825 // through: `Path::is_absolute` returns false on `-` (the
10826 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10827 // `starts_with('$')` / `starts_with(' ')` all return false,
10828 // and `0x2D` sits outside the control-byte set. The lacre
10829 // embedded the value verbatim and the resolver folded it
10830 // through `Path::join` looking for a literal `./-rf` /
10831 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10832 // `Path::join` time is non-self-locating but harmless, while
10833 // the failure at every downstream `git -C {caminho}` /
10834 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10835 // is arbitrary-CLI-arg-injection because none of those
10836 // porcelains carry a `--` argument-list terminator between
10837 // the flag block and the path argument. The new arm moves the
10838 // rejection to `Caixa::from_lisp` boundary time and names
10839 // the offending dep + caminho verbatim.
10840 //
10841 // Sweep spans the canonical CLI-arg-injection shapes matching
10842 // the peer sweep on the sibling `is_git_ref_name` /
10843 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10844 // `find -rf` reinterpretation vector), `-C` (the `git -C`
10845 // change-directory-config-injection paste), long-flag
10846 // `--upload-pack=cat /etc/passwd` (the canonical
10847 // arbitrary-command-execution vector on every git porcelain
10848 // entry point), git-config-injection `--config=core.merge=ours`,
10849 // and the degenerate single-byte `-` value.
10850 for caminho in [
10851 "-rf",
10852 "-C",
10853 "--upload-pack=cat /etc/passwd",
10854 "--config=core.merge=ours",
10855 "-",
10856 ] {
10857 let d = dep_with_fonte(DepSource::Path {
10858 caminho: caminho.into(),
10859 });
10860 let err = d.validate().unwrap_err();
10861 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10862 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10863 };
10864 assert_eq!(nome, "caixa-teia");
10865 assert_eq!(got, caminho);
10866 }
10867 }
10868
10869 #[test]
10870 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10871 // The leading-`-` is the canonical CLI-arg-injection footgun
10872 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10873 // canonical kebab-separator-between-alphanumeric-segments
10874 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10875 // — a mid-path segment starting with `-`, still a legitimate
10876 // POSIX filename byte at that non-leading position because the
10877 // subprocess reads the whole `{caminho}` value as one positional
10878 // argument, so only the very first byte of the composite path
10879 // string is at the CLI-arg-injection boundary) is a legitimate
10880 // path with no CLI-flag-reinterpretation semantic at the non-
10881 // leading position of the top-level value. Pinned so the gate
10882 // doesn't widen to a full no-`-`-anywhere sweep that would
10883 // break every legitimate-shape kebab-in-filename path (i.e.
10884 // essentially every sibling-workspace caixa dep).
10885 for caminho in [
10886 "../caixa-teia",
10887 "../caixa-teia/-hidden",
10888 "./my-lib",
10889 "../foo-bar/baz",
10890 ] {
10891 let d = dep_with_fonte(DepSource::Path {
10892 caminho: caminho.into(),
10893 });
10894 d.validate()
10895 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10896 }
10897 }
10898
10899 #[test]
10900 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10901 // Cascade pin: the leading-whitespace arm structurally precedes
10902 // the leading-hyphen arm. A value like `" -rf"` probes positive
10903 // on both (leading space AND, one byte in, a `-` — though the
10904 // leading-hyphen arm probes only the very first byte so it
10905 // wouldn't fire on this value; the pin instead documents the
10906 // arm order on the more common "leading space then a hyphen"
10907 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10908 // The narrower leading-space diagnostic (the paste-from-aligned-
10909 // doc footgun) wins so the author sees the more self-locating
10910 // whitespace arm first. Mirrors the
10911 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10912 // discipline on the immediate-predecessor arm.
10913 let d = dep_with_fonte(DepSource::Path {
10914 caminho: " -rf".into(),
10915 });
10916 let err = d.validate().unwrap_err();
10917 assert!(
10918 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10919 "got {err:?}",
10920 );
10921 }
10922
10923 #[test]
10924 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10925 // Cascade pin: the leading-hyphen arm structurally precedes
10926 // the control-char arm. A value like `"-rf\n"` probes positive
10927 // on both (starts with `-` AND contains LF), but the narrower
10928 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10929 // the author sees the more self-locating CLI-arg-injection arm
10930 // first. Mirrors the
10931 // `fonte_caminho_leading_whitespace_fires_before_control_char`
10932 // cascade discipline on the immediate-predecessor arm.
10933 let d = dep_with_fonte(DepSource::Path {
10934 caminho: "-rf\n".into(),
10935 });
10936 let err = d.validate().unwrap_err();
10937 assert!(
10938 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10939 "got {err:?}",
10940 );
10941 }
10942
10943 #[test]
10944 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10945 // Diagnostic-shape pin (peer with
10946 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10947 // payload assertion on the immediate-predecessor arm): the
10948 // error's Display surfaces both the offending `:nome` and the
10949 // offending `:caminho` verbatim plus the CLI-argument-injection
10950 // vocabulary, so a `feira lint` run can render the diagnostic
10951 // without re-parsing and the author can grep their caixa.lisp
10952 // for `:caminho "<value>"` and fix it in one edit.
10953 let d = dep_with_fonte(DepSource::Path {
10954 caminho: "--upload-pack=cat /etc/passwd".into(),
10955 });
10956 let rendered = d.validate().unwrap_err().to_string();
10957 assert!(
10958 rendered.contains("caixa-teia"),
10959 "diagnostic must name the offending dep: {rendered}",
10960 );
10961 assert!(
10962 rendered.contains("--upload-pack=cat /etc/passwd"),
10963 "diagnostic must quote the offending caminho: {rendered}",
10964 );
10965 assert!(
10966 rendered.contains("CLI-argument-injection"),
10967 "diagnostic must name the CLI-argument-injection vector: {rendered}",
10968 );
10969 assert!(
10970 rendered.contains("`-`"),
10971 "diagnostic must name the offending byte: {rendered}",
10972 );
10973 }
10974
10975 #[test]
10976 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10977 // Diagnostic-shape pin (peer with
10978 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10979 // payload assertion on the immediate-predecessor arm): the
10980 // error's Display surfaces the offending `:nome`, the
10981 // offending `:caminho` verbatim, and the offending byte in
10982 // hex form (`0x09` for tab) so a `feira lint` run can render
10983 // the diagnostic without re-parsing.
10984 let d = dep_with_fonte(DepSource::Path {
10985 caminho: "../caixa\tteia".into(),
10986 });
10987 let rendered = d.validate().unwrap_err().to_string();
10988 assert!(
10989 rendered.contains("caixa-teia"),
10990 "diagnostic must name the offending dep: {rendered}",
10991 );
10992 assert!(
10993 rendered.contains("../caixa\tteia"),
10994 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10995 );
10996 assert!(
10997 rendered.contains("0x09"),
10998 "diagnostic must name the offending byte in hex: {rendered:?}",
10999 );
11000 }
11001
11002 #[test]
11003 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
11004 // The fail-before-pass-after pin for the canonical Windows-
11005 // path-separator paste footgun: an author who pastes a path
11006 // from Windows-Explorer's `Copy as path`, PowerShell's
11007 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
11008 // produces `..\caixa-teia`-shape values that silently passed
11009 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
11010 // false; `\` is neither a leading-byte sentinel nor a
11011 // control byte). On POSIX resolvers the value rides through
11012 // `Path::join` as a literal directory name and fails at
11013 // resolve time with `No such file or directory`; on Windows
11014 // resolvers the value resolves to the parent's sibling — two
11015 // distinct directories for the byte-identical caixa.lisp.
11016 // The new arm moves the rejection to validate time and names
11017 // the offending dep + caminho verbatim.
11018 let d = dep_with_fonte(DepSource::Path {
11019 caminho: "..\\caixa-teia".into(),
11020 });
11021 let err = d.validate().unwrap_err();
11022 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
11023 panic!("expected FonteCaminhoBackslash, got {err:?}");
11024 };
11025 assert_eq!(nome, "caixa-teia");
11026 assert_eq!(caminho, "..\\caixa-teia");
11027 }
11028
11029 #[test]
11030 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
11031 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
11032 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
11033 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
11034 // false (POSIX absolute paths start with `/`, drive letters
11035 // are not a POSIX concept), so the b94fd83 absolute arm
11036 // doesn't fire; the value contains `\` bytes that this arm
11037 // now catches with the more self-locating Windows-path-
11038 // separator diagnostic. Pinned separately from the bare
11039 // `..\caixa-teia` shape so a future arm that targets only
11040 // leading-`..\` doesn't regress the drive-letter coverage.
11041 let d = dep_with_fonte(DepSource::Path {
11042 caminho: "C:\\work\\caixa-teia".into(),
11043 });
11044 let err = d.validate().unwrap_err();
11045 assert!(
11046 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11047 "got {err:?}",
11048 );
11049 }
11050
11051 #[test]
11052 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
11053 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
11054 // PowerShell tab-completion-on-a-directory append). Pinned
11055 // separately from the embedded-`\` shape so the gate's
11056 // contract is "any `\` anywhere", not "any `\` not at end".
11057 let d = dep_with_fonte(DepSource::Path {
11058 caminho: "..\\caixa-teia\\".into(),
11059 });
11060 let err = d.validate().unwrap_err();
11061 assert!(
11062 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11063 "got {err:?}",
11064 );
11065 }
11066
11067 #[test]
11068 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
11069 // The positive-control pin: the gate targets `\` only,
11070 // never `/`. The canonical relative POSIX path
11071 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
11072 // so legitimate nested-directory deps aren't broken. Pinned
11073 // so the gate doesn't accidentally widen to a "no path
11074 // separators at all" sweep.
11075 let d = dep_with_fonte(DepSource::Path {
11076 caminho: "../caixa-teia/foo/bar".into(),
11077 });
11078 d.validate().unwrap();
11079 }
11080
11081 #[test]
11082 fn fonte_caminho_control_char_fires_before_backslash() {
11083 // Cascade pin: the control-char arm structurally precedes the
11084 // backslash arm. A value like `"..\caixa\0teia"` probes
11085 // positive on both (`\` byte + NUL byte), but the control-
11086 // char diagnostic wins so the author sees the more self-
11087 // locating POSIX-syscall-rejected-byte diagnostic first
11088 // (NUL outright breaks `CString::new` at every `std::fs`
11089 // syscall boundary; the `\` divergence is the cross-OS-
11090 // separator axis). Mirrors the
11091 // `fonte_caminho_var_fires_before_control_char` cascade
11092 // discipline on the immediate-predecessor arm.
11093 let d = dep_with_fonte(DepSource::Path {
11094 caminho: "..\\caixa\0teia".into(),
11095 });
11096 let err = d.validate().unwrap_err();
11097 assert!(
11098 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11099 "got {err:?}",
11100 );
11101 }
11102
11103 #[test]
11104 fn fonte_caminho_absolute_fires_before_backslash() {
11105 // Cascade pin on the load-bearing leading-byte arm: a leading
11106 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
11107 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
11108 // — the host-layout-leak diagnostic is the load-bearing
11109 // axis, the `\` byte is the secondary observation. Same
11110 // precedence logic as every prior leading-byte arm.
11111 let d = dep_with_fonte(DepSource::Path {
11112 caminho: "/etc/passwd\\foo".into(),
11113 });
11114 let err = d.validate().unwrap_err();
11115 assert!(
11116 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11117 "got {err:?}",
11118 );
11119 }
11120
11121 #[test]
11122 fn fonte_caminho_var_fires_before_backslash() {
11123 // Cascade pin on the var-expansion arm: a leading-`$` value
11124 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
11125 // PowerShell-env-var paste-from-CI-manifest footgun) routes
11126 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
11127 // The shell-expansion diagnostic is the more self-locating
11128 // axis since both the leading `$` and the embedded `\`
11129 // are Windows-shell artifacts but the `$` is the root-cause
11130 // surface (an author who removes the `$` is likely to leave
11131 // the `\` too).
11132 let d = dep_with_fonte(DepSource::Path {
11133 caminho: "$WORKSPACE\\caixa-teia".into(),
11134 });
11135 let err = d.validate().unwrap_err();
11136 assert!(
11137 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11138 "got {err:?}",
11139 );
11140 }
11141
11142 #[test]
11143 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
11144 // Diagnostic-shape pin (peer with the prior
11145 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
11146 // on every preceding arm): the error's Display surfaces the
11147 // offending `:nome` and the offending `:caminho` verbatim
11148 // so a `feira lint` run can render the diagnostic without
11149 // re-parsing.
11150 let d = dep_with_fonte(DepSource::Path {
11151 caminho: "..\\caixa-teia".into(),
11152 });
11153 let rendered = d.validate().unwrap_err().to_string();
11154 assert!(
11155 rendered.contains("caixa-teia"),
11156 "diagnostic must name the offending dep: {rendered}",
11157 );
11158 assert!(
11159 rendered.contains("..\\caixa-teia"),
11160 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11161 );
11162 assert!(
11163 rendered.contains('\\'),
11164 "diagnostic must reference the backslash footgun: {rendered:?}",
11165 );
11166 }
11167
11168 #[test]
11169 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
11170 // The fail-before-pass-after pin for the canonical trailing-`/`
11171 // paste footgun: an author who shell-tab-completes a sibling
11172 // directory (every interactive shell — bash/zsh/fish/nushell —
11173 // appends `/` on tab-completing a directory) produces
11174 // `"../caixa-teia/"`-shape values that silently passed every
11175 // prior arm (the leading byte is `.`, no control bytes, no
11176 // backslash). `Path::join` resolves both shapes to the same
11177 // directory at the resolver, but the lacre embeds the value
11178 // verbatim and the BLAKE3 closures diverge across two
11179 // workstations whose authors differ only in tab-completion
11180 // habits.
11181 let d = dep_with_fonte(DepSource::Path {
11182 caminho: "../caixa-teia/".into(),
11183 });
11184 let err = d.validate().unwrap_err();
11185 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
11186 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
11187 };
11188 assert_eq!(nome, "caixa-teia");
11189 assert_eq!(caminho, "../caixa-teia/");
11190 }
11191
11192 #[test]
11193 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
11194 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
11195 // directory and tab-completed it" footgun). Pinned separately
11196 // from the canonical `"../caixa-teia/"` shape so the gate's
11197 // contract is "any trailing `/`", not "trailing `/` after a leaf
11198 // name".
11199 let d = dep_with_fonte(DepSource::Path {
11200 caminho: "./".into(),
11201 });
11202 let err = d.validate().unwrap_err();
11203 assert!(
11204 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
11205 "got {err:?}",
11206 );
11207 }
11208
11209 #[test]
11210 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
11211 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
11212 // that double-templated `${VAR}/` over an already-`/`-suffixed
11213 // path" footgun). The gate fires on the last byte being `/`
11214 // regardless of how many `/` precede it; the arm contract is
11215 // "the value ends with `/`", structurally.
11216 let d = dep_with_fonte(DepSource::Path {
11217 caminho: "../caixa-teia//".into(),
11218 });
11219 let err = d.validate().unwrap_err();
11220 assert!(
11221 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
11222 "got {err:?}",
11223 );
11224 }
11225
11226 #[test]
11227 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
11228 // The `"../"` shape (the canonical "I want the parent" tab-
11229 // completion footgun on a bare `..` path). Pinned separately so
11230 // the gate doesn't accidentally narrow to "trailing `/` only on
11231 // multi-segment paths".
11232 let d = dep_with_fonte(DepSource::Path {
11233 caminho: "../".into(),
11234 });
11235 let err = d.validate().unwrap_err();
11236 assert!(
11237 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
11238 "got {err:?}",
11239 );
11240 }
11241
11242 #[test]
11243 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
11244 // The positive-control pin: the gate targets the trailing byte
11245 // only, never internal `/` separators. The canonical nested
11246 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
11247 // to validate cleanly so legitimate deeply-nested deps aren't
11248 // broken. Pinned so the gate doesn't accidentally widen to a
11249 // "no `/` separators anywhere" sweep that would defeat the
11250 // entire path-fonte author surface.
11251 let d = dep_with_fonte(DepSource::Path {
11252 caminho: "../caixa-teia/foo/bar".into(),
11253 });
11254 d.validate().unwrap();
11255 }
11256
11257 #[test]
11258 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
11259 // The positive-control pin on the degenerate single-`.` shape
11260 // (the canonical "the caixa.lisp's own directory" idiom). The
11261 // gate fires on the trailing byte being `/`, not on the path
11262 // being short, so `"."` (one byte, not `/`) must continue to
11263 // validate cleanly.
11264 let d = dep_with_fonte(DepSource::Path {
11265 caminho: ".".into(),
11266 });
11267 d.validate().unwrap();
11268 }
11269
11270 #[test]
11271 fn fonte_caminho_control_char_fires_before_trailing_slash() {
11272 // Cascade pin: the control-char arm structurally precedes the
11273 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
11274 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
11275 // (control bytes are the paste-from-multiline-doc footgun the
11276 // d624c8d arm already closes). Mirrors the
11277 // `fonte_caminho_control_char_fires_before_backslash` cascade
11278 // discipline on the immediate-predecessor arm.
11279 let d = dep_with_fonte(DepSource::Path {
11280 caminho: "../foo\n/".into(),
11281 });
11282 let err = d.validate().unwrap_err();
11283 assert!(
11284 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11285 "got {err:?}",
11286 );
11287 }
11288
11289 #[test]
11290 fn fonte_caminho_backslash_fires_before_trailing_slash() {
11291 // Cascade pin on the backslash arm: a value like `"..\foo/"`
11292 // ends in `/` but the embedded `\` is the load-bearing
11293 // diagnostic (the cross-host-OS-separator divergence vector
11294 // the 3a4e1d7 arm closes). Same precedence logic as the prior
11295 // narrower-diagnostic-first cascade.
11296 let d = dep_with_fonte(DepSource::Path {
11297 caminho: "..\\caixa-teia/".into(),
11298 });
11299 let err = d.validate().unwrap_err();
11300 assert!(
11301 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11302 "got {err:?}",
11303 );
11304 }
11305
11306 #[test]
11307 fn fonte_caminho_absolute_fires_before_trailing_slash() {
11308 // Cascade pin on the load-bearing leading-byte arm: a leading
11309 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
11310 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
11311 // — the host-layout-leak diagnostic is the load-bearing axis,
11312 // the trailing `/` is the secondary observation. Same
11313 // precedence logic as every prior leading-byte arm.
11314 let d = dep_with_fonte(DepSource::Path {
11315 caminho: "/etc/passwd/".into(),
11316 });
11317 let err = d.validate().unwrap_err();
11318 assert!(
11319 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11320 "got {err:?}",
11321 );
11322 }
11323
11324 #[test]
11325 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
11326 // Diagnostic-shape pin (peer with the prior
11327 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
11328 // every preceding arm): the error's Display surfaces the
11329 // offending `:nome` and the offending `:caminho` verbatim so a
11330 // `feira lint` run can render the diagnostic without re-parsing.
11331 let d = dep_with_fonte(DepSource::Path {
11332 caminho: "../caixa-teia/".into(),
11333 });
11334 let rendered = d.validate().unwrap_err().to_string();
11335 assert!(
11336 rendered.contains("caixa-teia"),
11337 "diagnostic must name the offending dep: {rendered}",
11338 );
11339 assert!(
11340 rendered.contains("../caixa-teia/"),
11341 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11342 );
11343 assert!(
11344 rendered.contains("trailing"),
11345 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
11346 );
11347 }
11348
11349 // -- :caminho shell-redirection metacharacter arm -----------------------
11350
11351 #[test]
11352 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
11353 // The fail-before-pass-after pin for the canonical output-redirection
11354 // paste footgun: an author copies a shell pipeline tail
11355 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
11356 // line including the `> build.log` redirect" idiom) and silently
11357 // passed every prior arm (`Path::is_absolute` false on `..`, no
11358 // control bytes, no backslash, doesn't end in `/`). The lacre
11359 // embedded the value verbatim, the resolver folded it through
11360 // `Path::join` looking for a literal `./../caixa-teia>build.log`
11361 // subdirectory, and the failure surfaced at resolve time with a
11362 // non-self-locating `No such file or directory` error. The new arm
11363 // moves the rejection to validate time and names the offending dep
11364 // + caminho + byte verbatim.
11365 let d = dep_with_fonte(DepSource::Path {
11366 caminho: "../caixa-teia>build.log".into(),
11367 });
11368 let err = d.validate().unwrap_err();
11369 let DepError::FonteCaminhoShellRedirection {
11370 nome,
11371 caminho,
11372 byte,
11373 } = err
11374 else {
11375 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11376 };
11377 assert_eq!(nome, "caixa-teia");
11378 assert_eq!(caminho, "../caixa-teia>build.log");
11379 assert_eq!(byte, b'>');
11380 }
11381
11382 #[test]
11383 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
11384 // The symmetric input-redirection paste shape
11385 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
11386 // `command < input.lisp` line from a tatara-lisp REPL log"
11387 // idiom). Pinned separately from the `>` shape so the gate's
11388 // contract is "any `<` or `>` anywhere", not single-byte coverage.
11389 let d = dep_with_fonte(DepSource::Path {
11390 caminho: "../caixa-teia<input.lisp".into(),
11391 });
11392 let err = d.validate().unwrap_err();
11393 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
11394 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11395 };
11396 assert_eq!(byte, b'<');
11397 }
11398
11399 #[test]
11400 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
11401 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
11402 // "I forgot the source side of the redirect" idiom). Pinned
11403 // separately from the embedded-byte shapes so the gate covers
11404 // every position, not only mid-path.
11405 let d = dep_with_fonte(DepSource::Path {
11406 caminho: ">../caixa-teia".into(),
11407 });
11408 let err = d.validate().unwrap_err();
11409 assert!(
11410 matches!(
11411 err,
11412 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11413 ),
11414 "got {err:?}",
11415 );
11416 }
11417
11418 #[test]
11419 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
11420 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
11421 // the canonical "I copied a `>>` append redirect" idiom). The arm
11422 // fires on the first `>` encountered; pinned so a future arm that
11423 // tries to distinguish `>` from `>>` doesn't break the broader
11424 // contract.
11425 let d = dep_with_fonte(DepSource::Path {
11426 caminho: "../caixa-teia>>build.log".into(),
11427 });
11428 let err = d.validate().unwrap_err();
11429 assert!(
11430 matches!(
11431 err,
11432 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11433 ),
11434 "got {err:?}",
11435 );
11436 }
11437
11438 #[test]
11439 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
11440 // The positive-control pin: the gate targets only `<` / `>`,
11441 // never adjacent printable ASCII or POSIX-valid bytes. The
11442 // canonical relative POSIX path (`"../caixa-teia"`) and a
11443 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
11444 // continue to validate cleanly so the gate doesn't widen to a
11445 // "no printable punctuation anywhere" sweep that would defeat
11446 // the entire path-fonte author surface.
11447 let d = dep_with_fonte(DepSource::Path {
11448 caminho: "../caixa-teia/foo/bar".into(),
11449 });
11450 d.validate().unwrap();
11451 }
11452
11453 #[test]
11454 fn fonte_caminho_backslash_fires_before_shell_redirection() {
11455 // Cascade pin on the immediate-predecessor arm: a value carrying
11456 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
11457 // canonical "I pasted a Windows-shell command with output
11458 // redirect" footgun) routes through `FonteCaminhoBackslash` not
11459 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
11460 // divergence is the load-bearing axis (an author who removes
11461 // the `\` is the root-cause edit; the `>` falls away in the
11462 // same edit since it's downstream of the Windows-shell
11463 // convention).
11464 let d = dep_with_fonte(DepSource::Path {
11465 caminho: "..\\caixa-teia>build.log".into(),
11466 });
11467 let err = d.validate().unwrap_err();
11468 assert!(
11469 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11470 "got {err:?}",
11471 );
11472 }
11473
11474 #[test]
11475 fn fonte_caminho_control_char_fires_before_shell_redirection() {
11476 // Cascade pin on the embedded-control-byte arm: a value carrying
11477 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
11478 // canonical paste-from-multiline-doc footgun where a newline
11479 // landed mid-caminho) routes through `FonteCaminhoControlChar`
11480 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
11481 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11482 // load-bearing axis on every value that probes positive for
11483 // both — mirrors the cascade discipline on every prior arm.
11484 let d = dep_with_fonte(DepSource::Path {
11485 caminho: "../foo\n>bar".into(),
11486 });
11487 let err = d.validate().unwrap_err();
11488 assert!(
11489 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11490 "got {err:?}",
11491 );
11492 }
11493
11494 #[test]
11495 fn fonte_caminho_absolute_fires_before_shell_redirection() {
11496 // Cascade pin on the load-bearing leading-byte arm: a leading
11497 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
11498 // routes through `FonteCaminhoAbsolute` not
11499 // `FonteCaminhoShellRedirection` — the host-layout-leak
11500 // diagnostic is the load-bearing axis, the `>` byte is the
11501 // secondary observation. Same precedence logic as every prior
11502 // leading-byte arm.
11503 let d = dep_with_fonte(DepSource::Path {
11504 caminho: "/etc/passwd>out".into(),
11505 });
11506 let err = d.validate().unwrap_err();
11507 assert!(
11508 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11509 "got {err:?}",
11510 );
11511 }
11512
11513 #[test]
11514 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
11515 // Cascade pin on the immediate-successor arm: a value carrying
11516 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
11517 // canonical "I tab-completed a path that already had a
11518 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
11519 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11520 // the more semantic-locating axis (an author who removes the
11521 // `<` / `>` typically also drops the trailing separator since
11522 // both are paste-from-shell artifacts).
11523 let d = dep_with_fonte(DepSource::Path {
11524 caminho: "../foo></".into(),
11525 });
11526 let err = d.validate().unwrap_err();
11527 assert!(
11528 matches!(
11529 err,
11530 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11531 ),
11532 "got {err:?}",
11533 );
11534 }
11535
11536 #[test]
11537 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
11538 // Diagnostic-shape pin (peer with
11539 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
11540 // payload assertion on the closest peer arm that also carries a
11541 // `byte` field): the error's Display surfaces the offending
11542 // `:nome`, the offending `:caminho` verbatim, and the offending
11543 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
11544 // run can render the diagnostic without re-parsing.
11545 let d = dep_with_fonte(DepSource::Path {
11546 caminho: "../caixa-teia>build.log".into(),
11547 });
11548 let rendered = d.validate().unwrap_err().to_string();
11549 assert!(
11550 rendered.contains("caixa-teia"),
11551 "diagnostic must name the offending dep: {rendered}",
11552 );
11553 assert!(
11554 rendered.contains("../caixa-teia>build.log"),
11555 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11556 );
11557 assert!(
11558 rendered.contains("0x3e"),
11559 "diagnostic must name the offending byte in hex: {rendered:?}",
11560 );
11561 assert!(
11562 rendered.contains("redirection"),
11563 "diagnostic must name the shell-redirection footgun: {rendered:?}",
11564 );
11565 }
11566
11567 // -- :caminho shell-pipe metacharacter arm ----------------------------
11568
11569 #[test]
11570 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
11571 // The fail-before-pass-after pin for the canonical shell-pipe
11572 // paste footgun: an author copies a shell-history line
11573 // (`"../caixa-teia | grep foo"` — the canonical "I selected
11574 // the whole `ls dir | grep` line out of zsh history") and
11575 // silently passed every prior arm (`Path::is_absolute` false
11576 // on `..`, no control bytes, no backslash, no `<` / `>`,
11577 // doesn't end in `/`). The lacre embedded the value verbatim,
11578 // the resolver folded it through `Path::join` looking for a
11579 // literal `./../caixa-teia | grep foo` subdirectory, and the
11580 // failure surfaced at resolve time with a non-self-locating
11581 // `No such file or directory` error. The new arm moves the
11582 // rejection to validate time and names the offending dep +
11583 // caminho verbatim.
11584 let d = dep_with_fonte(DepSource::Path {
11585 caminho: "../caixa-teia | grep foo".into(),
11586 });
11587 let err = d.validate().unwrap_err();
11588 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
11589 panic!("expected FonteCaminhoShellPipe, got {err:?}");
11590 };
11591 assert_eq!(nome, "caixa-teia");
11592 assert_eq!(caminho, "../caixa-teia | grep foo");
11593 }
11594
11595 #[test]
11596 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
11597 // Leading-position `|` shape (`"|../caixa-teia"` — the
11598 // degenerate "I forgot the source side of the pipe" idiom).
11599 // Pinned separately from the embedded-byte shape so the gate
11600 // covers every position, not only mid-path.
11601 let d = dep_with_fonte(DepSource::Path {
11602 caminho: "|../caixa-teia".into(),
11603 });
11604 let err = d.validate().unwrap_err();
11605 assert!(
11606 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11607 "got {err:?}",
11608 );
11609 }
11610
11611 #[test]
11612 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
11613 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
11614 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
11615 // idiom). The arm fires on the first `|` encountered; pinned
11616 // so a future arm that tries to distinguish `|` from `||`
11617 // doesn't break the broader contract.
11618 let d = dep_with_fonte(DepSource::Path {
11619 caminho: "../caixa-teia||fallback".into(),
11620 });
11621 let err = d.validate().unwrap_err();
11622 assert!(
11623 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11624 "got {err:?}",
11625 );
11626 }
11627
11628 #[test]
11629 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
11630 // The positive-control pin: the gate targets only `|`, never
11631 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11632 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11633 // pathed variant with adjacent printable punctuation
11634 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11635 // cleanly so the gate doesn't widen to a "no printable
11636 // punctuation anywhere" sweep that would defeat the entire
11637 // path-fonte author surface.
11638 let d = dep_with_fonte(DepSource::Path {
11639 caminho: "../caixa-teia/sub-dir.v2".into(),
11640 });
11641 d.validate().unwrap();
11642 }
11643
11644 #[test]
11645 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
11646 // Cascade pin on the immediate-predecessor arm: a value carrying
11647 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
11648 // canonical "I pasted a `cmd < input | tee` pipeline tail"
11649 // footgun) routes through `FonteCaminhoShellRedirection` not
11650 // `FonteCaminhoShellPipe`. The input/output redirection
11651 // metachar carries the more self-locating `byte: u8` payload
11652 // (it names which of `<` or `>` triggered), so the prior arm
11653 // wins on every probe-as-both value — same cascade discipline
11654 // every prior `:caminho` arm establishes.
11655 let d = dep_with_fonte(DepSource::Path {
11656 caminho: "../caixa-teia<input|tee".into(),
11657 });
11658 let err = d.validate().unwrap_err();
11659 assert!(
11660 matches!(
11661 err,
11662 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
11663 ),
11664 "got {err:?}",
11665 );
11666 }
11667
11668 #[test]
11669 fn fonte_caminho_backslash_fires_before_shell_pipe() {
11670 // Cascade pin on the upstream backslash arm: a value carrying
11671 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
11672 // "I pasted a Windows-shell command with pipe to tee"
11673 // footgun) routes through `FonteCaminhoBackslash` not
11674 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
11675 // divergence is the load-bearing axis on every probe-as-both
11676 // value (an author who removes the `\` is the root-cause edit;
11677 // the `|` falls away in the same edit since it's downstream of
11678 // the Windows-shell convention).
11679 let d = dep_with_fonte(DepSource::Path {
11680 caminho: "..\\caixa-teia|tee".into(),
11681 });
11682 let err = d.validate().unwrap_err();
11683 assert!(
11684 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11685 "got {err:?}",
11686 );
11687 }
11688
11689 #[test]
11690 fn fonte_caminho_control_char_fires_before_shell_pipe() {
11691 // Cascade pin on the embedded-control-byte arm: a value
11692 // carrying both a control byte and `|` (`"../foo\n|bar"` —
11693 // the canonical paste-from-multiline-doc footgun where a
11694 // newline landed mid-caminho) routes through
11695 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
11696 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11697 // diagnostic is the load-bearing axis on every value that
11698 // probes positive for both — mirrors the cascade discipline
11699 // on every prior arm.
11700 let d = dep_with_fonte(DepSource::Path {
11701 caminho: "../foo\n|bar".into(),
11702 });
11703 let err = d.validate().unwrap_err();
11704 assert!(
11705 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11706 "got {err:?}",
11707 );
11708 }
11709
11710 #[test]
11711 fn fonte_caminho_absolute_fires_before_shell_pipe() {
11712 // Cascade pin on the load-bearing leading-byte arm: a leading
11713 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
11714 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
11715 // — the host-layout-leak diagnostic is the load-bearing axis,
11716 // the `|` byte is the secondary observation. Same precedence
11717 // logic as every prior leading-byte arm.
11718 let d = dep_with_fonte(DepSource::Path {
11719 caminho: "/etc/passwd|tee".into(),
11720 });
11721 let err = d.validate().unwrap_err();
11722 assert!(
11723 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11724 "got {err:?}",
11725 );
11726 }
11727
11728 #[test]
11729 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
11730 // Cascade pin on the immediate-successor arm: a value carrying
11731 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
11732 // "I tab-completed a path that already had a pipeline tail"
11733 // footgun) routes through `FonteCaminhoShellPipe` not
11734 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11735 // the more semantic-locating axis (an author who removes the
11736 // `|` typically also drops the trailing separator since both
11737 // are paste-from-shell artifacts).
11738 let d = dep_with_fonte(DepSource::Path {
11739 caminho: "../foo|tee/".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_pipe_diagnostic_carries_offending_dep_and_caminho() {
11750 // Diagnostic-shape pin (peer with
11751 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
11752 // on the closest single-byte peer arm): the error's Display
11753 // surfaces the offending `:nome` and the offending `:caminho`
11754 // verbatim, and names the shell-pipe footgun explicitly so a
11755 // `feira lint` run can render the diagnostic without
11756 // re-parsing.
11757 let d = dep_with_fonte(DepSource::Path {
11758 caminho: "../caixa-teia | grep foo".into(),
11759 });
11760 let rendered = d.validate().unwrap_err().to_string();
11761 assert!(
11762 rendered.contains("caixa-teia"),
11763 "diagnostic must name the offending dep: {rendered}",
11764 );
11765 assert!(
11766 rendered.contains("../caixa-teia | grep foo"),
11767 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11768 );
11769 assert!(
11770 rendered.contains('|'),
11771 "diagnostic must reference the pipe footgun: {rendered:?}",
11772 );
11773 assert!(
11774 rendered.contains("pipe"),
11775 "diagnostic must name the shell-pipe footgun: {rendered:?}",
11776 );
11777 }
11778
11779 // -- :caminho shell-command-separator metacharacter arm ---------------
11780
11781 #[test]
11782 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11783 // The fail-before-pass-after pin for the canonical shell-command-
11784 // separator paste footgun: an author copies a shell one-liner
11785 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11786 // whole `cd path; do-thing` chain out of a shell-history block")
11787 // and silently passed every prior arm (`Path::is_absolute` false
11788 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11789 // doesn't end in `/`). The lacre embedded the value verbatim, the
11790 // resolver folded it through `Path::join` looking for a literal
11791 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11792 // surfaced at resolve time with a non-self-locating `No such file
11793 // or directory` error. The new arm moves the rejection to validate
11794 // time and names the offending dep + caminho verbatim.
11795 let d = dep_with_fonte(DepSource::Path {
11796 caminho: "../caixa-teia; rm -rf build".into(),
11797 });
11798 let err = d.validate().unwrap_err();
11799 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11800 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11801 };
11802 assert_eq!(nome, "caixa-teia");
11803 assert_eq!(caminho, "../caixa-teia; rm -rf build");
11804 }
11805
11806 #[test]
11807 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11808 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11809 // "I forgot the prior command side of the separator" idiom).
11810 // Pinned separately from the embedded-byte shape so the gate
11811 // covers every position, not only mid-path.
11812 let d = dep_with_fonte(DepSource::Path {
11813 caminho: ";../caixa-teia".into(),
11814 });
11815 let err = d.validate().unwrap_err();
11816 assert!(
11817 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11818 "got {err:?}",
11819 );
11820 }
11821
11822 #[test]
11823 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11824 // The POSIX `case` arm `;;` terminator shape
11825 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11826 // arm tail" idiom). The arm fires on the first `;` encountered;
11827 // pinned so a future arm that tries to distinguish `;` from `;;`
11828 // doesn't break the broader contract.
11829 let d = dep_with_fonte(DepSource::Path {
11830 caminho: "../caixa-teia;;next".into(),
11831 });
11832 let err = d.validate().unwrap_err();
11833 assert!(
11834 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11835 "got {err:?}",
11836 );
11837 }
11838
11839 #[test]
11840 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11841 // The positive-control pin: the gate targets only `;`, never
11842 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11843 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11844 // pathed variant with adjacent printable punctuation
11845 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11846 // cleanly so the gate doesn't widen to a "no printable
11847 // punctuation anywhere" sweep that would defeat the entire
11848 // path-fonte author surface.
11849 let d = dep_with_fonte(DepSource::Path {
11850 caminho: "../caixa-teia/sub-dir.v2".into(),
11851 });
11852 d.validate().unwrap();
11853 }
11854
11855 #[test]
11856 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11857 // Cascade pin on the immediate-predecessor arm: a value carrying
11858 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11859 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11860 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11861 // pipeline-tail paste is the load-bearing root-cause edit on
11862 // every probe-as-both value (an author who removes the `|`
11863 // typically also drops the trailing `; cleanup` since both are
11864 // the same paste-from-shell-history artifact) — same cascade
11865 // discipline every prior `:caminho` arm establishes.
11866 let d = dep_with_fonte(DepSource::Path {
11867 caminho: "../caixa-teia | tee; rm".into(),
11868 });
11869 let err = d.validate().unwrap_err();
11870 assert!(
11871 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11872 "got {err:?}",
11873 );
11874 }
11875
11876 #[test]
11877 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11878 // Cascade pin on the upstream shell-redirection arm: a value
11879 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11880 // the canonical "I pasted a `cmd > log; cleanup` chain"
11881 // footgun) routes through `FonteCaminhoShellRedirection` not
11882 // `FonteCaminhoShellSemicolon`. The input/output redirection
11883 // metachar carries the more self-locating `byte: u8` payload
11884 // (it names which of `<` or `>` triggered), so the prior arm
11885 // wins on every probe-as-both value.
11886 let d = dep_with_fonte(DepSource::Path {
11887 caminho: "../caixa-teia>log; rm".into(),
11888 });
11889 let err = d.validate().unwrap_err();
11890 assert!(
11891 matches!(
11892 err,
11893 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11894 ),
11895 "got {err:?}",
11896 );
11897 }
11898
11899 #[test]
11900 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11901 // Cascade pin on the upstream backslash arm: a value carrying
11902 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11903 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11904 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11905 // The cross-host-OS-separator divergence is the load-bearing axis
11906 // on every probe-as-both value (an author who removes the `\` is
11907 // the root-cause edit; the `;` falls away in the same edit since
11908 // it's downstream of the Windows-shell convention).
11909 let d = dep_with_fonte(DepSource::Path {
11910 caminho: "..\\caixa-teia;rm".into(),
11911 });
11912 let err = d.validate().unwrap_err();
11913 assert!(
11914 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11915 "got {err:?}",
11916 );
11917 }
11918
11919 #[test]
11920 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11921 // Cascade pin on the embedded-control-byte arm: a value carrying
11922 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11923 // paste-from-multiline-doc footgun where a newline landed mid-
11924 // caminho) routes through `FonteCaminhoControlChar` not
11925 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11926 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11927 // on every value that probes positive for both — mirrors the
11928 // cascade discipline on every prior arm.
11929 let d = dep_with_fonte(DepSource::Path {
11930 caminho: "../foo\n;bar".into(),
11931 });
11932 let err = d.validate().unwrap_err();
11933 assert!(
11934 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11935 "got {err:?}",
11936 );
11937 }
11938
11939 #[test]
11940 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11941 // Cascade pin on the load-bearing leading-byte arm: a leading
11942 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11943 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11944 // — the host-layout-leak diagnostic is the load-bearing axis,
11945 // the `;` byte is the secondary observation. Same precedence
11946 // logic as every prior leading-byte arm.
11947 let d = dep_with_fonte(DepSource::Path {
11948 caminho: "/etc/passwd;rm".into(),
11949 });
11950 let err = d.validate().unwrap_err();
11951 assert!(
11952 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11953 "got {err:?}",
11954 );
11955 }
11956
11957 #[test]
11958 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11959 // Cascade pin on the immediate-successor arm: a value carrying
11960 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11961 // "I tab-completed a path that already had a `; cleanup` tail"
11962 // footgun) routes through `FonteCaminhoShellSemicolon` not
11963 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11964 // the more semantic-locating axis (an author who removes the
11965 // `;` typically also drops the trailing separator since both
11966 // are paste-from-shell artifacts).
11967 let d = dep_with_fonte(DepSource::Path {
11968 caminho: "../foo;rm/".into(),
11969 });
11970 let err = d.validate().unwrap_err();
11971 assert!(
11972 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11973 "got {err:?}",
11974 );
11975 }
11976
11977 #[test]
11978 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11979 // Diagnostic-shape pin (peer with
11980 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11981 // on the closest single-byte peer arm): the error's Display
11982 // surfaces the offending `:nome` and the offending `:caminho`
11983 // verbatim, and names the shell-command-separator footgun
11984 // explicitly so a `feira lint` run can render the diagnostic
11985 // without re-parsing.
11986 let d = dep_with_fonte(DepSource::Path {
11987 caminho: "../caixa-teia; rm -rf build".into(),
11988 });
11989 let rendered = d.validate().unwrap_err().to_string();
11990 assert!(
11991 rendered.contains("caixa-teia"),
11992 "diagnostic must name the offending dep: {rendered}",
11993 );
11994 assert!(
11995 rendered.contains("../caixa-teia; rm -rf build"),
11996 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11997 );
11998 assert!(
11999 rendered.contains(';'),
12000 "diagnostic must reference the semicolon footgun: {rendered:?}",
12001 );
12002 assert!(
12003 rendered.contains("command-separator"),
12004 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
12005 );
12006 }
12007
12008 #[test]
12009 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
12010 // The fail-before-pass-after pin for the canonical shell-
12011 // background-task paste footgun: an author copies a shell one-
12012 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
12013 // the whole `cd path & sleep 1` background-launch out of a
12014 // shell-history block") and silently passed every prior arm
12015 // (`Path::is_absolute` false on `..`, no control bytes, no
12016 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
12017 // The lacre embedded the value verbatim, the resolver folded it
12018 // through `Path::join` looking for a literal `./../caixa-teia &
12019 // sleep 1` subdirectory, and the failure surfaced at resolve
12020 // time with a non-self-locating `No such file or directory`
12021 // error. The new arm moves the rejection to validate time and
12022 // names the offending dep + caminho verbatim.
12023 let d = dep_with_fonte(DepSource::Path {
12024 caminho: "../caixa-teia & sleep 1".into(),
12025 });
12026 let err = d.validate().unwrap_err();
12027 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
12028 panic!("expected FonteCaminhoShellBackground, got {err:?}");
12029 };
12030 assert_eq!(nome, "caixa-teia");
12031 assert_eq!(caminho, "../caixa-teia & sleep 1");
12032 }
12033
12034 #[test]
12035 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
12036 // Leading-position `&` shape (`"&../caixa-teia"` — the
12037 // degenerate "I forgot the prior command side of the
12038 // background terminator" idiom). Pinned separately from the
12039 // embedded-byte shape so the gate covers every position, not
12040 // only mid-path.
12041 let d = dep_with_fonte(DepSource::Path {
12042 caminho: "&../caixa-teia".into(),
12043 });
12044 let err = d.validate().unwrap_err();
12045 assert!(
12046 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12047 "got {err:?}",
12048 );
12049 }
12050
12051 #[test]
12052 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
12053 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
12054 // canonical "I copied a `cd path && make` build chain" idiom
12055 // every Makefile / shell-script wraps). The arm fires on the
12056 // first `&` encountered; pinned so a future arm that tries to
12057 // distinguish `&` from `&&` doesn't break the broader contract.
12058 let d = dep_with_fonte(DepSource::Path {
12059 caminho: "../caixa-teia && make".into(),
12060 });
12061 let err = d.validate().unwrap_err();
12062 assert!(
12063 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12064 "got {err:?}",
12065 );
12066 }
12067
12068 #[test]
12069 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
12070 // The positive-control pin: the gate targets only `&`, never
12071 // adjacent printable ASCII or POSIX-valid bytes. The canonical
12072 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
12073 // pathed variant with adjacent printable punctuation
12074 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
12075 // cleanly so the gate doesn't widen to a "no printable
12076 // punctuation anywhere" sweep that would defeat the entire
12077 // path-fonte author surface.
12078 let d = dep_with_fonte(DepSource::Path {
12079 caminho: "../caixa-teia/sub-dir.v2".into(),
12080 });
12081 d.validate().unwrap();
12082 }
12083
12084 #[test]
12085 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
12086 // Cascade pin on the immediate-predecessor arm: a value carrying
12087 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
12088 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
12089 // routes through `FonteCaminhoShellSemicolon` not
12090 // `FonteCaminhoShellBackground`. The sequential-command-
12091 // separator paste is the more common shell-history paste idiom
12092 // on every probe-as-both value (an author who removes the `;`
12093 // typically also drops the trailing `& sleep` since both are
12094 // paste-from-shell-history artifacts) — same cascade discipline
12095 // every prior `:caminho` arm establishes.
12096 let d = dep_with_fonte(DepSource::Path {
12097 caminho: "../caixa-teia; rm & sleep".into(),
12098 });
12099 let err = d.validate().unwrap_err();
12100 assert!(
12101 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12102 "got {err:?}",
12103 );
12104 }
12105
12106 #[test]
12107 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
12108 // Cascade pin on the upstream shell-pipe arm: a value carrying
12109 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
12110 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
12111 // chain" footgun) routes through `FonteCaminhoShellPipe` not
12112 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
12113 // load-bearing root-cause edit on every probe-as-both value.
12114 let d = dep_with_fonte(DepSource::Path {
12115 caminho: "../caixa-teia | tee & sleep".into(),
12116 });
12117 let err = d.validate().unwrap_err();
12118 assert!(
12119 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12120 "got {err:?}",
12121 );
12122 }
12123
12124 #[test]
12125 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
12126 // Cascade pin on the upstream shell-redirection arm: a value
12127 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
12128 // the canonical "I pasted a `cmd > log & sleep` background-
12129 // redirect chain" footgun) routes through
12130 // `FonteCaminhoShellRedirection` not
12131 // `FonteCaminhoShellBackground`. The input/output redirection
12132 // metachar carries the more self-locating `byte: u8` payload
12133 // (it names which of `<` or `>` triggered), so the prior arm
12134 // wins on every probe-as-both value.
12135 let d = dep_with_fonte(DepSource::Path {
12136 caminho: "../caixa-teia>log & sleep".into(),
12137 });
12138 let err = d.validate().unwrap_err();
12139 assert!(
12140 matches!(
12141 err,
12142 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12143 ),
12144 "got {err:?}",
12145 );
12146 }
12147
12148 #[test]
12149 fn fonte_caminho_backslash_fires_before_shell_background() {
12150 // Cascade pin on the upstream backslash arm: a value carrying
12151 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
12152 // "I pasted a Windows-shell `cd ..\path & sleep` background-
12153 // launch chain") routes through `FonteCaminhoBackslash` not
12154 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
12155 // divergence is the load-bearing axis on every probe-as-both
12156 // value (an author who removes the `\` is the root-cause edit;
12157 // the `&` falls away in the same edit since it's downstream of
12158 // the Windows-shell convention).
12159 let d = dep_with_fonte(DepSource::Path {
12160 caminho: "..\\caixa-teia & sleep".into(),
12161 });
12162 let err = d.validate().unwrap_err();
12163 assert!(
12164 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12165 "got {err:?}",
12166 );
12167 }
12168
12169 #[test]
12170 fn fonte_caminho_control_char_fires_before_shell_background() {
12171 // Cascade pin on the embedded-control-byte arm: a value
12172 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
12173 // the canonical paste-from-multiline-doc footgun where a
12174 // newline landed mid-caminho) routes through
12175 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
12176 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
12177 // diagnostic is the load-bearing axis on every value that
12178 // probes positive for both — mirrors the cascade discipline on
12179 // every prior arm.
12180 let d = dep_with_fonte(DepSource::Path {
12181 caminho: "../foo\n&sleep".into(),
12182 });
12183 let err = d.validate().unwrap_err();
12184 assert!(
12185 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12186 "got {err:?}",
12187 );
12188 }
12189
12190 #[test]
12191 fn fonte_caminho_absolute_fires_before_shell_background() {
12192 // Cascade pin on the load-bearing leading-byte arm: a leading
12193 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
12194 // through `FonteCaminhoAbsolute` not
12195 // `FonteCaminhoShellBackground` — the host-layout-leak
12196 // diagnostic is the load-bearing axis, the `&` byte is the
12197 // secondary observation. Same precedence logic as every prior
12198 // leading-byte arm.
12199 let d = dep_with_fonte(DepSource::Path {
12200 caminho: "/etc/passwd & sleep".into(),
12201 });
12202 let err = d.validate().unwrap_err();
12203 assert!(
12204 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12205 "got {err:?}",
12206 );
12207 }
12208
12209 #[test]
12210 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
12211 // Cascade pin on the immediate-successor arm: a value carrying
12212 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
12213 // canonical "I tab-completed a path that already had a `&
12214 // sleep` background-launch tail" footgun) routes through
12215 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
12216 // The embedded shell-metachar is the more semantic-locating
12217 // axis (an author who removes the `&` typically also drops
12218 // the trailing separator since both are paste-from-shell
12219 // artifacts).
12220 let d = dep_with_fonte(DepSource::Path {
12221 caminho: "../foo&sleep/".into(),
12222 });
12223 let err = d.validate().unwrap_err();
12224 assert!(
12225 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12226 "got {err:?}",
12227 );
12228 }
12229
12230 #[test]
12231 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
12232 // Diagnostic-shape pin (peer with
12233 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
12234 // on the closest single-byte peer arm): the error's Display
12235 // surfaces the offending `:nome` and the offending `:caminho`
12236 // verbatim, and names the shell-background / logical-AND
12237 // footgun explicitly so a `feira lint` run can render the
12238 // diagnostic without re-parsing.
12239 let d = dep_with_fonte(DepSource::Path {
12240 caminho: "../caixa-teia & sleep 1".into(),
12241 });
12242 let rendered = d.validate().unwrap_err().to_string();
12243 assert!(
12244 rendered.contains("caixa-teia"),
12245 "diagnostic must name the offending dep: {rendered}",
12246 );
12247 assert!(
12248 rendered.contains("../caixa-teia & sleep 1"),
12249 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12250 );
12251 assert!(
12252 rendered.contains('&'),
12253 "diagnostic must reference the ampersand footgun: {rendered:?}",
12254 );
12255 assert!(
12256 rendered.contains("background") || rendered.contains("list-AND"),
12257 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
12258 );
12259 }
12260
12261 #[test]
12262 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
12263 // The fail-before-pass-after pin for the canonical shell-
12264 // command-substitution paste footgun: an author copies a
12265 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
12266 // — the canonical "I pasted a path that included a `pwd`
12267 // / `whoami` / `date` legacy command-substitution expansion
12268 // out of a shell-history block") and silently passed every
12269 // prior arm (`Path::is_absolute` false on `..`, no control
12270 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
12271 // end in `/`). The lacre embedded the value verbatim, the
12272 // resolver folded it through `Path::join` looking for a
12273 // literal `./../caixa-teia/`whoami`` subdirectory, and the
12274 // failure surfaced at resolve time with a non-self-locating
12275 // `No such file or directory` error. The new arm moves the
12276 // rejection to validate time and names the offending dep +
12277 // caminho verbatim.
12278 let d = dep_with_fonte(DepSource::Path {
12279 caminho: "../caixa-teia/`whoami`".into(),
12280 });
12281 let err = d.validate().unwrap_err();
12282 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
12283 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
12284 };
12285 assert_eq!(nome, "caixa-teia");
12286 assert_eq!(caminho, "../caixa-teia/`whoami`");
12287 }
12288
12289 #[test]
12290 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
12291 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
12292 // the canonical `<backtick>pwd<backtick>/path` working-
12293 // directory expansion shape every shell-side path-composition
12294 // idiom carries). Pinned separately from the embedded-byte
12295 // shape so the gate covers every position, not only mid-path.
12296 let d = dep_with_fonte(DepSource::Path {
12297 caminho: "`pwd`/caixa-teia".into(),
12298 });
12299 let err = d.validate().unwrap_err();
12300 assert!(
12301 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12302 "got {err:?}",
12303 );
12304 }
12305
12306 #[test]
12307 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
12308 // Trailing-position backtick shape (`"../caixa-teia`"` — the
12309 // degenerate "I selected an unbalanced backtick out of a
12310 // shell-history block" idiom that probes for the cascade's
12311 // last-byte handling). The trailing-`/` arm fires only on
12312 // last-byte `/`; an unbalanced trailing backtick must route
12313 // through this arm regardless of position.
12314 let d = dep_with_fonte(DepSource::Path {
12315 caminho: "../caixa-teia`".into(),
12316 });
12317 let err = d.validate().unwrap_err();
12318 assert!(
12319 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12320 "got {err:?}",
12321 );
12322 }
12323
12324 #[test]
12325 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
12326 // The canonical balanced-pair shape (``"../<backtick>cat
12327 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
12328 // command-injection paste idiom every shell-side hardening
12329 // guide enumerates first). The arm fires on the first
12330 // backtick encountered; pinned so a future arm that tries to
12331 // distinguish the opening from the closing byte doesn't break
12332 // the broader contract.
12333 let d = dep_with_fonte(DepSource::Path {
12334 caminho: "../`cat /etc/passwd`".into(),
12335 });
12336 let err = d.validate().unwrap_err();
12337 assert!(
12338 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12339 "got {err:?}",
12340 );
12341 }
12342
12343 #[test]
12344 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
12345 // The positive-control pin: the gate targets only the
12346 // backtick byte, never adjacent printable ASCII or POSIX-
12347 // valid bytes. The canonical relative POSIX path
12348 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
12349 // adjacent printable punctuation
12350 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
12351 // cleanly so the gate doesn't widen to a "no printable
12352 // punctuation anywhere" sweep that would defeat the entire
12353 // path-fonte author surface.
12354 let d = dep_with_fonte(DepSource::Path {
12355 caminho: "../caixa-teia/sub-dir.v2".into(),
12356 });
12357 d.validate().unwrap();
12358 }
12359
12360 #[test]
12361 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
12362 // Cascade pin on the immediate-predecessor arm: a value
12363 // carrying both `&` and a backtick (``"../caixa-teia &
12364 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
12365 // `cmd & <backtick>sleep N<backtick>` background-launch +
12366 // command-substitution chain" footgun) routes through
12367 // `FonteCaminhoShellBackground` not
12368 // `FonteCaminhoShellCommandSubstitution`. The background-
12369 // launch tail is the more common shell-history paste idiom
12370 // on every probe-as-both value — same cascade discipline
12371 // every prior `:caminho` arm establishes.
12372 let d = dep_with_fonte(DepSource::Path {
12373 caminho: "../caixa-teia & `sleep 1`".into(),
12374 });
12375 let err = d.validate().unwrap_err();
12376 assert!(
12377 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12378 "got {err:?}",
12379 );
12380 }
12381
12382 #[test]
12383 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
12384 // Cascade pin on the upstream shell-semicolon arm: a value
12385 // carrying both `;` and a backtick (``"../caixa-teia;
12386 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12387 // `cmd; <backtick>follow-up<backtick>` sequential-chain
12388 // footgun) routes through `FonteCaminhoShellSemicolon` not
12389 // `FonteCaminhoShellCommandSubstitution`. The sequential-
12390 // command-separator paste is the load-bearing root-cause
12391 // edit on every probe-as-both value.
12392 let d = dep_with_fonte(DepSource::Path {
12393 caminho: "../caixa-teia; `whoami`".into(),
12394 });
12395 let err = d.validate().unwrap_err();
12396 assert!(
12397 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12398 "got {err:?}",
12399 );
12400 }
12401
12402 #[test]
12403 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
12404 // Cascade pin on the upstream shell-pipe arm: a value
12405 // carrying both `|` and a backtick (``"../caixa-teia |
12406 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
12407 // command-substitution paste idiom) routes through
12408 // `FonteCaminhoShellPipe` not
12409 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
12410 // paste is the load-bearing root-cause edit on every
12411 // probe-as-both value.
12412 let d = dep_with_fonte(DepSource::Path {
12413 caminho: "../caixa-teia | `tee log`".into(),
12414 });
12415 let err = d.validate().unwrap_err();
12416 assert!(
12417 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12418 "got {err:?}",
12419 );
12420 }
12421
12422 #[test]
12423 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
12424 // Cascade pin on the upstream shell-redirection arm: a value
12425 // carrying both `>` and a backtick (``"../caixa-teia>log
12426 // <backtick>date<backtick>"`` — the canonical "I pasted a
12427 // `cmd > log <backtick>date<backtick>` redirect-plus-
12428 // substitution chain" footgun) routes through
12429 // `FonteCaminhoShellRedirection` not
12430 // `FonteCaminhoShellCommandSubstitution`. The input/output
12431 // redirection metachar carries the more self-locating `byte`
12432 // payload (it names which of `<` or `>` triggered), so the
12433 // prior arm wins on every probe-as-both value.
12434 let d = dep_with_fonte(DepSource::Path {
12435 caminho: "../caixa-teia>log `date`".into(),
12436 });
12437 let err = d.validate().unwrap_err();
12438 assert!(
12439 matches!(
12440 err,
12441 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12442 ),
12443 "got {err:?}",
12444 );
12445 }
12446
12447 #[test]
12448 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
12449 // Cascade pin on the upstream backslash arm: a value
12450 // carrying both `\` and a backtick (``"..\caixa-teia
12451 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12452 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
12453 // chain") routes through `FonteCaminhoBackslash` not
12454 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
12455 // separator divergence is the load-bearing axis on every
12456 // probe-as-both value (an author who removes the `\` is the
12457 // root-cause edit; the backtick falls away in the same edit
12458 // since it's downstream of the Windows-shell convention).
12459 let d = dep_with_fonte(DepSource::Path {
12460 caminho: "..\\caixa-teia `whoami`".into(),
12461 });
12462 let err = d.validate().unwrap_err();
12463 assert!(
12464 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12465 "got {err:?}",
12466 );
12467 }
12468
12469 #[test]
12470 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
12471 // Cascade pin on the embedded-control-byte arm: a value
12472 // carrying both a control byte and a backtick (`"../foo\n
12473 // `whoami`"` — the canonical paste-from-multiline-doc
12474 // footgun where a newline landed mid-caminho between two
12475 // paste fragments) routes through `FonteCaminhoControlChar`
12476 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
12477 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
12478 // is the load-bearing axis on every value that probes
12479 // positive for both — mirrors the cascade discipline on
12480 // every prior arm.
12481 let d = dep_with_fonte(DepSource::Path {
12482 caminho: "../foo\n`whoami`".into(),
12483 });
12484 let err = d.validate().unwrap_err();
12485 assert!(
12486 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12487 "got {err:?}",
12488 );
12489 }
12490
12491 #[test]
12492 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
12493 // Cascade pin on the load-bearing leading-byte arm: a
12494 // leading `/` value with embedded backtick (``"/etc/passwd
12495 // <backtick>whoami<backtick>"``) routes through
12496 // `FonteCaminhoAbsolute` not
12497 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
12498 // leak diagnostic is the load-bearing axis, the backtick
12499 // byte is the secondary observation. Same precedence logic
12500 // as every prior leading-byte arm.
12501 let d = dep_with_fonte(DepSource::Path {
12502 caminho: "/etc/passwd `whoami`".into(),
12503 });
12504 let err = d.validate().unwrap_err();
12505 assert!(
12506 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12507 "got {err:?}",
12508 );
12509 }
12510
12511 #[test]
12512 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
12513 // Cascade pin on the immediate-successor arm: a value
12514 // carrying both a backtick and a trailing `/`
12515 // (``"../`whoami`/"`` — the canonical "I tab-completed a
12516 // path that already had a backticked `whoami` substitution
12517 // tail" footgun) routes through
12518 // `FonteCaminhoShellCommandSubstitution` not
12519 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12520 // is the more semantic-locating axis (an author who removes
12521 // the backtick typically also drops the trailing separator
12522 // since both are paste-from-shell artifacts).
12523 let d = dep_with_fonte(DepSource::Path {
12524 caminho: "../`whoami`/".into(),
12525 });
12526 let err = d.validate().unwrap_err();
12527 assert!(
12528 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12529 "got {err:?}",
12530 );
12531 }
12532
12533 #[test]
12534 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
12535 // Diagnostic-shape pin (peer with
12536 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
12537 // on the closest single-byte peer arm): the error's Display
12538 // surfaces the offending `:nome` and the offending `:caminho`
12539 // verbatim, and names the shell-command-substitution footgun
12540 // explicitly so a `feira lint` run can render the diagnostic
12541 // without re-parsing.
12542 let d = dep_with_fonte(DepSource::Path {
12543 caminho: "../caixa-teia/`whoami`".into(),
12544 });
12545 let rendered = d.validate().unwrap_err().to_string();
12546 assert!(
12547 rendered.contains("caixa-teia"),
12548 "diagnostic must name the offending dep: {rendered}",
12549 );
12550 assert!(
12551 rendered.contains("../caixa-teia/`whoami`"),
12552 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12553 );
12554 assert!(
12555 rendered.contains('`'),
12556 "diagnostic must reference the backtick footgun: {rendered:?}",
12557 );
12558 assert!(
12559 rendered.contains("command-substitution"),
12560 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
12561 );
12562 }
12563
12564 #[test]
12565 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
12566 // The fail-before-pass-after pin for the canonical pathname-
12567 // expansion paste footgun: an author copies an `ls
12568 // ../caixa-teia/*` shell-listing tail into the `:caminho`
12569 // slot and silently passes every prior arm
12570 // (`Path::is_absolute` false on `..`, no control bytes, no
12571 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
12572 // doesn't end in `/`). The lacre embedded the value
12573 // verbatim, the resolver folded it through `Path::join`
12574 // looking for a literal `./../caixa-teia/*` subdirectory,
12575 // and the failure surfaced at resolve time with a non-self-
12576 // locating `No such file or directory` error. The new arm
12577 // moves the rejection to validate time and names the
12578 // offending dep + caminho + byte verbatim.
12579 let d = dep_with_fonte(DepSource::Path {
12580 caminho: "../caixa-teia/*".into(),
12581 });
12582 let err = d.validate().unwrap_err();
12583 let DepError::FonteCaminhoShellGlob {
12584 nome,
12585 caminho,
12586 byte,
12587 } = err
12588 else {
12589 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12590 };
12591 assert_eq!(nome, "caixa-teia");
12592 assert_eq!(caminho, "../caixa-teia/*");
12593 assert_eq!(byte, b'*');
12594 }
12595
12596 #[test]
12597 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
12598 // The symmetric single-char-wildcard paste shape
12599 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
12600 // out of shell history" idiom). Pinned separately from the
12601 // `*` shape so the gate's contract is "any `*` or `?`
12602 // anywhere", not single-byte coverage.
12603 let d = dep_with_fonte(DepSource::Path {
12604 caminho: "../foo?".into(),
12605 });
12606 let err = d.validate().unwrap_err();
12607 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
12608 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12609 };
12610 assert_eq!(byte, b'?');
12611 }
12612
12613 #[test]
12614 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
12615 // Leading-position `*` shape (`"*/caixa-teia"` — the
12616 // degenerate "I selected only the wildcard prefix out of a
12617 // shell-glob expression" idiom). Pinned separately from the
12618 // embedded-byte shapes so the gate covers every position,
12619 // not only mid-path.
12620 let d = dep_with_fonte(DepSource::Path {
12621 caminho: "*/caixa-teia".into(),
12622 });
12623 let err = d.validate().unwrap_err();
12624 assert!(
12625 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12626 "got {err:?}",
12627 );
12628 }
12629
12630 #[test]
12631 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
12632 // The bash/zsh `globstar` recursive-glob shape
12633 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
12634 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
12635 // The arm fires on the first `*` encountered; pinned so a
12636 // future arm that tries to distinguish single `*` from
12637 // double `**` doesn't break the broader contract.
12638 let d = dep_with_fonte(DepSource::Path {
12639 caminho: "../caixa-teia/**/foo".into(),
12640 });
12641 let err = d.validate().unwrap_err();
12642 assert!(
12643 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12644 "got {err:?}",
12645 );
12646 }
12647
12648 #[test]
12649 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
12650 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
12651 // — the "I selected `*.lisp` to mean every Lisp source file
12652 // in the dep root" footgun the prior arms structurally
12653 // cannot catch since `.` is a POSIX-valid path-component
12654 // byte). Pinned so the gate's contract covers the most
12655 // idiomatic glob-paste shape every author meets first.
12656 let d = dep_with_fonte(DepSource::Path {
12657 caminho: "../caixa-teia/*.lisp".into(),
12658 });
12659 let err = d.validate().unwrap_err();
12660 assert!(
12661 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12662 "got {err:?}",
12663 );
12664 }
12665
12666 #[test]
12667 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
12668 // The positive-control pin: the gate targets only `*` /
12669 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
12670 // The canonical relative POSIX path (`"../caixa-teia"`) and
12671 // a nested deeply-pathed variant with adjacent printable
12672 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12673 // to validate cleanly so the gate doesn't widen to a "no
12674 // printable punctuation anywhere" sweep that would defeat
12675 // the entire path-fonte author surface.
12676 let d = dep_with_fonte(DepSource::Path {
12677 caminho: "../caixa-teia/sub-dir.v2".into(),
12678 });
12679 d.validate().unwrap();
12680 }
12681
12682 #[test]
12683 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
12684 // Cascade pin on the immediate-predecessor arm: a value
12685 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
12686 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
12687 // command-substitution + glob chain") routes through
12688 // `FonteCaminhoShellCommandSubstitution` not
12689 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
12690 // injection vector is the load-bearing root-cause edit on
12691 // every probe-as-both value — same cascade discipline every
12692 // prior `:caminho` arm establishes.
12693 let d = dep_with_fonte(DepSource::Path {
12694 caminho: "../`whoami`/*".into(),
12695 });
12696 let err = d.validate().unwrap_err();
12697 assert!(
12698 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12699 "got {err:?}",
12700 );
12701 }
12702
12703 #[test]
12704 fn fonte_caminho_shell_background_fires_before_shell_glob() {
12705 // Cascade pin on the upstream shell-background arm: a value
12706 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
12707 // canonical "I pasted a `cmd & ls /*` background + glob
12708 // chain" footgun) routes through `FonteCaminhoShellBackground`
12709 // not `FonteCaminhoShellGlob`. The background-launch tail is
12710 // the load-bearing root-cause edit on every probe-as-both
12711 // value.
12712 let d = dep_with_fonte(DepSource::Path {
12713 caminho: "../caixa-teia & ls /*".into(),
12714 });
12715 let err = d.validate().unwrap_err();
12716 assert!(
12717 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12718 "got {err:?}",
12719 );
12720 }
12721
12722 #[test]
12723 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
12724 // Cascade pin on the upstream shell-semicolon arm: a value
12725 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
12726 // canonical sequential-cleanup + glob paste idiom) routes
12727 // through `FonteCaminhoShellSemicolon` not
12728 // `FonteCaminhoShellGlob`. The sequential-command-separator
12729 // paste is the load-bearing root-cause edit on every
12730 // probe-as-both value.
12731 let d = dep_with_fonte(DepSource::Path {
12732 caminho: "../caixa-teia; rm *".into(),
12733 });
12734 let err = d.validate().unwrap_err();
12735 assert!(
12736 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12737 "got {err:?}",
12738 );
12739 }
12740
12741 #[test]
12742 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
12743 // Cascade pin on the upstream shell-pipe arm: a value
12744 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
12745 // canonical pipeline-to-glob paste idiom) routes through
12746 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
12747 // pipeline-tail paste is the load-bearing root-cause edit
12748 // on every probe-as-both value.
12749 let d = dep_with_fonte(DepSource::Path {
12750 caminho: "../caixa-teia | ls *".into(),
12751 });
12752 let err = d.validate().unwrap_err();
12753 assert!(
12754 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12755 "got {err:?}",
12756 );
12757 }
12758
12759 #[test]
12760 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
12761 // Cascade pin on the upstream shell-redirection arm: a value
12762 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
12763 // canonical "I pasted a `cmd > log *` redirect-plus-glob
12764 // chain" footgun) routes through
12765 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
12766 // The input/output redirection metachar carries the more
12767 // self-locating `byte` payload (it names which of `<` or `>`
12768 // triggered), so the prior arm wins on every probe-as-both
12769 // value.
12770 let d = dep_with_fonte(DepSource::Path {
12771 caminho: "../caixa-teia>log *".into(),
12772 });
12773 let err = d.validate().unwrap_err();
12774 assert!(
12775 matches!(
12776 err,
12777 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12778 ),
12779 "got {err:?}",
12780 );
12781 }
12782
12783 #[test]
12784 fn fonte_caminho_backslash_fires_before_shell_glob() {
12785 // Cascade pin on the upstream backslash arm: a value
12786 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12787 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12788 // expression" footgun) routes through
12789 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12790 // cross-host-OS-separator divergence is the load-bearing
12791 // axis on every probe-as-both value (an author who removes
12792 // the `\` is the root-cause edit; the `*` falls away in the
12793 // same edit since it's downstream of the Windows-shell
12794 // convention).
12795 let d = dep_with_fonte(DepSource::Path {
12796 caminho: "..\\caixa-teia\\*".into(),
12797 });
12798 let err = d.validate().unwrap_err();
12799 assert!(
12800 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12801 "got {err:?}",
12802 );
12803 }
12804
12805 #[test]
12806 fn fonte_caminho_control_char_fires_before_shell_glob() {
12807 // Cascade pin on the embedded-control-byte arm: a value
12808 // carrying both a control byte and `*` (`"../foo\n*"` — the
12809 // canonical paste-from-multiline-doc footgun where a
12810 // newline landed mid-caminho between two paste fragments)
12811 // routes through `FonteCaminhoControlChar` not
12812 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12813 // NUL-`CString::new`-fail diagnostic is the load-bearing
12814 // axis on every value that probes positive for both —
12815 // mirrors the cascade discipline on every prior arm.
12816 let d = dep_with_fonte(DepSource::Path {
12817 caminho: "../foo\n*".into(),
12818 });
12819 let err = d.validate().unwrap_err();
12820 assert!(
12821 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12822 "got {err:?}",
12823 );
12824 }
12825
12826 #[test]
12827 fn fonte_caminho_absolute_fires_before_shell_glob() {
12828 // Cascade pin on the load-bearing leading-byte arm: a
12829 // leading `/` value with embedded `*` (`"/etc/*"`) routes
12830 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12831 // — the host-layout-leak diagnostic is the load-bearing
12832 // axis, the glob byte is the secondary observation. Same
12833 // precedence logic as every prior leading-byte arm.
12834 let d = dep_with_fonte(DepSource::Path {
12835 caminho: "/etc/*".into(),
12836 });
12837 let err = d.validate().unwrap_err();
12838 assert!(
12839 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12840 "got {err:?}",
12841 );
12842 }
12843
12844 #[test]
12845 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12846 // Cascade pin on the immediate-successor arm: a value
12847 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12848 // canonical "I tab-completed a path that already had a
12849 // glob-expansion tail" footgun) routes through
12850 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12851 // The embedded shell-metachar is the more semantic-locating
12852 // axis (an author who removes the `*` typically also drops
12853 // the trailing separator since both are paste-from-shell
12854 // artifacts).
12855 let d = dep_with_fonte(DepSource::Path {
12856 caminho: "../foo*/".into(),
12857 });
12858 let err = d.validate().unwrap_err();
12859 assert!(
12860 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12861 "got {err:?}",
12862 );
12863 }
12864
12865 #[test]
12866 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12867 // Diagnostic-shape pin (peer with
12868 // `fonte_caminho_shell_redirection_diagnostic_*` on the
12869 // closest two-byte peer arm): the error's Display surfaces
12870 // the offending `:nome`, the offending `:caminho` verbatim,
12871 // the offending byte's hex / character form, and names the
12872 // shell-glob / pathname-expansion footgun explicitly so a
12873 // `feira lint` run can render the diagnostic without
12874 // re-parsing.
12875 let d = dep_with_fonte(DepSource::Path {
12876 caminho: "../caixa-teia/*.lisp".into(),
12877 });
12878 let rendered = d.validate().unwrap_err().to_string();
12879 assert!(
12880 rendered.contains("caixa-teia"),
12881 "diagnostic must name the offending dep: {rendered}",
12882 );
12883 assert!(
12884 rendered.contains("../caixa-teia/*.lisp"),
12885 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12886 );
12887 assert!(
12888 rendered.contains("0x2a"),
12889 "diagnostic must surface the offending byte hex: {rendered:?}",
12890 );
12891 assert!(
12892 rendered.contains("glob"),
12893 "diagnostic must name the shell-glob footgun: {rendered:?}",
12894 );
12895 assert!(
12896 rendered.contains("pathname-expansion"),
12897 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12898 );
12899 }
12900
12901 #[test]
12902 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12903 // The fail-before-pass-after pin for the canonical modern-Bourne
12904 // command-substitution paste footgun: an author copies a
12905 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12906 // `$(<cmd>)` expansion would land the current date as a
12907 // subdirectory name and silently passed every prior arm
12908 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12909 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12910 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12911 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12912 // sits mid-path). The lacre embedded the value verbatim, the
12913 // resolver folded it through `Path::join` looking for a literal
12914 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12915 // surfaced at resolve time with a non-self-locating `No such
12916 // file or directory` error. The new arm moves the rejection to
12917 // validate time and names the offending dep + caminho + byte
12918 // verbatim. The arm fires on the first `(` encountered (the
12919 // opening byte of `$(date)`).
12920 let d = dep_with_fonte(DepSource::Path {
12921 caminho: "../caixa-teia/$(date)/build".into(),
12922 });
12923 let err = d.validate().unwrap_err();
12924 let DepError::FonteCaminhoShellSubshellGrouping {
12925 nome,
12926 caminho,
12927 byte,
12928 } = err
12929 else {
12930 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12931 };
12932 assert_eq!(nome, "caixa-teia");
12933 assert_eq!(caminho, "../caixa-teia/$(date)/build");
12934 assert_eq!(byte, b'(');
12935 }
12936
12937 #[test]
12938 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12939 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12940 // the degenerate "I selected an unbalanced closing paren out of
12941 // a shell-history block" idiom that probes for the cascade's
12942 // last-byte handling on a value carrying only the closing byte).
12943 // Pinned separately from the open-paren shape so the gate's
12944 // contract is "any `(` or `)` anywhere", not single-byte
12945 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12946 // caminho_carrying_question_glob` shape on the immediate-
12947 // predecessor `FonteCaminhoShellGlob` arm.
12948 let d = dep_with_fonte(DepSource::Path {
12949 caminho: "../caixa-teia)".into(),
12950 });
12951 let err = d.validate().unwrap_err();
12952 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12953 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12954 };
12955 assert_eq!(byte, b')');
12956 }
12957
12958 #[test]
12959 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12960 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12961 // canonical "I selected a `(cd foo)` subshell-grouping prefix
12962 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12963 // Pinned separately from the embedded-byte shape so the gate
12964 // covers every position, not only mid-path.
12965 let d = dep_with_fonte(DepSource::Path {
12966 caminho: "(cd foo)/caixa-teia".into(),
12967 });
12968 let err = d.validate().unwrap_err();
12969 assert!(
12970 matches!(
12971 err,
12972 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12973 ),
12974 "got {err:?}",
12975 );
12976 }
12977
12978 #[test]
12979 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12980 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12981 // — the canonical "I copied a `(pwd)` working-directory-probe
12982 // subshell-grouping idiom every shell-history block carries"
12983 // footgun). The value carries no other cascade-preceding
12984 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12985 // `*` / `?`) so the arm fires on the first `(` encountered;
12986 // pinned so a future arm that tries to distinguish the
12987 // opening from the closing byte doesn't break the broader
12988 // contract. Mirrors the peer
12989 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12990 // backtick_pair` shape on the upstream `FonteCaminhoShell\
12991 // CommandSubstitution` arm.
12992 let d = dep_with_fonte(DepSource::Path {
12993 caminho: "../(pwd)/caixa-teia".into(),
12994 });
12995 let err = d.validate().unwrap_err();
12996 assert!(
12997 matches!(
12998 err,
12999 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13000 ),
13001 "got {err:?}",
13002 );
13003 }
13004
13005 #[test]
13006 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
13007 // The positive-control pin: the gate targets only `(` / `)`,
13008 // never adjacent printable ASCII or POSIX-valid bytes. The
13009 // canonical relative POSIX path (`"../caixa-teia"`) and a
13010 // nested deeply-pathed variant with adjacent printable
13011 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
13012 // validate cleanly so the gate doesn't widen to a "no printable
13013 // punctuation anywhere" sweep that would defeat the entire
13014 // path-fonte author surface.
13015 let d = dep_with_fonte(DepSource::Path {
13016 caminho: "../caixa-teia/sub-dir.v2".into(),
13017 });
13018 d.validate().unwrap();
13019 }
13020
13021 #[test]
13022 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
13023 // Cascade pin on the immediate-predecessor arm: a value
13024 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
13025 // canonical "I pasted a glob expansion followed by a
13026 // subshell-grouping tail" footgun) routes through
13027 // `FonteCaminhoShellGlob` not
13028 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
13029 // shape is the more common shell-history paste idiom on every
13030 // probe-as-both value — same cascade discipline every prior
13031 // `:caminho` arm establishes.
13032 let d = dep_with_fonte(DepSource::Path {
13033 caminho: "../caixa-teia/*(date)".into(),
13034 });
13035 let err = d.validate().unwrap_err();
13036 assert!(
13037 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13038 "got {err:?}",
13039 );
13040 }
13041
13042 #[test]
13043 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
13044 // Cascade pin on the upstream shell-command-substitution arm: a
13045 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
13046 // — the canonical "I pasted a legacy-backtick + modern-paren
13047 // command-substitution chain" footgun) routes through
13048 // `FonteCaminhoShellCommandSubstitution` not
13049 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
13050 // command-injection vector is the load-bearing root-cause edit
13051 // on every probe-as-both value.
13052 let d = dep_with_fonte(DepSource::Path {
13053 caminho: "../`whoami`/$(date)".into(),
13054 });
13055 let err = d.validate().unwrap_err();
13056 assert!(
13057 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13058 "got {err:?}",
13059 );
13060 }
13061
13062 #[test]
13063 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
13064 // Cascade pin on the upstream shell-background arm: a value
13065 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
13066 // the canonical "I pasted a `cmd & (cd foo)` background-launch
13067 // + subshell-grouping chain" footgun) routes through
13068 // `FonteCaminhoShellBackground` not
13069 // `FonteCaminhoShellSubshellGrouping`. The background-launch
13070 // tail is the load-bearing root-cause edit on every probe-as-
13071 // both value.
13072 let d = dep_with_fonte(DepSource::Path {
13073 caminho: "../caixa-teia & (cd foo)".into(),
13074 });
13075 let err = d.validate().unwrap_err();
13076 assert!(
13077 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13078 "got {err:?}",
13079 );
13080 }
13081
13082 #[test]
13083 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
13084 // Cascade pin on the upstream shell-semicolon arm: a value
13085 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
13086 // the canonical sequential-cleanup + subshell-grouping paste
13087 // idiom) routes through `FonteCaminhoShellSemicolon` not
13088 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
13089 // separator paste is the load-bearing root-cause edit on
13090 // every probe-as-both value.
13091 let d = dep_with_fonte(DepSource::Path {
13092 caminho: "../caixa-teia; (cd foo)".into(),
13093 });
13094 let err = d.validate().unwrap_err();
13095 assert!(
13096 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13097 "got {err:?}",
13098 );
13099 }
13100
13101 #[test]
13102 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
13103 // Cascade pin on the upstream shell-pipe arm: a value carrying
13104 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
13105 // canonical pipeline-to-subshell-grouping paste idiom) routes
13106 // through `FonteCaminhoShellPipe` not
13107 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
13108 // is the load-bearing root-cause edit on every probe-as-both
13109 // value.
13110 let d = dep_with_fonte(DepSource::Path {
13111 caminho: "../caixa-teia | (tee log)".into(),
13112 });
13113 let err = d.validate().unwrap_err();
13114 assert!(
13115 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13116 "got {err:?}",
13117 );
13118 }
13119
13120 #[test]
13121 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
13122 // Cascade pin on the upstream shell-redirection arm: a value
13123 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
13124 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
13125 // plus-subshell-grouping chain" footgun) routes through
13126 // `FonteCaminhoShellRedirection` not
13127 // `FonteCaminhoShellSubshellGrouping`. The input/output
13128 // redirection metachar carries the more self-locating `byte`
13129 // payload (it names which of `<` or `>` triggered), so the
13130 // prior arm wins on every probe-as-both value.
13131 let d = dep_with_fonte(DepSource::Path {
13132 caminho: "../caixa-teia>log (cd foo)".into(),
13133 });
13134 let err = d.validate().unwrap_err();
13135 assert!(
13136 matches!(
13137 err,
13138 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13139 ),
13140 "got {err:?}",
13141 );
13142 }
13143
13144 #[test]
13145 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
13146 // Cascade pin on the upstream backslash arm: a value carrying
13147 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
13148 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
13149 // through `FonteCaminhoBackslash` not
13150 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
13151 // separator divergence is the load-bearing axis on every
13152 // probe-as-both value (an author who removes the `\` is the
13153 // root-cause edit; the `(` falls away in the same edit since
13154 // it's downstream of the Windows-shell convention).
13155 let d = dep_with_fonte(DepSource::Path {
13156 caminho: "..\\caixa-teia\\(cd foo)".into(),
13157 });
13158 let err = d.validate().unwrap_err();
13159 assert!(
13160 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13161 "got {err:?}",
13162 );
13163 }
13164
13165 #[test]
13166 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
13167 // Cascade pin on the embedded-control-byte arm: a value
13168 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
13169 // the canonical paste-from-multiline-doc footgun where a
13170 // newline landed mid-caminho between two paste fragments)
13171 // routes through `FonteCaminhoControlChar` not
13172 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
13173 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13174 // load-bearing axis on every value that probes positive for
13175 // both — mirrors the cascade discipline on every prior arm.
13176 let d = dep_with_fonte(DepSource::Path {
13177 caminho: "../foo\n(cd bar)".into(),
13178 });
13179 let err = d.validate().unwrap_err();
13180 assert!(
13181 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13182 "got {err:?}",
13183 );
13184 }
13185
13186 #[test]
13187 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
13188 // Cascade pin on the load-bearing leading-byte arm: a leading
13189 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
13190 // through `FonteCaminhoAbsolute` not
13191 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
13192 // diagnostic is the load-bearing axis, the subshell-grouping
13193 // byte is the secondary observation. Same precedence logic as
13194 // every prior leading-byte arm.
13195 let d = dep_with_fonte(DepSource::Path {
13196 caminho: "/etc/(cd foo)".into(),
13197 });
13198 let err = d.validate().unwrap_err();
13199 assert!(
13200 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13201 "got {err:?}",
13202 );
13203 }
13204
13205 #[test]
13206 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
13207 // Cascade pin on the upstream leading-`$` var-expansion arm: a
13208 // value carrying both a leading `$` and a `(` (`"$(date)/\
13209 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
13210 // command-substitution at the head of a sibling-workspace
13211 // path" footgun) routes through `FonteCaminhoVarExpansion` not
13212 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
13213 // shell-variable-expansion is the more self-locating diagnostic
13214 // on values that probe as both — same load-bearing-leading-
13215 // byte cascade discipline every prior `:caminho` arm
13216 // establishes. Closing both halves of `$(<cmd>)` structurally
13217 // (leading `$` here, trailing `)` on the new arm) excludes the
13218 // entire modern Bourne command-substitution surface from the
13219 // typed `:caminho` accepted set; the cascade preserves the
13220 // narrower leading-byte diagnostic on values that probe both
13221 // halves at the canonical leading position.
13222 let d = dep_with_fonte(DepSource::Path {
13223 caminho: "$(date)/caixa-teia".into(),
13224 });
13225 let err = d.validate().unwrap_err();
13226 assert!(
13227 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13228 "got {err:?}",
13229 );
13230 }
13231
13232 #[test]
13233 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
13234 // Cascade pin on the immediate-successor arm: a value carrying
13235 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
13236 // "I tab-completed a path that already had a subshell-grouping
13237 // expansion tail" footgun) routes through
13238 // `FonteCaminhoShellSubshellGrouping` not
13239 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
13240 // the more semantic-locating axis (an author who removes the
13241 // `(` typically also drops the trailing separator since both
13242 // are paste-from-shell artifacts).
13243 let d = dep_with_fonte(DepSource::Path {
13244 caminho: "../(cd foo)/".into(),
13245 });
13246 let err = d.validate().unwrap_err();
13247 assert!(
13248 matches!(
13249 err,
13250 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13251 ),
13252 "got {err:?}",
13253 );
13254 }
13255
13256 #[test]
13257 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13258 // Diagnostic-shape pin (peer with
13259 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
13260 // on the closest two-byte peer arm): the error's Display
13261 // surfaces the offending `:nome`, the offending `:caminho`
13262 // verbatim, the offending byte's hex / character form, and
13263 // names the shell-subshell-grouping footgun explicitly so a
13264 // `feira lint` run can render the diagnostic without re-
13265 // parsing.
13266 let d = dep_with_fonte(DepSource::Path {
13267 caminho: "../caixa-teia/$(date)/build".into(),
13268 });
13269 let rendered = d.validate().unwrap_err().to_string();
13270 assert!(
13271 rendered.contains("caixa-teia"),
13272 "diagnostic must name the offending dep: {rendered}",
13273 );
13274 assert!(
13275 rendered.contains("../caixa-teia/$(date)/build"),
13276 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13277 );
13278 assert!(
13279 rendered.contains("0x28"),
13280 "diagnostic must surface the offending byte hex: {rendered:?}",
13281 );
13282 assert!(
13283 rendered.contains("subshell-grouping"),
13284 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
13285 );
13286 assert!(
13287 rendered.contains("command-substitution"),
13288 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
13289 {rendered:?}",
13290 );
13291 }
13292
13293 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
13294 //
13295 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
13296 // `)`) byte-pair arm: the same per-byte cascade with the same
13297 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
13298 // `}` brace-expansion / URI-Template placeholder axis. The peer
13299 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
13300 // byte pair on the sibling `:fonte :repo` axis under the same
13301 // banner.
13302
13303 #[test]
13304 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
13305 // The fail-before-pass-after pin for the canonical paste-from-
13306 // shell-history brace-expansion footgun: an author copies a
13307 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
13308 // liner whose `{a,b}` brace expansion fans across two siblings
13309 // and silently passed every prior arm (`Path::is_absolute`
13310 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
13311 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
13312 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
13313 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13314 // value starts with `..` not `$`). The lacre embedded the
13315 // value verbatim, the resolver folded it through `Path::join`
13316 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
13317 // subdirectory, and the failure surfaced at resolve time with
13318 // a non-self-locating `No such file or directory` error. The
13319 // new arm moves the rejection to validate time and names the
13320 // offending dep + caminho + byte verbatim. The arm fires on
13321 // the first `{` encountered.
13322 let d = dep_with_fonte(DepSource::Path {
13323 caminho: "../{caixa-teia,caixa-helm}/build".into(),
13324 });
13325 let err = d.validate().unwrap_err();
13326 let DepError::FonteCaminhoShellBraceExpansion {
13327 nome,
13328 caminho,
13329 byte,
13330 } = err
13331 else {
13332 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13333 };
13334 assert_eq!(nome, "caixa-teia");
13335 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
13336 assert_eq!(byte, b'{');
13337 }
13338
13339 #[test]
13340 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
13341 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
13342 // the degenerate "I selected an unbalanced closing brace out
13343 // of a shell-history block" idiom that probes for the
13344 // cascade's last-byte handling on a value carrying only the
13345 // closing byte). Pinned separately from the open-brace shape
13346 // so the gate's contract is "any `{` or `}` anywhere", not
13347 // single-byte coverage. Mirrors the peer
13348 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
13349 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
13350 // arm.
13351 let d = dep_with_fonte(DepSource::Path {
13352 caminho: "../caixa-teia}".into(),
13353 });
13354 let err = d.validate().unwrap_err();
13355 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
13356 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13357 };
13358 assert_eq!(byte, b'}');
13359 }
13360
13361 #[test]
13362 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
13363 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
13364 // — the canonical "I selected a `{a,b}` brace-expansion prefix
13365 // out of a shell-history one-liner" idiom). Pinned separately
13366 // from the embedded-byte shape so the gate covers every
13367 // position, not only mid-path.
13368 let d = dep_with_fonte(DepSource::Path {
13369 caminho: "{caixa-teia,caixa-helm}/build".into(),
13370 });
13371 let err = d.validate().unwrap_err();
13372 assert!(
13373 matches!(
13374 err,
13375 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13376 ),
13377 "got {err:?}",
13378 );
13379 }
13380
13381 #[test]
13382 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
13383 // The canonical URI-Template / Mustache / Helm doubled-brace
13384 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
13385 // "I copied a `https://github.com/{{org}}/caixa-teia` README
13386 // quick-start / OpenAPI spec / Helm chart `home:` template
13387 // and forgot to substitute the placeholder" footgun). The arm
13388 // fires on the first `{` encountered; pinned so the gate's
13389 // coverage extends from the bare-brace shell-history shape to
13390 // the doubled-brace URI-Template / templating-engine shape.
13391 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
13392 // sibling `:fonte :repo` axis.
13393 let d = dep_with_fonte(DepSource::Path {
13394 caminho: "../{{org}}/caixa-teia".into(),
13395 });
13396 let err = d.validate().unwrap_err();
13397 assert!(
13398 matches!(
13399 err,
13400 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13401 ),
13402 "got {err:?}",
13403 );
13404 }
13405
13406 #[test]
13407 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
13408 // The canonical bash brace-range-expansion shape (`"../caixa-
13409 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
13410 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
13411 // sequence-range form to the `{a,b,c}` comma-separated form).
13412 // The arm fires on the first `{` encountered; pinned so the
13413 // gate's coverage extends from the comma-separated form to
13414 // the integer-range form.
13415 let d = dep_with_fonte(DepSource::Path {
13416 caminho: "../caixa-v{1..10}".into(),
13417 });
13418 let err = d.validate().unwrap_err();
13419 assert!(
13420 matches!(
13421 err,
13422 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13423 ),
13424 "got {err:?}",
13425 );
13426 }
13427
13428 #[test]
13429 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
13430 // The positive-control pin: the gate targets only `{` / `}`,
13431 // never adjacent printable ASCII or POSIX-valid bytes. The
13432 // canonical relative POSIX path (`"../caixa-teia"`) and a
13433 // nested deeply-pathed variant with adjacent printable
13434 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
13435 // validate cleanly so the gate doesn't widen to a "no
13436 // printable punctuation anywhere" sweep that would defeat
13437 // the entire path-fonte author surface. Peer with
13438 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
13439 // on the immediate-predecessor arm.
13440 let d = dep_with_fonte(DepSource::Path {
13441 caminho: "../caixa-teia/sub-dir.v2".into(),
13442 });
13443 d.validate().unwrap();
13444 }
13445
13446 #[test]
13447 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
13448 // Cascade pin on the immediate-predecessor arm: a value
13449 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
13450 // canonical "I pasted a subshell-grouping followed by a
13451 // brace-expansion tail" footgun) routes through
13452 // `FonteCaminhoShellSubshellGrouping` not
13453 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
13454 // shape is the more semantic-locating axis on every probe-
13455 // as-both value because it closes both halves of the modern
13456 // Bourne `$(<cmd>)` command-substitution surface — same
13457 // cascade discipline every prior `:caminho` arm establishes.
13458 let d = dep_with_fonte(DepSource::Path {
13459 caminho: "../(cd foo)/{a,b}".into(),
13460 });
13461 let err = d.validate().unwrap_err();
13462 assert!(
13463 matches!(
13464 err,
13465 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13466 ),
13467 "got {err:?}",
13468 );
13469 }
13470
13471 #[test]
13472 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
13473 // Cascade pin on the upstream shell-glob arm: a value carrying
13474 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
13475 // "I pasted a glob expansion followed by a brace-expansion
13476 // tail" footgun) routes through `FonteCaminhoShellGlob` not
13477 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
13478 // shape is the load-bearing root-cause edit on every
13479 // probe-as-both value.
13480 let d = dep_with_fonte(DepSource::Path {
13481 caminho: "../caixa-teia/*{a,b}".into(),
13482 });
13483 let err = d.validate().unwrap_err();
13484 assert!(
13485 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13486 "got {err:?}",
13487 );
13488 }
13489
13490 #[test]
13491 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
13492 // Cascade pin on the upstream shell-command-substitution arm:
13493 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
13494 // — the canonical "I pasted a legacy-backtick command-
13495 // substitution followed by a brace-expansion fan-out" footgun)
13496 // routes through `FonteCaminhoShellCommandSubstitution` not
13497 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
13498 // command-injection vector is the load-bearing root-cause
13499 // edit on every probe-as-both value.
13500 let d = dep_with_fonte(DepSource::Path {
13501 caminho: "../`whoami`/{a,b}".into(),
13502 });
13503 let err = d.validate().unwrap_err();
13504 assert!(
13505 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13506 "got {err:?}",
13507 );
13508 }
13509
13510 #[test]
13511 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
13512 // Cascade pin on the upstream shell-background arm: a value
13513 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
13514 // canonical "I pasted a `cmd & {fork-fan}` background-launch
13515 // + brace-expansion chain" footgun) routes through
13516 // `FonteCaminhoShellBackground` not
13517 // `FonteCaminhoShellBraceExpansion`. The background-launch
13518 // tail is the load-bearing root-cause edit on every
13519 // probe-as-both value.
13520 let d = dep_with_fonte(DepSource::Path {
13521 caminho: "../caixa-teia & {a,b}".into(),
13522 });
13523 let err = d.validate().unwrap_err();
13524 assert!(
13525 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13526 "got {err:?}",
13527 );
13528 }
13529
13530 #[test]
13531 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
13532 // Cascade pin on the upstream shell-semicolon arm: a value
13533 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
13534 // canonical sequential-cleanup + brace-expansion paste
13535 // idiom) routes through `FonteCaminhoShellSemicolon` not
13536 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
13537 // separator paste is the load-bearing root-cause edit on
13538 // every probe-as-both value.
13539 let d = dep_with_fonte(DepSource::Path {
13540 caminho: "../caixa-teia; {a,b}".into(),
13541 });
13542 let err = d.validate().unwrap_err();
13543 assert!(
13544 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13545 "got {err:?}",
13546 );
13547 }
13548
13549 #[test]
13550 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
13551 // Cascade pin on the upstream shell-pipe arm: a value
13552 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
13553 // — the canonical pipeline-to-brace-expansion paste idiom)
13554 // routes through `FonteCaminhoShellPipe` not
13555 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
13556 // is the load-bearing root-cause edit on every probe-as-
13557 // both value.
13558 let d = dep_with_fonte(DepSource::Path {
13559 caminho: "../caixa-teia | {tee,cat}".into(),
13560 });
13561 let err = d.validate().unwrap_err();
13562 assert!(
13563 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13564 "got {err:?}",
13565 );
13566 }
13567
13568 #[test]
13569 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
13570 // Cascade pin on the upstream shell-redirection arm: a value
13571 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
13572 // the canonical "I pasted a `cmd > log {a,b}` redirect-
13573 // plus-brace-expansion chain" footgun) routes through
13574 // `FonteCaminhoShellRedirection` not
13575 // `FonteCaminhoShellBraceExpansion`. The input/output
13576 // redirection metachar carries the more self-locating
13577 // `byte` payload, so the prior arm wins on every probe-
13578 // as-both value.
13579 let d = dep_with_fonte(DepSource::Path {
13580 caminho: "../caixa-teia>log {a,b}".into(),
13581 });
13582 let err = d.validate().unwrap_err();
13583 assert!(
13584 matches!(
13585 err,
13586 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13587 ),
13588 "got {err:?}",
13589 );
13590 }
13591
13592 #[test]
13593 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
13594 // Cascade pin on the upstream backslash arm: a value
13595 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
13596 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
13597 // chain") routes through `FonteCaminhoBackslash` not
13598 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
13599 // separator divergence is the load-bearing axis on every
13600 // probe-as-both value.
13601 let d = dep_with_fonte(DepSource::Path {
13602 caminho: "..\\caixa-teia\\{a,b}".into(),
13603 });
13604 let err = d.validate().unwrap_err();
13605 assert!(
13606 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13607 "got {err:?}",
13608 );
13609 }
13610
13611 #[test]
13612 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
13613 // Cascade pin on the embedded-control-byte arm: a value
13614 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
13615 // the canonical paste-from-multiline-doc footgun where a
13616 // newline landed mid-caminho between two paste fragments)
13617 // routes through `FonteCaminhoControlChar` not
13618 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
13619 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13620 // load-bearing axis on every value that probes positive for
13621 // both — mirrors the cascade discipline on every prior arm.
13622 let d = dep_with_fonte(DepSource::Path {
13623 caminho: "../foo\n{a,b}".into(),
13624 });
13625 let err = d.validate().unwrap_err();
13626 assert!(
13627 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13628 "got {err:?}",
13629 );
13630 }
13631
13632 #[test]
13633 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
13634 // Cascade pin on the load-bearing leading-byte arm: a
13635 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
13636 // routes through `FonteCaminhoAbsolute` not
13637 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
13638 // diagnostic is the load-bearing axis, the brace-expansion
13639 // byte is the secondary observation. Same precedence logic
13640 // as every prior leading-byte arm.
13641 let d = dep_with_fonte(DepSource::Path {
13642 caminho: "/etc/{a,b}".into(),
13643 });
13644 let err = d.validate().unwrap_err();
13645 assert!(
13646 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13647 "got {err:?}",
13648 );
13649 }
13650
13651 #[test]
13652 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
13653 // Cascade pin on the upstream leading-`$` var-expansion
13654 // arm: a value carrying both a leading `$` and a `{`
13655 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
13656 // `${ORG}` shell-variable + curly-brace expansion at the
13657 // head of a sibling-workspace path" footgun) routes through
13658 // `FonteCaminhoVarExpansion` not
13659 // `FonteCaminhoShellBraceExpansion`. The leading-byte
13660 // shell-variable-expansion is the more self-locating
13661 // diagnostic on values that probe as both — same
13662 // load-bearing-leading-byte cascade discipline every prior
13663 // `:caminho` arm establishes.
13664 let d = dep_with_fonte(DepSource::Path {
13665 caminho: "${ORG}/caixa-teia".into(),
13666 });
13667 let err = d.validate().unwrap_err();
13668 assert!(
13669 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13670 "got {err:?}",
13671 );
13672 }
13673
13674 #[test]
13675 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
13676 // Cascade pin on the immediate-successor arm: a value
13677 // carrying both `{` and a trailing `/`
13678 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
13679 // tab-completed a path that already had a brace-expansion
13680 // expansion tail" footgun) routes through
13681 // `FonteCaminhoShellBraceExpansion` not
13682 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13683 // is the more semantic-locating axis (an author who removes
13684 // the `{` typically also drops the trailing separator since
13685 // both are paste-from-shell artifacts).
13686 let d = dep_with_fonte(DepSource::Path {
13687 caminho: "../{caixa-teia,caixa-helm}/".into(),
13688 });
13689 let err = d.validate().unwrap_err();
13690 assert!(
13691 matches!(
13692 err,
13693 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13694 ),
13695 "got {err:?}",
13696 );
13697 }
13698
13699 #[test]
13700 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13701 // Diagnostic-shape pin (peer with
13702 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13703 // on the closest two-byte peer arm): the error's Display
13704 // surfaces the offending `:nome`, the offending `:caminho`
13705 // verbatim, the offending byte's hex / character form, and
13706 // names the shell-brace-expansion / URI-Template footgun
13707 // explicitly so a `feira lint` run can render the diagnostic
13708 // without re-parsing.
13709 let d = dep_with_fonte(DepSource::Path {
13710 caminho: "../{caixa-teia,caixa-helm}/build".into(),
13711 });
13712 let rendered = d.validate().unwrap_err().to_string();
13713 assert!(
13714 rendered.contains("caixa-teia"),
13715 "diagnostic must name the offending dep: {rendered}",
13716 );
13717 assert!(
13718 rendered.contains("../{caixa-teia,caixa-helm}/build"),
13719 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13720 );
13721 assert!(
13722 rendered.contains("0x7b"),
13723 "diagnostic must surface the offending byte hex: {rendered:?}",
13724 );
13725 assert!(
13726 rendered.contains("brace-expansion"),
13727 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
13728 );
13729 assert!(
13730 rendered.contains("URI Template"),
13731 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
13732 {rendered:?}",
13733 );
13734 }
13735
13736 #[test]
13737 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
13738 // The canonical paste-from-shell-history bracket-glob /
13739 // character-class footgun: an author copies a
13740 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
13741 // `[a-z]` POSIX glob character-class matches every lowercase-
13742 // ASCII-suffix sibling caixa directory and silently passed
13743 // every prior arm (`Path::is_absolute` false on `..`, no
13744 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
13745 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
13746 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
13747 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13748 // value starts with `..` not `$`). The lacre embedded the
13749 // value verbatim, the resolver folded it through
13750 // `Path::join` looking for a literal `./../caixa-[a-z]/
13751 // build` subdirectory, and the failure surfaced at resolve
13752 // time with a non-self-locating `No such file or directory`
13753 // error. The new arm moves the rejection to validate time
13754 // and names the offending dep + caminho + byte verbatim.
13755 // The arm fires on the first `[` encountered.
13756 let d = dep_with_fonte(DepSource::Path {
13757 caminho: "../caixa-[a-z]/build".into(),
13758 });
13759 let err = d.validate().unwrap_err();
13760 let DepError::FonteCaminhoShellBracketExpansion {
13761 nome,
13762 caminho,
13763 byte,
13764 } = err
13765 else {
13766 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13767 };
13768 assert_eq!(nome, "caixa-teia");
13769 assert_eq!(caminho, "../caixa-[a-z]/build");
13770 assert_eq!(byte, b'[');
13771 }
13772
13773 #[test]
13774 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13775 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13776 // — the degenerate "I selected an unbalanced closing bracket
13777 // out of a glob character-class block" idiom that probes for
13778 // the cascade's last-byte handling on a value carrying only
13779 // the closing byte). Pinned separately from the open-bracket
13780 // shape so the gate's contract is "any `[` or `]` anywhere",
13781 // not single-byte coverage. Mirrors the peer
13782 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13783 // shape on the immediate-predecessor
13784 // `FonteCaminhoShellBraceExpansion` arm.
13785 let d = dep_with_fonte(DepSource::Path {
13786 caminho: "../caixa-teia]".into(),
13787 });
13788 let err = d.validate().unwrap_err();
13789 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13790 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13791 };
13792 assert_eq!(byte, b']');
13793 }
13794
13795 #[test]
13796 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13797 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13798 // canonical "I selected a `[caixa-teia]` TOML-table-header /
13799 // glob-character-class prefix out of an aligned config /
13800 // shell-history one-liner" idiom). Pinned separately from
13801 // the embedded-byte shape so the gate covers every position,
13802 // not only mid-path.
13803 let d = dep_with_fonte(DepSource::Path {
13804 caminho: "[caixa-teia]/build".into(),
13805 });
13806 let err = d.validate().unwrap_err();
13807 assert!(
13808 matches!(
13809 err,
13810 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13811 ),
13812 "got {err:?}",
13813 );
13814 }
13815
13816 #[test]
13817 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13818 // The canonical TOML inline-array / YAML flow-sequence
13819 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13820 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13821 // inline-array out of a sibling-Cargo manifest" cross-idiom
13822 // leak; the symmetric YAML flow-sequence form `paths: [/a,
13823 // /b]` paste-from-values.yaml shape carries the same
13824 // bracket pair). The arm fires on the first `[` encountered;
13825 // pinned so the gate's coverage extends from the bare-
13826 // bracket glob-character-class shape to the TOML / YAML /
13827 // JSON array-literal shape.
13828 let d = dep_with_fonte(DepSource::Path {
13829 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13830 });
13831 let err = d.validate().unwrap_err();
13832 assert!(
13833 matches!(
13834 err,
13835 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13836 ),
13837 "got {err:?}",
13838 );
13839 }
13840
13841 #[test]
13842 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13843 // The canonical POSIX `test` / `[` builtin command paste
13844 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13845 // script conditional every paste-from-shell-script idiom
13846 // carries; bash's `[[ <expr> ]]` extended-test grammar
13847 // would surface the same byte pair). The arm fires on the
13848 // first `[` encountered; pinned so the gate's coverage
13849 // extends from the embedded-glob-character-class shape to
13850 // the leading-`test`-builtin / extended-test form.
13851 let d = dep_with_fonte(DepSource::Path {
13852 caminho: "../[ -d caixa-teia ]".into(),
13853 });
13854 let err = d.validate().unwrap_err();
13855 assert!(
13856 matches!(
13857 err,
13858 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13859 ),
13860 "got {err:?}",
13861 );
13862 }
13863
13864 #[test]
13865 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13866 // The positive-control pin: the gate targets only `[` /
13867 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13868 // The canonical relative POSIX path (`"../caixa-teia"`) and
13869 // a nested deeply-pathed variant with adjacent printable
13870 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13871 // to validate cleanly so the gate doesn't widen to a "no
13872 // printable punctuation anywhere" sweep that would defeat
13873 // the entire path-fonte author surface. Peer with
13874 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13875 // on the immediate-predecessor arm.
13876 let d = dep_with_fonte(DepSource::Path {
13877 caminho: "../caixa-teia/sub-dir.v2".into(),
13878 });
13879 d.validate().unwrap();
13880 }
13881
13882 #[test]
13883 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13884 // Cascade pin on the immediate-predecessor arm: a value
13885 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13886 // canonical "I pasted a brace-expansion fan followed by a
13887 // glob-character-class tail" footgun) routes through
13888 // `FonteCaminhoShellBraceExpansion` not
13889 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13890 // fan is the load-bearing root-cause edit on every
13891 // probe-as-both value because the bracket-class tail
13892 // typically rides on a prior brace-expansion expansion;
13893 // same cascade discipline every prior `:caminho` arm
13894 // establishes.
13895 let d = dep_with_fonte(DepSource::Path {
13896 caminho: "../{a,b}[ch]".into(),
13897 });
13898 let err = d.validate().unwrap_err();
13899 assert!(
13900 matches!(
13901 err,
13902 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13903 ),
13904 "got {err:?}",
13905 );
13906 }
13907
13908 #[test]
13909 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13910 // Cascade pin on the upstream shell-subshell-grouping arm:
13911 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13912 // the canonical "I pasted a subshell-grouping followed by
13913 // a glob-character-class tail" footgun) routes through
13914 // `FonteCaminhoShellSubshellGrouping` not
13915 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13916 // `$(<cmd>)` command-substitution boundary is the load-
13917 // bearing axis on every probe-as-both value.
13918 let d = dep_with_fonte(DepSource::Path {
13919 caminho: "../(cd foo)/[ch]".into(),
13920 });
13921 let err = d.validate().unwrap_err();
13922 assert!(
13923 matches!(
13924 err,
13925 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13926 ),
13927 "got {err:?}",
13928 );
13929 }
13930
13931 #[test]
13932 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13933 // Cascade pin on the upstream shell-glob arm: a value
13934 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13935 // canonical "I pasted a `*.[ch]` C-source-file glob whose
13936 // unbounded `*` precedes the bracket character-class"
13937 // footgun) routes through `FonteCaminhoShellGlob` not
13938 // `FonteCaminhoShellBracketExpansion`. The unbounded
13939 // pathname-expansion sentinel is the load-bearing root-
13940 // cause edit on every probe-as-both value — the unbounded
13941 // `*` carries the more aggressive expansion vector than
13942 // the bounded `[ch]` class, so the prior arm wins.
13943 let d = dep_with_fonte(DepSource::Path {
13944 caminho: "../caixa-teia/*[ch]".into(),
13945 });
13946 let err = d.validate().unwrap_err();
13947 assert!(
13948 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13949 "got {err:?}",
13950 );
13951 }
13952
13953 #[test]
13954 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13955 // Cascade pin on the upstream shell-command-substitution
13956 // arm: a value carrying both a backtick and `[`
13957 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13958 // legacy-backtick command-substitution followed by a
13959 // glob-character-class tail" footgun) routes through
13960 // `FonteCaminhoShellCommandSubstitution` not
13961 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13962 // command-injection vector is the load-bearing root-cause
13963 // edit on every probe-as-both value.
13964 let d = dep_with_fonte(DepSource::Path {
13965 caminho: "../`whoami`/[ch]".into(),
13966 });
13967 let err = d.validate().unwrap_err();
13968 assert!(
13969 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13970 "got {err:?}",
13971 );
13972 }
13973
13974 #[test]
13975 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13976 // Cascade pin on the upstream shell-background arm: a
13977 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13978 // — the canonical "I pasted a `cmd & [glob]` background-
13979 // launch + bracket-class chain" footgun) routes through
13980 // `FonteCaminhoShellBackground` not
13981 // `FonteCaminhoShellBracketExpansion`. The background-
13982 // launch tail is the load-bearing root-cause edit on
13983 // every probe-as-both value.
13984 let d = dep_with_fonte(DepSource::Path {
13985 caminho: "../caixa-teia & [ch]".into(),
13986 });
13987 let err = d.validate().unwrap_err();
13988 assert!(
13989 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13990 "got {err:?}",
13991 );
13992 }
13993
13994 #[test]
13995 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13996 // Cascade pin on the upstream shell-semicolon arm: a value
13997 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13998 // canonical sequential-cleanup + bracket-class paste
13999 // idiom) routes through `FonteCaminhoShellSemicolon` not
14000 // `FonteCaminhoShellBracketExpansion`. The sequential-
14001 // command-separator paste is the load-bearing root-cause
14002 // edit on every probe-as-both value.
14003 let d = dep_with_fonte(DepSource::Path {
14004 caminho: "../caixa-teia; [ch]".into(),
14005 });
14006 let err = d.validate().unwrap_err();
14007 assert!(
14008 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14009 "got {err:?}",
14010 );
14011 }
14012
14013 #[test]
14014 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
14015 // Cascade pin on the upstream shell-pipe arm: a value
14016 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
14017 // the canonical pipeline-to-bracket-class paste idiom)
14018 // routes through `FonteCaminhoShellPipe` not
14019 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
14020 // paste is the load-bearing root-cause edit on every
14021 // probe-as-both value.
14022 let d = dep_with_fonte(DepSource::Path {
14023 caminho: "../caixa-teia | [tee]".into(),
14024 });
14025 let err = d.validate().unwrap_err();
14026 assert!(
14027 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14028 "got {err:?}",
14029 );
14030 }
14031
14032 #[test]
14033 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
14034 // Cascade pin on the upstream shell-redirection arm: a
14035 // value carrying both `>` and `[` (`"../caixa-teia>log
14036 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
14037 // redirect-plus-bracket chain" footgun) routes through
14038 // `FonteCaminhoShellRedirection` not
14039 // `FonteCaminhoShellBracketExpansion`. The input/output
14040 // redirection metachar carries the more self-locating
14041 // `byte` payload, so the prior arm wins on every
14042 // probe-as-both value.
14043 let d = dep_with_fonte(DepSource::Path {
14044 caminho: "../caixa-teia>log [ch]".into(),
14045 });
14046 let err = d.validate().unwrap_err();
14047 assert!(
14048 matches!(
14049 err,
14050 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14051 ),
14052 "got {err:?}",
14053 );
14054 }
14055
14056 #[test]
14057 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
14058 // Cascade pin on the upstream backslash arm: a value
14059 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
14060 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
14061 // chain") routes through `FonteCaminhoBackslash` not
14062 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
14063 // separator divergence is the load-bearing axis on every
14064 // probe-as-both value.
14065 let d = dep_with_fonte(DepSource::Path {
14066 caminho: "..\\caixa-teia\\[ch]".into(),
14067 });
14068 let err = d.validate().unwrap_err();
14069 assert!(
14070 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14071 "got {err:?}",
14072 );
14073 }
14074
14075 #[test]
14076 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
14077 // Cascade pin on the embedded-control-byte arm: a value
14078 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
14079 // the canonical paste-from-multiline-doc footgun where a
14080 // newline landed mid-caminho between two paste fragments)
14081 // routes through `FonteCaminhoControlChar` not
14082 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
14083 // rejected-byte / NUL-`CString::new`-fail diagnostic is
14084 // the load-bearing axis on every value that probes
14085 // positive for both — mirrors the cascade discipline on
14086 // every prior arm.
14087 let d = dep_with_fonte(DepSource::Path {
14088 caminho: "../foo\n[ch]".into(),
14089 });
14090 let err = d.validate().unwrap_err();
14091 assert!(
14092 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14093 "got {err:?}",
14094 );
14095 }
14096
14097 #[test]
14098 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
14099 // Cascade pin on the load-bearing leading-byte arm: a
14100 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
14101 // routes through `FonteCaminhoAbsolute` not
14102 // `FonteCaminhoShellBracketExpansion` — the host-layout-
14103 // leak diagnostic is the load-bearing axis, the bracket-
14104 // expansion byte is the secondary observation. Same
14105 // precedence logic as every prior leading-byte arm.
14106 let d = dep_with_fonte(DepSource::Path {
14107 caminho: "/etc/[ch]".into(),
14108 });
14109 let err = d.validate().unwrap_err();
14110 assert!(
14111 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14112 "got {err:?}",
14113 );
14114 }
14115
14116 #[test]
14117 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
14118 // Cascade pin on the upstream leading-`$` var-expansion
14119 // arm: a value carrying both a leading `$` and a `[`
14120 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
14121 // variable + bracket-class at the head of a sibling-
14122 // workspace path" footgun) routes through
14123 // `FonteCaminhoVarExpansion` not
14124 // `FonteCaminhoShellBracketExpansion`. The leading-byte
14125 // shell-variable-expansion is the more self-locating
14126 // diagnostic on values that probe as both — same
14127 // load-bearing-leading-byte cascade discipline every
14128 // prior `:caminho` arm establishes.
14129 let d = dep_with_fonte(DepSource::Path {
14130 caminho: "$DIR/[ch]".into(),
14131 });
14132 let err = d.validate().unwrap_err();
14133 assert!(
14134 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14135 "got {err:?}",
14136 );
14137 }
14138
14139 #[test]
14140 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
14141 // Cascade pin on the immediate-successor arm: a value
14142 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
14143 // the canonical "I tab-completed a path that already had
14144 // a bracket-glob-character-class expansion tail" footgun)
14145 // routes through `FonteCaminhoShellBracketExpansion` not
14146 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14147 // is the more semantic-locating axis (an author who
14148 // removes the `[` typically also drops the trailing
14149 // separator since both are paste-from-shell artifacts).
14150 let d = dep_with_fonte(DepSource::Path {
14151 caminho: "../[a-z]/".into(),
14152 });
14153 let err = d.validate().unwrap_err();
14154 assert!(
14155 matches!(
14156 err,
14157 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14158 ),
14159 "got {err:?}",
14160 );
14161 }
14162
14163 #[test]
14164 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14165 // Diagnostic-shape pin (peer with
14166 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14167 // on the closest two-byte peer arm): the error's Display
14168 // surfaces the offending `:nome`, the offending `:caminho`
14169 // verbatim, the offending byte's hex / character form, and
14170 // names the shell-bracket-expansion / glob-character-class
14171 // footgun explicitly so a `feira lint` run can render the
14172 // diagnostic without re-parsing.
14173 let d = dep_with_fonte(DepSource::Path {
14174 caminho: "../caixa-[a-z]/build".into(),
14175 });
14176 let rendered = d.validate().unwrap_err().to_string();
14177 assert!(
14178 rendered.contains("caixa-teia"),
14179 "diagnostic must name the offending dep: {rendered}",
14180 );
14181 assert!(
14182 rendered.contains("../caixa-[a-z]/build"),
14183 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14184 );
14185 assert!(
14186 rendered.contains("0x5b"),
14187 "diagnostic must surface the offending byte hex: {rendered:?}",
14188 );
14189 assert!(
14190 rendered.contains("bracket-expansion"),
14191 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
14192 );
14193 assert!(
14194 rendered.contains("glob-character-class"),
14195 "diagnostic must reference the POSIX glob-character-class vocabulary: \
14196 {rendered:?}",
14197 );
14198 }
14199
14200 #[test]
14201 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
14202 // The canonical paste-from-shell-history strong-quoted
14203 // sibling-workspace-path footgun: an author copies a
14204 // `cd '../caixa-teia'` shell-history one-liner whose strong-
14205 // quoting preserved the path across a whitespace paste
14206 // boundary and silently passed every prior arm
14207 // (`Path::is_absolute` false on `'..`, no control bytes, no
14208 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
14209 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
14210 // doesn't end in `/`; the leading-`$` f4efe9c
14211 // `FonteCaminhoVarExpansion` arm doesn't fire because the
14212 // value starts with `'` not `$`). The lacre embedded the
14213 // value verbatim, the resolver folded it through
14214 // `Path::join` looking for a literal `./'../caixa-teia'`
14215 // subdirectory, and the failure surfaced at resolve time
14216 // with a non-self-locating `No such file or directory`
14217 // error. The new arm moves the rejection to validate time
14218 // and names the offending dep + caminho + byte verbatim.
14219 // The arm fires on the first `'` encountered.
14220 let d = dep_with_fonte(DepSource::Path {
14221 caminho: "'../caixa-teia'".into(),
14222 });
14223 let err = d.validate().unwrap_err();
14224 let DepError::FonteCaminhoShellQuoteGrouping {
14225 nome,
14226 caminho,
14227 byte,
14228 } = err
14229 else {
14230 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
14231 };
14232 assert_eq!(nome, "caixa-teia");
14233 assert_eq!(caminho, "'../caixa-teia'");
14234 assert_eq!(byte, b'\'');
14235 }
14236
14237 #[test]
14238 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
14239 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
14240 // — the canonical paste-from-JSON-config / paste-from-YAML-
14241 // flow-scalar / paste-from-TOML-basic-string / paste-from-
14242 // tatara-lisp-string-literal cross-idiom leak). Pinned
14243 // separately from the single-quote shape so the gate's
14244 // contract is "any `'` or `\"` anywhere", not single-byte
14245 // coverage. Mirrors the peer
14246 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
14247 // shape on the immediate-predecessor
14248 // `FonteCaminhoShellBracketExpansion` arm.
14249 let d = dep_with_fonte(DepSource::Path {
14250 caminho: "\"../caixa-teia\"".into(),
14251 });
14252 let err = d.validate().unwrap_err();
14253 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
14254 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
14255 };
14256 assert_eq!(byte, b'"');
14257 }
14258
14259 #[test]
14260 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
14261 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
14262 // canonical "I pasted a JSON key-value pair fragment into
14263 // the middle of the path" idiom). Pinned separately from
14264 // the leading-byte shape so the gate covers every position,
14265 // not only leading.
14266 let d = dep_with_fonte(DepSource::Path {
14267 caminho: "../\"caixa-teia\"".into(),
14268 });
14269 let err = d.validate().unwrap_err();
14270 assert!(
14271 matches!(
14272 err,
14273 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
14274 ),
14275 "got {err:?}",
14276 );
14277 }
14278
14279 #[test]
14280 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
14281 // The canonical YAML double-quoted flow-scalar cross-idiom
14282 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
14283 // `path: \"...\"` YAML flow-scalar entry out of an aligned
14284 // values.yaml / K8s manifest and dropped it verbatim into
14285 // the `:caminho` slot including the `path: ` key prefix"
14286 // paste-idiom). The arm fires on the first `"` encountered;
14287 // pinned so the gate's coverage extends from the bare-quote
14288 // paste shape to the aligned-YAML-manifest cross-idiom-leak
14289 // shape.
14290 let d = dep_with_fonte(DepSource::Path {
14291 caminho: "path: \"../caixa-teia\"".into(),
14292 });
14293 let err = d.validate().unwrap_err();
14294 assert!(
14295 matches!(
14296 err,
14297 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
14298 ),
14299 "got {err:?}",
14300 );
14301 }
14302
14303 #[test]
14304 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
14305 // The positive-control pin: the gate targets only `'` /
14306 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
14307 // The canonical relative POSIX path (`"../caixa-teia"`) and
14308 // a nested deeply-pathed variant with adjacent printable
14309 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14310 // to validate cleanly so the gate doesn't widen to a "no
14311 // printable punctuation anywhere" sweep that would defeat
14312 // the entire path-fonte author surface. Peer with
14313 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
14314 // on the immediate-predecessor arm.
14315 let d = dep_with_fonte(DepSource::Path {
14316 caminho: "../caixa-teia/sub-dir.v2".into(),
14317 });
14318 d.validate().unwrap();
14319 }
14320
14321 #[test]
14322 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
14323 // Cascade pin on the immediate-predecessor arm: a value
14324 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
14325 // "I pasted a glob-character-class followed by a strong-
14326 // quoted literal tail" footgun) routes through
14327 // `FonteCaminhoShellBracketExpansion` not
14328 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
14329 // expansion is the load-bearing root-cause edit on every
14330 // probe-as-both value; same cascade discipline every prior
14331 // `:caminho` arm establishes.
14332 let d = dep_with_fonte(DepSource::Path {
14333 caminho: "../[a-z]'x'".into(),
14334 });
14335 let err = d.validate().unwrap_err();
14336 assert!(
14337 matches!(
14338 err,
14339 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14340 ),
14341 "got {err:?}",
14342 );
14343 }
14344
14345 #[test]
14346 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
14347 // Cascade pin on the upstream shell-brace-expansion arm: a
14348 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
14349 // canonical "I pasted a brace-expansion fan followed by a
14350 // strong-quoted literal tail" footgun) routes through
14351 // `FonteCaminhoShellBraceExpansion` not
14352 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
14353 // is the load-bearing root-cause edit on every probe-as-
14354 // both value.
14355 let d = dep_with_fonte(DepSource::Path {
14356 caminho: "../{a,b}'x'".into(),
14357 });
14358 let err = d.validate().unwrap_err();
14359 assert!(
14360 matches!(
14361 err,
14362 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14363 ),
14364 "got {err:?}",
14365 );
14366 }
14367
14368 #[test]
14369 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
14370 // Cascade pin on the upstream shell-subshell-grouping arm:
14371 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
14372 // the canonical "I pasted a subshell-grouping followed by
14373 // a strong-quoted literal tail" footgun) routes through
14374 // `FonteCaminhoShellSubshellGrouping` not
14375 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
14376 // `$(<cmd>)` command-substitution boundary is the load-
14377 // bearing axis on every probe-as-both value.
14378 let d = dep_with_fonte(DepSource::Path {
14379 caminho: "../(cd foo)/'x'".into(),
14380 });
14381 let err = d.validate().unwrap_err();
14382 assert!(
14383 matches!(
14384 err,
14385 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14386 ),
14387 "got {err:?}",
14388 );
14389 }
14390
14391 #[test]
14392 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
14393 // Cascade pin on the upstream shell-glob arm: a value
14394 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
14395 // canonical "I pasted a `*` unbounded pathname-expansion
14396 // followed by a strong-quoted literal tail" footgun) routes
14397 // through `FonteCaminhoShellGlob` not
14398 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
14399 // expansion sentinel is the load-bearing root-cause edit
14400 // on every probe-as-both value.
14401 let d = dep_with_fonte(DepSource::Path {
14402 caminho: "../caixa-teia/*'x'".into(),
14403 });
14404 let err = d.validate().unwrap_err();
14405 assert!(
14406 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14407 "got {err:?}",
14408 );
14409 }
14410
14411 #[test]
14412 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
14413 // Cascade pin on the upstream shell-command-substitution
14414 // arm: a value carrying both a backtick and `'`
14415 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
14416 // legacy-backtick command-substitution followed by a
14417 // strong-quoted literal tail" footgun) routes through
14418 // `FonteCaminhoShellCommandSubstitution` not
14419 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
14420 // command-injection vector is the load-bearing root-cause
14421 // edit on every probe-as-both value.
14422 let d = dep_with_fonte(DepSource::Path {
14423 caminho: "../`whoami`/'x'".into(),
14424 });
14425 let err = d.validate().unwrap_err();
14426 assert!(
14427 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14428 "got {err:?}",
14429 );
14430 }
14431
14432 #[test]
14433 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
14434 // Cascade pin on the upstream shell-background arm: a value
14435 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
14436 // canonical "I pasted a `cmd & 'literal'` background-launch
14437 // + quote chain" footgun) routes through
14438 // `FonteCaminhoShellBackground` not
14439 // `FonteCaminhoShellQuoteGrouping`. The background-launch
14440 // tail is the load-bearing root-cause edit on every
14441 // probe-as-both value.
14442 let d = dep_with_fonte(DepSource::Path {
14443 caminho: "../caixa-teia & 'x'".into(),
14444 });
14445 let err = d.validate().unwrap_err();
14446 assert!(
14447 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14448 "got {err:?}",
14449 );
14450 }
14451
14452 #[test]
14453 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
14454 // Cascade pin on the upstream shell-semicolon arm: a value
14455 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
14456 // canonical sequential-cleanup + quote paste idiom) routes
14457 // through `FonteCaminhoShellSemicolon` not
14458 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
14459 // separator paste is the load-bearing root-cause edit on
14460 // every probe-as-both value.
14461 let d = dep_with_fonte(DepSource::Path {
14462 caminho: "../caixa-teia; 'x'".into(),
14463 });
14464 let err = d.validate().unwrap_err();
14465 assert!(
14466 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14467 "got {err:?}",
14468 );
14469 }
14470
14471 #[test]
14472 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
14473 // Cascade pin on the upstream shell-pipe arm: a value
14474 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
14475 // canonical pipeline-to-quoted-literal paste idiom) routes
14476 // through `FonteCaminhoShellPipe` not
14477 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
14478 // is the load-bearing root-cause edit on every probe-as-
14479 // both value.
14480 let d = dep_with_fonte(DepSource::Path {
14481 caminho: "../caixa-teia | 'x'".into(),
14482 });
14483 let err = d.validate().unwrap_err();
14484 assert!(
14485 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14486 "got {err:?}",
14487 );
14488 }
14489
14490 #[test]
14491 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
14492 // Cascade pin on the upstream shell-redirection arm: a
14493 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
14494 // — the canonical "I pasted a `cmd > log 'literal'`
14495 // redirect-plus-quote chain" footgun) routes through
14496 // `FonteCaminhoShellRedirection` not
14497 // `FonteCaminhoShellQuoteGrouping`. The input/output
14498 // redirection metachar carries the more self-locating
14499 // `byte` payload, so the prior arm wins on every probe-as-
14500 // both value.
14501 let d = dep_with_fonte(DepSource::Path {
14502 caminho: "../caixa-teia>log 'x'".into(),
14503 });
14504 let err = d.validate().unwrap_err();
14505 assert!(
14506 matches!(
14507 err,
14508 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14509 ),
14510 "got {err:?}",
14511 );
14512 }
14513
14514 #[test]
14515 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
14516 // Cascade pin on the upstream backslash arm: a value
14517 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
14518 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
14519 // chain" footgun) routes through `FonteCaminhoBackslash`
14520 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
14521 // separator divergence is the load-bearing axis on every
14522 // probe-as-both value.
14523 let d = dep_with_fonte(DepSource::Path {
14524 caminho: "..\\caixa-teia\\'x'".into(),
14525 });
14526 let err = d.validate().unwrap_err();
14527 assert!(
14528 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14529 "got {err:?}",
14530 );
14531 }
14532
14533 #[test]
14534 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
14535 // Cascade pin on the embedded-control-byte arm: a value
14536 // carrying both a control byte and `'` (`"../foo\n'x'"` —
14537 // the canonical paste-from-multiline-doc footgun where a
14538 // newline landed mid-caminho between two paste fragments)
14539 // routes through `FonteCaminhoControlChar` not
14540 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
14541 // rejected-byte / NUL-`CString::new`-fail diagnostic is
14542 // the load-bearing axis on every value that probes
14543 // positive for both — mirrors the cascade discipline on
14544 // every prior arm.
14545 let d = dep_with_fonte(DepSource::Path {
14546 caminho: "../foo\n'x'".into(),
14547 });
14548 let err = d.validate().unwrap_err();
14549 assert!(
14550 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14551 "got {err:?}",
14552 );
14553 }
14554
14555 #[test]
14556 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
14557 // Cascade pin on the load-bearing leading-byte arm: a
14558 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
14559 // through `FonteCaminhoAbsolute` not
14560 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
14561 // diagnostic is the load-bearing axis, the quote byte is
14562 // the secondary observation. Same precedence logic as every
14563 // prior leading-byte arm.
14564 let d = dep_with_fonte(DepSource::Path {
14565 caminho: "/etc/'x'".into(),
14566 });
14567 let err = d.validate().unwrap_err();
14568 assert!(
14569 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14570 "got {err:?}",
14571 );
14572 }
14573
14574 #[test]
14575 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
14576 // Cascade pin on the upstream leading-`$` var-expansion
14577 // arm: a value carrying both a leading `$` and a `'`
14578 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
14579 // variable + quoted literal at the head of a sibling-
14580 // workspace path" footgun) routes through
14581 // `FonteCaminhoVarExpansion` not
14582 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
14583 // shell-variable-expansion is the more self-locating
14584 // diagnostic on values that probe as both — same
14585 // load-bearing-leading-byte cascade discipline every
14586 // prior `:caminho` arm establishes.
14587 let d = dep_with_fonte(DepSource::Path {
14588 caminho: "$DIR/'x'".into(),
14589 });
14590 let err = d.validate().unwrap_err();
14591 assert!(
14592 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14593 "got {err:?}",
14594 );
14595 }
14596
14597 #[test]
14598 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
14599 // Cascade pin on the immediate-successor arm: a value
14600 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
14601 // — the canonical "I tab-completed a path whose strong-
14602 // quoted body already carried the quoting from a shell-
14603 // history paste" footgun) routes through
14604 // `FonteCaminhoShellQuoteGrouping` not
14605 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14606 // is the more semantic-locating axis (an author who removes
14607 // the `'` typically also drops the trailing separator since
14608 // both are paste-from-shell artifacts).
14609 let d = dep_with_fonte(DepSource::Path {
14610 caminho: "../'caixa-teia'/".into(),
14611 });
14612 let err = d.validate().unwrap_err();
14613 assert!(
14614 matches!(
14615 err,
14616 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14617 ),
14618 "got {err:?}",
14619 );
14620 }
14621
14622 #[test]
14623 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
14624 // Diagnostic-shape pin (peer with
14625 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14626 // on the closest two-byte peer arm): the error's Display
14627 // surfaces the offending `:nome`, the offending `:caminho`
14628 // verbatim, the offending byte's hex / character form, and
14629 // names the shell-quote-grouping / cross-config-DSL-string-
14630 // literal-delimiter footgun explicitly so a `feira lint`
14631 // run can render the diagnostic without re-parsing.
14632 let d = dep_with_fonte(DepSource::Path {
14633 caminho: "'../caixa-teia'".into(),
14634 });
14635 let rendered = d.validate().unwrap_err().to_string();
14636 assert!(
14637 rendered.contains("caixa-teia"),
14638 "diagnostic must name the offending dep: {rendered}",
14639 );
14640 assert!(
14641 rendered.contains("'../caixa-teia'"),
14642 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14643 );
14644 assert!(
14645 rendered.contains("0x27"),
14646 "diagnostic must surface the offending byte hex: {rendered:?}",
14647 );
14648 assert!(
14649 rendered.contains("quote-grouping"),
14650 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
14651 );
14652 assert!(
14653 rendered.contains("string-literal"),
14654 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
14655 vocabulary: {rendered:?}",
14656 );
14657 }
14658
14659 #[test]
14660 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
14661 // The canonical paste-from-shell-history-with-trailing-
14662 // annotation footgun: an author pastes a `cd ../caixa-teia
14663 // # legacy sibling` shell-history one-liner whose unquoted `#`
14664 // comment-lead separates the path from an inline annotation.
14665 // The POSIX shell trims the annotation to `../caixa-teia`
14666 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
14667 // `Path::is_absolute` returns false on `..`, `#` is neither
14668 // a leading-byte sentinel nor a control byte nor `\` nor
14669 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
14670 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
14671 // `"`, and the value's last byte isn't `/` — so the value
14672 // silently passed every prior arm. The resolver folded the
14673 // value through `Path::join` looking for a literal
14674 // `./../caixa-teia # legacy sibling` subdirectory and the
14675 // failure surfaced at resolve time with a non-self-locating
14676 // `No such file or directory` error. The new arm moves the
14677 // rejection to validate time and names the offending dep +
14678 // caminho + byte verbatim.
14679 let d = dep_with_fonte(DepSource::Path {
14680 caminho: "../caixa-teia # legacy sibling".into(),
14681 });
14682 let err = d.validate().unwrap_err();
14683 let DepError::FonteCaminhoShellComment {
14684 nome,
14685 caminho,
14686 byte,
14687 } = err
14688 else {
14689 panic!("expected FonteCaminhoShellComment, got {err:?}");
14690 };
14691 assert_eq!(nome, "caixa-teia");
14692 assert_eq!(caminho, "../caixa-teia # legacy sibling");
14693 assert_eq!(byte, b'#');
14694 }
14695
14696 #[test]
14697 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
14698 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
14699 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
14700 // canonical "I copied a `path: ../caixa-teia # pin` YAML
14701 // scalar-plus-comment entry out of an aligned values.yaml and
14702 // dropped it verbatim into the `:caminho` slot" paste-idiom).
14703 // Pinned separately from the shell-history shape so the
14704 // gate's coverage extends from the single-space `#` shape to
14705 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
14706 // requires the `#` to be preceded by whitespace to lex as a
14707 // comment (bare `foo#bar` is a single scalar); the double-
14708 // space paste from an aligned manifest is the canonical
14709 // shape.
14710 let d = dep_with_fonte(DepSource::Path {
14711 caminho: "../caixa-teia # pin".into(),
14712 });
14713 let err = d.validate().unwrap_err();
14714 assert!(
14715 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14716 "got {err:?}",
14717 );
14718 }
14719
14720 #[test]
14721 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
14722 // The URL-fragment-identifier paste shape
14723 // (`"../caixa-teia#readme"` — the canonical
14724 // paste-from-browser-address-bar permalink shape where the
14725 // browser preserved the `#anchor` tail on the copy). Pinned
14726 // separately from the whitespace-separated shell / YAML
14727 // comment shapes so the gate covers the unpadded RFC 3986
14728 // §3.5 fragment-delimiter position too, not only positions
14729 // preceded by unquoted whitespace. Peer with the immediate-
14730 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
14731 // (a68f818) which closes the same byte under the same URL-
14732 // fragment-identifier banner.
14733 let d = dep_with_fonte(DepSource::Path {
14734 caminho: "../caixa-teia#readme".into(),
14735 });
14736 let err = d.validate().unwrap_err();
14737 assert!(
14738 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14739 "got {err:?}",
14740 );
14741 }
14742
14743 #[test]
14744 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
14745 // Leading-position `#` shape (`"#../caixa-teia"` — the
14746 // "I copied a shell-comment-out entry from a commented-out
14747 // dep row" footgun). Pinned separately from the embedded
14748 // shapes so the gate covers every position, not only
14749 // whitespace-preceded / mid-value.
14750 let d = dep_with_fonte(DepSource::Path {
14751 caminho: "#../caixa-teia".into(),
14752 });
14753 let err = d.validate().unwrap_err();
14754 assert!(
14755 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14756 "got {err:?}",
14757 );
14758 }
14759
14760 #[test]
14761 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
14762 // The positive-control pin: the gate targets only `#`,
14763 // never adjacent printable ASCII or POSIX-valid bytes. The
14764 // canonical relative POSIX path (`"../caixa-teia"`) and a
14765 // nested deeply-pathed variant with adjacent printable
14766 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14767 // to validate cleanly so the gate doesn't widen to a "no
14768 // printable punctuation anywhere" sweep that would defeat
14769 // the entire path-fonte author surface. Peer with
14770 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
14771 // on the immediate-predecessor arm.
14772 let d = dep_with_fonte(DepSource::Path {
14773 caminho: "../caixa-teia/sub-dir.v2".into(),
14774 });
14775 d.validate().unwrap();
14776 }
14777
14778 #[test]
14779 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14780 // Cascade pin on the immediate-predecessor arm: a value
14781 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14782 // "I pasted a strong-quoted literal followed by a URL-
14783 // fragment permalink tail" footgun) routes through
14784 // `FonteCaminhoShellQuoteGrouping` not
14785 // `FonteCaminhoShellComment`. The shell-string-literal-
14786 // delimiter is the load-bearing root-cause edit on every
14787 // probe-as-both value; same cascade discipline every prior
14788 // `:caminho` arm establishes.
14789 let d = dep_with_fonte(DepSource::Path {
14790 caminho: "../'x'#pin".into(),
14791 });
14792 let err = d.validate().unwrap_err();
14793 assert!(
14794 matches!(
14795 err,
14796 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14797 ),
14798 "got {err:?}",
14799 );
14800 }
14801
14802 #[test]
14803 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14804 // Cascade pin on the upstream shell-bracket-expansion arm:
14805 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14806 // canonical "I pasted a glob-character-class followed by a
14807 // URL-fragment tail" footgun) routes through
14808 // `FonteCaminhoShellBracketExpansion` not
14809 // `FonteCaminhoShellComment`. The glob-character-class
14810 // expansion is the load-bearing root-cause edit on every
14811 // probe-as-both value.
14812 let d = dep_with_fonte(DepSource::Path {
14813 caminho: "../[a-z]#pin".into(),
14814 });
14815 let err = d.validate().unwrap_err();
14816 assert!(
14817 matches!(
14818 err,
14819 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14820 ),
14821 "got {err:?}",
14822 );
14823 }
14824
14825 #[test]
14826 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14827 // Cascade pin on the upstream shell-brace-expansion arm: a
14828 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14829 // canonical "I pasted a brace-expansion fan followed by a
14830 // URL-fragment tail" footgun) routes through
14831 // `FonteCaminhoShellBraceExpansion` not
14832 // `FonteCaminhoShellComment`. The brace-expansion fan is the
14833 // load-bearing root-cause edit on every probe-as-both value.
14834 let d = dep_with_fonte(DepSource::Path {
14835 caminho: "../{a,b}#pin".into(),
14836 });
14837 let err = d.validate().unwrap_err();
14838 assert!(
14839 matches!(
14840 err,
14841 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14842 ),
14843 "got {err:?}",
14844 );
14845 }
14846
14847 #[test]
14848 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14849 // Cascade pin on the upstream shell-subshell-grouping arm:
14850 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14851 // the canonical "I pasted a subshell-grouping followed by a
14852 // URL-fragment tail" footgun) routes through
14853 // `FonteCaminhoShellSubshellGrouping` not
14854 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14855 // command-substitution boundary is the load-bearing axis on
14856 // every probe-as-both value.
14857 let d = dep_with_fonte(DepSource::Path {
14858 caminho: "../(cd foo)#pin".into(),
14859 });
14860 let err = d.validate().unwrap_err();
14861 assert!(
14862 matches!(
14863 err,
14864 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14865 ),
14866 "got {err:?}",
14867 );
14868 }
14869
14870 #[test]
14871 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14872 // Cascade pin on the upstream shell-glob arm: a value
14873 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14874 // canonical "I pasted a `*` unbounded pathname-expansion
14875 // followed by a URL-fragment tail" footgun) routes through
14876 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14877 // The unbounded pathname-expansion sentinel is the load-
14878 // bearing root-cause edit on every probe-as-both value.
14879 let d = dep_with_fonte(DepSource::Path {
14880 caminho: "../caixa-teia/*#pin".into(),
14881 });
14882 let err = d.validate().unwrap_err();
14883 assert!(
14884 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14885 "got {err:?}",
14886 );
14887 }
14888
14889 #[test]
14890 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14891 // Cascade pin on the upstream shell-command-substitution
14892 // arm: a value carrying both a backtick and `#`
14893 // (``"../`whoami`#pin"`` — the canonical "I pasted a
14894 // legacy-backtick command-substitution followed by a URL-
14895 // fragment tail" footgun) routes through
14896 // `FonteCaminhoShellCommandSubstitution` not
14897 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14898 // injection vector is the load-bearing root-cause edit on
14899 // every probe-as-both value.
14900 let d = dep_with_fonte(DepSource::Path {
14901 caminho: "../`whoami`#pin".into(),
14902 });
14903 let err = d.validate().unwrap_err();
14904 assert!(
14905 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14906 "got {err:?}",
14907 );
14908 }
14909
14910 #[test]
14911 fn fonte_caminho_shell_background_fires_before_shell_comment() {
14912 // Cascade pin on the upstream shell-background arm: a value
14913 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14914 // the canonical "I pasted a `cmd &` background-launch
14915 // followed by a URL-fragment tail" footgun) routes through
14916 // `FonteCaminhoShellBackground` not
14917 // `FonteCaminhoShellComment`. The background-launch tail is
14918 // the load-bearing root-cause edit on every probe-as-both
14919 // value.
14920 let d = dep_with_fonte(DepSource::Path {
14921 caminho: "../caixa-teia&pin#tail".into(),
14922 });
14923 let err = d.validate().unwrap_err();
14924 assert!(
14925 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14926 "got {err:?}",
14927 );
14928 }
14929
14930 #[test]
14931 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14932 // Cascade pin on the upstream shell-semicolon arm: a value
14933 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14934 // the canonical sequential-cleanup + URL-fragment paste
14935 // idiom) routes through `FonteCaminhoShellSemicolon` not
14936 // `FonteCaminhoShellComment`. The sequential-command-
14937 // separator paste is the load-bearing root-cause edit on
14938 // every probe-as-both value.
14939 let d = dep_with_fonte(DepSource::Path {
14940 caminho: "../caixa-teia;pin#tail".into(),
14941 });
14942 let err = d.validate().unwrap_err();
14943 assert!(
14944 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14945 "got {err:?}",
14946 );
14947 }
14948
14949 #[test]
14950 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14951 // Cascade pin on the upstream shell-pipe arm: a value
14952 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14953 // the canonical pipeline-to-URL-fragment paste idiom) routes
14954 // through `FonteCaminhoShellPipe` not
14955 // `FonteCaminhoShellComment`. The pipeline-tail paste is
14956 // the load-bearing root-cause edit on every probe-as-both
14957 // value.
14958 let d = dep_with_fonte(DepSource::Path {
14959 caminho: "../caixa-teia|pin#tail".into(),
14960 });
14961 let err = d.validate().unwrap_err();
14962 assert!(
14963 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14964 "got {err:?}",
14965 );
14966 }
14967
14968 #[test]
14969 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14970 // Cascade pin on the upstream shell-redirection arm: a
14971 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14972 // — the canonical "I pasted a `cmd > log` redirect followed
14973 // by a URL-fragment tail" footgun) routes through
14974 // `FonteCaminhoShellRedirection` not
14975 // `FonteCaminhoShellComment`. The input/output redirection
14976 // metachar carries the more self-locating `byte` payload,
14977 // so the prior arm wins on every probe-as-both value.
14978 let d = dep_with_fonte(DepSource::Path {
14979 caminho: "../caixa-teia>log#pin".into(),
14980 });
14981 let err = d.validate().unwrap_err();
14982 assert!(
14983 matches!(
14984 err,
14985 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14986 ),
14987 "got {err:?}",
14988 );
14989 }
14990
14991 #[test]
14992 fn fonte_caminho_backslash_fires_before_shell_comment() {
14993 // Cascade pin on the upstream backslash arm: a value
14994 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14995 // canonical "I pasted a Windows-shell path followed by a
14996 // URL-fragment tail" footgun) routes through
14997 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14998 // The cross-host-OS-separator divergence is the load-
14999 // bearing axis on every probe-as-both value.
15000 let d = dep_with_fonte(DepSource::Path {
15001 caminho: "..\\caixa-teia#pin".into(),
15002 });
15003 let err = d.validate().unwrap_err();
15004 assert!(
15005 matches!(err, DepError::FonteCaminhoBackslash { .. }),
15006 "got {err:?}",
15007 );
15008 }
15009
15010 #[test]
15011 fn fonte_caminho_control_char_fires_before_shell_comment() {
15012 // Cascade pin on the embedded-control-byte arm: a value
15013 // carrying both a control byte and `#` (`"../foo\n#pin"` —
15014 // the canonical paste-from-multiline-doc footgun where a
15015 // newline landed mid-caminho between the path and an
15016 // annotation) routes through `FonteCaminhoControlChar` not
15017 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
15018 // byte diagnostic is the load-bearing axis on every value
15019 // that probes positive for both — mirrors the cascade
15020 // discipline on every prior arm.
15021 let d = dep_with_fonte(DepSource::Path {
15022 caminho: "../foo\n#pin".into(),
15023 });
15024 let err = d.validate().unwrap_err();
15025 assert!(
15026 matches!(err, DepError::FonteCaminhoControlChar { .. }),
15027 "got {err:?}",
15028 );
15029 }
15030
15031 #[test]
15032 fn fonte_caminho_absolute_fires_before_shell_comment() {
15033 // Cascade pin on the load-bearing leading-byte arm: a
15034 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
15035 // routes through `FonteCaminhoAbsolute` not
15036 // `FonteCaminhoShellComment` — the host-layout-leak
15037 // diagnostic is the load-bearing axis, the fragment byte is
15038 // the secondary observation. Same precedence logic as every
15039 // prior leading-byte arm.
15040 let d = dep_with_fonte(DepSource::Path {
15041 caminho: "/etc/foo#pin".into(),
15042 });
15043 let err = d.validate().unwrap_err();
15044 assert!(
15045 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
15046 "got {err:?}",
15047 );
15048 }
15049
15050 #[test]
15051 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
15052 // Cascade pin on the upstream leading-`$` var-expansion
15053 // arm: a value carrying both a leading `$` and a `#`
15054 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
15055 // shell-variable at the head of a sibling-workspace path
15056 // followed by a URL-fragment tail" footgun) routes through
15057 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
15058 // The leading-byte shell-variable-expansion is the more
15059 // self-locating diagnostic on values that probe as both.
15060 let d = dep_with_fonte(DepSource::Path {
15061 caminho: "$DIR/foo#pin".into(),
15062 });
15063 let err = d.validate().unwrap_err();
15064 assert!(
15065 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15066 "got {err:?}",
15067 );
15068 }
15069
15070 #[test]
15071 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
15072 // Cascade pin on the immediate-successor arm: a value
15073 // carrying both `#` and a trailing `/`
15074 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
15075 // a URL-fragment-carrying path" footgun) routes through
15076 // `FonteCaminhoShellComment` not
15077 // `FonteCaminhoTrailingSlash`. The embedded fragment /
15078 // comment-lead byte is the more semantic-locating axis (an
15079 // author who removes the `#pin` fragment typically also
15080 // drops the trailing separator since both are paste-from-
15081 // URL / paste-from-shell-tab-completion artifacts).
15082 let d = dep_with_fonte(DepSource::Path {
15083 caminho: "../caixa-teia#pin/".into(),
15084 });
15085 let err = d.validate().unwrap_err();
15086 assert!(
15087 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
15088 "got {err:?}",
15089 );
15090 }
15091
15092 #[test]
15093 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
15094 // Diagnostic-shape pin (peer with
15095 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
15096 // on the immediate-predecessor arm): the error's Display
15097 // surfaces the offending `:nome`, the offending `:caminho`
15098 // verbatim, the offending byte's hex / character form, and
15099 // names the shell-comment / URL-fragment-identifier /
15100 // YAML-comment cross-config-DSL footgun explicitly so a
15101 // `feira lint` run can render the diagnostic without
15102 // re-parsing.
15103 let d = dep_with_fonte(DepSource::Path {
15104 caminho: "../caixa-teia#readme".into(),
15105 });
15106 let rendered = d.validate().unwrap_err().to_string();
15107 assert!(
15108 rendered.contains("caixa-teia"),
15109 "diagnostic must name the offending dep: {rendered}",
15110 );
15111 assert!(
15112 rendered.contains("../caixa-teia#readme"),
15113 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15114 );
15115 assert!(
15116 rendered.contains("0x23"),
15117 "diagnostic must surface the offending byte hex: {rendered:?}",
15118 );
15119 assert!(
15120 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
15121 "diagnostic must name the shell-comment footgun: {rendered:?}",
15122 );
15123 assert!(
15124 rendered.contains("fragment") || rendered.contains("URL-fragment"),
15125 "diagnostic must reference the URL-fragment-identifier vocabulary: \
15126 {rendered:?}",
15127 );
15128 }
15129
15130 #[test]
15131 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
15132 // The canonical paste-from-browser-address-bar percent-
15133 // encoded-space footgun: an author copies `../caixa%20teia`
15134 // out of a URL-encoded README hyperlink / browser address
15135 // bar / percent-encoded permalink expecting `%20` to decode
15136 // to a literal space at the filesystem layer. POSIX
15137 // `std::path::Path` treats `%` as a literal path-component
15138 // byte, so `Path::join` looks for a literal
15139 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
15140 // returns false on `..`, `%` is neither a leading-byte
15141 // sentinel nor a control byte nor `\` nor `<` / `>` nor
15142 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
15143 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
15144 // and the value's last byte isn't `/` — so the value
15145 // silently passed every prior arm. The new arm moves the
15146 // rejection to validate time and names the offending dep +
15147 // caminho + byte verbatim.
15148 let d = dep_with_fonte(DepSource::Path {
15149 caminho: "../caixa%20teia".into(),
15150 });
15151 let err = d.validate().unwrap_err();
15152 let DepError::FonteCaminhoUrlPercentEncoding {
15153 nome,
15154 caminho,
15155 byte,
15156 } = err
15157 else {
15158 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
15159 };
15160 assert_eq!(nome, "caixa-teia");
15161 assert_eq!(caminho, "../caixa%20teia");
15162 assert_eq!(byte, b'%');
15163 }
15164
15165 #[test]
15166 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
15167 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
15168 // intending the `%2F` as the URL encoding of `/`) locks a
15169 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
15170 // the byte-identical `path:../caixa/teia` form. Pinned
15171 // separately from the space-encoded shape so the gate's
15172 // coverage extends past the single canonical `%20` example
15173 // to any two-hex-digit percent-encoded sequence.
15174 let d = dep_with_fonte(DepSource::Path {
15175 caminho: "../caixa%2Fteia".into(),
15176 });
15177 let err = d.validate().unwrap_err();
15178 assert!(
15179 matches!(
15180 err,
15181 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15182 ),
15183 "got {err:?}",
15184 );
15185 }
15186
15187 #[test]
15188 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
15189 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
15190 // where `%` isn't followed by two hex digits) — every
15191 // WHATWG-conformant URL parser rejects the value at parse
15192 // time per RFC 3986 §2.1, but the byte would silently ride
15193 // into the lacre before the resolver subprocess crosses the
15194 // URL-parser boundary. Pinned separately from the well-
15195 // formed `%HH` shapes so the gate covers every percent-
15196 // occurrence, not only strictly-conformant escapes.
15197 let d = dep_with_fonte(DepSource::Path {
15198 caminho: "../caixa-teia%foo".into(),
15199 });
15200 let err = d.validate().unwrap_err();
15201 assert!(
15202 matches!(
15203 err,
15204 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15205 ),
15206 "got {err:?}",
15207 );
15208 }
15209
15210 #[test]
15211 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
15212 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
15213 // — the canonical paste-from-top-of-doc YAML directive
15214 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
15215 // separately from embedded shapes so the gate covers the
15216 // leading-position `%` too, not only mid-value occurrences.
15217 let d = dep_with_fonte(DepSource::Path {
15218 caminho: "%YAML/../caixa-teia".into(),
15219 });
15220 let err = d.validate().unwrap_err();
15221 assert!(
15222 matches!(
15223 err,
15224 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15225 ),
15226 "got {err:?}",
15227 );
15228 }
15229
15230 #[test]
15231 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
15232 // The printf-format-specifier paste shape
15233 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
15234 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
15235 // 134 format-string-injection vector). Pinned separately
15236 // from the URL-encoding shapes so the gate's rationale
15237 // extends past the RFC 3986 axis to the C / POSIX printf
15238 // format-directive-lead axis.
15239 let d = dep_with_fonte(DepSource::Path {
15240 caminho: "../caixa-%s-teia".into(),
15241 });
15242 let err = d.validate().unwrap_err();
15243 assert!(
15244 matches!(
15245 err,
15246 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15247 ),
15248 "got {err:?}",
15249 );
15250 }
15251
15252 #[test]
15253 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
15254 // The positive-control pin: the gate targets only `%`,
15255 // never adjacent printable ASCII or POSIX-valid bytes. The
15256 // canonical relative POSIX path (`"../caixa-teia"`) and a
15257 // nested deeply-pathed variant with adjacent printable
15258 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
15259 // to validate cleanly so the gate doesn't widen to a "no
15260 // printable punctuation anywhere" sweep that would defeat
15261 // the entire path-fonte author surface. Peer with
15262 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
15263 // on the immediate-predecessor arm.
15264 let d = dep_with_fonte(DepSource::Path {
15265 caminho: "../caixa-teia/sub-dir.v2".into(),
15266 });
15267 d.validate().unwrap();
15268 }
15269
15270 #[test]
15271 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
15272 // Cascade pin on the immediate-predecessor arm: a value
15273 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
15274 // canonical "I pasted a URL-fragment permalink followed by a
15275 // percent-encoded space tail" footgun) routes through
15276 // `FonteCaminhoShellComment` not
15277 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
15278 // identifier is the load-bearing downstream-truncation edit
15279 // on every probe-as-both value; same cascade discipline
15280 // every prior `:caminho` arm establishes.
15281 let d = dep_with_fonte(DepSource::Path {
15282 caminho: "../caixa-teia#pin%20".into(),
15283 });
15284 let err = d.validate().unwrap_err();
15285 assert!(
15286 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
15287 "got {err:?}",
15288 );
15289 }
15290
15291 #[test]
15292 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
15293 // Cascade pin on the upstream shell-quote-grouping arm: a
15294 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
15295 // canonical "I pasted a strong-quoted literal followed by
15296 // a percent-encoded space" footgun) routes through
15297 // `FonteCaminhoShellQuoteGrouping` not
15298 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
15299 // literal-delimiter is the load-bearing root-cause edit on
15300 // every probe-as-both value.
15301 let d = dep_with_fonte(DepSource::Path {
15302 caminho: "../'x'%20teia".into(),
15303 });
15304 let err = d.validate().unwrap_err();
15305 assert!(
15306 matches!(
15307 err,
15308 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
15309 ),
15310 "got {err:?}",
15311 );
15312 }
15313
15314 #[test]
15315 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
15316 // Cascade pin on the upstream backslash arm: a value
15317 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
15318 // canonical "I pasted a Windows-shell path followed by a
15319 // percent-encoded space" footgun) routes through
15320 // `FonteCaminhoBackslash` not
15321 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
15322 // separator divergence is the load-bearing root-cause edit
15323 // on every probe-as-both value.
15324 let d = dep_with_fonte(DepSource::Path {
15325 caminho: "..\\caixa%20teia".into(),
15326 });
15327 let err = d.validate().unwrap_err();
15328 assert!(
15329 matches!(err, DepError::FonteCaminhoBackslash { .. }),
15330 "got {err:?}",
15331 );
15332 }
15333
15334 #[test]
15335 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
15336 // Cascade pin on the upstream control-char arm: a value
15337 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
15338 // the canonical "I pasted a paste-from-binary-blob path
15339 // followed by a percent-encoded space" footgun) routes
15340 // through `FonteCaminhoControlChar` not
15341 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
15342 // rejected byte is the load-bearing root-cause edit on
15343 // every probe-as-both value.
15344 let d = dep_with_fonte(DepSource::Path {
15345 caminho: "../caixa\0%20teia".into(),
15346 });
15347 let err = d.validate().unwrap_err();
15348 assert!(
15349 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
15350 "got {err:?}",
15351 );
15352 }
15353
15354 #[test]
15355 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
15356 // Cascade pin on the upstream absolute-path arm: a value
15357 // that's both absolute and carries `%` (`"/etc/passwd%20"`
15358 // — the canonical "I pasted an absolute path with a
15359 // percent-encoded space tail" footgun) routes through
15360 // `FonteCaminhoAbsolute` not
15361 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
15362 // the load-bearing root-cause edit on every probe-as-both
15363 // value.
15364 let d = dep_with_fonte(DepSource::Path {
15365 caminho: "/etc/passwd%20".into(),
15366 });
15367 let err = d.validate().unwrap_err();
15368 assert!(
15369 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
15370 "got {err:?}",
15371 );
15372 }
15373
15374 #[test]
15375 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
15376 // Cascade pin on the upstream var-expansion arm: a value
15377 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
15378 // — the canonical "I pasted a `$HOME`-rooted path with a
15379 // percent-encoded space" footgun) routes through
15380 // `FonteCaminhoVarExpansion` not
15381 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
15382 // expansion is the load-bearing root-cause edit on every
15383 // probe-as-both value.
15384 let d = dep_with_fonte(DepSource::Path {
15385 caminho: "$HOME/caixa%20teia".into(),
15386 });
15387 let err = d.validate().unwrap_err();
15388 assert!(
15389 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15390 "got {err:?}",
15391 );
15392 }
15393
15394 #[test]
15395 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
15396 // Cascade pin on the immediate-successor arm: a value
15397 // carrying both `%` and a trailing `/`
15398 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
15399 // percent-encoded-space-carrying path" footgun) routes
15400 // through `FonteCaminhoUrlPercentEncoding` not
15401 // `FonteCaminhoTrailingSlash`. The embedded percent-
15402 // encoding-escape byte is the more semantic-locating axis
15403 // (an author who decodes the `%20` to a literal space is
15404 // likely to also tab-strip the trailing separator since
15405 // both are paste-from-URL / paste-from-shell-tab-completion
15406 // artifacts).
15407 let d = dep_with_fonte(DepSource::Path {
15408 caminho: "../caixa%20teia/".into(),
15409 });
15410 let err = d.validate().unwrap_err();
15411 assert!(
15412 matches!(
15413 err,
15414 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15415 ),
15416 "got {err:?}",
15417 );
15418 }
15419
15420 #[test]
15421 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
15422 // Diagnostic-shape pin (peer with
15423 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
15424 // on the immediate-predecessor arm): the error's Display
15425 // surfaces the offending `:nome`, the offending `:caminho`
15426 // verbatim, the offending byte's hex / character form, and
15427 // names the URL-percent-encoding-escape / printf-format-
15428 // specifier footgun explicitly so a `feira lint` run can
15429 // render the diagnostic without re-parsing.
15430 let d = dep_with_fonte(DepSource::Path {
15431 caminho: "../caixa%20teia".into(),
15432 });
15433 let rendered = d.validate().unwrap_err().to_string();
15434 assert!(
15435 rendered.contains("caixa-teia"),
15436 "diagnostic must name the offending dep: {rendered}",
15437 );
15438 assert!(
15439 rendered.contains("../caixa%20teia"),
15440 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15441 );
15442 assert!(
15443 rendered.contains("0x25"),
15444 "diagnostic must surface the offending byte hex: {rendered:?}",
15445 );
15446 assert!(
15447 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
15448 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
15449 );
15450 assert!(
15451 rendered.contains("printf") || rendered.contains("format-specifier"),
15452 "diagnostic must reference the printf-format-specifier vocabulary: \
15453 {rendered:?}",
15454 );
15455 }
15456
15457 #[test]
15458 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
15459 // The canonical embedded-`$` shell-variable-expansion paste
15460 // shape (`"../foo$HOME/bar"` — an author copies a partially-
15461 // substituted shell one-liner where the leading segment is a
15462 // literal `../foo` while the mid segment carries the un-
15463 // substituted `$HOME` template). The leading-`$` position is
15464 // already gated by the f4efe9c leading-byte arm which routes
15465 // through `FonteCaminhoVarExpansion`; this arm closes the
15466 // last positional gap on `$` — every position on the axis is
15467 // structurally rejected.
15468 let d = dep_with_fonte(DepSource::Path {
15469 caminho: "../foo$HOME/bar".into(),
15470 });
15471 let err = d.validate().unwrap_err();
15472 let DepError::FonteCaminhoShellVariableExpansion {
15473 nome,
15474 caminho,
15475 byte,
15476 } = err
15477 else {
15478 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
15479 };
15480 assert_eq!(nome, "caixa-teia");
15481 assert_eq!(caminho, "../foo$HOME/bar");
15482 assert_eq!(byte, b'$');
15483 }
15484
15485 #[test]
15486 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
15487 // The symmetric braced-CI-manifest paste shape
15488 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
15489 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
15490 // footgun). Pinned separately from the bare-`$VAR` shape so
15491 // the gate covers both POSIX shell §2.6 Parameter Expansion
15492 // syntactic forms, not only the unbraced variant. The
15493 // embedded `{` byte in `${...}` is also caught by the 598b770
15494 // shell-brace-expansion arm but that arm fires earlier in
15495 // the cascade — the `$` arm's coverage extends to `${...}`
15496 // structurally, so the diagnostic asserted here is the
15497 // brace-expansion one (which is a valid outcome; the point
15498 // of the pin is that the value never survives validation).
15499 let d = dep_with_fonte(DepSource::Path {
15500 caminho: "../foo${WORKSPACE}/bar".into(),
15501 });
15502 let err = d.validate().unwrap_err();
15503 assert!(
15504 matches!(
15505 err,
15506 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
15507 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15508 ),
15509 "got {err:?}",
15510 );
15511 }
15512
15513 #[test]
15514 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
15515 // The paste-from-shell-prompt command-substitution idiom
15516 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
15517 // `$VAR` shape so the gate's rationale extends to POSIX shell
15518 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
15519 // legacy `` `<cmd>` `` form is already closed by the c370458
15520 // backtick arm). The embedded `(` byte in `$(...)` is also
15521 // caught structurally by the 0633c91 shell-subshell-grouping
15522 // arm which fires earlier in the cascade — the diagnostic
15523 // asserted here is either outcome, since both structurally
15524 // reject the value; the point of the pin is that the value
15525 // never survives validation.
15526 let d = dep_with_fonte(DepSource::Path {
15527 caminho: "../foo$(whoami)/bar".into(),
15528 });
15529 let err = d.validate().unwrap_err();
15530 assert!(
15531 matches!(
15532 err,
15533 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
15534 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15535 ),
15536 "got {err:?}",
15537 );
15538 }
15539
15540 #[test]
15541 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
15542 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
15543 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
15544 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
15545 // idiom copied into a caminho template). None of the prior
15546 // shell-metachar arms cover this shape (`1` is a bare digit;
15547 // no `(` / `{` / letter follows the `$`), so the arm is the
15548 // sole gate on the shape.
15549 let d = dep_with_fonte(DepSource::Path {
15550 caminho: "../foo$1/bar".into(),
15551 });
15552 let err = d.validate().unwrap_err();
15553 assert!(
15554 matches!(
15555 err,
15556 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15557 ),
15558 "got {err:?}",
15559 );
15560 }
15561
15562 #[test]
15563 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
15564 // The positive-control pin (peer with
15565 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
15566 // on the immediate-predecessor arm): the gate targets only
15567 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
15568 // A relative POSIX path carrying dashes / dots / slashes /
15569 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15570 // validate cleanly so the gate doesn't widen to a "no
15571 // printable punctuation anywhere" sweep that would defeat
15572 // the entire path-fonte author surface.
15573 let d = dep_with_fonte(DepSource::Path {
15574 caminho: "../caixa-teia/sub-dir.v2".into(),
15575 });
15576 d.validate().unwrap();
15577 }
15578
15579 #[test]
15580 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
15581 // Cascade pin on the leading-`$` sibling arm at line 540: a
15582 // value starting with `$` and carrying an embedded `$` too
15583 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
15584 // fully-templated CI path with two un-substituted variables")
15585 // routes through `FonteCaminhoVarExpansion` not
15586 // `FonteCaminhoShellVariableExpansion`. The leading-byte
15587 // host-layout-leak is the load-bearing self-locating axis
15588 // (the leading position dominates the semantic-locating
15589 // rationale on every probe-as-both value); the embedded
15590 // arm's positional-agnostic sweep catches only values whose
15591 // leading byte doesn't route through the earlier leading-
15592 // byte arms.
15593 let d = dep_with_fonte(DepSource::Path {
15594 caminho: "$HOME/foo$WORKSPACE/bar".into(),
15595 });
15596 let err = d.validate().unwrap_err();
15597 assert!(
15598 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15599 "got {err:?}",
15600 );
15601 }
15602
15603 #[test]
15604 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
15605 // Cascade pin on the immediate-predecessor arm: a value
15606 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
15607 // — the canonical "I pasted a percent-encoded space adjacent
15608 // to a `$HOME` template") routes through
15609 // `FonteCaminhoUrlPercentEncoding` not
15610 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
15611 // encoding-escape byte is the more semantic-locating axis
15612 // (the paste-from-browser-address-bar shape is the load-
15613 // bearing self-locating edit); same cascade discipline every
15614 // prior `:caminho` arm establishes.
15615 let d = dep_with_fonte(DepSource::Path {
15616 caminho: "../foo%20$HOME/bar".into(),
15617 });
15618 let err = d.validate().unwrap_err();
15619 assert!(
15620 matches!(
15621 err,
15622 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15623 ),
15624 "got {err:?}",
15625 );
15626 }
15627
15628 #[test]
15629 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
15630 // Cascade pin on the immediate-successor arm: a value
15631 // carrying both embedded `$` and a trailing `/`
15632 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
15633 // `$HOME`-template-carrying path") routes through
15634 // `FonteCaminhoShellVariableExpansion` not
15635 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
15636 // expansion byte is the more semantic-locating axis on
15637 // probe-as-both values (an author who substitutes the
15638 // `$HOME` template with a literal value is likely to also
15639 // tab-strip the trailing separator).
15640 let d = dep_with_fonte(DepSource::Path {
15641 caminho: "../foo$HOME/bar/".into(),
15642 });
15643 let err = d.validate().unwrap_err();
15644 assert!(
15645 matches!(
15646 err,
15647 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15648 ),
15649 "got {err:?}",
15650 );
15651 }
15652
15653 #[test]
15654 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15655 // Diagnostic-shape pin (peer with
15656 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
15657 // on the immediate-predecessor arm): the error's Display
15658 // surfaces the offending `:nome`, the offending `:caminho`
15659 // verbatim, the offending byte's hex / character form, and
15660 // names the shell-variable-expansion / command-substitution
15661 // footgun explicitly so a `feira lint` run can render the
15662 // diagnostic without re-parsing.
15663 let d = dep_with_fonte(DepSource::Path {
15664 caminho: "../foo$HOME/bar".into(),
15665 });
15666 let rendered = d.validate().unwrap_err().to_string();
15667 assert!(
15668 rendered.contains("caixa-teia"),
15669 "diagnostic must name the offending dep: {rendered}",
15670 );
15671 assert!(
15672 rendered.contains("../foo$HOME/bar"),
15673 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15674 );
15675 assert!(
15676 rendered.contains("0x24"),
15677 "diagnostic must surface the offending byte hex: {rendered:?}",
15678 );
15679 assert!(
15680 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
15681 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
15682 );
15683 assert!(
15684 rendered.contains("command-substitution") || rendered.contains("command substitution"),
15685 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
15686 );
15687 }
15688
15689 #[test]
15690 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
15691 // The fail-before-pass-after pin for the canonical paste-from-
15692 // shell-history footgun on `:caminho`. An author copies a `cd
15693 // ../caixa-teia && !sudo make install` one-liner from a quick-
15694 // start README, intending the trailing `!sudo` as a shell-
15695 // history-expansion reference but the typed slot is itself a
15696 // byte-level string parser, not a shell context, so the byte
15697 // rides into the value verbatim. Until this arm landed the `!`
15698 // byte silently passed every prior `:caminho` cascade arm
15699 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
15700 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
15701 // `#` / `%` / `$`); bash with the default `histexpand` mode
15702 // rewrites `!command` to the most recent history entry
15703 // beginning with `command`, the canonical RCE-class injection
15704 // vector when the byte rides into a shell argument executed
15705 // under `bash -i` (the operator-notebook interactive shell).
15706 let d = dep_with_fonte(DepSource::Path {
15707 caminho: "../caixa-teia!sudo".into(),
15708 });
15709 let err = d.validate().unwrap_err();
15710 let DepError::FonteCaminhoShellHistoryExpansion {
15711 nome,
15712 caminho,
15713 byte,
15714 } = err
15715 else {
15716 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
15717 };
15718 assert_eq!(nome, "caixa-teia");
15719 assert_eq!(caminho, "../caixa-teia!sudo");
15720 assert_eq!(byte, b'!');
15721 }
15722
15723 #[test]
15724 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
15725 // The symmetric `!!` repeat-prior-command paste idiom (peer with
15726 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
15727 // on `is_git_repo_url`). Pinned separately from the wrapped
15728 // `!command` shape so a future diagnostic-surface change that
15729 // only checked the leading or paired-bang position surfaces
15730 // here — the per-byte arm fires anywhere `!` appears in the
15731 // value, including at consecutive positions in the middle.
15732 let d = dep_with_fonte(DepSource::Path {
15733 caminho: "../foo!!/bar".into(),
15734 });
15735 let err = d.validate().unwrap_err();
15736 assert!(
15737 matches!(
15738 err,
15739 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15740 ),
15741 "got {err:?}",
15742 );
15743 }
15744
15745 #[test]
15746 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
15747 // The English-typography enthusiasm-form paste-from-prose
15748 // idiom: an author writes `:caminho "../caixa-teia!"`
15749 // expecting the substrate to coerce it to a kebab-case slug.
15750 // Pinned separately from the `!<word>` shell-history shape so
15751 // the gate's rationale extends to the paste-from-prose surface
15752 // (the same rationale the peer `is_git_repo_url` bang arm at
15753 // 7d53c68 covers). None of the prior shell-metachar arms cover
15754 // this shape (no `!<word>` reference and no `!!` repeat), so
15755 // the arm is the sole gate on the shape.
15756 let d = dep_with_fonte(DepSource::Path {
15757 caminho: "../caixa-teia!".into(),
15758 });
15759 let err = d.validate().unwrap_err();
15760 assert!(
15761 matches!(
15762 err,
15763 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15764 ),
15765 "got {err:?}",
15766 );
15767 }
15768
15769 #[test]
15770 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
15771 // The positive-control pin (peer with
15772 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
15773 // on the immediate-predecessor arm): the gate targets only
15774 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15775 // A relative POSIX path carrying dashes / dots / slashes /
15776 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15777 // validate cleanly so the gate doesn't widen to a "no
15778 // printable punctuation anywhere" sweep that would defeat
15779 // the entire path-fonte author surface.
15780 let d = dep_with_fonte(DepSource::Path {
15781 caminho: "../caixa-teia/sub-dir.v2".into(),
15782 });
15783 d.validate().unwrap();
15784 }
15785
15786 #[test]
15787 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15788 // Cascade pin on the immediate-predecessor arm: a value
15789 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15790 // — the canonical "I pasted a `$HOME`-templated path adjacent
15791 // to a trailing `!sudo` history-expansion") routes through
15792 // `FonteCaminhoShellVariableExpansion` not
15793 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15794 // expansion byte is the more semantic-locating axis on
15795 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15796 // template shape is the load-bearing self-locating edit);
15797 // same cascade discipline every prior `:caminho` arm
15798 // establishes.
15799 let d = dep_with_fonte(DepSource::Path {
15800 caminho: "../foo$HOME/bar!sudo".into(),
15801 });
15802 let err = d.validate().unwrap_err();
15803 assert!(
15804 matches!(
15805 err,
15806 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15807 ),
15808 "got {err:?}",
15809 );
15810 }
15811
15812 #[test]
15813 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15814 // Cascade pin on the immediate-successor arm: a value carrying
15815 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15816 // — the canonical "I tab-completed a `!sudo`-carrying path")
15817 // routes through `FonteCaminhoShellHistoryExpansion` not
15818 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15819 // expansion byte is the more semantic-locating axis on probe-
15820 // as-both values (an author who removes the `!sudo` history
15821 // reference is likely to also tab-strip the trailing separator).
15822 let d = dep_with_fonte(DepSource::Path {
15823 caminho: "../caixa-teia!sudo/".into(),
15824 });
15825 let err = d.validate().unwrap_err();
15826 assert!(
15827 matches!(
15828 err,
15829 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15830 ),
15831 "got {err:?}",
15832 );
15833 }
15834
15835 #[test]
15836 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15837 // Diagnostic-shape pin (peer with
15838 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15839 // on the immediate-predecessor arm): the error's Display
15840 // surfaces the offending `:nome`, the offending `:caminho`
15841 // verbatim, the offending byte's hex / character form, and
15842 // names the shell-history-expansion / bang-operator footgun
15843 // explicitly so a `feira lint` run can render the diagnostic
15844 // without re-parsing.
15845 let d = dep_with_fonte(DepSource::Path {
15846 caminho: "../caixa-teia!sudo".into(),
15847 });
15848 let rendered = d.validate().unwrap_err().to_string();
15849 assert!(
15850 rendered.contains("caixa-teia"),
15851 "diagnostic must name the offending dep: {rendered}",
15852 );
15853 assert!(
15854 rendered.contains("../caixa-teia!sudo"),
15855 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15856 );
15857 assert!(
15858 rendered.contains("0x21"),
15859 "diagnostic must surface the offending byte hex: {rendered:?}",
15860 );
15861 assert!(
15862 rendered.contains("history-expansion") || rendered.contains("history expansion"),
15863 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15864 );
15865 assert!(
15866 rendered.contains("bang"),
15867 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15868 );
15869 }
15870
15871 #[test]
15872 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15873 // The fail-before-pass-after pin for the canonical paste-from-
15874 // shell-history-quick-substitution footgun on `:caminho`. An
15875 // author copies a `git clone <bad-url>` line from their terminal,
15876 // corrects it via bash's `^bad^good` quick-substitution history
15877 // operator (bash reference §9.3, `set -o histexpand` mode's
15878 // default for interactive sessions), and pastes the trailing
15879 // `^bad^good` substitution fragment into a `:caminho` value
15880 // without trimming the leading `git clone` prefix — the byte
15881 // rides into the manifest verbatim. Until this arm landed the
15882 // `^` byte silently passed every prior `:caminho` cascade arm
15883 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15884 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15885 // `%` / `$` / `!`); bash with the default `histexpand` mode
15886 // rewrites the prior command's `bad` string to `good` and re-
15887 // executes it, the paired-operator half of the `set -o
15888 // histexpand` feature the peer `!` arm already closes the prefix
15889 // half of. The peer `is_git_repo_url` axis rejects the byte at
15890 // 49e142f under the same shell-history-substitution / RFC-3986-
15891 // unwise banner.
15892 let d = dep_with_fonte(DepSource::Path {
15893 caminho: "../foo^bad^good".into(),
15894 });
15895 let err = d.validate().unwrap_err();
15896 let DepError::FonteCaminhoShellHistorySubstitution {
15897 nome,
15898 caminho,
15899 byte,
15900 } = err
15901 else {
15902 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15903 };
15904 assert_eq!(nome, "caixa-teia");
15905 assert_eq!(caminho, "../foo^bad^good");
15906 assert_eq!(byte, b'^');
15907 }
15908
15909 #[test]
15910 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15911 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15912 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15913 // on `is_git_repo_url`). An author copies a `grep '^archived'`
15914 // regex-anchor / negation idiom from a doc snippet and the byte
15915 // rides in verbatim. Pinned separately from the `^old^new^`
15916 // quick-substitution shape so a future diagnostic-surface change
15917 // that only checked the paired-caret history-substitution
15918 // position surfaces here — the per-byte arm fires anywhere `^`
15919 // appears in the value, including at a solitary leading-of-
15920 // segment position.
15921 let d = dep_with_fonte(DepSource::Path {
15922 caminho: "../foo/^archived".into(),
15923 });
15924 let err = d.validate().unwrap_err();
15925 assert!(
15926 matches!(
15927 err,
15928 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15929 ),
15930 "got {err:?}",
15931 );
15932 }
15933
15934 #[test]
15935 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15936 // The trailing-`^` history-substitution-open shape — an author
15937 // starts typing a `^bad^good` quick-substitution but pastes only
15938 // the leading `^` sentinel before context-switching (a bash-
15939 // reference §9.3 valid histexpand prefix on its own — even a
15940 // solitary `^` on the prior command's whole re-execution shape).
15941 // Pinned separately from the `^old^new^` full-form and the leading-
15942 // of-segment `^archived` regex-anchor shape so the gate's
15943 // rationale extends to the paste-from-shell-history-with-only-
15944 // the-first-byte-selected surface. None of the prior shell-
15945 // metachar arms cover this shape.
15946 let d = dep_with_fonte(DepSource::Path {
15947 caminho: "../caixa-teia^".into(),
15948 });
15949 let err = d.validate().unwrap_err();
15950 assert!(
15951 matches!(
15952 err,
15953 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15954 ),
15955 "got {err:?}",
15956 );
15957 }
15958
15959 #[test]
15960 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15961 // The positive-control pin (peer with
15962 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15963 // on the immediate-predecessor arm): the gate targets only
15964 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15965 // A relative POSIX path carrying dashes / dots / slashes /
15966 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15967 // continue to validate cleanly so the gate doesn't widen to
15968 // a "no printable punctuation anywhere" sweep that would
15969 // defeat the entire path-fonte author surface.
15970 let d = dep_with_fonte(DepSource::Path {
15971 caminho: "../caixa-teia/sub_v2.rc".into(),
15972 });
15973 d.validate().unwrap();
15974 }
15975
15976 #[test]
15977 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15978 // Cascade pin on the immediate-predecessor arm: a value carrying
15979 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15980 // canonical "I pasted a `!sudo` history-reference next to a
15981 // `^bad^good` quick-substitution") routes through
15982 // `FonteCaminhoShellHistoryExpansion` not
15983 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15984 // the more semantic-locating axis on probe-as-both values (an
15985 // author who removes the `!sudo` reference is likely to also
15986 // strip the paired `^` substitution fragment); same cascade
15987 // discipline every prior `:caminho` arm establishes.
15988 let d = dep_with_fonte(DepSource::Path {
15989 caminho: "../foo!sudo^bad^good".into(),
15990 });
15991 let err = d.validate().unwrap_err();
15992 assert!(
15993 matches!(
15994 err,
15995 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15996 ),
15997 "got {err:?}",
15998 );
15999 }
16000
16001 #[test]
16002 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
16003 // Cascade pin on the immediate-successor arm: a value carrying
16004 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
16005 // the canonical "I tab-completed a `^bad^good`-carrying path")
16006 // routes through `FonteCaminhoShellHistorySubstitution` not
16007 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
16008 // substitution byte is the more semantic-locating axis on probe-
16009 // as-both values (an author who removes the `^bad^good`
16010 // substitution fragment is likely to also tab-strip the trailing
16011 // separator).
16012 let d = dep_with_fonte(DepSource::Path {
16013 caminho: "../foo^bad^good/".into(),
16014 });
16015 let err = d.validate().unwrap_err();
16016 assert!(
16017 matches!(
16018 err,
16019 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
16020 ),
16021 "got {err:?}",
16022 );
16023 }
16024
16025 #[test]
16026 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
16027 {
16028 // Diagnostic-shape pin (peer with
16029 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
16030 // on the immediate-predecessor arm): the error's Display
16031 // surfaces the offending `:nome`, the offending `:caminho`
16032 // verbatim, the offending byte's hex form, and names the
16033 // shell-history-substitution / RFC-3986-'unwise' / regex-
16034 // negation footgun explicitly so a `feira lint` run can render
16035 // the diagnostic without re-parsing.
16036 let d = dep_with_fonte(DepSource::Path {
16037 caminho: "../foo^bad^good".into(),
16038 });
16039 let rendered = d.validate().unwrap_err().to_string();
16040 assert!(
16041 rendered.contains("caixa-teia"),
16042 "diagnostic must name the offending dep: {rendered}",
16043 );
16044 assert!(
16045 rendered.contains("../foo^bad^good"),
16046 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
16047 );
16048 assert!(
16049 rendered.contains("0x5e") || rendered.contains("0x5E"),
16050 "diagnostic must surface the offending byte hex: {rendered:?}",
16051 );
16052 assert!(
16053 rendered.contains("history-substitution") || rendered.contains("history substitution"),
16054 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
16055 );
16056 assert!(
16057 rendered.contains("unwise"),
16058 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
16059 );
16060 }
16061
16062 #[test]
16063 fn fonte_repo_empty_fires_before_pin_missing() {
16064 // Order pin: empty `:repo` is the more self-locating diagnostic
16065 // (every git source needs a repo; the pin discussion is
16066 // secondary), so it fires before the pin-missing arm even when
16067 // both are violated. Mirrors the
16068 // `nome_empty_takes_precedence_over_versao_invalid` ordering
16069 // discipline on the per-entry layer.
16070 let d = dep_with_fonte(DepSource::Git {
16071 repo: String::new(),
16072 tag: None,
16073 rev: None,
16074 branch: None,
16075 });
16076 let err = d.validate().unwrap_err();
16077 assert!(
16078 matches!(err, DepError::FonteRepoEmpty { .. }),
16079 "got {err:?}"
16080 );
16081 }
16082
16083 #[test]
16084 fn fonte_pin_missing_fires_before_pin_empty() {
16085 // Order pin: a fully-None pin set is structurally distinct from
16086 // a Some(empty) pin — the first surfaces as FontePinMissing
16087 // (no axis chosen), the second as FontePinEmpty (axis chosen
16088 // but value blank). Pin the disjoint relationship so a future
16089 // unification collapses to one variant only as a structural
16090 // decision.
16091 let d = dep_with_fonte(DepSource::Git {
16092 repo: "github:pleme-io/caixa-teia".into(),
16093 tag: None,
16094 rev: None,
16095 branch: None,
16096 });
16097 assert!(matches!(
16098 d.validate().unwrap_err(),
16099 DepError::FontePinMissing { .. }
16100 ));
16101 }
16102
16103 #[test]
16104 fn nome_empty_takes_precedence_over_fonte_invalid() {
16105 // Order pin: a per-entry diagnostic without a non-empty :nome
16106 // can't be self-locating, so :nome "" fires first even when
16107 // :fonte is also malformed. Mirrors
16108 // `nome_empty_takes_precedence_over_versao_invalid` on the
16109 // adjacent axis.
16110 let mut d = dep_with_fonte(DepSource::Git {
16111 repo: String::new(),
16112 tag: None,
16113 rev: None,
16114 branch: None,
16115 });
16116 d.nome = String::new();
16117 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
16118 }
16119
16120 #[test]
16121 fn versao_invalid_takes_precedence_over_fonte_invalid() {
16122 // Order pin: the :versao parse-side diagnostic is narrower than
16123 // the :fonte shape diagnostic — a malformed :versao always names
16124 // the parser's reason, which is more actionable than the
16125 // :fonte gate's "the pins are wrong" wording. Pin the ordering
16126 // so a re-ordering surfaces here.
16127 let mut d = dep_with_fonte(DepSource::Git {
16128 repo: String::new(),
16129 tag: None,
16130 rev: None,
16131 branch: None,
16132 });
16133 d.versao = "v0.1".into();
16134 let err = d.validate().unwrap_err();
16135 assert!(
16136 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
16137 "got {err:?}"
16138 );
16139 }
16140
16141 #[test]
16142 fn fonte_invalid_diagnostic_carries_offending_nome() {
16143 // The diagnostic-shape pin: every :fonte error variant names
16144 // the offending dep's :nome verbatim, so the author can grep
16145 // caixa.lisp for the `:nome "<n>"` block and fix it in one
16146 // edit. Cover all seven variants so a future variant addition
16147 // forces a parallel diagnostic-shape decision.
16148 for (case, fonte) in [
16149 (
16150 "repo-empty",
16151 DepSource::Git {
16152 repo: String::new(),
16153 tag: Some("v1".into()),
16154 rev: None,
16155 branch: None,
16156 },
16157 ),
16158 (
16159 "repo-shape",
16160 DepSource::Git {
16161 repo: "github:p/x ".into(),
16162 tag: Some("v1".into()),
16163 rev: None,
16164 branch: None,
16165 },
16166 ),
16167 (
16168 "pin-missing",
16169 DepSource::Git {
16170 repo: "github:p/x".into(),
16171 tag: None,
16172 rev: None,
16173 branch: None,
16174 },
16175 ),
16176 (
16177 "pin-ambiguous",
16178 DepSource::Git {
16179 repo: "github:p/x".into(),
16180 tag: Some("v1".into()),
16181 rev: None,
16182 branch: Some("main".into()),
16183 },
16184 ),
16185 (
16186 "pin-empty",
16187 DepSource::Git {
16188 repo: "github:p/x".into(),
16189 tag: Some(String::new()),
16190 rev: None,
16191 branch: None,
16192 },
16193 ),
16194 (
16195 "caminho-empty",
16196 DepSource::Path {
16197 caminho: String::new(),
16198 },
16199 ),
16200 (
16201 "caminho-absolute",
16202 DepSource::Path {
16203 caminho: "/home/me/work/caixa-teia".into(),
16204 },
16205 ),
16206 ] {
16207 let d = dep_with_fonte(fonte);
16208 let msg = d
16209 .validate()
16210 .expect_err(&format!("{case}: expected fonte error"))
16211 .to_string();
16212 assert!(
16213 msg.contains("\"caixa-teia\""),
16214 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16215 );
16216 }
16217 }
16218
16219 // -- :tag / :branch value-shape gate ----------------------------------
16220
16221 #[test]
16222 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
16223 // The canonical paste-from-doc footgun on `:tag` — author
16224 // copies `"v0.1.0 "` (trailing space) out of a release-notes
16225 // paragraph. Until this gate landed the empty-pin arm passed
16226 // (the string isn't empty), the resolver issued
16227 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
16228 // surfaced at clone time with a quoting-confused git error
16229 // far from the source caixa.lisp. The new gate moves the
16230 // check to caixa-build time and names the offending dep +
16231 // pin + value verbatim.
16232 let d = dep_with_fonte(DepSource::Git {
16233 repo: "github:pleme-io/caixa-teia".into(),
16234 tag: Some("v0.1.0 ".into()),
16235 rev: None,
16236 branch: None,
16237 });
16238 let err = d.validate().unwrap_err();
16239 let DepError::FontePinShape {
16240 nome,
16241 pin,
16242 value,
16243 reason,
16244 } = err
16245 else {
16246 panic!("expected FontePinShape, got other variant");
16247 };
16248 assert_eq!(nome, "caixa-teia");
16249 assert_eq!(pin, ":tag");
16250 assert_eq!(value, "v0.1.0 ");
16251 assert!(
16252 reason.contains("whitespace"),
16253 "reason must surface the whitespace arm, got {reason:?}"
16254 );
16255 }
16256
16257 #[test]
16258 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
16259 // The `.lock` suffix is git's atomic-rename guard for
16260 // in-flight ref updates — a refname ending in `.lock` is
16261 // unwritable on disk. Pinned separately from the whitespace
16262 // arm so a future relaxation that admits one but not the
16263 // other surfaces here.
16264 let d = dep_with_fonte(DepSource::Git {
16265 repo: "github:pleme-io/caixa-teia".into(),
16266 tag: Some("v0.1.0.lock".into()),
16267 rev: None,
16268 branch: None,
16269 });
16270 let err = d.validate().unwrap_err();
16271 let DepError::FontePinShape {
16272 pin, value, reason, ..
16273 } = err
16274 else {
16275 panic!("expected FontePinShape, got other variant");
16276 };
16277 assert_eq!(pin, ":tag");
16278 assert_eq!(value, "v0.1.0.lock");
16279 assert!(
16280 reason.contains(".lock"),
16281 "reason must surface the .lock arm, got {reason:?}"
16282 );
16283 }
16284
16285 #[test]
16286 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
16287 // The canonical "branch name with spaces" footgun (`feature
16288 // foo`, `release branch`) — git's refname parser rejects raw
16289 // whitespace, and the failure surfaces at `git checkout
16290 // 'feature foo'` time with a quoting-confused error far from
16291 // the source caixa.lisp. Pinned on the `:branch` axis so the
16292 // gate-applies-to-both-:tag-and-:branch contract is a build-
16293 // error to relax.
16294 let d = dep_with_fonte(DepSource::Git {
16295 repo: "github:pleme-io/caixa-teia".into(),
16296 tag: None,
16297 rev: None,
16298 branch: Some("feature/foo bar".into()),
16299 });
16300 let err = d.validate().unwrap_err();
16301 let DepError::FontePinShape {
16302 pin, value, reason, ..
16303 } = err
16304 else {
16305 panic!("expected FontePinShape, got other variant");
16306 };
16307 assert_eq!(pin, ":branch");
16308 assert_eq!(value, "feature/foo bar");
16309 assert!(
16310 reason.contains("whitespace"),
16311 "reason must surface the whitespace arm, got {reason:?}"
16312 );
16313 }
16314
16315 #[test]
16316 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
16317 // The `refs/heads/main` shape — the canonical "I copied the
16318 // fully-qualified ref out of `git show-ref` instead of the
16319 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
16320 // at clone time, so this resolves to a literal ref named
16321 // `refs/heads/refs/heads/main` on disk; the silent double-
16322 // prefix is the load-bearing reason to gate at validate.
16323 // The diagnostic must enumerate the leaf the author probably
16324 // meant (`"main"`) so the fix is one edit.
16325 let d = dep_with_fonte(DepSource::Git {
16326 repo: "github:pleme-io/caixa-teia".into(),
16327 tag: None,
16328 rev: None,
16329 branch: Some("refs/heads/main".into()),
16330 });
16331 let err = d.validate().unwrap_err();
16332 let DepError::FontePinShape {
16333 pin, value, reason, ..
16334 } = err
16335 else {
16336 panic!("expected FontePinShape, got other variant");
16337 };
16338 assert_eq!(pin, ":branch");
16339 assert_eq!(value, "refs/heads/main");
16340 assert!(
16341 reason.contains("fully-qualified"),
16342 "reason must surface the qualified-prefix arm, got {reason:?}"
16343 );
16344 assert!(
16345 reason.contains("\"main\""),
16346 "reason must quote the leaf the author probably meant, got {reason:?}"
16347 );
16348 }
16349
16350 #[test]
16351 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
16352 // Sibling arm of the qualified-prefix gate on the `:tag`
16353 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
16354 // footgun). Pinned separately so a future relaxation that
16355 // only catches the `:branch` arm surfaces here.
16356 let d = dep_with_fonte(DepSource::Git {
16357 repo: "github:pleme-io/caixa-teia".into(),
16358 tag: Some("refs/tags/v0.1.0".into()),
16359 rev: None,
16360 branch: None,
16361 });
16362 let err = d.validate().unwrap_err();
16363 let DepError::FontePinShape {
16364 pin, value, reason, ..
16365 } = err
16366 else {
16367 panic!("expected FontePinShape, got other variant");
16368 };
16369 assert_eq!(pin, ":tag");
16370 assert_eq!(value, "refs/tags/v0.1.0");
16371 assert!(
16372 reason.contains("fully-qualified"),
16373 "reason must surface the qualified-prefix arm, got {reason:?}"
16374 );
16375 assert!(
16376 reason.contains("\"v0.1.0\""),
16377 "reason must quote the leaf the author probably meant, got {reason:?}"
16378 );
16379 }
16380
16381 #[test]
16382 fn validate_rejects_git_fonte_with_branch_named_at() {
16383 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
16384 // unsourceable. Pinned so a future relaxation that admits
16385 // any single-character refname surfaces here.
16386 let d = dep_with_fonte(DepSource::Git {
16387 repo: "github:pleme-io/caixa-teia".into(),
16388 tag: None,
16389 rev: None,
16390 branch: Some("@".into()),
16391 });
16392 let err = d.validate().unwrap_err();
16393 let DepError::FontePinShape { pin, value, .. } = err else {
16394 panic!("expected FontePinShape, got other variant");
16395 };
16396 assert_eq!(pin, ":branch");
16397 assert_eq!(value, "@");
16398 }
16399
16400 #[test]
16401 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
16402 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
16403 // a `:tag "../escape"` (path-traversal-shaped slug) silently
16404 // passes parse and surfaces as a refname-parse error or, on
16405 // older git, a literal `../escape` checkout that escapes the
16406 // refs/ directory tree. Pinned separately from the
16407 // qualified-prefix arm so a future relaxation that catches
16408 // one but not the other surfaces here.
16409 let d = dep_with_fonte(DepSource::Git {
16410 repo: "github:pleme-io/caixa-teia".into(),
16411 tag: Some("../escape".into()),
16412 rev: None,
16413 branch: None,
16414 });
16415 let err = d.validate().unwrap_err();
16416 let DepError::FontePinShape { pin, value, .. } = err else {
16417 panic!("expected FontePinShape, got other variant");
16418 };
16419 assert_eq!(pin, ":tag");
16420 assert_eq!(value, "../escape");
16421 }
16422
16423 #[test]
16424 fn validate_accepts_git_fonte_with_hierarchical_branch() {
16425 // The positive-control pin: hierarchical refnames with one or
16426 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
16427 // canonical idiom) round-trip through the gate. Pinned
16428 // separately from the leaf-`"main"` positive control so a
16429 // future tightening that rejects all multi-component refnames
16430 // surfaces here.
16431 let d = dep_with_fonte(DepSource::Git {
16432 repo: "github:pleme-io/caixa-teia".into(),
16433 tag: None,
16434 rev: None,
16435 branch: Some("feature/checkout-rewrite".into()),
16436 });
16437 d.validate().unwrap();
16438 }
16439
16440 #[test]
16441 fn validate_accepts_git_fonte_with_prerelease_tag() {
16442 // The positive-control pin: semver pre-release shape
16443 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
16444 // (only consecutive `..` and trailing `.` are rejected), the
16445 // mid-component hyphen is allowed. Pinned separately from
16446 // the bare-`"v0.1.0"` positive control so a future tightening
16447 // that rejects pre-release tags surfaces here.
16448 let d = dep_with_fonte(DepSource::Git {
16449 repo: "github:pleme-io/caixa-teia".into(),
16450 tag: Some("v0.1.0-alpha.1".into()),
16451 rev: None,
16452 branch: None,
16453 });
16454 d.validate().unwrap();
16455 }
16456
16457 #[test]
16458 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
16459 // The `:rev` axis is routed through `crate::render::is_git_oid`
16460 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
16461 // value with refname-shape punctuation (here, a `:` mid-string
16462 // — would be a refname violation under `is_git_ref_name` too)
16463 // is rejected at the OID-shape gate. The two predicates
16464 // partition the `:fonte` pin axes structurally: an `:rev` value
16465 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
16466 // *still* rejected here because every refname character outside
16467 // `[0-9a-f]` fails the OID gate. Same shape as
16468 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
16469 // on the refname-shaped axes — the diagnostic names the
16470 // offending dep + pin + value verbatim. The flip-from-accept
16471 // case the prior `:tag`/`:branch` gate left as a "future axis"
16472 // (e70d213) — now landed.
16473 let d = dep_with_fonte(DepSource::Git {
16474 repo: "github:pleme-io/caixa-teia".into(),
16475 tag: None,
16476 rev: Some("c0ffee:notarefname".into()),
16477 branch: None,
16478 });
16479 let err = d.validate().unwrap_err();
16480 let DepError::FontePinShape {
16481 nome,
16482 pin,
16483 value,
16484 reason,
16485 } = err
16486 else {
16487 panic!("expected FontePinShape, got other variant");
16488 };
16489 assert_eq!(nome, "caixa-teia");
16490 assert_eq!(pin, ":rev");
16491 assert_eq!(value, "c0ffee:notarefname");
16492 assert!(
16493 !reason.is_empty(),
16494 "FontePinShape `reason` must carry the predicate's wording verbatim"
16495 );
16496 }
16497
16498 #[test]
16499 fn validate_accepts_git_fonte_with_rev_full_sha1() {
16500 // The positive-control pin on the SHA-1 OID width: exactly 40
16501 // lowercase hex characters — the canonical `git rev-parse HEAD`
16502 // emission on a SHA-1-hashed repository (the default on every
16503 // pre-2.42 git and the canonical pleme-io substrate hash).
16504 // Pinned separately from the SHA-256 positive control so a
16505 // future tightening that only admits one width surfaces here.
16506 let d = dep_with_fonte(DepSource::Git {
16507 repo: "github:pleme-io/caixa-teia".into(),
16508 tag: None,
16509 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
16510 branch: None,
16511 });
16512 d.validate().unwrap();
16513 }
16514
16515 #[test]
16516 fn validate_accepts_git_fonte_with_rev_full_sha256() {
16517 // The positive-control pin on the SHA-256 OID width: exactly
16518 // 64 lowercase hex characters — `git`'s
16519 // `extensions.objectFormat = sha256` emission (GA since Git
16520 // 2.42 / Oct 2023). The substrate admits either canonical
16521 // width so an `:rev` authored against a SHA-256-hashed
16522 // upstream round-trips through the gate without per-repo
16523 // configuration. Pinned separately from the SHA-1 positive
16524 // control so a future tightening that drops one width surfaces
16525 // here as a structural decision.
16526 let d = dep_with_fonte(DepSource::Git {
16527 repo: "github:pleme-io/caixa-teia".into(),
16528 tag: None,
16529 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
16530 branch: None,
16531 });
16532 d.validate().unwrap();
16533 }
16534
16535 #[test]
16536 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
16537 // The canonical `git log --short` / `git rev-parse --short HEAD`
16538 // paste-from-release-notes footgun: a 7-char prefix (git's
16539 // default `core.abbrev`) silently passes string emptiness
16540 // checks and resolves to one commit today, but becomes ambiguous
16541 // tomorrow as the repo grows. Until this gate landed the empty-
16542 // pin arm passed (the string isn't empty) and the resolver
16543 // accepted the prefix through git's separate prefix-lookup pass
16544 // — defeating the reproducibility contract `:rev` carries vs.
16545 // `:tag` / `:branch`. The new gate moves the check to caixa-
16546 // build time and names the offending dep + pin + value verbatim.
16547 let d = dep_with_fonte(DepSource::Git {
16548 repo: "github:pleme-io/caixa-teia".into(),
16549 tag: None,
16550 rev: Some("c0ffee0".into()),
16551 branch: None,
16552 });
16553 let err = d.validate().unwrap_err();
16554 let DepError::FontePinShape {
16555 pin, value, reason, ..
16556 } = err
16557 else {
16558 panic!("expected FontePinShape, got other variant");
16559 };
16560 assert_eq!(pin, ":rev");
16561 assert_eq!(value, "c0ffee0");
16562 assert!(
16563 reason.contains("abbreviated") || reason.contains("ambiguous"),
16564 "reason must surface the abbreviation arm, got {reason:?}"
16565 );
16566 }
16567
16568 #[test]
16569 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
16570 // The canonical "I pasted the SHA in uppercase" footgun: `git
16571 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
16572 // bearing `:rev` round-trips inconsistently across the
16573 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
16574 // equality-check pipeline and fails the lacre's content-
16575 // addressing probe with a confusing case-only diff. Pinned
16576 // separately from the non-hex arm so a future relaxation that
16577 // admits one but not the other surfaces here.
16578 let d = dep_with_fonte(DepSource::Git {
16579 repo: "github:pleme-io/caixa-teia".into(),
16580 tag: None,
16581 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
16582 branch: None,
16583 });
16584 let err = d.validate().unwrap_err();
16585 let DepError::FontePinShape {
16586 pin, value, reason, ..
16587 } = err
16588 else {
16589 panic!("expected FontePinShape, got other variant");
16590 };
16591 assert_eq!(pin, ":rev");
16592 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
16593 assert!(
16594 reason.contains("uppercase"),
16595 "reason must surface the uppercase arm, got {reason:?}"
16596 );
16597 }
16598
16599 #[test]
16600 fn validate_rejects_git_fonte_with_rev_refname_value() {
16601 // The cross-axis mis-slot footgun: `:rev "main"` — the author
16602 // conflated `:rev` (hex commit ID, immutable) and `:branch`
16603 // (mutable ref pointing at whatever HEAD is today). Until this
16604 // gate landed the resolver silently dispatched on the value
16605 // shape ("`main` doesn't look like a SHA, fall back to
16606 // refname"), defeating the `:rev` reproducibility contract.
16607 // The new gate rejects every non-hex value on the `:rev` axis,
16608 // so the `:rev`/`:branch` boundary is structurally enforced —
16609 // a refname in the `:rev` slot is a build error, not a
16610 // resolver-time silent reinterpretation.
16611 let d = dep_with_fonte(DepSource::Git {
16612 repo: "github:pleme-io/caixa-teia".into(),
16613 tag: None,
16614 rev: Some("main".into()),
16615 branch: None,
16616 });
16617 let err = d.validate().unwrap_err();
16618 let DepError::FontePinShape {
16619 pin, value, reason, ..
16620 } = err
16621 else {
16622 panic!("expected FontePinShape, got other variant");
16623 };
16624 assert_eq!(pin, ":rev");
16625 assert_eq!(value, "main");
16626 // 4 chars `main` fails the length arm before the character arm,
16627 // so the diagnostic surfaces the abbreviation wording (same
16628 // path the `c0ffee0` 7-char fixture lands on); the structural
16629 // assertion is just that the `:rev "main"` value is rejected.
16630 assert!(
16631 !reason.is_empty(),
16632 "FontePinShape reason must be non-empty for refname-shaped :rev"
16633 );
16634 }
16635
16636 #[test]
16637 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
16638 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
16639 // conflated `:rev` and `:tag`. Pinned separately from the
16640 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
16641 // that catches one but not the other surfaces here. The
16642 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
16643 // assertion is just that the cross-axis mis-slot is a build
16644 // error, regardless of which sub-arm surfaces the diagnostic
16645 // (`is_git_oid` rejects at the first violation; longer
16646 // tag-shape values would hit the non-hex arm instead).
16647 let d = dep_with_fonte(DepSource::Git {
16648 repo: "github:pleme-io/caixa-teia".into(),
16649 tag: None,
16650 rev: Some("v0.1.0".into()),
16651 branch: None,
16652 });
16653 let err = d.validate().unwrap_err();
16654 let DepError::FontePinShape {
16655 pin, value, reason, ..
16656 } = err
16657 else {
16658 panic!("expected FontePinShape, got other variant");
16659 };
16660 assert_eq!(pin, ":rev");
16661 assert_eq!(value, "v0.1.0");
16662 assert!(
16663 !reason.is_empty(),
16664 "FontePinShape reason must be non-empty for tag-shaped :rev"
16665 );
16666 }
16667
16668 #[test]
16669 fn validate_rejects_git_fonte_with_rev_too_long() {
16670 // Boundary case on the upper end: 41 hex chars — one past the
16671 // SHA-1 width, well below the SHA-256 width. Pin so a future
16672 // relaxation that admits "long enough to be a SHA" without
16673 // matching either canonical width surfaces here. The diagnostic
16674 // names the offending length verbatim so the author's grep
16675 // target is unambiguous (either trim one char or paste the
16676 // full SHA-256).
16677 let too_long: String = "0".repeat(41);
16678 let d = dep_with_fonte(DepSource::Git {
16679 repo: "github:pleme-io/caixa-teia".into(),
16680 tag: None,
16681 rev: Some(too_long.clone()),
16682 branch: None,
16683 });
16684 let err = d.validate().unwrap_err();
16685 let DepError::FontePinShape {
16686 pin, value, reason, ..
16687 } = err
16688 else {
16689 panic!("expected FontePinShape, got other variant");
16690 };
16691 assert_eq!(pin, ":rev");
16692 assert_eq!(value, too_long);
16693 assert!(
16694 reason.contains("41"),
16695 "reason must surface the offending length verbatim, got {reason:?}"
16696 );
16697 }
16698
16699 #[test]
16700 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
16701 // The canonical paste-from-doc footgun on `:rev` — author
16702 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
16703 // commit-message paragraph. Until this gate landed the empty-
16704 // pin arm passed (the string isn't empty), the resolver issued
16705 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
16706 // clone time with a quoting-confused git error far from the
16707 // source caixa.lisp. The new gate moves the check to caixa-
16708 // build time. Length is 41 (40 hex + space) so the length arm
16709 // fires first — pinned separately from the pure-length arm to
16710 // ensure the diagnostic surfaces *some* parser wording, not
16711 // silently pass through.
16712 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
16713 let d = dep_with_fonte(DepSource::Git {
16714 repo: "github:pleme-io/caixa-teia".into(),
16715 tag: None,
16716 rev: Some(with_space.clone()),
16717 branch: None,
16718 });
16719 let err = d.validate().unwrap_err();
16720 let DepError::FontePinShape {
16721 pin, value, reason, ..
16722 } = err
16723 else {
16724 panic!("expected FontePinShape, got other variant");
16725 };
16726 assert_eq!(pin, ":rev");
16727 assert_eq!(value, with_space);
16728 assert!(
16729 !reason.is_empty(),
16730 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
16731 );
16732 }
16733
16734 #[test]
16735 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
16736 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
16737 // variant on this axis names the offending dep's `:nome` + the
16738 // `:rev` axis + the offending value verbatim, so the author's
16739 // grep target is the literal `:rev "<value>"` block in
16740 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
16741 // carries_offending_nome_pin_value` test on the refname-shaped
16742 // (`:tag` / `:branch`) axes.
16743 let d = dep_with_fonte(DepSource::Git {
16744 repo: "github:p/x".into(),
16745 tag: None,
16746 rev: Some("not-a-sha".into()),
16747 branch: None,
16748 });
16749 let msg = d
16750 .validate()
16751 .expect_err(":rev: expected FontePinShape")
16752 .to_string();
16753 assert!(
16754 msg.contains("\"caixa-teia\""),
16755 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16756 );
16757 assert!(
16758 msg.contains(":rev"),
16759 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
16760 );
16761 assert!(
16762 msg.contains("not-a-sha"),
16763 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
16764 );
16765 }
16766
16767 #[test]
16768 fn fonte_pin_empty_fires_before_pin_shape() {
16769 // Order pin: a `Some("")` `:tag` is the more self-locating
16770 // diagnostic (the author chose an axis but left it blank;
16771 // grep is unambiguous), so it fires before the shape gate
16772 // even when both arms would match. Pinned so a future
16773 // reordering surfaces here. Mirrors the
16774 // `fonte_repo_empty_fires_before_pin_missing` ordering
16775 // discipline on the peer per-axis arms.
16776 let d = dep_with_fonte(DepSource::Git {
16777 repo: "github:pleme-io/caixa-teia".into(),
16778 tag: Some(String::new()),
16779 rev: None,
16780 branch: None,
16781 });
16782 assert!(matches!(
16783 d.validate().unwrap_err(),
16784 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16785 ));
16786 }
16787
16788 #[test]
16789 fn fonte_pin_shape_fires_after_repo_empty() {
16790 // Order pin: `:repo ""` is the more self-locating axis
16791 // (every git source needs a repo; the per-pin shape gate is
16792 // secondary), so the repo-empty arm fires before the
16793 // per-pin shape arm even when both are violated. Pinned so
16794 // a future reordering surfaces here. Mirrors
16795 // `fonte_repo_empty_fires_before_pin_missing` on the
16796 // adjacent axis pair.
16797 let d = dep_with_fonte(DepSource::Git {
16798 repo: String::new(),
16799 tag: Some("v0.1.0 ".into()),
16800 rev: None,
16801 branch: None,
16802 });
16803 assert!(matches!(
16804 d.validate().unwrap_err(),
16805 DepError::FonteRepoEmpty { .. }
16806 ));
16807 }
16808
16809 #[test]
16810 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16811 // Diagnostic-shape pin across both refname-shaped axes
16812 // (`:tag` + `:branch`): every `FontePinShape` variant names
16813 // the offending dep's `:nome` + the offending pin axis + the
16814 // offending value verbatim, so the author's grep target is
16815 // unambiguous (the literal `:tag "<value>"` / `:branch
16816 // "<value>"` lands in caixa.lisp with quotes). Cover both
16817 // pin axes so a future variant addition forces a parallel
16818 // diagnostic-shape decision.
16819 for (pin_label, fonte) in [
16820 (
16821 ":tag",
16822 DepSource::Git {
16823 repo: "github:p/x".into(),
16824 tag: Some("v0.1.0~1".into()),
16825 rev: None,
16826 branch: None,
16827 },
16828 ),
16829 (
16830 ":branch",
16831 DepSource::Git {
16832 repo: "github:p/x".into(),
16833 tag: None,
16834 rev: None,
16835 branch: Some("feature/foo*".into()),
16836 },
16837 ),
16838 ] {
16839 let d = dep_with_fonte(fonte);
16840 let msg = d
16841 .validate()
16842 .expect_err(&format!("{pin_label}: expected FontePinShape"))
16843 .to_string();
16844 assert!(
16845 msg.contains("\"caixa-teia\""),
16846 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16847 );
16848 assert!(
16849 msg.contains(pin_label),
16850 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16851 );
16852 }
16853 }
16854
16855 #[test]
16856 fn git_source_json_round_trip() {
16857 let src = DepSource::Git {
16858 repo: "github:pleme-io/caixa-teia".into(),
16859 tag: Some("v0.1.0".into()),
16860 rev: None,
16861 branch: None,
16862 };
16863 let s = serde_json::to_string(&src).unwrap();
16864 assert!(s.contains(&format!(
16865 r#""{tipo}":"{git}""#,
16866 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16867 git = crate::render::DEP_SOURCE_TIPO_GIT,
16868 )));
16869 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16870 assert!(s.contains(r#""tag":"v0.1.0""#));
16871 assert!(!s.contains("rev"));
16872 assert!(!s.contains("branch"));
16873 let round: DepSource = serde_json::from_str(&s).unwrap();
16874 assert_eq!(round, src);
16875 }
16876
16877 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16878 //
16879 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16880 // attribute on [`DepSource`] pins three load-bearing byte-sequences
16881 // that flow into every serialized `Dep.fonte` block: the outer
16882 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16883 // the two admitted variant-tag values `"git"` / `"path"` the
16884 // `rename_all = "lowercase"` attribute pins as the discriminator's
16885 // closed-set arms. The three pin tests below round-trip a
16886 // fully-populated variant of each arm through
16887 // [`serde_json::to_value`] and assert each canonical byte-sequence
16888 // appears at its axis — pins a hypothetical future
16889 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16890 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16891 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16892 // at build time rather than at fetch time when the resolver's
16893 // `Dep.fonte` dispatch silently fails to match on the drifted
16894 // discriminator. Same "serialize-and-check" discipline the peer
16895 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16896 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16897 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16898 // family in caixa-core lacking a lifted peer.
16899
16900 #[test]
16901 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16902 // Fail-before-pass-after: a future `tag = "type"` at the derive
16903 // attribute would serialize under `"type":"git"`, and this test
16904 // would trip because `"tipo"` no longer appears at the emitted
16905 // discriminator key. A future `rename_all = "kebab-case"` /
16906 // `"snake_case"` (both no-ops on `Git` since it lacks internal
16907 // word boundaries) is caught by the sibling
16908 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16909 // pin below (Path has no internal boundary either but the pair
16910 // catches any per-arm inconsistency). A future variant rename
16911 // `Git` → `Repository` would emit `"tipo":"repository"` and
16912 // trip this pin.
16913 let src = DepSource::Git {
16914 repo: "github:pleme-io/caixa-teia".into(),
16915 tag: Some("v0.1.0".into()),
16916 rev: None,
16917 branch: None,
16918 };
16919 let json = serde_json::to_value(&src).unwrap();
16920 let obj = json.as_object().expect("Git serializes as a JSON object");
16921 assert_eq!(
16922 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16923 .and_then(serde_json::Value::as_str),
16924 Some(crate::render::DEP_SOURCE_TIPO_GIT),
16925 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16926 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16927 detected in {json}"
16928 );
16929 }
16930
16931 #[test]
16932 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16933 // Fail-before-pass-after: a future variant rename `Path` →
16934 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16935 // this pin. A per-consumer disambiguation as the `defcaixa`
16936 // macro stabilizes ("caminho" → "path" for English-uniformity)
16937 // is scoped to the inner field key, not the discriminator; this
16938 // pin is orthogonal to that and catches only the outer
16939 // discriminator drift.
16940 let src = DepSource::Path {
16941 caminho: "../caixa-teia".into(),
16942 };
16943 let json = serde_json::to_value(&src).unwrap();
16944 let obj = json.as_object().expect("Path serializes as a JSON object");
16945 assert_eq!(
16946 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16947 .and_then(serde_json::Value::as_str),
16948 Some(crate::render::DEP_SOURCE_TIPO_PATH),
16949 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16950 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16951 detected in {json}"
16952 );
16953 }
16954
16955 #[test]
16956 fn dep_source_key_consts_are_pairwise_distinct() {
16957 // Cross-axis collapse detector: a hypothetical future edit that
16958 // accidentally set two of the three consts to the same byte
16959 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16960 // pass every per-arm serialize pin above but silently collapse
16961 // the discriminator's closed-set arms onto one another; this pin
16962 // catches the collapse at build time.
16963 assert_ne!(
16964 crate::render::DEP_SOURCE_KEY_TIPO,
16965 crate::render::DEP_SOURCE_TIPO_GIT,
16966 );
16967 assert_ne!(
16968 crate::render::DEP_SOURCE_KEY_TIPO,
16969 crate::render::DEP_SOURCE_TIPO_PATH,
16970 );
16971 assert_ne!(
16972 crate::render::DEP_SOURCE_TIPO_GIT,
16973 crate::render::DEP_SOURCE_TIPO_PATH,
16974 );
16975 }
16976
16977 #[test]
16978 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16979 // Shape pin against `rename_all` drift: the two variant-tag
16980 // consts must be ASCII-lowercase-only to match the
16981 // `rename_all = "lowercase"` attribute the derive uses; a future
16982 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16983 // would emit `"GIT"` / `"Git"` instead and trip this pin.
16984 for (label, s) in [
16985 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16986 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16987 ] {
16988 assert!(!s.is_empty(), "{label} must not be empty");
16989 assert!(
16990 s.bytes().all(|b| b.is_ascii_lowercase()),
16991 "{label} must be ASCII-lowercase-only (matching \
16992 rename_all = \"lowercase\"), got {s:?}",
16993 );
16994 }
16995 }
16996
16997 // ── per-entry :caracteristicas set-not-multiset gate ────────────
16998 //
16999 // Every Vec-keyed-by-name authoring surface on the typed Caixa
17000 // surface that identifies its entries by a name field now uniformly
17001 // closes the set-not-multiset discipline at build time (cite
17002 // `validate_caracteristicas`'s peer-axis enumeration). The
17003 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
17004 // set-shaped (a feature is either enabled or not — there is no
17005 // `feature × 2` semantic), so two entries naming the same feature
17006 // are a redundant declaration the caixa-resolver's lacre pipeline
17007 // would silently dedup at resolve time. The empty-feature arm
17008 // closes the parallel "operationally-meaningless value" axis on
17009 // the same slot. Same linear-walk + `HashSet` + first-collision
17010 // shape every peer set gate uses; same empty-first cascade every
17011 // peer per-entry shape + duplicate gate uses (the empty-feature
17012 // axis is the more-actionable defect since two `""` entries would
17013 // both report `caracteristica: ""` under a duplicate-first
17014 // ordering, with no way to distinguish the offending site).
17015
17016 fn dep_with_features(features: &[&str]) -> Dep {
17017 Dep {
17018 nome: "caixa-teia".into(),
17019 versao: "^0.1".into(),
17020 fonte: None,
17021 opcional: false,
17022 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
17023 }
17024 }
17025
17026 #[test]
17027 fn validate_rejects_empty_caracteristica() {
17028 // Fail-before-pass-after pin: every pre-gate codebase accepted
17029 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
17030 // imposed no per-entry shape contract), the dep validated, and
17031 // the empty feature would have reached the future caixa-resolver
17032 // lacre pipeline as a no-op feature enable — silently dropping
17033 // the author's intent far from the source `caixa.lisp`. The new
17034 // gate surfaces the structural defect at the typed-validate
17035 // surface with a self-locating diagnostic naming the offending
17036 // dep's `:nome`.
17037 let d = dep_with_features(&[""]);
17038 assert!(
17039 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
17040 "expected CaracteristicaEmpty, got {:?}",
17041 d.validate(),
17042 );
17043 }
17044
17045 #[test]
17046 fn validate_rejects_duplicate_caracteristica() {
17047 // Fail-before-pass-after pin on the set-not-multiset arm: the
17048 // feature-toggle slot is set-shaped, so `(:caracteristicas
17049 // ("http" "http"))` is a redundant declaration the lacre
17050 // pipeline dedupes silently at resolve time. The diagnostic
17051 // names the offending dep + the colliding feature verbatim so
17052 // the author can grep their caixa.lisp for `:caracteristicas`
17053 // and fix it in one edit. First-collision determinism is
17054 // pinned separately below.
17055 let d = dep_with_features(&["http", "http"]);
17056 assert!(
17057 matches!(
17058 d.validate().unwrap_err(),
17059 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
17060 if nome == "caixa-teia" && caracteristica == "http"
17061 ),
17062 "expected CaracteristicaDuplicate, got {:?}",
17063 d.validate(),
17064 );
17065 }
17066
17067 #[test]
17068 fn validate_accepts_distinct_caracteristicas() {
17069 // The canonical authoring shape — every feature distinct — must
17070 // remain a clean pass (positive control sweep). Covers the
17071 // canonical kebab-case feature names a target caixa typically
17072 // declares.
17073 dep_with_features(&["http", "json", "tls"])
17074 .validate()
17075 .unwrap();
17076 }
17077
17078 #[test]
17079 fn validate_accepts_single_caracteristica() {
17080 // Single-element list is the minimum non-empty shape; passes
17081 // the gate as the identity of the duplicate check (no second
17082 // entry to collide with).
17083 dep_with_features(&["http"]).validate().unwrap();
17084 }
17085
17086 #[test]
17087 fn validate_accepts_empty_caracteristicas_list() {
17088 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
17089 // produces `caracteristicas: Vec::new()`; the empty list is
17090 // the gate's empty-set identity and passes vacuously. Pin
17091 // this so a future tightening that requires ≥1 feature
17092 // surfaces here as a test failure rather than a silent
17093 // contract narrowing.
17094 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17095 assert!(dep_with_features(&[]).validate().is_ok());
17096 }
17097
17098 #[test]
17099 fn validate_caracteristica_empty_fires_before_duplicate() {
17100 // Empty-first cascade: an entry with an empty feature *and*
17101 // duplicate entries surfaces the empty diagnostic first. The
17102 // empty-feature axis is the more-actionable defect since
17103 // `caracteristica: ""` is unambiguous; under duplicate-first
17104 // ordering the diagnostic could report the empty string from
17105 // either of two empty entries with no way to distinguish.
17106 // Mirrors the peer empty-before-duplicate ordering
17107 // discipline every per-entry shape + duplicate gate establishes
17108 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
17109 // `DuplicateChildCaixa`, `validate_membros`'s
17110 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
17111 let d = dep_with_features(&["", "http", "http"]);
17112 assert!(matches!(
17113 d.validate().unwrap_err(),
17114 DepError::CaracteristicaEmpty { .. }
17115 ));
17116 }
17117
17118 #[test]
17119 fn validate_caracteristica_duplicate_first_collision_determinism() {
17120 // Three matching entries: the second occurrence surfaces the
17121 // diagnostic (the second is the first *collision* — the first
17122 // entry is the establishing one, not a duplicate). Mirrors
17123 // every peer first-collision posture
17124 // (`SupervisorError::DuplicateChildCaixa` reports the second
17125 // collision, `AplicacaoError::MembroDuplicate` reports the
17126 // second, `DepError::DuplicateNome` reports the second).
17127 // Pinning this so a future shortcut that flips to last-
17128 // collision (or non-deterministic) surfaces here.
17129 let d = dep_with_features(&["http", "http", "http"]);
17130 assert!(matches!(
17131 d.validate().unwrap_err(),
17132 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
17133 ));
17134 }
17135
17136 #[test]
17137 fn validate_per_entry_shape_fires_before_caracteristicas() {
17138 // Per-entry shape precedence: a dep with a malformed `:nome`
17139 // (uppercase) AND duplicate `:caracteristicas` surfaces the
17140 // narrower `NomeInvalid` diagnostic first, not the set-gate
17141 // diagnostic. The `:nome` is the self-locating axis (every
17142 // diagnostic from the caracteristicas gate quotes the
17143 // offending dep's `:nome` to anchor the grep target —
17144 // surfacing the malformed name first keeps that anchor
17145 // valid). Same precedence shape every peer per-entry-shape
17146 // arm establishes against its peer set-gate
17147 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
17148 // on the cross-entry `:nome` axis).
17149 let d = Dep {
17150 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
17151 versao: "^0.1".into(),
17152 fonte: None,
17153 opcional: false,
17154 caracteristicas: vec!["http".into(), "http".into()],
17155 };
17156 assert!(matches!(
17157 d.validate().unwrap_err(),
17158 DepError::NomeInvalid { .. }
17159 ));
17160 }
17161
17162 // ── per-entry :caracteristicas value-shape gate ──────────────────
17163 //
17164 // Until this gate landed `:caracteristicas` only refused the empty
17165 // string and cross-entry duplicates: a non-empty distinct but
17166 // structurally invalid feature name silently passed validate and the
17167 // failure surfaced at `cargo metadata` time as Cargo's
17168 // `restricted_names::validate_feature_name` parser rejection, far from
17169 // the source `caixa.lisp` with no field naming which `:deps` entry's
17170 // `:caracteristicas` carried the typo. The lifted predicate makes the
17171 // Cargo-feature-name-grammar intersection-floor a substrate-level
17172 // invariant at validate time. Same trajectory as the eight peer
17173 // value-shape predicates each typed surface downstream of a structured
17174 // grammar already follows.
17175
17176 #[test]
17177 fn validate_rejects_caracteristica_with_leading_plus() {
17178 // Fail-before-pass-after pin on the canonical Cargo
17179 // `+<feature>` activation-form-in-feature-name-slot footgun.
17180 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
17181 // `+optional-feature` as an enablement of a previously-disabled
17182 // feature; pasting that activation form into `:caracteristicas`
17183 // (which names the feature itself) silently passed pre-gate and
17184 // failed at `cargo metadata` parse time.
17185 let d = dep_with_features(&["+http"]);
17186 let err = d.validate().unwrap_err();
17187 assert!(
17188 matches!(
17189 err,
17190 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
17191 if nome == "caixa-teia" && caracteristica == "+http"
17192 ),
17193 "expected CaracteristicaInvalid, got {err:?}"
17194 );
17195 }
17196
17197 #[test]
17198 fn validate_rejects_caracteristica_with_leading_hyphen() {
17199 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
17200 // is a legitimate continuation character (kebab-case feature
17201 // names like `runtime-tokio` pass) but Cargo rejects it at the
17202 // start; the structural defect — and its CLI-argument-injection
17203 // adjacency at any downstream Cargo subprocess invocation — is
17204 // closed at validate time, not at `cargo metadata` time.
17205 let d = dep_with_features(&["-json"]);
17206 let err = d.validate().unwrap_err();
17207 assert!(
17208 matches!(
17209 err,
17210 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
17211 ),
17212 "expected CaracteristicaInvalid, got {err:?}"
17213 );
17214 }
17215
17216 #[test]
17217 fn validate_rejects_caracteristica_with_leading_dot() {
17218 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
17219 // a legitimate continuation character (version-suffix shapes
17220 // like `feat.v2` pass) but the leading-dot form is the
17221 // canonical dotted-version-suffix-as-feature-name confusion.
17222 let d = dep_with_features(&[".feat"]);
17223 let err = d.validate().unwrap_err();
17224 assert!(matches!(
17225 err,
17226 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
17227 ));
17228 }
17229
17230 #[test]
17231 fn validate_rejects_caracteristica_with_whitespace() {
17232 // Fail-before-pass-after pin on the embedded-whitespace footgun:
17233 // a feature name with a space inside is structurally a multi-
17234 // token blob (the canonical paste-from-doc footgun, or an
17235 // accidental `"http server"` where the author meant
17236 // `"http-server"`).
17237 let d = dep_with_features(&["http feature"]);
17238 let err = d.validate().unwrap_err();
17239 assert!(matches!(
17240 err,
17241 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
17242 ));
17243 }
17244
17245 #[test]
17246 fn validate_rejects_caracteristica_with_comma() {
17247 // Fail-before-pass-after pin on the embedded-comma footgun:
17248 // the list-separator-belongs-to-the-list-grammar
17249 // miscomprehension where the author writes
17250 // `:caracteristicas ("http,json")` intending two features but
17251 // the `Vec<String>` field consumes the bare token as one entry.
17252 let d = dep_with_features(&["http,json"]);
17253 let err = d.validate().unwrap_err();
17254 assert!(matches!(
17255 err,
17256 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
17257 ));
17258 }
17259
17260 #[test]
17261 fn validate_rejects_caracteristica_with_slash() {
17262 // Fail-before-pass-after pin on the embedded-slash footgun:
17263 // Cargo's `dep/feat` namespaced-dep syntax applies inside
17264 // `[dependencies.<dep>.features]` list entries that already
17265 // name the parent dep (so the syntax says "enable feature
17266 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
17267 // per-dep already (a sibling slot on the `Dep` itself), so the
17268 // segment separator within an entry must be `-`, `_`, `+`,
17269 // or `.`. The diagnostic remediation points at the canonical
17270 // Cargo namespaced-dep discipline.
17271 let d = dep_with_features(&["http/json"]);
17272 let err = d.validate().unwrap_err();
17273 assert!(matches!(
17274 err,
17275 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
17276 ));
17277 }
17278
17279 #[test]
17280 fn validate_rejects_caracteristica_with_non_ascii() {
17281 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
17282 // byte footgun: NFC-vs-NFD normalization across filesystems
17283 // silently rewrites the feature-key, breaking the lacre's
17284 // content-addressing invariant. Pinned at a canonical
17285 // smart-quote-paste shape (`café`) where the raw `é` byte is the
17286 // documented APFS round-trip break.
17287 let d = dep_with_features(&["caf\u{e9}"]);
17288 let err = d.validate().unwrap_err();
17289 assert!(matches!(
17290 err,
17291 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
17292 ));
17293 }
17294
17295 #[test]
17296 fn validate_rejects_caracteristica_with_control_character() {
17297 // Fail-before-pass-after pin on the embedded-control-character
17298 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
17299 // feature name is the canonical paste-from-multiline-doc
17300 // footgun the predicate's reason wording specifically calls out.
17301 let d = dep_with_features(&["http\njson"]);
17302 let err = d.validate().unwrap_err();
17303 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
17304 }
17305
17306 #[test]
17307 fn validate_accepts_canonical_caracteristicas_shapes() {
17308 // Positive control sweep: every canonical Cargo feature name
17309 // shape the pleme-io ecosystem uses must still pass. Mirrors
17310 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
17311 // sweep — drift between either landing site and the predicate's
17312 // accepted set is a build error visible at this pair of tests,
17313 // not a per-renderer "this passed validate but failed at
17314 // cargo metadata time" surprise on the next acceptance.
17315 for s in [
17316 "http",
17317 "json",
17318 "derive",
17319 "serde_json",
17320 "runtime-tokio",
17321 "tokio.full",
17322 "v0.1",
17323 "http+json",
17324 "_internal",
17325 "__private",
17326 "default",
17327 "rt-multi-thread",
17328 "feat.v2",
17329 ] {
17330 let d = dep_with_features(&[s]);
17331 d.validate().unwrap_or_else(|e| {
17332 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
17333 });
17334 }
17335 }
17336
17337 #[test]
17338 fn validate_caracteristica_empty_fires_before_invalid() {
17339 // Cascade precedence pin: an entry list with both an empty
17340 // feature AND an invalid-shape feature surfaces the
17341 // `CaracteristicaEmpty` arm first (the empty value carries no
17342 // self-locating data — `caracteristica: ""` is the diagnostic
17343 // with no way to anchor a grep target — so closing the empty
17344 // axis first preserves the per-entry-shape diagnostic's
17345 // self-locating discipline). Same empty-first cascade every
17346 // peer per-entry shape gate establishes
17347 // (`SupervisorSpec::validate`'s `EmptyChildName` before
17348 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
17349 // before `MembroCaixaInvalid`).
17350 let d = dep_with_features(&["", "+http"]);
17351 assert!(matches!(
17352 d.validate().unwrap_err(),
17353 DepError::CaracteristicaEmpty { .. }
17354 ));
17355 }
17356
17357 #[test]
17358 fn validate_caracteristica_invalid_fires_before_duplicate() {
17359 // Per-entry-shape precedence pin: an entry list with the same
17360 // invalid feature shape declared twice surfaces the
17361 // `CaracteristicaInvalid` diagnostic on the first entry, not
17362 // the `CaracteristicaDuplicate` on the second collision. The
17363 // per-entry shape gate fires before the cross-entry set gate
17364 // — same precedence shape every peer two-arm-plus-set gate
17365 // establishes (`SupervisorSpec::validate`'s
17366 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
17367 // `validate_membros`'s `MembroCaixaInvalid` before
17368 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
17369 // cross-list `DuplicateNome`).
17370 let d = dep_with_features(&["+http", "+http"]);
17371 assert!(matches!(
17372 d.validate().unwrap_err(),
17373 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
17374 ));
17375 }
17376
17377 #[test]
17378 fn validate_rejects_caracteristica_at_65_byte_boundary() {
17379 // Boundary pin on the 64-byte cap — both the boundary-accepting
17380 // case and the boundary-exceeding case in one place, so a
17381 // future cap shift surfaces both arms simultaneously, mirroring
17382 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
17383 // predicate-level pin at the dep-axis landing site.
17384 let max_ok = "a".repeat(64);
17385 dep_with_features(&[&max_ok])
17386 .validate()
17387 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
17388 let too_long = "a".repeat(65);
17389 let d = dep_with_features(&[&too_long]);
17390 assert!(matches!(
17391 d.validate().unwrap_err(),
17392 DepError::CaracteristicaInvalid { .. }
17393 ));
17394 }
17395
17396 // ── self-dep cross-slot gate ─────────────────────────────────────
17397
17398 #[test]
17399 fn validate_no_self_dep_rejects_self_in_deps() {
17400 // A caixa whose `:deps` lists its own `:nome` is a one-node
17401 // cycle in the lacre closure's dep-graph traversal — rejected,
17402 // naming the parent and the offending list tag.
17403 let deps = vec![
17404 Dep::simple("caixa-teia", "^0.1"),
17405 Dep::simple("orquestra", "^0.1"),
17406 ];
17407 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17408 assert!(
17409 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17410 "got {err:?}"
17411 );
17412 }
17413
17414 #[test]
17415 fn validate_no_self_dep_rejects_self_in_deps_dev() {
17416 // Same gate on the `:deps-dev` axis — neither dep list is a
17417 // second-class citizen on the self-edge invariant.
17418 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17419 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17420 assert!(
17421 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17422 "got {err:?}"
17423 );
17424 }
17425
17426 #[test]
17427 fn validate_no_self_dep_deps_fires_before_deps_dev() {
17428 // Walk order pin: a caixa that self-references on both lists
17429 // surfaces the `:deps` arm first — the load-bearing axis the
17430 // lacre closure resolves at every build. Mirrors the canonical
17431 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
17432 let deps = vec![Dep::simple("orquestra", "^0.1")];
17433 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
17434 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
17435 assert!(
17436 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17437 "got {err:?}"
17438 );
17439 }
17440
17441 #[test]
17442 fn validate_no_self_dep_accepts_distinct_names() {
17443 // Positive control: every dep names a distinct caixa. The
17444 // canonical author surface — peer of
17445 // [`validate_no_self_supervision_accepts_distinct_children`].
17446 let deps = vec![
17447 Dep::simple("caixa-teia", "^0.1"),
17448 Dep::simple("caixa-arch", "^0.1"),
17449 ];
17450 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
17451 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
17452 }
17453
17454 #[test]
17455 fn validate_no_self_dep_empty_lists_pass() {
17456 // A caixa with no declared deps has nothing to self-reference —
17457 // the gate is vacuously satisfied. Peer of
17458 // [`validate_no_self_supervision_empty_children_is_ok`].
17459 validate_no_self_dep(&[], &[], "orquestra").unwrap();
17460 }
17461
17462 #[test]
17463 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
17464 // Diagnostic-shape pin (peer with
17465 // [`validate_no_self_supervision`]'s diagnostic): the error's
17466 // Display surfaces both the offending list tag and the
17467 // parent's `:nome` verbatim, so the author can grep their
17468 // caixa.lisp for the offending block in one edit. Names
17469 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
17470 // surface — every legitimate "I want to use code from this
17471 // caixa" intent routes through one of those three slots.
17472 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17473 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
17474 .unwrap_err()
17475 .to_string();
17476 assert!(
17477 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17478 "diagnostic must name the offending list tag: {rendered}",
17479 );
17480 assert!(
17481 rendered.contains("orquestra"),
17482 "diagnostic must quote the parent caixa name: {rendered}",
17483 );
17484 assert!(
17485 rendered.contains(":bibliotecas"),
17486 "diagnostic must point at the corrective code-surface slot: {rendered}",
17487 );
17488 }
17489
17490 #[test]
17491 fn validate_no_self_dep_accepts_coincidental_substring_match() {
17492 // Identity is exact-string equality, not substring — a dep
17493 // named `"orquestra-helper"` is a distinct caixa even when the
17494 // parent is `"orquestra"`. Pin the exact-match discipline so a
17495 // future relaxation that uses `contains` surfaces here, peer
17496 // with the supervision-tree and Aplicacao-membership gates
17497 // which all use exact-string equality on the typed identity.
17498 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
17499 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17500 }
17501
17502 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
17503
17504 #[test]
17505 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
17506 // Scalar-value pin: the two author-facing kebab-case labels the
17507 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
17508 // the two-list dep-graph slot axis, one arm per typed slot.
17509 // Mirrors the peer scalar-value pin the sibling
17510 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
17511 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
17512 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
17513 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
17514 // (882f498) M3 top-level author-labels, and
17515 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
17516 // Supervisor top-level author-labels carry, so every kind-scoped
17517 // typed-slot-family axis routes through one canonical per-arm
17518 // declaration.
17519 //
17520 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
17521 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
17522 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
17523 // for symmetry) lands as an edit to exactly one const, and
17524 // every consumer that reaches for the label picks it up at
17525 // build time rather than at runtime as a downstream mismatch on
17526 // a `DepError::DuplicateNome { list: … }` diagnostic far from
17527 // the rename's commit.
17528 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
17529 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
17530 }
17531
17532 #[test]
17533 fn dep_author_key_consts_are_pairwise_distinct() {
17534 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
17535 // must not collapse onto one byte-string. A future copy-paste
17536 // slip that renamed both consts to the same value (or a rebrand
17537 // that dropped the `-dev` suffix from one but not the other)
17538 // would leave every `DepError::DuplicateNome { list: … }`
17539 // diagnostic naming an unattributable list — the linter would
17540 // route the author to the wrong caixa.lisp block, or the
17541 // cross-list precedence gate
17542 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
17543 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
17544 // duplicate. Peer of the sibling
17545 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
17546 // other top-level kind-scoped slot-family axes carry
17547 // (implicitly held by their different byte-values today).
17548 assert_ne!(
17549 crate::render::DEP_AUTHOR_KEY_DEPS,
17550 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17551 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
17552 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
17553 self-locates the offending block in the author's caixa.lisp",
17554 );
17555 }
17556
17557 #[test]
17558 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
17559 // Production-through-const pin: the two per-arm list tags
17560 // [`validate_no_self_dep`] threads onto the `list:` field of a
17561 // returned [`DepError::DepIsSelf`] route through the lifted
17562 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
17563 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
17564 // the walker (a rename that reaches one arm but not the const,
17565 // or vice versa) surfaces here at build time rather than at
17566 // runtime as a `feira lint` diagnostic naming the wrong list
17567 // tag. Mirror of the peer
17568 // [`crate::Caixa::declared_servico_slots`] production tagger
17569 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
17570 // onto the two-list dep-graph gate.
17571 let deps = vec![Dep::simple("orquestra", "^0.1")];
17572 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17573 let DepError::DepIsSelf { list, .. } = err else {
17574 panic!("expected DepIsSelf from :deps walk");
17575 };
17576 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
17577
17578 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17579 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17580 let DepError::DepIsSelf { list, .. } = err else {
17581 panic!("expected DepIsSelf from :deps-dev walk");
17582 };
17583 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
17584 }
17585
17586 // ── Dep::nome accessor pins ───────────────────────────────────────
17587 //
17588 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
17589 // projection over the plain-shorthand / explicit-git / explicit-path
17590 // fixture triad the [`Dep`] docstring lists (so the accessor's
17591 // accept-set is exercised across every author-surface `:fonte`
17592 // shape); by-borrow pointer identity so the projection stays
17593 // zero-copy at every consumer site; and validate-composition through
17594 // the [`validate_no_self_dep`] cross-slot gate reading its
17595 // parent-name equality check through the lifted accessor rather than
17596 // the raw field.
17597
17598 #[test]
17599 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
17600 // Plain-shorthand form (`:fonte None`).
17601 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
17602 // Explicit git-source form with a tag pin — same accessor path.
17603 assert_eq!(
17604 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
17605 "caixa-teia",
17606 );
17607 // Explicit path-source form.
17608 assert_eq!(
17609 Dep {
17610 nome: "caixa-teia".to_string(),
17611 versao: "0.1.0".to_string(),
17612 fonte: Some(DepSource::Path {
17613 caminho: "../caixa-teia".to_string(),
17614 }),
17615 opcional: false,
17616 caracteristicas: Vec::new(),
17617 }
17618 .nome(),
17619 "caixa-teia",
17620 );
17621 // The empty-string `:nome` sentinel (which [`Dep::validate`]
17622 // refuses through the [`DepError::NomeEmpty`] arm) still round-
17623 // trips as an empty `&str` through the accessor — the accessor is
17624 // a projection, not a gate; the gate is [`Dep::validate`].
17625 assert_eq!(Dep::simple("", "^0.1").nome(), "");
17626 }
17627
17628 #[test]
17629 fn dep_nome_is_by_borrow_pointer_identity() {
17630 // Zero-copy pin: the accessor must borrow into the field's own
17631 // storage, not clone. If a future rewrite regresses to
17632 // `self.nome.clone().leak()` or an owned-buffer shape, the two
17633 // pointers diverge and this pin fails at build time.
17634 let d = Dep::simple("caixa-teia", "^0.1");
17635 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
17636 }
17637
17638 // ── Dep::versao_requirement accessor pins ─────────────────────────
17639 //
17640 // Three coherence pins on the lifted `Dep::versao_requirement`
17641 // accessor: byte-equal projection over the plain-shorthand /
17642 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
17643 // lists plus the empty-sentinel that round-trips as `""` (the accessor
17644 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
17645 // borrow pointer identity so the projection stays zero-copy at every
17646 // consumer site; and validate-composition through the
17647 // [`crate::render::require_valid_versao_requirement`] cascade reading
17648 // its requirement-shape check through the lifted accessor rather than
17649 // the raw field.
17650 #[test]
17651 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
17652 // Plain-shorthand form (`:fonte None`).
17653 assert_eq!(
17654 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
17655 "^0.1",
17656 );
17657 // Explicit git-source form with a tag pin — same accessor path.
17658 assert_eq!(
17659 Dep::git(
17660 "caixa-teia",
17661 "~0.1.2",
17662 "github:pleme-io/caixa-teia",
17663 "v0.1.0"
17664 )
17665 .versao_requirement(),
17666 "~0.1.2",
17667 );
17668 // Explicit path-source form.
17669 assert_eq!(
17670 Dep {
17671 nome: "caixa-teia".to_string(),
17672 versao: "0.1.0".to_string(),
17673 fonte: Some(DepSource::Path {
17674 caminho: "../caixa-teia".to_string(),
17675 }),
17676 opcional: false,
17677 caracteristicas: Vec::new(),
17678 }
17679 .versao_requirement(),
17680 "0.1.0",
17681 );
17682 // The wildcard requirement (`"*"`) — the shorthand
17683 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
17684 // verbatim through the accessor as `"*"`, same byte-shape the
17685 // author wrote.
17686 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
17687 // The empty-string `:versao` sentinel (which [`Dep::validate`]
17688 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
17689 // trips as an empty `&str` through the accessor — the accessor is
17690 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
17691 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
17692 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
17693 }
17694
17695 #[test]
17696 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
17697 // Zero-copy pin: the accessor must borrow into the field's own
17698 // storage, not clone. If a future rewrite regresses to
17699 // `self.versao.clone().leak()` or an owned-buffer shape, the two
17700 // pointers diverge and this pin fails at build time. Peer of the
17701 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
17702 // discipline extended onto the requirement-carrying axis.
17703 let d = Dep::simple("caixa-teia", "^0.1");
17704 assert!(std::ptr::eq(
17705 d.versao_requirement().as_ptr(),
17706 d.versao.as_ptr(),
17707 ));
17708 }
17709
17710 #[test]
17711 fn dep_validate_reads_requirement_through_accessor() {
17712 // Composition pin: the [`Dep::validate`]
17713 // [`crate::render::require_valid_versao_requirement`] cascade
17714 // consumes the requirement string through the lifted accessor —
17715 // both the requirement-gate input and the
17716 // [`DepError::VersaoInvalid`] error-body carrier route through
17717 // `self.versao_requirement()`. A valid requirement passes
17718 // (positive control); a malformed-but-non-empty requirement fails
17719 // and the diagnostic quotes the offending byte-string verbatim
17720 // (same shape the accessor projects), so a future regression that
17721 // detoured the requirement carrier through a different byte-
17722 // string (say the parsed `VersionReq`'s `Display`, or a
17723 // normalized rewrite) would surface here at build time. The
17724 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
17725 // ahead of the parse arm, pinning the empty-first cascade the
17726 // accessor's `""` sentinel round-trip acknowledges.
17727 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17728 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
17729 assert!(
17730 matches!(
17731 &err,
17732 DepError::VersaoInvalid {
17733 nome,
17734 versao,
17735 ..
17736 } if nome == "caixa-teia" && versao == "v0.1",
17737 ),
17738 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
17739 );
17740 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
17741 assert!(
17742 matches!(
17743 &err,
17744 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
17745 ),
17746 "expected VersaoEmpty from the empty-first arm, got {err:?}",
17747 );
17748 }
17749
17750 // ── Dep::fonte accessor pins ──────────────────────────────────────
17751 //
17752 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
17753 // equal projection over the plain-shorthand (`:fonte None`) /
17754 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
17755 // docstring lists (so the accessor's accept-set is exercised across
17756 // every author-surface `:fonte` shape and both `DepSource` variants);
17757 // pointer identity so the borrowed reference points into the field's
17758 // own `Option<DepSource>` storage (not a cloned side-buffer); and
17759 // validate-composition through the [`Dep::validate`] gate reading
17760 // its per-`:fonte` [`DepSource::validate`] delegation through the
17761 // lifted accessor rather than the raw `if let Some(ref fonte) =
17762 // self.fonte` bracket.
17763
17764 #[test]
17765 fn dep_fonte_returns_declared_source_across_shapes() {
17766 // Plain-shorthand form — `:fonte` omitted, accessor projects
17767 // the `None` partition the resolver-side default-fill treats
17768 // as "resolve through `github:<default-org>/<nome>`".
17769 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
17770 // Explicit git-source form with a tag pin — same accessor path.
17771 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17772 match git.fonte() {
17773 Some(DepSource::Git {
17774 repo,
17775 tag,
17776 rev,
17777 branch,
17778 }) => {
17779 assert_eq!(repo, "github:pleme-io/caixa-teia");
17780 assert_eq!(tag.as_deref(), Some("v0.1.0"));
17781 assert!(rev.is_none());
17782 assert!(branch.is_none());
17783 }
17784 other => panic!("expected explicit git :fonte, got {other:?}"),
17785 }
17786 // Explicit path-source form — the dev-only local-filesystem
17787 // arm the [`Dep`] docstring's third fixture carries.
17788 let path = Dep {
17789 nome: "caixa-teia".to_string(),
17790 versao: "0.1.0".to_string(),
17791 fonte: Some(DepSource::Path {
17792 caminho: "../caixa-teia".to_string(),
17793 }),
17794 opcional: false,
17795 caracteristicas: Vec::new(),
17796 };
17797 match path.fonte() {
17798 Some(DepSource::Path { caminho }) => {
17799 assert_eq!(caminho, "../caixa-teia");
17800 }
17801 other => panic!("expected explicit path :fonte, got {other:?}"),
17802 }
17803 }
17804
17805 #[test]
17806 fn dep_fonte_is_by_borrow_pointer_identity() {
17807 // Zero-copy pin: the accessor must borrow into the field's own
17808 // `Option<DepSource>` storage, not clone into a side buffer. If
17809 // a future rewrite regresses to `self.fonte.clone()` or an
17810 // owned-buffer shape, the two pointers diverge and this pin
17811 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17812 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17813 // identity pins — same by-borrow discipline extended onto the
17814 // outer-`Dep` `Option<&Composite>` composite-reference axis.
17815 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17816 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17817 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17818 assert!(std::ptr::eq(accessed, raw));
17819 }
17820
17821 #[test]
17822 fn dep_validate_reads_fonte_through_accessor() {
17823 // Composition pin: [`Dep::validate`]'s per-`:fonte`
17824 // [`DepSource::validate`] delegation consumes the typed slot
17825 // through the lifted accessor — an author-omitted `:fonte`
17826 // still passes the outer gate (positive control), an explicit
17827 // well-formed git source with exactly one pin passes, and a
17828 // malformed git source (empty `:repo`) surfaces the
17829 // [`DepError::FonteRepoEmpty`] variant quoting the offending
17830 // dep's `:nome` verbatim so a future regression that detoured
17831 // the `:fonte` delegation through a different path (say a
17832 // per-scope override projector) would surface here at build
17833 // time. Peer of the sibling
17834 // `dep_validate_reads_requirement_through_accessor` composition
17835 // pin on the `:versao` axis.
17836 // Positive control 1: no `:fonte` at all.
17837 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17838 // Positive control 2: well-formed git source.
17839 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17840 .validate()
17841 .unwrap();
17842 // Negative control: empty `:repo` — the accessor still returns
17843 // `Some(&DepSource::Git { repo: "", … })` and the delegated
17844 // `DepSource::validate` gate raises the typed carrier.
17845 let bad = Dep {
17846 nome: "caixa-teia".to_string(),
17847 versao: "^0.1".to_string(),
17848 fonte: Some(DepSource::Git {
17849 repo: String::new(),
17850 tag: Some("v0.1.0".to_string()),
17851 rev: None,
17852 branch: None,
17853 }),
17854 opcional: false,
17855 caracteristicas: Vec::new(),
17856 };
17857 let err = bad.validate().unwrap_err();
17858 assert!(
17859 matches!(
17860 &err,
17861 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17862 ),
17863 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17864 );
17865 }
17866
17867 #[test]
17868 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17869 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17870 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17871 // own `:nome` through the lifted accessor rather than the raw
17872 // field. Fails-before-passes-after: with the accessor lifted the
17873 // gate reads its equality check through `dep.nome() ==
17874 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17875 // the diagnostic still names the offending list tag as expected.
17876 let deps = vec![Dep::simple("orquestra", "^0.1")];
17877 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17878 assert!(matches!(
17879 err,
17880 DepError::DepIsSelf {
17881 ref nome,
17882 list,
17883 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17884 ));
17885 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17886 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17887 assert!(matches!(
17888 err,
17889 DepError::DepIsSelf {
17890 ref nome,
17891 list,
17892 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17893 ));
17894 // A non-matching `:nome` passes through the accessor gate.
17895 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17896 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17897 }
17898
17899 // ── Dep::caracteristicas accessor pins ────────────────────────────
17900 //
17901 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17902 // byte-equal projection over the default-empty / single-entry /
17903 // multi-entry fixture triad (so the accessor's accept-set is
17904 // exercised across every author-surface `:caracteristicas` shape,
17905 // matching the peer sibling family's fixture-triad discipline); by-
17906 // borrow pointer identity so the projection stays zero-copy at every
17907 // consumer site; and validate-composition through the
17908 // [`Dep::validate_caracteristicas`] gate reading its per-entry
17909 // linear walk through the lifted accessor rather than the raw
17910 // `for c in &self.caracteristicas` bracket.
17911
17912 #[test]
17913 fn dep_caracteristicas_returns_declared_features_across_shapes() {
17914 // Default-empty form — the [`Dep::simple`] constructor's
17915 // `Vec::new()` fill; the accessor projects the empty slice
17916 // verbatim (no `None` collapse).
17917 assert!(
17918 Dep::simple("caixa-teia", "^0.1")
17919 .caracteristicas()
17920 .is_empty(),
17921 );
17922 // Single-entry form — the canonical Cargo-shaped one-feature
17923 // enable ([`crate::render::is_cargo_feature_name`] accepts the
17924 // `"http"` byte-string as a valid feature name).
17925 let one = Dep {
17926 nome: "caixa-teia".to_string(),
17927 versao: "^0.1".to_string(),
17928 fonte: None,
17929 opcional: false,
17930 caracteristicas: vec!["http".to_string()],
17931 };
17932 assert_eq!(one.caracteristicas(), &["http".to_string()]);
17933 // Multi-entry form — the substrate's set-shaped multi-feature
17934 // enable, exercising the accessor over a length-two slice with
17935 // no duplicate collapse.
17936 let two = Dep {
17937 nome: "caixa-teia".to_string(),
17938 versao: "^0.1".to_string(),
17939 fonte: None,
17940 opcional: false,
17941 caracteristicas: vec!["http".to_string(), "json".to_string()],
17942 };
17943 assert_eq!(
17944 two.caracteristicas(),
17945 &["http".to_string(), "json".to_string()],
17946 );
17947 }
17948
17949 #[test]
17950 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17951 // Zero-copy pin: the accessor must borrow into the field's own
17952 // `Vec<String>` storage, not clone into a side buffer. If a
17953 // future rewrite regresses to `self.caracteristicas.clone()` or
17954 // an owned-buffer shape, the two pointers diverge and this pin
17955 // fails at build time. Peer of the sibling per-`Dep`
17956 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17957 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17958 // borrow discipline extended onto the outer-`Dep` `&[String]`
17959 // slice-projection axis.
17960 let d = Dep {
17961 nome: "caixa-teia".to_string(),
17962 versao: "^0.1".to_string(),
17963 fonte: None,
17964 opcional: false,
17965 caracteristicas: vec!["http".to_string(), "json".to_string()],
17966 };
17967 assert!(std::ptr::eq(
17968 d.caracteristicas().as_ptr(),
17969 d.caracteristicas.as_ptr(),
17970 ));
17971 }
17972
17973 #[test]
17974 fn dep_validate_reads_caracteristicas_through_accessor() {
17975 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17976 // linear walk consumes the feature-toggle list through the
17977 // lifted accessor — a well-formed `:caracteristicas` set passes
17978 // (positive control), an empty-string entry surfaces the
17979 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17980 // `Dep::nome`, and a within-list duplicate surfaces the
17981 // [`DepError::CaracteristicaDuplicate`] variant so a future
17982 // regression that detoured the walk through a different byte-
17983 // string list (say a per-scope override projector) would surface
17984 // here at build time. Peer of the sibling
17985 // `dep_validate_reads_fonte_through_accessor` /
17986 // `dep_validate_reads_requirement_through_accessor` composition
17987 // pins on the `:fonte` / `:versao` axes.
17988 // Positive control: two distinct well-formed feature names pass.
17989 Dep {
17990 nome: "caixa-teia".to_string(),
17991 versao: "^0.1".to_string(),
17992 fonte: None,
17993 opcional: false,
17994 caracteristicas: vec!["http".to_string(), "json".to_string()],
17995 }
17996 .validate()
17997 .unwrap();
17998 // Negative control 1: empty-string feature-name entry — the
17999 // accessor still returns `&[""]` and the walk raises the typed
18000 // empty-first carrier.
18001 let err = Dep {
18002 nome: "caixa-teia".to_string(),
18003 versao: "^0.1".to_string(),
18004 fonte: None,
18005 opcional: false,
18006 caracteristicas: vec![String::new()],
18007 }
18008 .validate()
18009 .unwrap_err();
18010 assert!(
18011 matches!(
18012 &err,
18013 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
18014 ),
18015 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
18016 );
18017 // Negative control 2: within-list duplicate — the accessor's
18018 // slice view carries both entries, and the walk's dedup arm
18019 // raises the typed duplicate carrier quoting the offending
18020 // feature name verbatim.
18021 let err = Dep {
18022 nome: "caixa-teia".to_string(),
18023 versao: "^0.1".to_string(),
18024 fonte: None,
18025 opcional: false,
18026 caracteristicas: vec!["http".to_string(), "http".to_string()],
18027 }
18028 .validate()
18029 .unwrap_err();
18030 assert!(
18031 matches!(
18032 &err,
18033 DepError::CaracteristicaDuplicate {
18034 nome,
18035 caracteristica,
18036 } if nome == "caixa-teia" && caracteristica == "http",
18037 ),
18038 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
18039 );
18040 }
18041
18042 // ── Dep::opcional accessor pins ───────────────────────────────────
18043 //
18044 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
18045 // equal projection over the default-`false` / explicit-`true`
18046 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
18047 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
18048 // exercising the accessor's accept-set over every author-surface
18049 // `:fonte` shape × every author-surface `:opcional` shape; and by-
18050 // `Copy` idempotency so the projection stays value-return (no
18051 // silent detour to a fresh `&bool` borrow that would introduce a
18052 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
18053 // shape elides). No composition pin — `:opcional` does not
18054 // participate in [`Dep::validate`] (an opcional dep with any bool
18055 // value is validate-accepted; the missing-source arm is a resolver-
18056 // side runtime dispatch, not a build-time refusal), so the axis
18057 // reduces to the value-shape + `Copy` pin pair the peer
18058 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
18059 // outer-`Option<Copy>` accessor pins already carry.
18060
18061 #[test]
18062 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
18063 // Default-`false` form via the [`Dep::simple`] constructor —
18064 // the accessor projects the `false` bit the default-fill sets.
18065 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
18066 // Default-`false` form via the [`Dep::git`] constructor — same
18067 // default fill; the accessor projects `false` regardless of the
18068 // `:fonte` arm.
18069 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
18070 // Explicit-`true` form × plain-shorthand `:fonte` — the
18071 // canonical author-surface "this dep may be missing" shape.
18072 let plain_true = Dep {
18073 nome: "caixa-teia".to_string(),
18074 versao: "^0.1".to_string(),
18075 fonte: None,
18076 opcional: true,
18077 caracteristicas: Vec::new(),
18078 };
18079 assert!(plain_true.opcional());
18080 // Explicit-`true` form × explicit git-source — the accessor
18081 // projects the bit verbatim regardless of the `:fonte` arm.
18082 let git_true = Dep {
18083 nome: "caixa-teia".to_string(),
18084 versao: "^0.1".to_string(),
18085 fonte: Some(DepSource::Git {
18086 repo: "github:pleme-io/caixa-teia".to_string(),
18087 tag: Some("v0.1.0".to_string()),
18088 rev: None,
18089 branch: None,
18090 }),
18091 opcional: true,
18092 caracteristicas: Vec::new(),
18093 };
18094 assert!(git_true.opcional());
18095 // Explicit-`true` form × explicit path-source — the dev-only
18096 // local-filesystem arm the [`Dep`] docstring's third fixture
18097 // carries.
18098 let path_true = Dep {
18099 nome: "caixa-teia".to_string(),
18100 versao: "0.1.0".to_string(),
18101 fonte: Some(DepSource::Path {
18102 caminho: "../caixa-teia".to_string(),
18103 }),
18104 opcional: true,
18105 caracteristicas: Vec::new(),
18106 };
18107 assert!(path_true.opcional());
18108 }
18109
18110 #[test]
18111 fn dep_opcional_projects_bool_by_copy() {
18112 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
18113 // (`bool: Copy`) — the accessor does not borrow `&self` past
18114 // the call (no lifetime on the return type), and calling the
18115 // accessor twice on the same [`Dep`] must yield discriminant-
18116 // equal values (idempotent, no side effects on `&self`). Peer
18117 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
18118 // `max_restarts_projects_option_by_copy` (eba5211) /
18119 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
18120 // outer-`Caixa` altitude — extended here to the outer-`Dep`
18121 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
18122 // replaces the pointer-equality claim the sibling per-`Dep`
18123 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
18124 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
18125 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
18126 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
18127 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
18128 // the same discriminant, so the axis reduces to discriminant
18129 // equality).
18130 //
18131 // Pins against a future silent detour that returned a fresh
18132 // `&bool` reference (which would type-check but silently
18133 // introduce a borrow of `&self` past the call, collapsing the
18134 // load-bearing "no lifetime on the return type" `Copy`
18135 // projection the plain-`Copy`-scalar axis's `bool` shape
18136 // carries) or a stale-read side effect that flipped the outer
18137 // discriminant on successive calls.
18138 for opcional in [false, true] {
18139 let d = Dep {
18140 nome: "caixa-teia".to_string(),
18141 versao: "^0.1".to_string(),
18142 fonte: None,
18143 opcional,
18144 caracteristicas: Vec::new(),
18145 };
18146 let first = d.opcional();
18147 let second = d.opcional();
18148 assert_eq!(
18149 first, second,
18150 "Dep::opcional must be idempotent — two successive calls \
18151 on the same &self must return the same bool",
18152 );
18153 assert_eq!(
18154 first, opcional,
18155 "Dep::opcional must return :opcional verbatim by Copy — \
18156 got {first}, expected {opcional}",
18157 );
18158 assert_eq!(
18159 d.opcional(),
18160 d.opcional,
18161 "Dep::opcional accessor and self.opcional field access \
18162 must byte-equal — a bit-flip drift would silently split \
18163 the paired resolver-side drop-vs-error dispatch from \
18164 the storage-side default-fill the [`Dep::simple`] / \
18165 [`Dep::git`] constructor pair carries",
18166 );
18167 }
18168 }
18169
18170 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
18171
18172 #[test]
18173 fn sole_pin_returns_none_for_path_source() {
18174 // A path source carries no git-ref, so `sole_pin()` returns
18175 // `None` structurally — the sibling arm every git-fetching
18176 // consumer partitions off before reaching for a git-ref. Pins
18177 // the Path-arm branch of the accessor against a future silent
18178 // detour that treats a `Self::Path` as an unpinned-git source
18179 // and returns the wrong "no pin" signal (e.g. the empty string,
18180 // or a hard-coded `Some("HEAD")` matching the caixa-crd
18181 // path-arm `git_ref` fill).
18182 let s = DepSource::Path {
18183 caminho: "../local-caixa".to_string(),
18184 };
18185 assert_eq!(s.sole_pin(), None);
18186 }
18187
18188 #[test]
18189 fn sole_pin_returns_none_for_unpinned_git_source() {
18190 // The [`DepSource::default_github`] shorthand shape carries no
18191 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
18192 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
18193 // materializes when the author omits `:fonte` entirely, then
18194 // hands to `fetch_git` which raises `ResolveError::MissingPin`
18195 // on the `None` arm — the accessor's return matches the arm
18196 // the resolver's diagnostic keys off.
18197 let s = DepSource::default_github("pleme-io", "caixa-teia");
18198 assert_eq!(s.sole_pin(), None);
18199 }
18200
18201 #[test]
18202 fn sole_pin_returns_rev_when_only_rev_is_set() {
18203 let s = DepSource::Git {
18204 repo: "github:o/x".into(),
18205 tag: None,
18206 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
18207 branch: None,
18208 };
18209 assert_eq!(
18210 s.sole_pin(),
18211 Some("deadbeefcafebabe1234567890abcdef12345678")
18212 );
18213 }
18214
18215 #[test]
18216 fn sole_pin_returns_tag_when_only_tag_is_set() {
18217 let s = DepSource::Git {
18218 repo: "github:o/x".into(),
18219 tag: Some("v0.1.0".into()),
18220 rev: None,
18221 branch: None,
18222 };
18223 assert_eq!(s.sole_pin(), Some("v0.1.0"));
18224 }
18225
18226 #[test]
18227 fn sole_pin_returns_branch_when_only_branch_is_set() {
18228 let s = DepSource::Git {
18229 repo: "github:o/x".into(),
18230 tag: None,
18231 rev: None,
18232 branch: Some("main".into()),
18233 };
18234 assert_eq!(s.sole_pin(), Some("main"));
18235 }
18236
18237 #[test]
18238 fn sole_pin_precedence_rev_beats_tag_and_branch() {
18239 // Precedence: rev > tag > branch. Validate() rejects
18240 // multiple-pin shapes, but the accessor's precedence is defined
18241 // for pre-validate consumers (the resolver's `MissingPin`
18242 // diagnostic path, the caixa-crd round-trip's default `"main"`
18243 // fallback) and as defense-in-depth if the gate is ever
18244 // bypassed. Pins the same precedence caixa-resolver's
18245 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
18246 // inline.
18247 let s = DepSource::Git {
18248 repo: "github:o/x".into(),
18249 tag: Some("v1".into()),
18250 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
18251 branch: Some("main".into()),
18252 };
18253 assert_eq!(
18254 s.sole_pin(),
18255 Some("deadbeefcafebabe1234567890abcdef12345678")
18256 );
18257 }
18258
18259 #[test]
18260 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
18261 let s = DepSource::Git {
18262 repo: "github:o/x".into(),
18263 tag: Some("v1".into()),
18264 rev: None,
18265 branch: Some("main".into()),
18266 };
18267 assert_eq!(s.sole_pin(), Some("v1"));
18268 }
18269
18270 #[test]
18271 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
18272 // Fail-before-pass-after byte-parity pin: the substrate accessor
18273 // must return byte-identical to the inline
18274 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
18275 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
18276 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
18277 // time if the accessor's precedence silently drifts from the
18278 // consumer-side cascade — the exact drift this lift converges
18279 // to one substrate primitive to close structurally.
18280 //
18281 // Iterates through the 2^3 = 8 combinations of (tag, rev,
18282 // branch) each-either-`None`-or-`Some`, so every arm of the
18283 // precedence cascade lands under the pin. `validate()` refuses
18284 // the 4 multi-pin combinations, but the accessor's return is
18285 // defined on all 8.
18286 let vals = [Some("R".to_string()), None];
18287 for tag in &vals {
18288 for rev in &vals {
18289 for branch in &vals {
18290 let s = DepSource::Git {
18291 repo: "github:o/x".into(),
18292 tag: tag.clone(),
18293 rev: rev.clone(),
18294 branch: branch.clone(),
18295 };
18296 // The exact inline cascade the two pre-lift
18297 // consumer sites hand-rolled, byte-for-byte.
18298 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
18299 assert_eq!(
18300 s.sole_pin(),
18301 expected,
18302 "sole_pin() must byte-equal \
18303 rev.or(tag).or(branch) for \
18304 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
18305 a drift would silently split caixa-resolver's \
18306 fetch_git checkout target from caixa-crd's \
18307 dep_into_ref git_ref fill",
18308 );
18309 }
18310 }
18311 }
18312 }
18313
18314 // Fail-before-pass-after pins on the eleven
18315 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
18316 // constructors folded from the [`DepSource::validate_caminho`]
18317 // wire-up sites. Each pins the generated ctor's output to the
18318 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
18319 // any wrapper-side lowercase / trim / re-order / silent-field-swap
18320 // regression on the two-field `{ nome: nome.to_string(), caminho:
18321 // caminho.to_string() }` construction surfaces here rather than at
18322 // a downstream diagnostic-shape mismatch. Peer of the sibling
18323 // `empty_child_version_ctor_matches_struct_literal_wrap` /
18324 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
18325 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
18326 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
18327 // pins on the peer `SupervisorError` / `AplicacaoError` /
18328 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
18329
18330 #[test]
18331 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
18332 assert_eq!(
18333 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
18334 DepError::FonteCaminhoAbsolute {
18335 nome: "caixa-teia".to_string(),
18336 caminho: "/home/me/work/caixa-teia".to_string(),
18337 },
18338 "generated fonte_caminho_absolute ctor must produce byte-equal \
18339 DepError to the open-coded struct-literal wrap on the same \
18340 (&str, &str) fixture",
18341 );
18342 }
18343
18344 #[test]
18345 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
18346 assert_eq!(
18347 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
18348 DepError::FonteCaminhoTildeExpansion {
18349 nome: "caixa-teia".to_string(),
18350 caminho: "~/work/caixa-teia".to_string(),
18351 },
18352 );
18353 }
18354
18355 #[test]
18356 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
18357 assert_eq!(
18358 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
18359 DepError::FonteCaminhoVarExpansion {
18360 nome: "caixa-teia".to_string(),
18361 caminho: "$HOME/work/caixa-teia".to_string(),
18362 },
18363 );
18364 }
18365
18366 #[test]
18367 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
18368 assert_eq!(
18369 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
18370 DepError::FonteCaminhoLeadingWhitespace {
18371 nome: "caixa-teia".to_string(),
18372 caminho: " ../caixa-teia".to_string(),
18373 },
18374 );
18375 }
18376
18377 #[test]
18378 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
18379 assert_eq!(
18380 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
18381 DepError::FonteCaminhoLeadingHyphen {
18382 nome: "caixa-teia".to_string(),
18383 caminho: "-rf".to_string(),
18384 },
18385 );
18386 }
18387
18388 #[test]
18389 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
18390 assert_eq!(
18391 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
18392 DepError::FonteCaminhoBackslash {
18393 nome: "caixa-teia".to_string(),
18394 caminho: "..\\caixa-teia".to_string(),
18395 },
18396 );
18397 }
18398
18399 #[test]
18400 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
18401 assert_eq!(
18402 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
18403 DepError::FonteCaminhoShellPipe {
18404 nome: "caixa-teia".to_string(),
18405 caminho: "../caixa-teia|evil".to_string(),
18406 },
18407 );
18408 }
18409
18410 #[test]
18411 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
18412 assert_eq!(
18413 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
18414 DepError::FonteCaminhoShellSemicolon {
18415 nome: "caixa-teia".to_string(),
18416 caminho: "../caixa-teia;evil".to_string(),
18417 },
18418 );
18419 }
18420
18421 #[test]
18422 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
18423 assert_eq!(
18424 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
18425 DepError::FonteCaminhoShellBackground {
18426 nome: "caixa-teia".to_string(),
18427 caminho: "../caixa-teia&".to_string(),
18428 },
18429 );
18430 }
18431
18432 #[test]
18433 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
18434 assert_eq!(
18435 DepError::fonte_caminho_shell_command_substitution(
18436 "caixa-teia",
18437 "../caixa-teia`whoami`",
18438 ),
18439 DepError::FonteCaminhoShellCommandSubstitution {
18440 nome: "caixa-teia".to_string(),
18441 caminho: "../caixa-teia`whoami`".to_string(),
18442 },
18443 );
18444 }
18445
18446 #[test]
18447 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
18448 assert_eq!(
18449 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
18450 DepError::FonteCaminhoTrailingSlash {
18451 nome: "caixa-teia".to_string(),
18452 caminho: "../caixa-teia/".to_string(),
18453 },
18454 );
18455 }
18456
18457 #[test]
18458 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
18459 // Cross-axis pin: sweep the two constructor input axes
18460 // (`nome: &str`, `caminho: &str`) through a non-default fixture
18461 // pair against every generated arm in the
18462 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
18463 // / trim / truncate / re-order on the two-field
18464 // `{ nome, caminho }` construction — or a silent field swap
18465 // between the two axes at codegen time — surfaces here rather
18466 // than at a downstream diagnostic-shape mismatch. Peer of the
18467 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
18468 // to_string` cross-axis routing pin on the peer
18469 // `SupervisorError` envelope, extended here onto the
18470 // `DepError` `{ nome: String, caminho: String }` envelope so
18471 // every substrate-primitive ctor family in caixa-core
18472 // guarantees each `&str`-field construction routes the
18473 // caller's `&str` verbatim through `.to_string()`.
18474 let nome = "sibling-teia";
18475 let caminho = "../workspace/sibling";
18476 let cases: [(DepError, DepError); 11] = [
18477 (
18478 DepError::fonte_caminho_absolute(nome, caminho),
18479 DepError::FonteCaminhoAbsolute {
18480 nome: nome.to_string(),
18481 caminho: caminho.to_string(),
18482 },
18483 ),
18484 (
18485 DepError::fonte_caminho_tilde_expansion(nome, caminho),
18486 DepError::FonteCaminhoTildeExpansion {
18487 nome: nome.to_string(),
18488 caminho: caminho.to_string(),
18489 },
18490 ),
18491 (
18492 DepError::fonte_caminho_var_expansion(nome, caminho),
18493 DepError::FonteCaminhoVarExpansion {
18494 nome: nome.to_string(),
18495 caminho: caminho.to_string(),
18496 },
18497 ),
18498 (
18499 DepError::fonte_caminho_leading_whitespace(nome, caminho),
18500 DepError::FonteCaminhoLeadingWhitespace {
18501 nome: nome.to_string(),
18502 caminho: caminho.to_string(),
18503 },
18504 ),
18505 (
18506 DepError::fonte_caminho_leading_hyphen(nome, caminho),
18507 DepError::FonteCaminhoLeadingHyphen {
18508 nome: nome.to_string(),
18509 caminho: caminho.to_string(),
18510 },
18511 ),
18512 (
18513 DepError::fonte_caminho_backslash(nome, caminho),
18514 DepError::FonteCaminhoBackslash {
18515 nome: nome.to_string(),
18516 caminho: caminho.to_string(),
18517 },
18518 ),
18519 (
18520 DepError::fonte_caminho_shell_pipe(nome, caminho),
18521 DepError::FonteCaminhoShellPipe {
18522 nome: nome.to_string(),
18523 caminho: caminho.to_string(),
18524 },
18525 ),
18526 (
18527 DepError::fonte_caminho_shell_semicolon(nome, caminho),
18528 DepError::FonteCaminhoShellSemicolon {
18529 nome: nome.to_string(),
18530 caminho: caminho.to_string(),
18531 },
18532 ),
18533 (
18534 DepError::fonte_caminho_shell_background(nome, caminho),
18535 DepError::FonteCaminhoShellBackground {
18536 nome: nome.to_string(),
18537 caminho: caminho.to_string(),
18538 },
18539 ),
18540 (
18541 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
18542 DepError::FonteCaminhoShellCommandSubstitution {
18543 nome: nome.to_string(),
18544 caminho: caminho.to_string(),
18545 },
18546 ),
18547 (
18548 DepError::fonte_caminho_trailing_slash(nome, caminho),
18549 DepError::FonteCaminhoTrailingSlash {
18550 nome: nome.to_string(),
18551 caminho: caminho.to_string(),
18552 },
18553 ),
18554 ];
18555 for (via_ctor, via_struct_literal) in cases {
18556 assert_eq!(
18557 via_ctor, via_struct_literal,
18558 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
18559 through `.to_string()` in declared field order — a field-swap or \
18560 silent-conversion regression surfaces here rather than at a \
18561 downstream diagnostic-shape mismatch",
18562 );
18563 }
18564 }
18565
18566 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
18567 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
18568 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
18569 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
18570 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
18571
18572 #[test]
18573 fn versao_empty_ctor_matches_struct_literal_wrap() {
18574 assert_eq!(
18575 DepError::versao_empty("caixa-teia"),
18576 DepError::VersaoEmpty {
18577 nome: "caixa-teia".to_string(),
18578 },
18579 );
18580 }
18581
18582 #[test]
18583 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
18584 assert_eq!(
18585 DepError::fonte_repo_empty("caixa-teia"),
18586 DepError::FonteRepoEmpty {
18587 nome: "caixa-teia".to_string(),
18588 },
18589 );
18590 }
18591
18592 #[test]
18593 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
18594 assert_eq!(
18595 DepError::fonte_pin_missing("caixa-teia"),
18596 DepError::FontePinMissing {
18597 nome: "caixa-teia".to_string(),
18598 },
18599 );
18600 }
18601
18602 #[test]
18603 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
18604 assert_eq!(
18605 DepError::fonte_caminho_empty("caixa-teia"),
18606 DepError::FonteCaminhoEmpty {
18607 nome: "caixa-teia".to_string(),
18608 },
18609 );
18610 }
18611
18612 #[test]
18613 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
18614 assert_eq!(
18615 DepError::caracteristica_empty("caixa-teia"),
18616 DepError::CaracteristicaEmpty {
18617 nome: "caixa-teia".to_string(),
18618 },
18619 );
18620 }
18621
18622 #[test]
18623 fn dep_nome_only_ctors_route_nome_through_to_string() {
18624 // Cross-axis routing pin: sweep the single constructor input
18625 // axis (`nome: &str`) through a non-default fixture against
18626 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
18627 // any wrapper-side lowercase / trim / truncate at codegen time
18628 // — or a silent field re-name away from the canonical `nome`
18629 // axis on any one variant — surfaces here rather than at a
18630 // downstream diagnostic-shape mismatch. Peer of the sibling
18631 // `fonte_caminho_ctors_route_nome_and_caminho_through_
18632 // to_string` cross-axis routing pin on the same envelope's
18633 // two-slot family (f85f145) and of the peer
18634 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
18635 // pin on the `SupervisorError` single-slot family (db09650).
18636 let nome = "sibling-teia";
18637 let cases: [(DepError, DepError); 5] = [
18638 (
18639 DepError::versao_empty(nome),
18640 DepError::VersaoEmpty {
18641 nome: nome.to_string(),
18642 },
18643 ),
18644 (
18645 DepError::fonte_repo_empty(nome),
18646 DepError::FonteRepoEmpty {
18647 nome: nome.to_string(),
18648 },
18649 ),
18650 (
18651 DepError::fonte_pin_missing(nome),
18652 DepError::FontePinMissing {
18653 nome: nome.to_string(),
18654 },
18655 ),
18656 (
18657 DepError::fonte_caminho_empty(nome),
18658 DepError::FonteCaminhoEmpty {
18659 nome: nome.to_string(),
18660 },
18661 ),
18662 (
18663 DepError::caracteristica_empty(nome),
18664 DepError::CaracteristicaEmpty {
18665 nome: nome.to_string(),
18666 },
18667 ),
18668 ];
18669 for (via_ctor, via_struct_literal) in cases {
18670 assert_eq!(
18671 via_ctor, via_struct_literal,
18672 "dep_nome_only_ctors!-generated ctor must route `nome` \
18673 through `.to_string()` onto the canonical `nome` field \
18674 — a field-rename or silent-conversion regression surfaces \
18675 here rather than at a downstream diagnostic-shape mismatch",
18676 );
18677 }
18678 }
18679
18680 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
18681 // &'static str }` two-slot envelope on `DepError`, strict
18682 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
18683 // same envelope's `{ nome: String }` one-slot shape and of the
18684 // peer `supervisor_caixa_only_ctors!` (db09650) on the
18685 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
18686
18687 #[test]
18688 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
18689 assert_eq!(
18690 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
18691 DepError::DuplicateNome {
18692 nome: "caixa-teia".to_string(),
18693 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18694 },
18695 "generated duplicate_nome ctor must produce byte-equal \
18696 `DepError::DuplicateNome` to the pre-lift struct-literal \
18697 wrap on the same scalar fixtures",
18698 );
18699 }
18700
18701 #[test]
18702 fn dep_is_self_ctor_matches_struct_literal_wrap() {
18703 assert_eq!(
18704 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18705 DepError::DepIsSelf {
18706 nome: "orquestra".to_string(),
18707 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18708 },
18709 "generated dep_is_self ctor must produce byte-equal \
18710 `DepError::DepIsSelf` to the pre-lift struct-literal \
18711 wrap on the same scalar fixtures",
18712 );
18713 }
18714
18715 #[test]
18716 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
18717 // Cross-axis routing pin: sweep the two constructor input axes
18718 // (`nome: &str`, `list: &'static str`) through non-default
18719 // fixtures against every generated arm in the
18720 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
18721 // lowercase / trim / truncate at codegen time — or a silent
18722 // field re-name away from the canonical `nome` / `list` axes
18723 // on any one variant, or a `list` axis silently rerouted
18724 // through `.to_string()` instead of passed as `&'static str`
18725 // verbatim — surfaces here rather than at a downstream
18726 // diagnostic-shape mismatch. Peer of the sibling
18727 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18728 // (792aa92) on the same envelope's one-slot family, and of the
18729 // peer
18730 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
18731 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
18732 // two-slot `{ caixa: String, reason: String }` shape.
18733 let nome = "sibling-teia";
18734 let cases: [(DepError, DepError); 4] = [
18735 (
18736 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18737 DepError::DuplicateNome {
18738 nome: nome.to_string(),
18739 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18740 },
18741 ),
18742 (
18743 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18744 DepError::DuplicateNome {
18745 nome: nome.to_string(),
18746 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18747 },
18748 ),
18749 (
18750 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18751 DepError::DepIsSelf {
18752 nome: nome.to_string(),
18753 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18754 },
18755 ),
18756 (
18757 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18758 DepError::DepIsSelf {
18759 nome: nome.to_string(),
18760 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18761 },
18762 ),
18763 ];
18764 for (via_ctor, via_struct_literal) in cases {
18765 assert_eq!(
18766 via_ctor, via_struct_literal,
18767 "dep_nome_list_ctors!-generated ctor must route `nome` \
18768 through `.to_string()` onto the canonical `nome` field \
18769 and pass `list` verbatim onto the canonical `&'static str` \
18770 `list` field — a field-rename, silent-conversion, or \
18771 axis-swap regression surfaces here rather than at a \
18772 downstream diagnostic-shape mismatch",
18773 );
18774 }
18775 }
18776
18777 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18778 // value: String, reason: String }` four-slot envelope on
18779 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18780 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18781 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18782 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
18783 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
18784 // envelope. Single-variant lift closing the last open-coded ctor
18785 // site on the `:fonte (:tipo git …)` value-shape trajectory.
18786
18787 #[test]
18788 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18789 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18790 // ctor: sweep both wire-up-shape arms (the refname-pin arm
18791 // routing `":tag"` / `":branch"` value through
18792 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18793 // routing `":rev"` through [`crate::render::is_git_oid`]) and
18794 // assert byte-equal `PartialEq` against the pre-lift
18795 // struct-literal, so any wrapper-side field-rename /
18796 // silent-conversion regression surfaces here rather than at a
18797 // downstream diagnostic-shape mismatch. Peer of the sibling
18798 // per-envelope byte-equal ctor pins
18799 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18800 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18801 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18802 assert_eq!(
18803 DepError::fonte_pin_shape(
18804 "caixa-teia",
18805 ":tag",
18806 "v0.1.0 ",
18807 "trailing whitespace".to_string(),
18808 ),
18809 DepError::FontePinShape {
18810 nome: "caixa-teia".to_string(),
18811 pin: ":tag".to_string(),
18812 value: "v0.1.0 ".to_string(),
18813 reason: "trailing whitespace".to_string(),
18814 },
18815 "fonte_pin_shape ctor must produce byte-equal \
18816 `DepError::FontePinShape` to the pre-lift struct-literal \
18817 wrap on a refname-pin (`:tag` / `:branch`) fixture",
18818 );
18819 assert_eq!(
18820 DepError::fonte_pin_shape(
18821 "caixa-teia",
18822 ":rev",
18823 "DEADBEEF",
18824 "abbreviated OID rejected".to_string(),
18825 ),
18826 DepError::FontePinShape {
18827 nome: "caixa-teia".to_string(),
18828 pin: ":rev".to_string(),
18829 value: "DEADBEEF".to_string(),
18830 reason: "abbreviated OID rejected".to_string(),
18831 },
18832 "fonte_pin_shape ctor must produce byte-equal \
18833 `DepError::FontePinShape` to the pre-lift struct-literal \
18834 wrap on a hex-OID-pin (`:rev`) fixture",
18835 );
18836 }
18837
18838 #[test]
18839 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18840 // Cross-axis routing pin: sweep every one of the four
18841 // constructor input axes (`nome: &str`, `pin: &str`,
18842 // `value: &str`, `reason: String`) through non-default
18843 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18844 // any wrapper-side lowercase / trim / truncate at codegen time
18845 // — or a silent field re-name / axis-swap on any one of the
18846 // four fields, or a `reason` axis silently routed through
18847 // `.to_string()` instead of forwarded owned — surfaces here
18848 // rather than at a downstream diagnostic-shape mismatch. Peer
18849 // of the sibling
18850 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18851 // (792aa92) and
18852 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18853 // pin (6f5e0cd) on the same envelope's one- and two-slot
18854 // families. Distinct-per-axis fixtures rule out any two-axis
18855 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18856 // etc.) that would still pass a same-fixture-per-axis pin.
18857 let nome = "sibling-teia";
18858 let pin = ":branch";
18859 let value = "feature/bar";
18860 let reason = "embedded space".to_string();
18861 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18862 let via_struct_literal = DepError::FontePinShape {
18863 nome: nome.to_string(),
18864 pin: pin.to_string(),
18865 value: value.to_string(),
18866 reason: reason.clone(),
18867 };
18868 assert_eq!(
18869 via_ctor, via_struct_literal,
18870 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18871 through `.to_string()` onto their canonical fields and \
18872 forward `reason` owned onto the canonical `reason` field \
18873 — a field-rename, silent-conversion, or axis-swap \
18874 regression surfaces here rather than at a downstream \
18875 diagnostic-shape mismatch",
18876 );
18877 let DepError::FontePinShape {
18878 nome: n,
18879 pin: p,
18880 value: v,
18881 reason: r,
18882 } = via_ctor
18883 else {
18884 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18885 };
18886 assert_eq!(n, nome);
18887 assert_eq!(p, pin);
18888 assert_eq!(v, value);
18889 assert_eq!(r, reason);
18890 }
18891
18892 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18893 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18894 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18895 // the same envelope's `{ nome: String, caminho: String }` two-slot
18896 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18897 // same envelope's `{ nome: String }` one-slot shape.
18898
18899 #[test]
18900 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18901 assert_eq!(
18902 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18903 DepError::FonteCaminhoControlChar {
18904 nome: "caixa-teia".to_string(),
18905 caminho: "../caixa-teia\x00foo".to_string(),
18906 byte: 0x00,
18907 },
18908 );
18909 }
18910
18911 #[test]
18912 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18913 assert_eq!(
18914 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18915 DepError::FonteCaminhoShellRedirection {
18916 nome: "caixa-teia".to_string(),
18917 caminho: "../caixa-teia>log".to_string(),
18918 byte: b'>',
18919 },
18920 );
18921 }
18922
18923 #[test]
18924 #[allow(
18925 clippy::too_many_lines,
18926 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18927 byte-classification arm on the {nome,caminho,byte} envelope; \
18928 the linear per-variant repetition is exactly what the sweep \
18929 is pinning — a helper macro would hide the shape the fold is \
18930 keying on"
18931 )]
18932 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18933 // Cross-axis routing pin: sweep the three constructor input axes
18934 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18935 // non-default fixture triple against every generated arm in the
18936 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18937 // lowercase / trim / truncate on the two `&str` axes — a silent
18938 // field swap between `nome` and `caminho`, or a silent
18939 // re-classification of the offending byte — surfaces here rather
18940 // than at a downstream diagnostic-shape mismatch. Peer of the
18941 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18942 // to_string` cross-axis routing pin on the same envelope's
18943 // two-slot family (f85f145) and of the sibling
18944 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18945 // same envelope's one-slot family (792aa92), extended here onto
18946 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18947 // envelope so every substrate-primitive ctor family in
18948 // caixa-core's `DepError` envelope guarantees each field routes
18949 // the caller's value verbatim through `.to_string()` (or byte-
18950 // identity for `byte: u8`) in declared field order.
18951 let nome = "sibling-teia";
18952 let caminho = "../workspace/sibling";
18953 let byte = 0x2A_u8;
18954 let cases: [(DepError, DepError); 12] = [
18955 (
18956 DepError::fonte_caminho_control_char(nome, caminho, byte),
18957 DepError::FonteCaminhoControlChar {
18958 nome: nome.to_string(),
18959 caminho: caminho.to_string(),
18960 byte,
18961 },
18962 ),
18963 (
18964 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18965 DepError::FonteCaminhoShellRedirection {
18966 nome: nome.to_string(),
18967 caminho: caminho.to_string(),
18968 byte,
18969 },
18970 ),
18971 (
18972 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18973 DepError::FonteCaminhoShellGlob {
18974 nome: nome.to_string(),
18975 caminho: caminho.to_string(),
18976 byte,
18977 },
18978 ),
18979 (
18980 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18981 DepError::FonteCaminhoShellSubshellGrouping {
18982 nome: nome.to_string(),
18983 caminho: caminho.to_string(),
18984 byte,
18985 },
18986 ),
18987 (
18988 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18989 DepError::FonteCaminhoShellBraceExpansion {
18990 nome: nome.to_string(),
18991 caminho: caminho.to_string(),
18992 byte,
18993 },
18994 ),
18995 (
18996 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18997 DepError::FonteCaminhoShellBracketExpansion {
18998 nome: nome.to_string(),
18999 caminho: caminho.to_string(),
19000 byte,
19001 },
19002 ),
19003 (
19004 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
19005 DepError::FonteCaminhoShellQuoteGrouping {
19006 nome: nome.to_string(),
19007 caminho: caminho.to_string(),
19008 byte,
19009 },
19010 ),
19011 (
19012 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
19013 DepError::FonteCaminhoShellComment {
19014 nome: nome.to_string(),
19015 caminho: caminho.to_string(),
19016 byte,
19017 },
19018 ),
19019 (
19020 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
19021 DepError::FonteCaminhoUrlPercentEncoding {
19022 nome: nome.to_string(),
19023 caminho: caminho.to_string(),
19024 byte,
19025 },
19026 ),
19027 (
19028 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
19029 DepError::FonteCaminhoShellVariableExpansion {
19030 nome: nome.to_string(),
19031 caminho: caminho.to_string(),
19032 byte,
19033 },
19034 ),
19035 (
19036 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
19037 DepError::FonteCaminhoShellHistoryExpansion {
19038 nome: nome.to_string(),
19039 caminho: caminho.to_string(),
19040 byte,
19041 },
19042 ),
19043 (
19044 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
19045 DepError::FonteCaminhoShellHistorySubstitution {
19046 nome: nome.to_string(),
19047 caminho: caminho.to_string(),
19048 byte,
19049 },
19050 ),
19051 ];
19052 for (via_ctor, via_struct_literal) in cases {
19053 assert_eq!(
19054 via_ctor, via_struct_literal,
19055 "fonte_caminho_byte_ctors!-generated ctor must route \
19056 (nome, caminho, byte) through `.to_string()` / byte-\
19057 identity in declared field order — a field-swap or \
19058 silent-conversion regression surfaces here rather than \
19059 at a downstream diagnostic-shape mismatch",
19060 );
19061 }
19062 }
19063
19064 #[test]
19065 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
19066 // Fail-before-pass-after byte-parity pin on the lifted
19067 // `impl AsRef<str> for DepList` — asserts the standard-
19068 // library trait impl and the substrate-primitive
19069 // [`super::DepList::as_str`] `pub const fn` accessor resolve
19070 // to the same `&str` per instance across the two-arm closed
19071 // set, so any future silent detour that routes the impl
19072 // through a divergent projection (a per-arm inline
19073 // `match self { DepList::Prod => ":deps", … }` re-inlining
19074 // that opens a compile-time link to the un-lifted arm-literal,
19075 // a swap onto a second projection axis) trips at caixa-core
19076 // test time under `PartialEq` rather than at a downstream
19077 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
19078 // every one of the two arms [`super::DepList::ALL`] carries
19079 // so no arm's projection is covered only by the sibling
19080 // `Display` path. Peer of the sibling
19081 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
19082 // (1723611) on the top-level dialect-classification closed-
19083 // set typed enum, and the peer
19084 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
19085 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
19086 // typed enum — the pins together close the substrate
19087 // primitive's `AsRef<str>` projection axis onto the seventh
19088 // (and last unlifted) closed-set typed enum on the caixa
19089 // surface.
19090 for &list in super::DepList::ALL {
19091 assert_eq!(
19092 <super::DepList as AsRef<str>>::as_ref(&list),
19093 list.as_str(),
19094 "AsRef<str> impl on DepList::{list:?} must byte-equal \
19095 DepList::as_str on the same instance — divergence \
19096 signals a silent detour off the substrate-primitive \
19097 accessor"
19098 );
19099 }
19100 }
19101
19102 #[test]
19103 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
19104 // Fail-before-pass-after byte-parity pin on the three-path
19105 // convergence discipline the [`super::DepList`] two-list
19106 // dep-graph closed-set typed enum now carries on the `&str`-
19107 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
19108 // newly lifted impl), `format!("{v}")` (the pre-existing
19109 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
19110 // primitive `pub const fn` accessor both trait impls delegate
19111 // through) must resolve to the same byte-string on every
19112 // instance across the two-arm closed set. Refuses any future
19113 // divergence between the two trait impls (a stray
19114 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
19115 // rather than delegating through the shared accessor; a
19116 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
19117 // literal cascade) that would silently split the two
19118 // projection paths of the same closed-set typed enum. Mirrors
19119 // the sibling three-path-convergence discipline the peer
19120 // [`crate::CaixaDialeto`] typed enum carries
19121 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
19122 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
19123 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
19124 // d8136db), the peer [`crate::CaixaKind`] triple
19125 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
19126 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
19127 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
19128 // 16d5c7e).
19129 for &list in super::DepList::ALL {
19130 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
19131 let via_display: String = format!("{list}");
19132 let via_accessor: &str = list.as_str();
19133 assert_eq!(via_as_ref, via_accessor);
19134 assert_eq!(via_display, via_accessor);
19135 assert_eq!(via_as_ref, via_display.as_str());
19136 }
19137 }
19138
19139 #[test]
19140 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
19141 // Fail-before-pass-after byte-parity pin on the newly lifted
19142 // `impl TryFrom<&str> for DepList` — asserts the standard-
19143 // library trait impl and the substrate-primitive
19144 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
19145 // to the same two-arm accept-set across every arm the
19146 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
19147 // the sibling
19148 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
19149 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
19150 // and the 12 other substrate-wide trait-idiomatic reverse-
19151 // projection routes-through pins — closes the campaign's
19152 // completeness gap on the two-list dep-graph closed-set enum.
19153 for &list in super::DepList::ALL {
19154 let wire = list.as_str();
19155 assert_eq!(
19156 <super::DepList as TryFrom<&str>>::try_from(wire),
19157 Ok(list),
19158 "TryFrom<&str> impl on DepList must round-trip \
19159 DepList::{list:?}.as_str() = {wire:?} back to \
19160 Ok(DepList::{list:?}) — divergence from \
19161 DepList::from_wire signals a silent detour off the \
19162 substrate-primitive accessor"
19163 );
19164 assert_eq!(
19165 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
19166 super::DepList::from_wire(wire),
19167 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
19168 DepList::from_wire on the same input"
19169 );
19170 }
19171 }
19172
19173 #[test]
19174 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
19175 // Rejection witness on the `impl TryFrom<&str> for DepList` —
19176 // sweeps candidate byte-strings outside the two-arm accept-set
19177 // the sibling [`super::DepList::as_str`] emits (`:deps` /
19178 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
19179 // future accidental widening of the trait impl's accept-set (a
19180 // stray case-fold path, a silent inclusion of a rebrand alias
19181 // like `":packages"`, an English rebrand `":dev-deps"` in
19182 // reverse arm-order that would silently swap the two arms) trips
19183 // at caixa-core test time. Peer of the sibling
19184 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
19185 // (5b828ed) rejection witness.
19186 let rejected: &[&str] = &[
19187 "",
19188 " ",
19189 "\t",
19190 "\n",
19191 ":deps ",
19192 " :deps",
19193 ":DEPS",
19194 ":Deps",
19195 ":Deps-Dev",
19196 ":deps_dev",
19197 ":deps-development",
19198 ":dev-deps",
19199 ":packages",
19200 ":packages-dev",
19201 "deps",
19202 "deps-dev",
19203 "Prod",
19204 "Dev",
19205 "prod",
19206 "dev",
19207 "\":deps\"",
19208 "\":deps-dev\"",
19209 ":deps\n",
19210 ":deps-dev\n",
19211 ];
19212 for &input in rejected {
19213 assert_eq!(
19214 <super::DepList as TryFrom<&str>>::try_from(input),
19215 Err(()),
19216 "TryFrom<&str> impl on DepList must reject unknown \
19217 byte-string {input:?} — divergence from \
19218 DepList::from_wire on the same input signals a silent \
19219 accept-set widening past the two lifted \
19220 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
19221 );
19222 assert_eq!(
19223 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
19224 super::DepList::from_wire(input),
19225 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
19226 DepList::from_wire on the same input — divergence signals \
19227 the two reverse-projection paths have drifted onto \
19228 different accept-sets"
19229 );
19230 }
19231 }
19232
19233 #[test]
19234 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
19235 // Fail-before-pass-after byte-parity pin on the newly lifted
19236 // `impl From<DepList> for &'static str` — asserts the standard-
19237 // library trait impl and the substrate-primitive
19238 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19239 // the same two-arm emit-set across every arm the exhaustive
19240 // [`super::DepList::ALL`] slice enumerates. Materializes the
19241 // `<&'static str as From<DepList>>::from` output in a
19242 // `const`-shape binding to make the `'static` lifetime promise
19243 // a build-time invariant — a future accidental downgrade of
19244 // either arm to a non-`&'static str` (a `String::leak()`-
19245 // produced return, a `Box::leak`-cast) trips at caixa-core
19246 // build time rather than at a downstream `'static`-bound
19247 // consumer. Peer of the sibling
19248 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
19249 // (523157d) and the 13 other substrate-wide forward-projection
19250 // routes-through pins.
19251 const PROD: &str = super::DepList::Prod.as_str();
19252 const DEV: &str = super::DepList::Dev.as_str();
19253 for &list in super::DepList::ALL {
19254 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
19255 let via_method: &'static str = list.as_str();
19256 assert_eq!(
19257 via_trait, via_method,
19258 "From<DepList> for &'static str impl must round-trip \
19259 DepList::{list:?} to the same lifted \
19260 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19261 DepList::as_str returns — divergence signals a silent \
19262 detour off the substrate-primitive accessor"
19263 );
19264 let via_into: &'static str = list.into();
19265 assert_eq!(
19266 via_into, via_method,
19267 "Into<&'static str>::into on DepList::{list:?} must \
19268 byte-equal DepList::as_str on the same input — the \
19269 blanket-derived Into shape must resolve to the same \
19270 as_str dispatch as the explicit From impl"
19271 );
19272 }
19273 assert_eq!(
19274 [PROD, DEV],
19275 [
19276 crate::render::DEP_AUTHOR_KEY_DEPS,
19277 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19278 ],
19279 "const-context DepList::as_str must resolve to the two lifted \
19280 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
19281 of either arm to a non-const or non-static byte-string breaks \
19282 the `&'static str`-lifetime promise the paired \
19283 From<DepList> for &'static str impl carries by construction"
19284 );
19285 }
19286
19287 #[test]
19288 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
19289 // Cross-axis partition pin: the paired trait-idiomatic
19290 // `From<DepList> for &'static str` forward projection and the
19291 // method-named [`super::DepList::as_str`] forward projection
19292 // must resolve identically on every arm, locking the two paths
19293 // together so any future detour trips at caixa-core test time.
19294 // Then a round-trip witness: every arm's forward `From` output
19295 // re-parses through the paired trait-idiomatic reverse
19296 // `TryFrom<&str>` back to the original variant, closing the
19297 // two-way `DepList ↔ &'static str` round-trip on the trait-
19298 // idiomatic axis pair, mirroring the pre-existing method-named
19299 // `as_str` + `from_wire` round-trip. Peer of the sibling
19300 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
19301 // (523157d).
19302 for &list in super::DepList::ALL {
19303 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
19304 let via_method: &'static str = list.as_str();
19305 assert_eq!(
19306 via_trait, via_method,
19307 "From<DepList> for &'static str and DepList::as_str must \
19308 resolve identically on DepList::{list:?} — divergence \
19309 signals the two forward-projection paths have drifted \
19310 onto different emit-sets"
19311 );
19312 }
19313 for &list in super::DepList::ALL {
19314 let emitted: &'static str = list.into();
19315 let re_parsed: Result<super::DepList, ()> =
19316 <super::DepList as TryFrom<&str>>::try_from(emitted);
19317 assert_eq!(
19318 re_parsed,
19319 Ok(list),
19320 "trait-idiomatic axis pair must round-trip \
19321 DepList::{list:?} through `.into::<&'static str>()` and \
19322 back through `TryFrom<&str>` — a break signals the \
19323 forward-emit and reverse-parse axes have drifted onto \
19324 different vocabularies"
19325 );
19326 }
19327 }
19328
19329 #[test]
19330 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
19331 // Fail-before-pass-after byte-parity pin on the newly lifted
19332 // `impl From<&DepList> for &'static str` — asserts the borrowed-
19333 // input standard-library trait impl and the substrate-primitive
19334 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19335 // the same two-arm emit-set across every arm the exhaustive
19336 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
19337 // does not auto-derive the borrowed-input sibling from a paired
19338 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
19339 // U: From<T>` blanket in `core`), so the borrowed-input axis is
19340 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
19341 // shape over [`super::DepList::ALL`] (whose iterator yields
19342 // `&DepList`, not `DepList`) reaches through this impl and no
19343 // other — the paired owned-input [`From<DepList>`] impl requires
19344 // an explicit `.copied()` / dereference before the trait fires.
19345 // Materializes the `<&'static str as From<&DepList>>::from`
19346 // output in a `const`-shape binding to make the `'static`
19347 // lifetime promise a build-time invariant.
19348 const PROD: &str = super::DepList::Prod.as_str();
19349 const DEV: &str = super::DepList::Dev.as_str();
19350 for list in super::DepList::ALL {
19351 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
19352 let via_method: &'static str = list.as_str();
19353 assert_eq!(
19354 via_trait, via_method,
19355 "From<&DepList> for &'static str impl must round-trip \
19356 &DepList::{list:?} to the same lifted \
19357 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19358 DepList::as_str returns — divergence signals a silent \
19359 detour off the substrate-primitive accessor"
19360 );
19361 let via_into: &'static str = list.into();
19362 assert_eq!(
19363 via_into, via_method,
19364 "Into<&'static str>::into on &DepList::{list:?} must \
19365 byte-equal DepList::as_str on the same input — the \
19366 blanket-derived Into shape must resolve to the same \
19367 as_str dispatch as the explicit From impl"
19368 );
19369 }
19370 assert_eq!(
19371 [PROD, DEV],
19372 [
19373 crate::render::DEP_AUTHOR_KEY_DEPS,
19374 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19375 ],
19376 "const-context DepList::as_str must resolve to the two lifted \
19377 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
19378 From<&DepList> for &'static str impl inherits its `'static` \
19379 lifetime promise from the same accessor the owned-input \
19380 sibling routes through"
19381 );
19382 }
19383
19384 #[test]
19385 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
19386 // Cross-axis partition pin: the paired trait-idiomatic
19387 // owned-input `From<DepList> for &'static str` (523157d
19388 // campaign-shape) and borrowed-input `From<&DepList> for
19389 // &'static str` (this lift) forward projections must resolve
19390 // identically on every arm, locking the two input-shape paths
19391 // together so any future detour trips at caixa-core test time.
19392 // Then a witness that a `.iter().map(Into::into)` pipe over
19393 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
19394 // materializes the two-arm accept-set through the borrowed-
19395 // input axis alone — the exact shape a future M4 admission-
19396 // webhook rejection body composer, a future substrate-wide
19397 // per-arm diagnostic column, or a
19398 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
19399 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
19400 // through — closing the two-way owned/borrowed input-shape
19401 // symmetry on the forward-projection trait-idiomatic axis.
19402 for &list in super::DepList::ALL {
19403 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
19404 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
19405 assert_eq!(
19406 owned, borrowed,
19407 "From<DepList> and From<&DepList> for &'static str must \
19408 resolve identically on DepList::{list:?} — divergence \
19409 signals the owned-input and borrowed-input forward-\
19410 projection paths have drifted onto different emit-sets"
19411 );
19412 }
19413 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
19414 let via_method: Vec<&'static str> =
19415 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19416 assert_eq!(
19417 via_iter, via_method,
19418 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
19419 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
19420 input `From<&DepList> for &'static str` axis is what makes \
19421 the `.iter().map(Into::into)` shape route through the \
19422 substrate-primitive `DepList::as_str` accessor rather than \
19423 through a per-call-site `.copied()` / dereference detour"
19424 );
19425 }
19426
19427 #[test]
19428 fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
19429 // Fail-before-pass-after byte-parity pin on the newly lifted
19430 // `impl From<DepList> for String` — asserts the owned-`String`
19431 // -returning standard-library trait impl and the substrate-
19432 // primitive [`super::DepList::as_str`] `pub const fn` accessor
19433 // resolve to the same two-arm emit-set across every arm the
19434 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19435 // standard library does not carry a blanket
19436 // `impl<T: AsRef<str>> From<T> for String` (nor an
19437 // `impl<T: fmt::Display> From<T> for String`), so the
19438 // owned-`String` forward-projection axis is a distinct trait-
19439 // idiomatic surface that a `let key: String = list.into();`-
19440 // shaped call site reaches through this impl and no other — the
19441 // paired sibling `From<DepList> for &'static str` impl forces
19442 // every owned-`String` call site through an explicit
19443 // `.to_owned()` / `String::from` restatement. Peer of the
19444 // first-mover
19445 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
19446 // (7baa18a), the second-peer
19447 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
19448 // (7851725), the third-peer
19449 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
19450 // (231a18c), and the fourth-peer
19451 // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
19452 // (88942cd) — extends the trait-idiomatic owned-`String`
19453 // forward-projection axis onto the fifth closed-set fieldless
19454 // typed enum on the caixa surface (the two-list dep-graph axis).
19455 for &variant in super::DepList::ALL {
19456 let via_trait: String = <String as From<super::DepList>>::from(variant);
19457 let via_method: &'static str = variant.as_str();
19458 assert_eq!(
19459 via_trait.as_str(),
19460 via_method,
19461 "From<DepList> for String impl must round-trip \
19462 DepList::{variant:?} to the same lifted \
19463 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19464 DepList::as_str returns — divergence signals a silent \
19465 detour off the substrate-primitive accessor"
19466 );
19467 let via_into: String = variant.into();
19468 assert_eq!(
19469 via_into.as_str(),
19470 via_method,
19471 "Into<String>::into on DepList::{variant:?} must \
19472 byte-equal DepList::as_str on the same input — the \
19473 blanket-derived Into shape must resolve to the same \
19474 as_str dispatch as the explicit From impl"
19475 );
19476 }
19477 }
19478
19479 #[test]
19480 fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
19481 // Cross-axis partition pin: the paired trait-idiomatic
19482 // owned-`String` `From<DepList> for String` (this lift) and
19483 // owned-`&'static str` `From<DepList> for &'static str`
19484 // (523157d campaign-shape) forward projections must resolve
19485 // identically on every arm, locking the two return-type-shape
19486 // paths together so any future detour trips at caixa-core test
19487 // time. Also byte-parity witness against the sibling
19488 // [`ToString::to_string`] surface routed through
19489 // [`std::fmt::Display`] — the three owned-heap-string paths
19490 // (`.into::<String>()`, `String::from`, `.to_string()`) must
19491 // resolve identically on every arm so a future consumer that
19492 // picks any of the three lands on the same two-arm lifted
19493 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19494 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
19495 // Then a `.iter().copied().map(String::from)` pipe witness
19496 // over [`super::DepList::ALL`] that materializes the two-arm
19497 // accept-set through the owned-`String` axis alone — the exact
19498 // shape a future M4 admission-webhook rejection body composer
19499 // or a
19500 // `HashMap::<String, DepList>::from_iter(
19501 // DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
19502 // style owned-key per-list lookup reaches through — closing the
19503 // owned-`String` forward-projection axis's iterator-pipe shape.
19504 // Then a direct round-trip witness through the paired
19505 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
19506 // owned-`String`'s [`String::as_str`] borrow that closes the
19507 // two-way `Self → String → Self` round-trip on the trait-
19508 // idiomatic owned-`String` forward + reverse axis pair.
19509 //
19510 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19511 // `From` emit lands on the lowercase Portuguese `as_str`
19512 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19513 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19514 // forcing the round-trip through an intermediate
19515 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19516 // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
19517 // parse resolve through the same lifted
19518 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19519 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19520 // construction (there is no wire/diagnostic axis split on this
19521 // enum), so the owned-`String` forward axis and the reverse
19522 // axis compose directly — matching the peer
19523 // [`crate::supervisor::RestartStrategy`] /
19524 // [`crate::supervisor::RestartPolicy`] /
19525 // [`crate::CaixaDialeto`] owned-`String` axis pairs.
19526 for &list in super::DepList::ALL {
19527 let owned_string: String = <String as From<super::DepList>>::from(list);
19528 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19529 assert_eq!(
19530 owned_string.as_str(),
19531 owned_static,
19532 "From<DepList> for String and From<DepList> for \
19533 &'static str must resolve identically on \
19534 DepList::{list:?} — divergence signals the owned-\
19535 `String` and owned-`&'static str` forward-projection \
19536 return-type-shape paths have drifted onto different \
19537 emit-sets"
19538 );
19539 let via_to_string: String = list.to_string();
19540 assert_eq!(
19541 owned_string, via_to_string,
19542 "From<DepList> for String must byte-equal \
19543 DepList::to_string on DepList::{list:?} — divergence \
19544 signals the trait-idiomatic owned-`String` forward-\
19545 projection axis and the ToString-through-Display axis \
19546 have drifted onto different emit-sets"
19547 );
19548 }
19549 let via_iter: Vec<String> = super::DepList::ALL
19550 .iter()
19551 .copied()
19552 .map(String::from)
19553 .collect();
19554 let via_method: Vec<String> = super::DepList::ALL
19555 .iter()
19556 .map(|l| l.as_str().to_owned())
19557 .collect();
19558 assert_eq!(
19559 via_iter, via_method,
19560 "`.iter().copied().map(String::from)` over DepList::ALL must \
19561 byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
19562 every arm — the owned-`String` `From<DepList> for String` \
19563 axis is what makes the `String::from` composition route \
19564 through the substrate-primitive `DepList::as_str` accessor \
19565 rather than through a per-call-site `.to_owned()` / \
19566 `String::from(list.as_str())` detour"
19567 );
19568 for &variant in super::DepList::ALL {
19569 let emitted: String = variant.into();
19570 let re_parsed: Result<super::DepList, ()> =
19571 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19572 assert_eq!(
19573 re_parsed,
19574 Ok(variant),
19575 "trait-idiomatic owned-`String` forward-projection + \
19576 reverse-projection axis pair must round-trip \
19577 DepList::{variant:?} through `.into::<String>()` and \
19578 back through `TryFrom<&str>` on the owned-`String`'s \
19579 String::as_str borrow — a break signals the owned-\
19580 `String` forward-emit and reverse-parse axes have \
19581 drifted onto different vocabularies (unlike the peer \
19582 CaixaKind axis pair, DepList's forward emit and \
19583 reverse parse share the same lifted \
19584 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
19585 round-trip composes directly)"
19586 );
19587 }
19588 }
19589
19590 #[test]
19591 fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
19592 // Fail-before-pass-after byte-parity pin on the newly lifted
19593 // `impl From<&DepList> for String` — asserts the borrowed-input
19594 // owned-`String`-returning standard-library trait impl and the
19595 // substrate-primitive [`super::DepList::as_str`] `pub const fn`
19596 // accessor resolve to the same two-arm emit-set across every
19597 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
19598 // Rust's standard library does not carry a blanket
19599 // `impl<T: AsRef<str>> From<&T> for String` (nor an
19600 // `impl<T: fmt::Display> From<&T> for String`), so the
19601 // borrowed-input owned-`String` forward-projection axis is a
19602 // distinct trait-idiomatic surface that a
19603 // `let key: String = (&list).into();`-shaped call site reaches
19604 // through this impl and no other — the paired sibling
19605 // `From<DepList> for String` impl forces every borrowed-input
19606 // call site through an explicit `Copy` deref
19607 // (`String::from(*list)`) or an `.as_str().to_owned()` /
19608 // `.to_string()` detour. Peer of the first-mover
19609 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19610 // (579385f) and the second-peer
19611 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19612 // (8465740) — extends the trait-idiomatic borrowed-input owned-
19613 // `String` forward-projection axis off the M2 OTP-shape sibling
19614 // axis pair onto the first non-M2 closed-set fieldless typed
19615 // enum peer (the two-list dep-graph axis).
19616 for &variant in super::DepList::ALL {
19617 let via_trait: String = <String as From<&super::DepList>>::from(&variant);
19618 let via_method: &'static str = variant.as_str();
19619 assert_eq!(
19620 via_trait.as_str(),
19621 via_method,
19622 "From<&DepList> for String impl must round-trip \
19623 &DepList::{variant:?} to the same lifted \
19624 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19625 DepList::as_str returns — divergence signals a silent \
19626 detour off the substrate-primitive accessor"
19627 );
19628 let via_into: String = (&variant).into();
19629 assert_eq!(
19630 via_into.as_str(),
19631 via_method,
19632 "Into<String>::into on &DepList::{variant:?} must \
19633 byte-equal DepList::as_str on the same input — the \
19634 blanket-derived Into shape must resolve to the same \
19635 as_str dispatch as the explicit From impl"
19636 );
19637 }
19638 }
19639
19640 #[test]
19641 fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
19642 // Cross-axis partition pin: the newly lifted trait-idiomatic
19643 // borrowed-input owned-`String` `From<&DepList> for String`
19644 // (this lift), the paired owned-input owned-`String`
19645 // `From<DepList> for String` (32b0ee8), the paired borrowed-
19646 // input owned-`&'static str` `From<&DepList> for &'static str`
19647 // (64aa742), and the paired owned-input owned-`&'static str`
19648 // `From<DepList> for &'static str` (3455cbf) — every corner of
19649 // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
19650 // idiomatic projection family — must resolve identically on
19651 // every arm, locking the four return-shape × input-shape paths
19652 // together so any future detour trips at caixa-core test time.
19653 // Also byte-parity witness against the sibling
19654 // [`ToString::to_string`] surface routed through
19655 // [`std::fmt::Display`] and a direct round-trip witness through
19656 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
19657 // the owned-`String`'s [`String::as_str`] borrow that closes
19658 // the two-way `&Self → String → Self` round-trip on the trait-
19659 // idiomatic borrowed-input owned-`String` forward + reverse
19660 // axis pair. Peer of the first-mover
19661 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19662 // (579385f) and the second-peer
19663 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19664 // (8465740) — closes the whole `{Self, &Self} × {&'static str,
19665 // String}` 2×2 projection corner on the third substrate-wide
19666 // closed-set fieldless typed enum peer (the two-list dep-graph
19667 // axis, first outside the M2 OTP-shape sibling pair).
19668 //
19669 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19670 // `From` emit lands on the lowercase Portuguese `as_str`
19671 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19672 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19673 // forcing the round-trip through an intermediate
19674 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19675 // [`super::DepList::as_str`] emit and
19676 // [`super::DepList::from_wire`] parse resolve through the same
19677 // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19678 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19679 // construction (there is no wire/diagnostic axis split on this
19680 // enum), so the borrowed-input owned-`String` forward axis and
19681 // the reverse axis compose directly — matching the peer
19682 // [`crate::supervisor::RestartStrategy`] /
19683 // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
19684 // `String` axis pairs.
19685 for &list in super::DepList::ALL {
19686 let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
19687 let owned_string: String = <String as From<super::DepList>>::from(list);
19688 let borrowed_static: &'static str =
19689 <&'static str as From<&super::DepList>>::from(&list);
19690 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19691 assert_eq!(
19692 borrowed_string, owned_string,
19693 "From<&DepList> for String and From<DepList> for String \
19694 must resolve identically on DepList::{list:?} — \
19695 divergence signals the borrowed-input and owned-input \
19696 owned-`String` forward-projection input-shape paths \
19697 have drifted onto different emit-sets"
19698 );
19699 assert_eq!(
19700 borrowed_string.as_str(),
19701 borrowed_static,
19702 "From<&DepList> for String and From<&DepList> for \
19703 &'static str must resolve identically on \
19704 DepList::{list:?} — divergence signals the borrowed-\
19705 input `&'static str` and owned-`String` return-shape \
19706 paths have drifted onto different emit-sets"
19707 );
19708 assert_eq!(
19709 borrowed_string.as_str(),
19710 owned_static,
19711 "From<&DepList> for String and From<DepList> for \
19712 &'static str must resolve identically on \
19713 DepList::{list:?} — divergence signals a break in the \
19714 diagonal corner of the {{Self, &Self}} × {{&'static \
19715 str, String}} 2×2 trait-idiomatic projection family"
19716 );
19717 let via_to_string: String = list.to_string();
19718 assert_eq!(
19719 borrowed_string, via_to_string,
19720 "From<&DepList> for String must byte-equal \
19721 DepList::to_string on DepList::{list:?} — divergence \
19722 signals the trait-idiomatic borrowed-input owned-\
19723 `String` forward-projection axis and the ToString-\
19724 through-Display axis have drifted onto different \
19725 emit-sets"
19726 );
19727 }
19728 let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
19729 let via_method: Vec<String> = super::DepList::ALL
19730 .iter()
19731 .map(|l| l.as_str().to_owned())
19732 .collect();
19733 assert_eq!(
19734 via_iter, via_method,
19735 "`.iter().map(String::from)` over DepList::ALL — a call \
19736 site whose iteration axis holds `&DepList` by construction \
19737 — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
19738 on every arm — the borrowed-input owned-`String` \
19739 `From<&DepList> for String` axis is what makes the \
19740 `String::from` composition route through the substrate-\
19741 primitive `DepList::as_str` accessor without a spurious \
19742 `Copy` deref (which would only be reachable through the \
19743 owned-input `From<DepList> for String` axis by first \
19744 calling `.copied()` on the iterator)"
19745 );
19746 for &variant in super::DepList::ALL {
19747 let emitted: String = (&variant).into();
19748 let re_parsed: Result<super::DepList, ()> =
19749 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19750 assert_eq!(
19751 re_parsed,
19752 Ok(variant),
19753 "trait-idiomatic borrowed-input owned-`String` \
19754 forward-projection + reverse-projection axis pair must \
19755 round-trip &DepList::{variant:?} through \
19756 `.into::<String>()` on the borrowed-input surface and \
19757 back through `TryFrom<&str>` on the owned-`String`'s \
19758 String::as_str borrow — a break signals the \
19759 borrowed-input owned-`String` forward-emit and \
19760 reverse-parse axes have drifted onto different \
19761 vocabularies (unlike the peer CaixaKind axis pair, \
19762 DepList's forward emit and reverse parse share the \
19763 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
19764 construction, so the round-trip composes directly)"
19765 );
19766 }
19767 }
19768
19769 #[test]
19770 fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
19771 // Fail-before-pass-after byte-parity pin on the newly lifted
19772 // `impl From<DepList> for std::borrow::Cow<'static, str>` —
19773 // asserts the standard-library trait impl and the substrate-
19774 // primitive [`super::DepList::as_str`] `pub const fn`
19775 // accessor resolve to the same two-arm emit-set across every
19776 // arm the exhaustive [`super::DepList::ALL`] slice
19777 // enumerates. Rust's standard library does not carry a
19778 // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19779 // (nor an `impl<T: fmt::Display> From<T> for
19780 // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19781 // projection axis is a distinct trait-idiomatic surface that
19782 // a `let key: Cow<'static, str> = list.into();`-shaped call
19783 // site reaches through this impl and no other — the paired
19784 // sibling `From<DepList> for &'static str` and
19785 // `From<DepList> for String` impls force every
19786 // `Cow<'static, str>`-parameterized call site through a
19787 // `Cow::Borrowed(list.as_str())` /
19788 // `Cow::Owned(list.to_string())` composition whose type
19789 // bounds have no compile-time link back to the substrate
19790 // primitive.
19791 //
19792 // Also asserts the projection lands on the zero-alloc
19793 // [`std::borrow::Cow::Borrowed`] arm (not the
19794 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19795 // [`super::DepList::as_str`] accessor's `&'static str`
19796 // return lifetime by construction (each match arm resolves
19797 // to one of the two lifted
19798 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19799 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19800 // &str` values) makes the borrowed arm the type-correct
19801 // projection with no runtime allocation. Any future silent
19802 // detour that routes the impl through the owned arm trips
19803 // at caixa-core test time under the
19804 // [`std::borrow::Cow::Borrowed`] discriminator witness
19805 // rather than at a downstream `Cow<'static, str>`-bound
19806 // consumer's silent allocation.
19807 //
19808 // First-mover on the outside-M3 substrate-wide tier of the
19809 // substrate-wide trait-idiomatic
19810 // [`std::borrow::Cow<'static, str>`] forward-projection
19811 // campaign — extends the axis off the paired
19812 // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19813 // the paired M2 OTP-shape
19814 // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19815 // and [`crate::supervisor::RestartPolicy`] (0612398 +
19816 // ee577fd), and the paired M3-mesh-shape
19817 // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19818 // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19819 // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19820 // peers onto the first outside-M3 caixa-core peer (the two-
19821 // list dep-graph axis), opening the outside-M3 caixa-core
19822 // tier of the substrate-wide Cow<'static, str> forward-
19823 // projection campaign's owned-input corner.
19824 for &variant in super::DepList::ALL {
19825 let via_trait: std::borrow::Cow<'static, str> =
19826 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19827 let via_method: &'static str = variant.as_str();
19828 assert_eq!(
19829 via_trait.as_ref(),
19830 via_method,
19831 "From<DepList> for Cow<'static, str> impl must \
19832 round-trip DepList::{variant:?} to the same lifted \
19833 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19834 DepList::as_str returns — divergence signals a \
19835 silent detour off the substrate-primitive accessor"
19836 );
19837 assert!(
19838 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19839 "From<DepList> for Cow<'static, str> impl must land \
19840 on the zero-alloc Cow::Borrowed arm on \
19841 DepList::{variant:?} — a Cow::Owned outcome signals \
19842 the projection has silently allocated where the \
19843 substrate-primitive DepList::as_str `&'static str` \
19844 return makes the borrowed arm the type-correct \
19845 projection"
19846 );
19847 let via_into: std::borrow::Cow<'static, str> = variant.into();
19848 assert_eq!(
19849 via_into.as_ref(),
19850 via_method,
19851 "Into<Cow<'static, str>>::into on DepList::\
19852 {variant:?} must byte-equal DepList::as_str on the \
19853 same input — the blanket-derived Into shape must \
19854 resolve to the same as_str dispatch as the explicit \
19855 From impl"
19856 );
19857 assert!(
19858 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19859 "Into<Cow<'static, str>>::into on DepList::\
19860 {variant:?} must land on the zero-alloc \
19861 Cow::Borrowed arm — the blanket-derived Into shape \
19862 must resolve to the same Cow::Borrowed dispatch as \
19863 the explicit From impl"
19864 );
19865 }
19866 }
19867
19868 #[test]
19869 fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19870 // Cross-axis partition pin: the newly lifted trait-idiomatic
19871 // `From<DepList> for std::borrow::Cow<'static, str>` (this
19872 // lift), the paired owned-input `From<DepList> for
19873 // &'static str` (3455cbf), and the paired owned-input
19874 // `From<DepList> for String` (32b0ee8) forward projections
19875 // must resolve identically on every arm, locking the three
19876 // return-shape paths together by construction so any future
19877 // detour trips at caixa-core test time. Also byte-parity
19878 // witness against the sibling [`ToString::to_string`]
19879 // surface routed through [`std::fmt::Display`] — every
19880 // owned-heap-string path (the `Cow::Owned` promotion of
19881 // this axis's `.into_owned()`, `From<DepList> for String`,
19882 // and `.to_string()`) resolves to the same two-arm lifted
19883 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19884 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19885 // arm.
19886 //
19887 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19888 // witness over [`super::DepList::ALL`] that materializes the
19889 // two-arm accept-set through the
19890 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19891 // shape a future M4 admission-webhook rejection body's
19892 // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19893 // future substrate-wide per-arm diagnostic surface whose
19894 // typing rules out the sibling [`AsRef<str>`] borrowed
19895 // return, or a future per-arm dep-list emitter that binds
19896 // through a [`std::borrow::Cow<'static, str>`] boundary
19897 // reaches through — opening the composable-projection axis
19898 // on the first outside-M3 caixa-core closed-set fieldless
19899 // typed enum peer on the caixa surface. The pipe witness
19900 // also pins the zero-alloc discipline: every element in the
19901 // collected vector satisfies the
19902 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19903 // accidental silent-allocation regression on the pipe's
19904 // iteration axis is a caixa-core-test-time failure.
19905 for &variant in super::DepList::ALL {
19906 let via_cow: std::borrow::Cow<'static, str> =
19907 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19908 let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19909 let via_string: String = <String as From<super::DepList>>::from(variant);
19910 assert_eq!(
19911 via_cow.as_ref(),
19912 via_static,
19913 "From<DepList> for Cow<'static, str> and \
19914 From<DepList> for &'static str must resolve \
19915 identically on DepList::{variant:?} — divergence \
19916 signals the Cow<'static, str> and &'static str \
19917 return-shape paths have drifted onto different \
19918 emit-sets"
19919 );
19920 assert_eq!(
19921 via_cow.as_ref(),
19922 via_string.as_str(),
19923 "From<DepList> for Cow<'static, str> and \
19924 From<DepList> for String must resolve identically \
19925 on DepList::{variant:?} — divergence signals the \
19926 Cow<'static, str> and String return-shape paths \
19927 have drifted onto different emit-sets"
19928 );
19929 let via_to_string: String = variant.to_string();
19930 assert_eq!(
19931 via_cow.as_ref(),
19932 via_to_string.as_str(),
19933 "From<DepList> for Cow<'static, str> must byte-equal \
19934 DepList::to_string on DepList::{variant:?} — \
19935 divergence signals the trait-idiomatic \
19936 Cow<'static, str> forward-projection axis and the \
19937 ToString-through-Display axis have drifted onto \
19938 different emit-sets"
19939 );
19940 }
19941 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19942 .iter()
19943 .copied()
19944 .map(std::borrow::Cow::from)
19945 .collect();
19946 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19947 .iter()
19948 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19949 .collect();
19950 assert_eq!(
19951 via_iter, via_method,
19952 "`.iter().copied().map(Cow::from)` over DepList::ALL \
19953 must byte-equal `.iter().map(|l| \
19954 Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19955 idiomatic `From<DepList> for Cow<'static, str>` axis is \
19956 what makes the `Cow::from` composition route through \
19957 the substrate-primitive `DepList::as_str` accessor with \
19958 the zero-alloc Cow::Borrowed arm by construction, \
19959 rather than a per-call-site `Cow::Owned(list.to_string())` \
19960 allocation"
19961 );
19962 for cow in &via_iter {
19963 assert!(
19964 matches!(cow, std::borrow::Cow::Borrowed(_)),
19965 "every element of the .iter().copied().map(Cow::from) \
19966 pipe over DepList::ALL must land on the zero-alloc \
19967 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19968 signals the pipe's iteration axis has silently \
19969 allocated where the substrate-primitive \
19970 DepList::as_str `&'static str` return makes the \
19971 borrowed arm the type-correct projection"
19972 );
19973 }
19974 }
19975
19976 #[test]
19977 fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19978 // Fail-before-pass-after byte-parity pin on the newly lifted
19979 // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19980 // asserts the borrowed-input standard-library trait impl and
19981 // the substrate-primitive [`super::DepList::as_str`] `pub const
19982 // fn` accessor resolve to the same two-arm emit-set across
19983 // every arm the exhaustive [`super::DepList::ALL`] slice
19984 // enumerates. Rust's standard library does not carry a blanket
19985 // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19986 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19987 // the borrowed-input `Cow<'static, str>` forward-projection
19988 // axis is a distinct trait-idiomatic surface that a
19989 // `let key: Cow<'static, str> = (&list).into();`-shaped call
19990 // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19991 // reaches through this impl and no other — the paired owned-
19992 // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19993 // forces every borrowed-input call site through an explicit
19994 // `Copy` deref (`Cow::from(*list)`) or a
19995 // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19996 // have no compile-time link back to the substrate primitive.
19997 //
19998 // Also asserts the projection lands on the zero-alloc
19999 // [`std::borrow::Cow::Borrowed`] arm (not the
20000 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
20001 // [`super::DepList::as_str`] accessor's `&'static str` return
20002 // lifetime by construction (each match arm resolves to one of
20003 // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20004 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20005 // values) makes the borrowed arm the type-correct projection
20006 // with no runtime allocation on the borrowed-input surface
20007 // just as on the paired owned-input surface.
20008 //
20009 // Closes the `{Self, &Self}` input-shape corner on the outside-
20010 // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
20011 // on the first outside-M3 caixa-core closed-set fieldless typed
20012 // enum peer on the caixa surface, exactly as afdf0f4 closed it
20013 // on the second M3-mesh-primitive peer
20014 // ([`crate::aplicacao::PlacementStrategy`]) one commit after
20015 // the owning half (eee504d) landed, as 25690ef closed it on
20016 // the first M3-mesh-primitive peer
20017 // ([`crate::aplicacao::WitShape`]) one commit after the owning
20018 // half (8634dec) landed, as d45c409 closed it on the top-level
20019 // [`crate::CaixaKind`] one commit after the owning half
20020 // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
20021 // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
20022 // [`crate::supervisor::RestartPolicy`] sibling peers one
20023 // commit after (7dd28b3 / 0612398) landed.
20024 for &variant in super::DepList::ALL {
20025 let via_trait: std::borrow::Cow<'static, str> =
20026 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20027 let via_method: &'static str = variant.as_str();
20028 assert_eq!(
20029 via_trait.as_ref(),
20030 via_method,
20031 "From<&DepList> for Cow<'static, str> impl must \
20032 round-trip &DepList::{variant:?} to the same lifted \
20033 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20034 DepList::as_str returns — divergence signals a silent \
20035 detour off the substrate-primitive accessor"
20036 );
20037 assert!(
20038 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
20039 "From<&DepList> for Cow<'static, str> impl must land \
20040 on the zero-alloc Cow::Borrowed arm on \
20041 &DepList::{variant:?} — a Cow::Owned outcome signals \
20042 the projection has silently allocated where the \
20043 substrate-primitive DepList::as_str `&'static str` \
20044 return makes the borrowed arm the type-correct \
20045 projection"
20046 );
20047 let via_into: std::borrow::Cow<'static, str> = (&variant).into();
20048 assert_eq!(
20049 via_into.as_ref(),
20050 via_method,
20051 "Into<Cow<'static, str>>::into on &DepList::\
20052 {variant:?} must byte-equal DepList::as_str on the \
20053 same input — the blanket-derived Into shape must \
20054 resolve to the same as_str dispatch as the explicit \
20055 From impl"
20056 );
20057 assert!(
20058 matches!(via_into, std::borrow::Cow::Borrowed(_)),
20059 "Into<Cow<'static, str>>::into on &DepList::\
20060 {variant:?} must land on the zero-alloc \
20061 Cow::Borrowed arm — the blanket-derived Into shape \
20062 must resolve to the same Cow::Borrowed dispatch as \
20063 the explicit From impl"
20064 );
20065 }
20066 }
20067
20068 #[test]
20069 fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
20070 // Cross-axis partition pin: the newly lifted trait-idiomatic
20071 // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
20072 // str>` (this lift), the paired owned-input `From<DepList> for
20073 // std::borrow::Cow<'static, str>` (6858bac), the paired
20074 // borrowed-input owned-`&'static str` `From<&DepList> for
20075 // &'static str` (3455cbf), and the paired borrowed-input
20076 // owned-`String` `From<&DepList> for String` must resolve
20077 // identically on every arm, locking the four return-shape ×
20078 // input-shape paths together by construction so any future
20079 // detour trips at caixa-core test time. Also byte-parity
20080 // witness against the sibling [`ToString::to_string`] surface
20081 // routed through [`std::fmt::Display`] — every owned-heap-
20082 // string path (this axis's `.into_owned()` promotion, the
20083 // paired [`From<&DepList> for String`], and `.to_string()`)
20084 // resolves to the same two-arm lifted
20085 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20086 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
20087 // arm.
20088 //
20089 // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
20090 // over [`super::DepList::ALL`] — whose iterator yields
20091 // `&DepList` by construction, so the borrowed-input
20092 // [`Cow<'static, str>`] axis is what routes the pipe through
20093 // the substrate-primitive [`super::DepList::as_str`] accessor
20094 // without a spurious [`Copy`] deref (which would only be
20095 // reachable through the owned-input [`From<DepList> for
20096 // Cow<'static, str>`] axis by first calling `.copied()` on the
20097 // iterator). The pipe witness also pins the zero-alloc
20098 // discipline: every element in the collected vector satisfies
20099 // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
20100 // future accidental silent-allocation regression on the pipe's
20101 // iteration axis is a caixa-core-test-time failure. Peer of
20102 // the sibling
20103 // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
20104 // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
20105 // axis — extends the whole borrowed-input `Cow<'static, str>`
20106 // + paired `{&'static str, String}` cross-axis-parity corner
20107 // onto the first outside-M3 caixa-core closed-set fieldless
20108 // typed enum peer on the caixa surface.
20109 for &variant in super::DepList::ALL {
20110 let borrowed_cow: std::borrow::Cow<'static, str> =
20111 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20112 let owned_cow: std::borrow::Cow<'static, str> =
20113 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20114 let borrowed_static: &'static str =
20115 <&'static str as From<&super::DepList>>::from(&variant);
20116 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20117 assert_eq!(
20118 borrowed_cow, owned_cow,
20119 "From<&DepList> for Cow<'static, str> and \
20120 From<DepList> for Cow<'static, str> must resolve \
20121 identically on DepList::{variant:?} — divergence \
20122 signals the borrowed-input and owned-input \
20123 Cow<'static, str> forward-projection input-shape \
20124 paths have drifted onto different emit-sets"
20125 );
20126 assert_eq!(
20127 borrowed_cow.as_ref(),
20128 borrowed_static,
20129 "From<&DepList> for Cow<'static, str> and \
20130 From<&DepList> for &'static str must resolve \
20131 identically on DepList::{variant:?} — divergence \
20132 signals the borrowed-input Cow<'static, str> and \
20133 &'static str return-shape paths have drifted onto \
20134 different emit-sets"
20135 );
20136 assert_eq!(
20137 borrowed_cow.as_ref(),
20138 borrowed_string.as_str(),
20139 "From<&DepList> for Cow<'static, str> and \
20140 From<&DepList> for String must resolve identically \
20141 on DepList::{variant:?} — divergence signals the \
20142 borrowed-input Cow<'static, str> and owned-`String` \
20143 return-shape paths have drifted onto different \
20144 emit-sets"
20145 );
20146 let via_to_string: String = variant.to_string();
20147 assert_eq!(
20148 borrowed_cow.as_ref(),
20149 via_to_string.as_str(),
20150 "From<&DepList> for Cow<'static, str> must byte-equal \
20151 DepList::to_string on DepList::{variant:?} — \
20152 divergence signals the trait-idiomatic borrowed-input \
20153 Cow<'static, str> forward-projection axis and the \
20154 ToString-through-Display axis have drifted onto \
20155 different emit-sets"
20156 );
20157 }
20158 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
20159 .iter()
20160 .map(std::borrow::Cow::from)
20161 .collect();
20162 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
20163 .iter()
20164 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
20165 .collect();
20166 assert_eq!(
20167 via_iter, via_method,
20168 "`.iter().map(Cow::from)` over DepList::ALL — a call site \
20169 whose iteration axis holds &DepList by construction — \
20170 must byte-equal `.iter().map(|l| \
20171 Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
20172 input Cow<'static, str> `From<&DepList> for Cow<'static, \
20173 str>` axis is what makes the `Cow::from` composition \
20174 route through the substrate-primitive `DepList::as_str` \
20175 accessor with the zero-alloc Cow::Borrowed arm by \
20176 construction and without a spurious `Copy` deref (which \
20177 would only be reachable through the owned-input \
20178 `From<DepList> for Cow<'static, str>` axis by first \
20179 calling `.copied()` on the iterator)"
20180 );
20181 for cow in &via_iter {
20182 assert!(
20183 matches!(cow, std::borrow::Cow::Borrowed(_)),
20184 "every element of the .iter().map(Cow::from) pipe \
20185 over DepList::ALL must land on the zero-alloc \
20186 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
20187 signals the pipe's iteration axis has silently \
20188 allocated where the substrate-primitive \
20189 DepList::as_str `&'static str` return makes the \
20190 borrowed arm the type-correct projection"
20191 );
20192 }
20193 }
20194
20195 #[test]
20196 fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
20197 // Fail-before-pass-after byte-parity pin on the newly lifted
20198 // `impl From<DepList> for Box<str>` — asserts the owned-input
20199 // standard-library trait impl and the substrate-primitive
20200 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
20201 // the same two-arm emit-set (the paired
20202 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20203 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20204 // byte-strings) across every arm the exhaustive
20205 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20206 // core-internal tier of the substrate-wide [`Box<str>`] forward-
20207 // projection campaign onto the second caixa-core-internal peer,
20208 // after the render-side path-shape-diagnostic
20209 // [`super::super::render::PathShapeViolation`] pair (0d87a72,
20210 // both corners in one axis) opened the tier. Rust's standard
20211 // library carries `impl From<&str> for Box<str>` and
20212 // `impl From<String> for Box<str>` but no blanket
20213 // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
20214 // distinct trait-idiomatic surface that a
20215 // `let key: Box<str> = list.into();`-shaped call site reaches
20216 // through this impl and no other — a paired
20217 // `Box::from(list.as_str())` open-code has no compile-time link
20218 // back to the substrate primitive.
20219 for &variant in super::DepList::ALL {
20220 let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20221 let via_method: &'static str = variant.as_str();
20222 assert_eq!(
20223 via_trait.as_ref(),
20224 via_method,
20225 "From<DepList> for Box<str> impl must round-trip \
20226 DepList::{variant:?} to the same lifted \
20227 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20228 DepList::as_str returns — divergence signals a silent \
20229 detour off the substrate-primitive accessor"
20230 );
20231 let via_into: Box<str> = variant.into();
20232 assert_eq!(
20233 via_into.as_ref(),
20234 via_method,
20235 "Into<Box<str>>::into on DepList::{variant:?} must \
20236 byte-equal DepList::as_str on the same input — the \
20237 blanket-derived Into shape must resolve to the same \
20238 as_str dispatch as the explicit From impl"
20239 );
20240 }
20241 }
20242
20243 #[test]
20244 fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
20245 // Fail-before-pass-after byte-parity pin on the newly lifted
20246 // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
20247 // standard-library trait impl and the substrate-primitive
20248 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
20249 // the same two-arm emit-set (the paired
20250 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20251 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20252 // byte-strings) across every arm the exhaustive
20253 // [`super::DepList::ALL`] slice enumerates. Rust's standard
20254 // library carries `impl From<&str> for Box<str>` and
20255 // `impl From<String> for Box<str>` but no blanket
20256 // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
20257 // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
20258 // input [`Box<str>`] forward-projection axis is a distinct
20259 // trait-idiomatic surface that a
20260 // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
20261 // iterator over `&'static [DepList]` yields `&DepList` by
20262 // construction) or a `let key: Box<str> = (&list).into();`-shaped
20263 // call site reaches through this impl and no other — the paired
20264 // owned-input `From<DepList> for Box<str>` impl alone would force
20265 // every borrowed-input call site through an explicit `Copy` deref
20266 // (`Box::<str>::from(*list)`) or a
20267 // `Box::<str>::from(list.as_str())` open-code whose type bounds
20268 // have no compile-time link back to the substrate primitive.
20269 //
20270 // Closes the `{Self, &Self}` input-shape corner on the second
20271 // caixa-core-internal closed-set fieldless typed enum peer of
20272 // the substrate-wide [`Box<str>`] forward-projection campaign —
20273 // one commit after the paired render-side path-shape-diagnostic
20274 // [`super::super::render::PathShapeViolation`] pair (0d87a72)
20275 // opened the caixa-core-internal tier — matching the trajectory
20276 // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
20277 // in one axis), the caixa-provedor `FerriteRuntime` pair
20278 // (14886a8, both corners in one axis), and the render-side
20279 // `PathShapeViolation` pair (0d87a72, both corners in one axis)
20280 // walked before it.
20281 for &variant in super::DepList::ALL {
20282 let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20283 let via_method: &'static str = variant.as_str();
20284 assert_eq!(
20285 via_trait.as_ref(),
20286 via_method,
20287 "From<&DepList> for Box<str> impl must round-trip \
20288 &DepList::{variant:?} to the same lifted \
20289 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20290 DepList::as_str returns — divergence signals a silent \
20291 detour off the substrate-primitive accessor"
20292 );
20293 let via_into: Box<str> = (&variant).into();
20294 assert_eq!(
20295 via_into.as_ref(),
20296 via_method,
20297 "Into<Box<str>>::into on &DepList::{variant:?} must \
20298 byte-equal DepList::as_str on the same input — the \
20299 blanket-derived Into shape on the borrowed-input \
20300 surface must resolve to the same as_str dispatch as \
20301 the explicit From impl"
20302 );
20303 }
20304
20305 // Pipe witness — the distinguishing shape that forces the
20306 // borrowed-input axis to be independent of the owned-input
20307 // peer. `DepList::ALL.iter()` yields `&DepList` by
20308 // construction, so `.map(Box::<str>::from)` resolves through
20309 // the borrowed-input `From<&DepList> for Box<str>` impl and
20310 // no other — without this axis, the same pipe would force an
20311 // explicit `.copied()` restatement whose type bounds bypass
20312 // the substrate primitive.
20313 let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
20314 let via_accessor: Vec<&'static str> =
20315 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
20316 assert_eq!(
20317 via_pipe.len(),
20318 via_accessor.len(),
20319 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
20320 preserve arity against the paired DepList::as_str \
20321 accessor — a length divergence signals the borrowed-input \
20322 axis has silently rejected an arm"
20323 );
20324 for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
20325 assert_eq!(
20326 pipe_arm.as_ref(),
20327 *accessor_arm,
20328 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
20329 byte-equal the paired \
20330 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
20331 arm — divergence signals the borrowed-input \
20332 `From<&DepList> for Box<str>` axis has silently \
20333 detoured off the substrate-primitive accessor"
20334 );
20335 }
20336 }
20337
20338 #[test]
20339 fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
20340 // Fail-before-pass-after byte-parity pin on the newly lifted
20341 // `impl From<DepList> for std::sync::Arc<str>` — asserts the
20342 // owned-input standard-library trait impl and the substrate-
20343 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20344 // resolve to the same two-arm emit-set (the paired
20345 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20346 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20347 // byte-strings) across every arm the exhaustive
20348 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20349 // core-internal tier of the substrate-wide
20350 // [`std::sync::Arc<str>`] forward-projection campaign onto the
20351 // second caixa-core-internal peer, after the top-level
20352 // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
20353 // opened the tier. Rust's standard library carries
20354 // `impl From<&str> for std::sync::Arc<str>` and
20355 // `impl From<String> for std::sync::Arc<str>` but no blanket
20356 // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
20357 // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
20358 // this axis is a distinct trait-idiomatic surface that a
20359 // `let key: std::sync::Arc<str> = list.into();`-shaped call site
20360 // reaches through this impl and no other — a paired
20361 // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
20362 // compile-time link back to the substrate primitive, and a two-
20363 // step `std::sync::Arc::<str>::from(String::from(list))`
20364 // composition through the owned-`String` axis allocates twice
20365 // (once into the intermediate `String`, once into the
20366 // [`std::sync::Arc<str>`] on the `From<String>` conversion)
20367 // where the single-step trait impl allocates once.
20368 //
20369 // Cross-axis byte-parity witness against the sibling owned-input
20370 // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
20371 // shape axes — locking the five return-shape paths on the owned-
20372 // input surface together by construction so any future detour
20373 // off the substrate-primitive [`super::DepList::as_str`] accessor
20374 // trips at caixa-core test time.
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::{variant:?} \
20393 must byte-equal DepList::as_str on the same input — \
20394 the blanket-derived Into shape must resolve to the same \
20395 as_str dispatch as the explicit From impl"
20396 );
20397 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20398 assert_eq!(
20399 via_trait.as_ref(),
20400 owned_static,
20401 "From<DepList> for std::sync::Arc<str> and \
20402 From<DepList> for &'static str must resolve identically \
20403 on DepList::{variant:?} — divergence signals the owned-\
20404 input std::sync::Arc<str> and &'static str return-shape \
20405 paths have drifted onto different emit-sets"
20406 );
20407 let owned_string: String = <String as From<super::DepList>>::from(variant);
20408 assert_eq!(
20409 via_trait.as_ref(),
20410 owned_string.as_str(),
20411 "From<DepList> for std::sync::Arc<str> and \
20412 From<DepList> for String must resolve identically on \
20413 DepList::{variant:?} — divergence signals the owned-\
20414 input std::sync::Arc<str> and owned-`String` return-shape \
20415 paths have drifted onto different emit-sets"
20416 );
20417 let owned_cow: std::borrow::Cow<'static, str> =
20418 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20419 assert_eq!(
20420 via_trait.as_ref(),
20421 owned_cow.as_ref(),
20422 "From<DepList> for std::sync::Arc<str> and \
20423 From<DepList> for Cow<'static, str> must resolve \
20424 identically on DepList::{variant:?} — divergence signals \
20425 the owned-input std::sync::Arc<str> and \
20426 Cow<'static, str> return-shape paths have drifted onto \
20427 different emit-sets"
20428 );
20429 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20430 assert_eq!(
20431 via_trait.as_ref(),
20432 owned_box.as_ref(),
20433 "From<DepList> for std::sync::Arc<str> and \
20434 From<DepList> for Box<str> must resolve identically on \
20435 DepList::{variant:?} — divergence signals the owned-\
20436 input std::sync::Arc<str> and Box<str> return-shape \
20437 paths have drifted onto different emit-sets"
20438 );
20439 }
20440 }
20441
20442 #[test]
20443 #[allow(
20444 clippy::too_many_lines,
20445 reason = "cross-axis partition pin folds four borrowed-input \
20446 return-shape paths (&'static str, String, Cow<'static, \
20447 str>, Box<str>) plus the paired owned-input Arc<str> \
20448 witness and the .iter().map(std::sync::Arc::<str>::from) \
20449 pipe witness into one exhaustive round-trip over \
20450 DepList::ALL — the accepted line-count cost of keying \
20451 the whole borrowed-input Arc<str> corner to the \
20452 substrate-primitive as_str accessor at the same test-site"
20453 )]
20454 fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
20455 // Fail-before-pass-after byte-parity pin on the newly lifted
20456 // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
20457 // borrowed-input standard-library trait impl and the substrate-
20458 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20459 // resolve to the same two-arm emit-set across every arm the
20460 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20461 // standard library does not carry a blanket
20462 // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
20463 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20464 // the borrowed-input `std::sync::Arc<str>` forward-projection
20465 // axis is a distinct trait-idiomatic surface that a
20466 // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
20467 // site or a
20468 // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
20469 // pipe reaches through this impl and no other — the paired
20470 // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
20471 // forces every borrowed-input call site through a spurious
20472 // `Copy` deref
20473 // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
20474 // `.copied()` restatement whose type bounds have no compile-time
20475 // link back to the substrate primitive.
20476 //
20477 // Closes the `{Self, &Self}` input-shape corner on the second
20478 // caixa-core-internal closed-set fieldless typed enum peer of
20479 // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
20480 // forward-projection campaign — one commit after the paired
20481 // top-level [`crate::CaixaKind`] pair (c17be64) opened the
20482 // caixa-core-internal tier — matching the
20483 // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
20484 // Box<str>}` 2×4 forward-projection matrix the peer projection
20485 // surfaces already close on this same enum.
20486 //
20487 // Cross-axis partition pin against the paired owned-input
20488 // [`From<DepList> for std::sync::Arc<str>`] and the sibling
20489 // borrowed-input `{&'static str, String, Cow<'static, str>,
20490 // Box<str>}` return-shape axes — locking the five return-shape
20491 // × input-shape paths on the borrowed-input surface together by
20492 // construction so any future detour off the substrate-primitive
20493 // accessor trips at caixa-core test time. Then a
20494 // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
20495 // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
20496 // construction, so the borrowed-input
20497 // [`std::sync::Arc<str>`] axis is what routes the pipe through
20498 // the substrate-primitive [`super::DepList::as_str`] accessor
20499 // without a spurious [`Copy`] deref (which would only be
20500 // reachable through the owned-input
20501 // [`From<DepList> for std::sync::Arc<str>`] axis by first
20502 // calling `.copied()` on the iterator).
20503 for &variant in super::DepList::ALL {
20504 let via_trait: std::sync::Arc<str> =
20505 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20506 let via_method: &'static str = variant.as_str();
20507 assert_eq!(
20508 via_trait.as_ref(),
20509 via_method,
20510 "From<&DepList> for std::sync::Arc<str> impl must round-\
20511 trip &DepList::{variant:?} to the same lifted \
20512 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20513 DepList::as_str returns — divergence signals a silent \
20514 detour off the substrate-primitive accessor"
20515 );
20516 let via_into: std::sync::Arc<str> = (&variant).into();
20517 assert_eq!(
20518 via_into.as_ref(),
20519 via_method,
20520 "Into<std::sync::Arc<str>>::into on &DepList::\
20521 {variant:?} must byte-equal DepList::as_str on the \
20522 same input — the blanket-derived Into shape on the \
20523 borrowed-input surface must resolve to the same as_str \
20524 dispatch as the explicit From impl"
20525 );
20526 let owned_arc: std::sync::Arc<str> =
20527 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20528 assert_eq!(
20529 via_trait, owned_arc,
20530 "From<&DepList> for std::sync::Arc<str> and \
20531 From<DepList> for std::sync::Arc<str> must resolve \
20532 identically on DepList::{variant:?} — divergence \
20533 signals the borrowed-input and owned-input \
20534 std::sync::Arc<str> forward-projection input-shape \
20535 paths have drifted onto different emit-sets"
20536 );
20537 let borrowed_static: &'static str =
20538 <&'static str as From<&super::DepList>>::from(&variant);
20539 assert_eq!(
20540 via_trait.as_ref(),
20541 borrowed_static,
20542 "From<&DepList> for std::sync::Arc<str> and \
20543 From<&DepList> for &'static str must resolve \
20544 identically on DepList::{variant:?} — divergence \
20545 signals the borrowed-input std::sync::Arc<str> and \
20546 &'static str return-shape paths have drifted onto \
20547 different emit-sets"
20548 );
20549 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20550 assert_eq!(
20551 via_trait.as_ref(),
20552 borrowed_string.as_str(),
20553 "From<&DepList> for std::sync::Arc<str> and \
20554 From<&DepList> for String must resolve identically on \
20555 DepList::{variant:?} — divergence signals the \
20556 borrowed-input std::sync::Arc<str> and owned-`String` \
20557 return-shape paths have drifted onto different emit-\
20558 sets"
20559 );
20560 let borrowed_cow: std::borrow::Cow<'static, str> =
20561 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20562 assert_eq!(
20563 via_trait.as_ref(),
20564 borrowed_cow.as_ref(),
20565 "From<&DepList> for std::sync::Arc<str> and \
20566 From<&DepList> for Cow<'static, str> must resolve \
20567 identically on DepList::{variant:?} — divergence \
20568 signals the borrowed-input std::sync::Arc<str> and \
20569 Cow<'static, str> return-shape paths have drifted onto \
20570 different emit-sets"
20571 );
20572 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20573 assert_eq!(
20574 via_trait.as_ref(),
20575 borrowed_box.as_ref(),
20576 "From<&DepList> for std::sync::Arc<str> and \
20577 From<&DepList> for Box<str> must resolve identically \
20578 on DepList::{variant:?} — divergence signals the \
20579 borrowed-input std::sync::Arc<str> and Box<str> \
20580 return-shape paths have drifted onto different emit-sets"
20581 );
20582 }
20583 let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
20584 .iter()
20585 .map(std::sync::Arc::<str>::from)
20586 .collect();
20587 let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
20588 .iter()
20589 .map(|l| std::sync::Arc::<str>::from(l.as_str()))
20590 .collect();
20591 assert_eq!(
20592 via_iter, via_method,
20593 "`.iter().map(std::sync::Arc::<str>::from)` over \
20594 DepList::ALL — a call site whose iteration axis holds \
20595 `&DepList` by construction — must byte-equal \
20596 `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
20597 on every arm — the borrowed-input std::sync::Arc<str> \
20598 `From<&DepList> for std::sync::Arc<str>` axis is what \
20599 makes the `std::sync::Arc::<str>::from` composition route \
20600 through the substrate-primitive `DepList::as_str` \
20601 accessor without a spurious `Copy` deref (which would \
20602 only be reachable through the owned-input \
20603 `From<DepList> for std::sync::Arc<str>` axis by first \
20604 calling `.copied()` on the iterator)"
20605 );
20606 }
20607
20608 #[test]
20609 fn dep_list_from_into_rc_str_routes_through_as_str_accessor() {
20610 // Fail-before-pass-after byte-parity pin on the newly lifted
20611 // `impl From<DepList> for std::rc::Rc<str>` — asserts the
20612 // owned-input standard-library trait impl and the substrate-
20613 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20614 // resolve to the same two-arm emit-set (the paired
20615 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20616 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20617 // byte-strings) across every arm the exhaustive
20618 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20619 // core-internal tier of the substrate-wide
20620 // [`std::rc::Rc<str>`] forward-projection campaign onto the
20621 // third caixa-core-internal peer, after the top-level
20622 // [`crate::CaixaKind`] (e04aff0), the second-peer
20623 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and the render-
20624 // side [`crate::render::PathShapeViolation`] (31fc43e) pairs
20625 // opened the tier. Rust's standard library carries
20626 // `impl From<&str> for std::rc::Rc<str>` and
20627 // `impl From<String> for std::rc::Rc<str>` but no blanket
20628 // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and the
20629 // [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait
20630 // tables are disjoint, so this axis is a distinct trait-
20631 // idiomatic surface that a
20632 // `let key: std::rc::Rc<str> = list.into();`-shaped call site
20633 // reaches through this impl and no other — a paired
20634 // `std::rc::Rc::<str>::from(list.as_str())` open-code has no
20635 // compile-time link back to the substrate primitive, and a
20636 // two-step `std::rc::Rc::<str>::from(String::from(list))`
20637 // composition through the owned-`String` axis allocates twice
20638 // (once into the intermediate `String`, once into the
20639 // [`std::rc::Rc<str>`] on the `From<String>` conversion) where
20640 // the single-step trait impl allocates once.
20641 //
20642 // Cross-axis byte-parity witness against the sibling owned-
20643 // input `{&'static str, String, Cow<'static, str>, Box<str>,
20644 // std::sync::Arc<str>}` return-shape axes — locking the six
20645 // return-shape paths on the owned-input surface together by
20646 // construction so any future detour off the substrate-
20647 // primitive [`super::DepList::as_str`] accessor trips at
20648 // caixa-core test time.
20649 for &variant in super::DepList::ALL {
20650 let via_trait: std::rc::Rc<str> =
20651 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20652 let via_method: &'static str = variant.as_str();
20653 assert_eq!(
20654 via_trait.as_ref(),
20655 via_method,
20656 "From<DepList> for std::rc::Rc<str> impl must round-\
20657 trip DepList::{variant:?} to the same lifted \
20658 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20659 DepList::as_str returns — divergence signals a silent \
20660 detour off the substrate-primitive accessor"
20661 );
20662 let via_into: std::rc::Rc<str> = variant.into();
20663 assert_eq!(
20664 via_into.as_ref(),
20665 via_method,
20666 "Into<std::rc::Rc<str>>::into on DepList::{variant:?} \
20667 must byte-equal DepList::as_str on the same input — \
20668 the blanket-derived Into shape must resolve to the \
20669 same as_str dispatch as the explicit From impl"
20670 );
20671 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20672 assert_eq!(
20673 via_trait.as_ref(),
20674 owned_static,
20675 "From<DepList> for std::rc::Rc<str> and \
20676 From<DepList> for &'static str must resolve identically \
20677 on DepList::{variant:?} — divergence signals the owned-\
20678 input std::rc::Rc<str> and &'static str return-shape \
20679 paths have drifted onto different emit-sets"
20680 );
20681 let owned_string: String = <String as From<super::DepList>>::from(variant);
20682 assert_eq!(
20683 via_trait.as_ref(),
20684 owned_string.as_str(),
20685 "From<DepList> for std::rc::Rc<str> and \
20686 From<DepList> for String must resolve identically on \
20687 DepList::{variant:?} — divergence signals the owned-\
20688 input std::rc::Rc<str> and owned-`String` return-shape \
20689 paths have drifted onto different emit-sets"
20690 );
20691 let owned_cow: std::borrow::Cow<'static, str> =
20692 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20693 assert_eq!(
20694 via_trait.as_ref(),
20695 owned_cow.as_ref(),
20696 "From<DepList> for std::rc::Rc<str> and \
20697 From<DepList> for Cow<'static, str> must resolve \
20698 identically on DepList::{variant:?} — divergence signals \
20699 the owned-input std::rc::Rc<str> and Cow<'static, str> \
20700 return-shape paths have drifted onto different emit-sets"
20701 );
20702 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20703 assert_eq!(
20704 via_trait.as_ref(),
20705 owned_box.as_ref(),
20706 "From<DepList> for std::rc::Rc<str> and \
20707 From<DepList> for Box<str> must resolve identically on \
20708 DepList::{variant:?} — divergence signals the owned-\
20709 input std::rc::Rc<str> and Box<str> return-shape paths \
20710 have drifted onto different emit-sets"
20711 );
20712 let owned_arc: std::sync::Arc<str> =
20713 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20714 assert_eq!(
20715 via_trait.as_ref(),
20716 owned_arc.as_ref(),
20717 "From<DepList> for std::rc::Rc<str> and \
20718 From<DepList> for std::sync::Arc<str> must resolve \
20719 identically on DepList::{variant:?} — divergence signals \
20720 the owned-input std::rc::Rc<str> and std::sync::Arc<str> \
20721 return-shape paths have drifted onto different emit-sets \
20722 (the two disjoint reference-counted trait tables have \
20723 desynchronized on the caixa-core two-list dep-graph axis)"
20724 );
20725 }
20726 }
20727
20728 #[test]
20729 #[allow(
20730 clippy::too_many_lines,
20731 reason = "cross-axis partition pin folds five borrowed-input \
20732 return-shape paths (&'static str, String, Cow<'static, \
20733 str>, Box<str>, std::sync::Arc<str>) plus the paired \
20734 owned-input Rc<str> witness and the \
20735 .iter().map(std::rc::Rc::<str>::from) pipe witness into \
20736 one exhaustive round-trip over DepList::ALL — the \
20737 accepted line-count cost of keying the whole borrowed-\
20738 input Rc<str> corner to the substrate-primitive as_str \
20739 accessor at the same test-site"
20740 )]
20741 fn dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
20742 // Fail-before-pass-after byte-parity pin on the newly lifted
20743 // `impl From<&DepList> for std::rc::Rc<str>` — asserts the
20744 // borrowed-input standard-library trait impl and the substrate-
20745 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20746 // resolve to the same two-arm emit-set across every arm the
20747 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20748 // standard library does not carry a blanket
20749 // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
20750 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20751 // the borrowed-input `std::rc::Rc<str>` forward-projection axis
20752 // is a distinct trait-idiomatic surface that a
20753 // `let key: std::rc::Rc<str> = (&list).into();`-shaped call
20754 // site or a
20755 // `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
20756 // pipe reaches through this impl and no other — the paired
20757 // owned-input `From<DepList> for std::rc::Rc<str>` impl alone
20758 // would force every borrowed-input call site through a spurious
20759 // `Copy` deref
20760 // (`std::rc::Rc::<str>::from((*list).as_str())`) or a
20761 // `.copied()` restatement whose type bounds have no compile-
20762 // time link back to the substrate primitive.
20763 //
20764 // Closes the `{Self, &Self}` input-shape corner on the third
20765 // caixa-core-internal closed-set fieldless typed enum peer of
20766 // the substrate-wide trait-idiomatic [`std::rc::Rc<str>`]
20767 // forward-projection campaign, matching the trajectory the
20768 // paired [`crate::CaixaKind`] (e04aff0),
20769 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and
20770 // [`crate::render::PathShapeViolation`] (31fc43e) pairs walked
20771 // before it on the same tier of the same axis.
20772 //
20773 // Cross-axis partition pin against the paired owned-input
20774 // [`From<DepList> for std::rc::Rc<str>`] and the sibling
20775 // borrowed-input `{&'static str, String, Cow<'static, str>,
20776 // Box<str>, std::sync::Arc<str>}` return-shape axes — locking
20777 // the six return-shape × input-shape paths on the borrowed-
20778 // input surface together by construction so any future detour
20779 // off the substrate-primitive accessor trips at caixa-core
20780 // test time. Then a `.iter().map(std::rc::Rc::<str>::from)`
20781 // pipe witness over [`super::DepList::ALL`] — whose iterator
20782 // yields `&DepList` by construction, so the borrowed-input
20783 // [`std::rc::Rc<str>`] axis is what routes the pipe through
20784 // the substrate-primitive [`super::DepList::as_str`] accessor
20785 // without a spurious [`Copy`] deref (which would only be
20786 // reachable through the owned-input
20787 // [`From<DepList> for std::rc::Rc<str>`] axis by first calling
20788 // `.copied()` on the iterator).
20789 for &variant in super::DepList::ALL {
20790 let via_trait: std::rc::Rc<str> =
20791 <std::rc::Rc<str> as From<&super::DepList>>::from(&variant);
20792 let via_method: &'static str = variant.as_str();
20793 assert_eq!(
20794 via_trait.as_ref(),
20795 via_method,
20796 "From<&DepList> for std::rc::Rc<str> impl must round-\
20797 trip &DepList::{variant:?} to the same lifted \
20798 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20799 DepList::as_str returns — divergence signals a silent \
20800 detour off the substrate-primitive accessor"
20801 );
20802 let via_into: std::rc::Rc<str> = (&variant).into();
20803 assert_eq!(
20804 via_into.as_ref(),
20805 via_method,
20806 "Into<std::rc::Rc<str>>::into on &DepList::\
20807 {variant:?} must byte-equal DepList::as_str on the \
20808 same input — the blanket-derived Into shape on the \
20809 borrowed-input surface must resolve to the same \
20810 as_str dispatch as the explicit From impl"
20811 );
20812 let owned_rc: std::rc::Rc<str> =
20813 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20814 assert_eq!(
20815 via_trait, owned_rc,
20816 "From<&DepList> for std::rc::Rc<str> and \
20817 From<DepList> for std::rc::Rc<str> must resolve \
20818 identically on DepList::{variant:?} — divergence \
20819 signals the borrowed-input and owned-input \
20820 std::rc::Rc<str> forward-projection input-shape \
20821 paths have drifted onto different emit-sets"
20822 );
20823 let borrowed_static: &'static str =
20824 <&'static str as From<&super::DepList>>::from(&variant);
20825 assert_eq!(
20826 via_trait.as_ref(),
20827 borrowed_static,
20828 "From<&DepList> for std::rc::Rc<str> and \
20829 From<&DepList> for &'static str must resolve \
20830 identically on DepList::{variant:?} — divergence \
20831 signals the borrowed-input std::rc::Rc<str> and \
20832 &'static str return-shape paths have drifted onto \
20833 different emit-sets"
20834 );
20835 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20836 assert_eq!(
20837 via_trait.as_ref(),
20838 borrowed_string.as_str(),
20839 "From<&DepList> for std::rc::Rc<str> and \
20840 From<&DepList> for String must resolve identically on \
20841 DepList::{variant:?} — divergence signals the \
20842 borrowed-input std::rc::Rc<str> and owned-`String` \
20843 return-shape paths have drifted onto different emit-\
20844 sets"
20845 );
20846 let borrowed_cow: std::borrow::Cow<'static, str> =
20847 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20848 assert_eq!(
20849 via_trait.as_ref(),
20850 borrowed_cow.as_ref(),
20851 "From<&DepList> for std::rc::Rc<str> and \
20852 From<&DepList> for Cow<'static, str> must resolve \
20853 identically on DepList::{variant:?} — divergence \
20854 signals the borrowed-input std::rc::Rc<str> and \
20855 Cow<'static, str> return-shape paths have drifted onto \
20856 different emit-sets"
20857 );
20858 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20859 assert_eq!(
20860 via_trait.as_ref(),
20861 borrowed_box.as_ref(),
20862 "From<&DepList> for std::rc::Rc<str> and \
20863 From<&DepList> for Box<str> must resolve identically \
20864 on DepList::{variant:?} — divergence signals the \
20865 borrowed-input std::rc::Rc<str> and Box<str> \
20866 return-shape paths have drifted onto different emit-sets"
20867 );
20868 let borrowed_arc: std::sync::Arc<str> =
20869 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20870 assert_eq!(
20871 via_trait.as_ref(),
20872 borrowed_arc.as_ref(),
20873 "From<&DepList> for std::rc::Rc<str> and \
20874 From<&DepList> for std::sync::Arc<str> must resolve \
20875 identically on DepList::{variant:?} — divergence \
20876 signals the borrowed-input std::rc::Rc<str> and \
20877 std::sync::Arc<str> return-shape paths have drifted \
20878 onto different emit-sets (the two disjoint reference-\
20879 counted trait tables have desynchronized on the \
20880 caixa-core two-list dep-graph axis)"
20881 );
20882 }
20883 let via_iter: Vec<std::rc::Rc<str>> = super::DepList::ALL
20884 .iter()
20885 .map(std::rc::Rc::<str>::from)
20886 .collect();
20887 let via_method: Vec<std::rc::Rc<str>> = super::DepList::ALL
20888 .iter()
20889 .map(|l| std::rc::Rc::<str>::from(l.as_str()))
20890 .collect();
20891 assert_eq!(
20892 via_iter, via_method,
20893 "`.iter().map(std::rc::Rc::<str>::from)` over \
20894 DepList::ALL — a call site whose iteration axis holds \
20895 `&DepList` by construction — must byte-equal \
20896 `.iter().map(|l| std::rc::Rc::<str>::from(l.as_str()))` \
20897 on every arm — the borrowed-input std::rc::Rc<str> \
20898 `From<&DepList> for std::rc::Rc<str>` axis is what makes \
20899 the `std::rc::Rc::<str>::from` composition route through \
20900 the substrate-primitive `DepList::as_str` accessor \
20901 without a spurious `Copy` deref (which would only be \
20902 reachable through the owned-input \
20903 `From<DepList> for std::rc::Rc<str>` axis by first \
20904 calling `.copied()` on the iterator)"
20905 );
20906 }
20907
20908 #[test]
20909 fn dep_list_author_keys_covers_every_arm() {
20910 // Load-bearing pin on the substrate-canonical
20911 // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
20912 // on the `:`-prefixed kebab-case tatara-lisp author-surface
20913 // key axis: every variant of the sibling
20914 // [`super::DepList::ALL`] exhaustive-iteration surface must
20915 // project through [`super::DepList::as_str`] onto an entry the
20916 // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
20917 // roster's length must byte-equal `super::DepList::ALL.len()`
20918 // so a silent skew between the [`super::DepList::as_str`]
20919 // match's arm-set and the roster's arm-set trips here at
20920 // caixa-core test time rather than at a downstream M4
20921 // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
20922 // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
20923 // a `feira dep --list …` "did you mean" hint drift / a
20924 // downstream [`super::DepError`] widening's typed `list:
20925 // DepList` carry that fans on the enum through a stale
20926 // accepted-set. A future arm addition (a `:build-dep` or
20927 // `:tool-dep` third list once the substrate grows Cargo-style
20928 // split-graphs — both trajectory items the sibling
20929 // [`super::DepList::from_wire`] doc block already names)
20930 // extends [`super::DepList::ALL`] as a single edit and this
20931 // pin sweeps the new arm by iteration; the paired
20932 // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
20933 // or this assertion trips. Every entry is further pinned to
20934 // open with the ASCII `:` byte (the tatara-lisp author-surface
20935 // keyword marker) so a silent collapse of the author-key axis
20936 // with any hypothetical peer un-prefixed wire-form axis (an
20937 // entry byte-identical to a sibling `deps` / `deps-dev`
20938 // bare-kebab byte-string that would let an author-key-axis
20939 // consumer accept the un-prefixed vocabulary) trips here
20940 // rather than at a downstream consumer's
20941 // vocabulary-collision miss.
20942 //
20943 // Peer of the sibling
20944 // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
20945 // (bd708bd) /
20946 // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
20947 // (427fe75) /
20948 // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
20949 // (3033f45) /
20950 // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
20951 // (ce9412b) /
20952 // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
20953 // (3e5b194) /
20954 // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
20955 // (9d9f585) /
20956 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20957 // (b553ec9) /
20958 // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
20959 // (1898d77) /
20960 // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
20961 // (cc42c0e) pins — the same closed-set exhaustive-roster
20962 // coverage discipline extended here onto the two-list dep-graph
20963 // closed-set typed enum, the ninth substrate-side closed-set
20964 // typed enum on the roster axis and the last unlifted
20965 // `&'static str`-carrying closed-set typed enum on the top-
20966 // level manifest surface to converge onto the discipline.
20967 //
20968 // Fail-before-pass-after locally verified by mutating one arm
20969 // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
20970 // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
20971 // `":deps-dev"` to `":deps_dev"`) — the length pin still
20972 // passes but the `contains` check fires on the mutated arm;
20973 // and by shortening the roster to one entry — the length pin
20974 // fires first.
20975 assert_eq!(
20976 super::DepList::AUTHOR_KEYS.len(),
20977 super::DepList::ALL.len(),
20978 "DepList::AUTHOR_KEYS.len() must byte-equal \
20979 DepList::ALL.len() — a mismatch means the roster and \
20980 the enum's arm-set have drifted; downstream consumers \
20981 that fan through both will silently disagree on the \
20982 accepted arm-set"
20983 );
20984 for &variant in super::DepList::ALL {
20985 let key = variant.as_str();
20986 assert!(
20987 super::DepList::AUTHOR_KEYS.contains(&key),
20988 "DepList::{variant:?}.as_str() = {key:?} must be a \
20989 member of DepList::AUTHOR_KEYS — the emitter and the \
20990 roster have drifted out of lockstep"
20991 );
20992 }
20993 for tag in super::DepList::AUTHOR_KEYS {
20994 let first = tag.chars().next().unwrap_or_else(|| {
20995 panic!(
20996 "DepList::AUTHOR_KEYS entry {tag:?} must be a \
20997 non-empty `:`-prefixed kebab-case tatara-lisp \
20998 author-surface key byte-string"
20999 )
21000 });
21001 assert_eq!(
21002 first, ':',
21003 "DepList::AUTHOR_KEYS entry {tag:?} must open with \
21004 the ASCII `:` byte (tatara-lisp author-surface \
21005 keyword marker) — an un-prefixed entry would \
21006 collide the roster with any hypothetical peer bare-\
21007 kebab wire-form axis a downstream consumer might \
21008 disambiguate against"
21009 );
21010 }
21011 // Pin the exact two-arm roster in declaration order so a
21012 // future arm-swap on either the roster or the paired
21013 // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
21014 // arm-key mapping that leaves both the length pin and the
21015 // membership pin passing on their own) trips at caixa-core
21016 // test time under `assert_eq!`. Order matches variant
21017 // declaration order verbatim (`Prod` → `Dev`) so the roster
21018 // is the canonical ordering every listing / rendering
21019 // consumer defers to. Same declaration-order pin the sibling
21020 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
21021 // (b553ec9) closes on the M3 `:politicas :rate-limit`
21022 // canonical-suffix axis.
21023 assert_eq!(
21024 super::DepList::AUTHOR_KEYS,
21025 &[
21026 crate::render::DEP_AUTHOR_KEY_DEPS,
21027 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
21028 ],
21029 "DepList::AUTHOR_KEYS must enumerate every arm's \
21030 author-surface key exactly once, in variant declaration \
21031 order (Prod → Dev)"
21032 );
21033 }
21034
21035 #[test]
21036 fn dep_list_from_str_routes_through_try_from_str_impl() {
21037 // Fail-before-pass-after byte-parity pin on the newly lifted
21038 // `impl std::str::FromStr for DepList` — asserts the standard-
21039 // library `.parse()` parse-axis entry point and the paired
21040 // [`super::DepList::try_from`] `TryFrom<&str>` impl (which in
21041 // turn routes through the substrate-primitive
21042 // [`super::DepList::from_wire`] `Option<Self>` accessor)
21043 // resolve to the same two-arm accept-set across every arm the
21044 // exhaustive [`super::DepList::ALL`] slice enumerates. First-
21045 // mover on the substrate-wide `FromStr` parse-axis campaign —
21046 // the peer method-named `from_wire` accessor and the paired
21047 // `TryFrom<&str>` trait impl fix the two-arm accept set; this
21048 // pin locks the `FromStr::from_str` trait entry point onto the
21049 // same set so any future divergence (a stray per-arm `match s`
21050 // re-inlining that opens a compile-time link to an un-lifted
21051 // arm-literal, a swap onto a hand-rolled parser that widens
21052 // the accept-set past the two wire-format consts) trips at
21053 // caixa-core test time.
21054 use std::str::FromStr;
21055 for &list in super::DepList::ALL {
21056 let wire = list.as_str();
21057 assert_eq!(
21058 <super::DepList as FromStr>::from_str(wire),
21059 Ok(list),
21060 "FromStr impl on DepList must round-trip \
21061 DepList::{list:?}.as_str() = {wire:?} back to \
21062 Ok(DepList::{list:?}) — divergence from \
21063 DepList::try_from signals a silent detour off the \
21064 paired reverse-projection trait impl"
21065 );
21066 assert_eq!(
21067 <super::DepList as FromStr>::from_str(wire).ok(),
21068 super::DepList::from_wire(wire),
21069 "FromStr ok()-projection on {wire:?} must byte-equal \
21070 DepList::from_wire on the same input — divergence \
21071 signals the two reverse-projection trait paths have \
21072 drifted off the substrate-primitive accessor"
21073 );
21074 // `.parse::<DepList>()` short-form witness — the stdlib
21075 // consumer surface that reaches the enum through the
21076 // `T: FromStr` bound, not through `TryFrom<&str>`.
21077 let via_parse: Result<super::DepList, ()> = wire.parse();
21078 assert_eq!(
21079 via_parse,
21080 Ok(list),
21081 "`{wire:?}`.parse::<DepList>() must resolve to \
21082 Ok(DepList::{list:?}) — divergence signals the \
21083 stdlib `.parse()` short-form has drifted from the \
21084 lifted `FromStr::from_str` impl"
21085 );
21086 }
21087 }
21088
21089 #[test]
21090 fn dep_list_from_str_rejects_unknown_byte_strings() {
21091 // Rejection witness on the `impl FromStr for DepList` —
21092 // sweeps candidate byte-strings outside the two-arm accept-set
21093 // the sibling [`super::DepList::as_str`] emits (`:deps` /
21094 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
21095 // future accidental widening of the trait impl's accept-set (a
21096 // stray case-fold path, a silent inclusion of a rebrand alias
21097 // like `":packages"`, an English rebrand `":dev-deps"` in
21098 // reverse arm-order that would silently swap the two arms) trips
21099 // at caixa-core test time. Peer of the sibling
21100 // `dep_list_try_from_str_rejects_unknown_byte_strings` rejection
21101 // witness — the two pins together bracket both reverse-projection
21102 // trait impls against the same rejected set.
21103 use std::str::FromStr;
21104 let rejected: &[&str] = &[
21105 "",
21106 " ",
21107 "\t",
21108 "\n",
21109 ":deps ",
21110 " :deps",
21111 ":DEPS",
21112 ":Deps",
21113 ":Deps-Dev",
21114 ":deps_dev",
21115 ":deps-development",
21116 ":dev-deps",
21117 ":packages",
21118 ":packages-dev",
21119 "deps",
21120 "deps-dev",
21121 "Prod",
21122 "Dev",
21123 "prod",
21124 "dev",
21125 "\":deps\"",
21126 "\":deps-dev\"",
21127 ":deps\n",
21128 ":deps-dev\n",
21129 ];
21130 for &input in rejected {
21131 assert_eq!(
21132 <super::DepList as FromStr>::from_str(input),
21133 Err(()),
21134 "FromStr impl on DepList must reject unknown \
21135 byte-string {input:?} — divergence from \
21136 DepList::from_wire on the same input signals a silent \
21137 accept-set widening past the two lifted \
21138 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
21139 );
21140 assert_eq!(
21141 <super::DepList as FromStr>::from_str(input).ok(),
21142 super::DepList::from_wire(input),
21143 "FromStr ok()-projection on {input:?} must byte-equal \
21144 DepList::from_wire on the same input — divergence \
21145 signals the FromStr trait path has drifted off the \
21146 substrate-primitive accessor"
21147 );
21148 let via_parse: Result<super::DepList, ()> = input.parse();
21149 assert_eq!(
21150 via_parse,
21151 Err(()),
21152 "`{input:?}`.parse::<DepList>() must reject the \
21153 unknown byte-string — divergence signals the stdlib \
21154 `.parse()` short-form has drifted from the lifted \
21155 `FromStr::from_str` impl"
21156 );
21157 }
21158 }
21159
21160 #[test]
21161 #[allow(
21162 clippy::too_many_lines,
21163 reason = "cross-axis partition pin folds the substrate-primitive \
21164 as_str accessor's `.as_bytes()` byte-tail plus the \
21165 paired str-view (AsRef<str>, Display, as_str) and \
21166 reverse-projection ({&'static str, String, \
21167 Cow<'static, str>, Box<str>, std::sync::Arc<str>, \
21168 std::rc::Rc<str>}) return-shape axes' `.as_bytes()` \
21169 byte-tails plus a <T: AsRef<[u8]>>-bound-consumer \
21170 witness plus a blake3::Hasher::update-shape byte-\
21171 input surface witness into one exhaustive round-trip \
21172 over DepList::ALL — the accepted line-count cost of \
21173 opening the byte-view axis keyed to the substrate-\
21174 primitive as_str accessor at the same test-site"
21175 )]
21176 #[allow(
21177 clippy::needless_borrows_for_generic_args,
21178 reason = "the borrowed-input surface (&variant) is exercised \
21179 deliberately: the `<T: AsRef<[u8]>>`-bound consumer \
21180 and the `blake3::Hasher::update`-shape byte-input \
21181 surface both accept either owned or borrowed input \
21182 through the standard-library blanket \
21183 `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`, \
21184 and this pin round-trips both input shapes to lock \
21185 the borrowed-input path load-bearing against a \
21186 future silent regression"
21187 )]
21188 fn dep_list_as_ref_bytes_routes_through_as_str_accessor() {
21189 // `<T: AsRef<[u8]>>`-bound-consumer witness helper: a generic
21190 // byte-input function accepts a [`super::DepList`] directly
21191 // through the trait bound, without the caller open-coding the
21192 // two-hop `list.as_str().as_bytes()` composition. Lifted to
21193 // the top of the function per `clippy::items_after_statements`.
21194 fn generic_bytes_sink<T: AsRef<[u8]>>(t: T) -> Vec<u8> {
21195 t.as_ref().to_vec()
21196 }
21197 // `blake3::Hasher::update`-shape byte-input surface mock:
21198 // mirrors `blake3::Hasher::update` / `ring::digest::Context::
21199 // update` / `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound
21200 // `update` signature so a per-caixa BLAKE3 content-address
21201 // closure that composes `hasher.update(list)` on the
21202 // [`crate::Lacre`] closure builder reaches the substrate-
21203 // primitive `as_str` accessor through the [`super::DepList`]
21204 // `AsRef<[u8]>` axis and no other. Lifted to the top of the
21205 // function per `clippy::items_after_statements`.
21206 struct MockHasher(Vec<u8>);
21207 impl MockHasher {
21208 fn new() -> Self {
21209 Self(Vec::new())
21210 }
21211 fn update(&mut self, bytes: impl AsRef<[u8]>) -> &mut Self {
21212 self.0.extend_from_slice(bytes.as_ref());
21213 self
21214 }
21215 fn finalize(self) -> Vec<u8> {
21216 self.0
21217 }
21218 }
21219
21220 // Fail-before-pass-after byte-parity pin on the newly lifted
21221 // `impl AsRef<[u8]> for DepList` — asserts the trait-idiomatic
21222 // byte-view standard-library impl and the substrate-primitive
21223 // [`super::DepList::as_str`] `pub const fn` accessor's
21224 // `.as_bytes()` byte-tail resolve to the same two-arm
21225 // `:`-prefixed kebab-case byte-string emit-set across every
21226 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
21227 // Extends the substrate-wide trait-idiomatic byte-view axis
21228 // onto the third closed-set fieldless typed enum on the
21229 // caixa-core-internal tier — matching the trajectory the
21230 // sibling [`super::CaixaKind`] first-mover [`AsRef<[u8]>`]
21231 // impl (69d8d86) and [`super::CaixaDialeto`] second-mover
21232 // impl (8151347) walked before it.
21233 for &variant in super::DepList::ALL {
21234 let via_trait: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21235 let via_method_bytes: &[u8] = variant.as_str().as_bytes();
21236 assert_eq!(
21237 via_trait, via_method_bytes,
21238 "AsRef<[u8]> for DepList impl must byte-equal \
21239 DepList::as_str().as_bytes() on DepList::\
21240 {variant:?} — divergence signals a silent detour off \
21241 the substrate-primitive accessor"
21242 );
21243 // Cross-axis witness against the paired str-view axes'
21244 // `.as_bytes()` byte-tails: [`AsRef<str>`] /
21245 // [`std::fmt::Display`] / [`super::DepList::as_str`] all
21246 // resolve to the same lifted `render::DEP_AUTHOR_KEY_*`
21247 // const roster, and the byte-view axis must byte-equal
21248 // each of their `.as_bytes()` byte-tails by construction
21249 // — locking the str-view and byte-view axes together at
21250 // the substrate-primitive accessor.
21251 let str_view_ref: &str = <super::DepList as AsRef<str>>::as_ref(&variant);
21252 assert_eq!(
21253 via_trait,
21254 str_view_ref.as_bytes(),
21255 "AsRef<[u8]> for DepList and AsRef<str> for DepList \
21256 must resolve to byte-equal byte-tails on DepList::\
21257 {variant:?} — divergence signals the byte-view and \
21258 str-view axes have drifted off the same substrate-\
21259 primitive as_str accessor"
21260 );
21261 let display_bytes = variant.to_string();
21262 assert_eq!(
21263 via_trait,
21264 display_bytes.as_bytes(),
21265 "AsRef<[u8]> for DepList and \
21266 <DepList as std::fmt::Display>::to_string must \
21267 resolve to byte-equal byte-tails on DepList::\
21268 {variant:?} — divergence signals the byte-view axis \
21269 and the Display formatter axis have drifted off the \
21270 same substrate-primitive as_str accessor"
21271 );
21272 // Cross-axis witness against the paired reverse-
21273 // projection axes' `.as_bytes()` byte-tails: every one of
21274 // `{&'static str, String, Cow<'static, str>, Box<str>,
21275 // std::sync::Arc<str>, std::rc::Rc<str>}` allocates (or
21276 // borrows) the same `:`-prefixed kebab byte-string the
21277 // substrate-primitive accessor emits, so the byte-view
21278 // axis must byte-equal each of their `.as_bytes()` byte-
21279 // tails by construction.
21280 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
21281 assert_eq!(
21282 via_trait,
21283 owned_static.as_bytes(),
21284 "AsRef<[u8]> for DepList and From<DepList> for \
21285 &'static str must resolve to byte-equal byte-tails on \
21286 DepList::{variant:?}"
21287 );
21288 let owned_string: String = <String as From<super::DepList>>::from(variant);
21289 assert_eq!(
21290 via_trait,
21291 owned_string.as_bytes(),
21292 "AsRef<[u8]> for DepList and From<DepList> for \
21293 String must resolve to byte-equal byte-tails on \
21294 DepList::{variant:?}"
21295 );
21296 let owned_cow: std::borrow::Cow<'static, str> =
21297 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
21298 assert_eq!(
21299 via_trait,
21300 owned_cow.as_bytes(),
21301 "AsRef<[u8]> for DepList and From<DepList> for \
21302 Cow<'static, str> must resolve to byte-equal byte-\
21303 tails on DepList::{variant:?}"
21304 );
21305 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
21306 assert_eq!(
21307 via_trait,
21308 owned_box.as_bytes(),
21309 "AsRef<[u8]> for DepList and From<DepList> for \
21310 Box<str> must resolve to byte-equal byte-tails on \
21311 DepList::{variant:?}"
21312 );
21313 let owned_arc: std::sync::Arc<str> =
21314 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
21315 assert_eq!(
21316 via_trait,
21317 owned_arc.as_bytes(),
21318 "AsRef<[u8]> for DepList and From<DepList> for \
21319 std::sync::Arc<str> must resolve to byte-equal byte-\
21320 tails on DepList::{variant:?}"
21321 );
21322 let owned_rc_str: std::rc::Rc<str> =
21323 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
21324 assert_eq!(
21325 via_trait,
21326 owned_rc_str.as_bytes(),
21327 "AsRef<[u8]> for DepList and From<DepList> for \
21328 std::rc::Rc<str> must resolve to byte-equal byte-\
21329 tails on DepList::{variant:?}"
21330 );
21331 }
21332 // `<T: AsRef<[u8]>>`-bound-consumer witness: the generic byte-
21333 // input function `generic_bytes_sink` (lifted above per
21334 // `clippy::items_after_statements`) accepts a [`super::DepList`]
21335 // directly through the trait bound, without the caller open-
21336 // coding the two-hop `list.as_str().as_bytes()` composition.
21337 // This is the shape that reaches the caixa-lacre BLAKE3
21338 // content-address closure's
21339 // `blake3::Hasher::update(impl AsRef<[u8]>)` byte-input surface
21340 // through this impl and no other. Exercised on both owned and
21341 // borrowed input surfaces via the standard-library blanket
21342 // `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`.
21343 for &variant in super::DepList::ALL {
21344 let via_generic = generic_bytes_sink(variant);
21345 let via_borrowed_generic = generic_bytes_sink(&variant);
21346 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21347 assert_eq!(
21348 via_generic, via_method_bytes,
21349 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21350 DepList::{variant:?} must yield the same byte-tail \
21351 DepList::as_str().as_bytes() returns — divergence \
21352 signals the byte-view axis fails to bridge a generic \
21353 byte-input trait bound to the substrate-primitive \
21354 accessor"
21355 );
21356 assert_eq!(
21357 via_borrowed_generic, via_method_bytes,
21358 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21359 &DepList::{variant:?} must yield the same byte-tail \
21360 DepList::as_str().as_bytes() returns — the borrowed-\
21361 input surface must resolve to the same as_str dispatch"
21362 );
21363 }
21364 // `blake3::Hasher::update`-shape byte-input surface witness
21365 // on the caixa-lacre compounding target: the `MockHasher`
21366 // (lifted above per `clippy::items_after_statements`) mirrors
21367 // `blake3::Hasher::update` / `ring::digest::Context::update` /
21368 // `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound update
21369 // signature and accepts a [`super::DepList`] directly, routing
21370 // its byte-tail through the substrate-primitive `as_str`
21371 // accessor — the shape a future per-caixa BLAKE3 content-
21372 // address closure composes to fold a dep-list discriminator
21373 // byte-tag into the [`crate::Lacre`] closure body so a
21374 // downstream `Lacre` consumer can partition the runtime-
21375 // closure `:deps` from the dev-only-closure `:deps-dev` at
21376 // content-address time.
21377 for &variant in super::DepList::ALL {
21378 let mut owned_hasher = MockHasher::new();
21379 owned_hasher.update(variant);
21380 let owned_folded = owned_hasher.finalize();
21381 assert_eq!(
21382 owned_folded,
21383 variant.as_str().as_bytes(),
21384 "`hasher.update(list)`-shape composition on DepList::\
21385 {variant:?} must fold the same byte-tail DepList::\
21386 as_str().as_bytes() returns — the shape a future \
21387 per-caixa BLAKE3 content-address closure composes to \
21388 fold a dep-list discriminator byte-tag into the Lacre \
21389 closure body"
21390 );
21391 let mut borrowed_hasher = MockHasher::new();
21392 borrowed_hasher.update(&variant);
21393 let borrowed_folded = borrowed_hasher.finalize();
21394 assert_eq!(
21395 borrowed_folded,
21396 variant.as_str().as_bytes(),
21397 "`hasher.update(&list)`-shape composition on \
21398 &DepList::{variant:?} must fold the same byte-tail \
21399 DepList::as_str().as_bytes() returns — the borrowed-\
21400 input surface must resolve to the same as_str dispatch"
21401 );
21402 }
21403 }
21404
21405 #[test]
21406 #[expect(
21407 clippy::too_many_lines,
21408 reason = "the byte-owned reverse-projection axis is extended \
21409 onto DepList here as the third peer on the substrate-\
21410 wide byte-owned Vec<u8>-output projection family \
21411 (after the sibling first-mover CaixaKind, b245fd6, \
21412 and second-mover CaixaDialeto, 4cceaf5), so the pin \
21413 binds the new impl against every paired byte-view \
21414 and str-view axis on the same enum plus a generic \
21415 <T: Into<Vec<u8>>>-bound consumer witness and a \
21416 std::io::Write::write_all-shape owned-byte-sink \
21417 surface witness on both owned and borrowed input \
21418 shapes to lock the whole family against a future \
21419 silent regression"
21420 )]
21421 fn dep_list_from_into_owned_vec_bytes_routes_through_as_str_accessor() {
21422 // `<T: Into<Vec<u8>>>`-bound-consumer witness helper: a generic
21423 // owned-byte-input function accepts a [`super::DepList`]
21424 // directly through the trait bound, without the caller open-
21425 // coding the three-hop `list.as_str().as_bytes().to_vec()`
21426 // composition. Lifted to the top of the function per
21427 // `clippy::items_after_statements`.
21428 fn generic_owned_bytes_sink<T: Into<Vec<u8>>>(t: T) -> Vec<u8> {
21429 t.into()
21430 }
21431 // `std::io::Write::write_all`-shape owned-byte-sink surface
21432 // mock: mirrors `std::io::Write::write_all` /
21433 // `bytes::BytesMut::extend_from_slice` / any per-arm audit-log
21434 // byte-sink that consumes a `Vec<u8>` payload via
21435 // `Into<Vec<u8>>`, so a future per-caixa per-`:deps`/`:deps-dev`
21436 // audit-log emit reaches the substrate-primitive `as_str`
21437 // accessor through the byte-owned reverse-projection axis and
21438 // no other. Lifted to the top of the function per
21439 // `clippy::items_after_statements`.
21440 struct MockOwnedByteSink(Vec<u8>);
21441 impl MockOwnedByteSink {
21442 fn new() -> Self {
21443 Self(Vec::new())
21444 }
21445 fn write_all(&mut self, bytes: impl Into<Vec<u8>>) -> &mut Self {
21446 self.0.extend_from_slice(&bytes.into());
21447 self
21448 }
21449 fn finalize(self) -> Vec<u8> {
21450 self.0
21451 }
21452 }
21453
21454 // Fail-before-pass-after byte-parity pin on the newly lifted
21455 // `impl From<DepList> for Vec<u8>` and
21456 // `impl From<&DepList> for Vec<u8>` — asserts the trait-
21457 // idiomatic byte-owned reverse-projection standard-library
21458 // impls and the substrate-primitive
21459 // [`super::DepList::as_str`] `pub const fn` accessor's
21460 // `.as_bytes().to_vec()` byte-tail resolve to the same two-arm
21461 // `:`-prefixed kebab-case byte-string emit-set across every
21462 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
21463 // Extends the substrate-wide trait-idiomatic byte-owned
21464 // reverse-projection axis onto the third closed-set fieldless
21465 // typed enum on the caixa-core-internal tier — matching the
21466 // trajectory the sibling first-mover [`super::CaixaKind`]
21467 // `From<{Self, &Self}> for Vec<u8>` impls (b245fd6) and the
21468 // second-mover [`crate::dialeto::CaixaDialeto`] impls (4cceaf5)
21469 // walked before it on the caixa-core tier of the byte-owned
21470 // axis.
21471 for &variant in super::DepList::ALL {
21472 let via_owned_from: Vec<u8> = <Vec<u8> as From<super::DepList>>::from(variant);
21473 let via_borrowed_from: Vec<u8> = <Vec<u8> as From<&super::DepList>>::from(&variant);
21474 let via_method_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
21475 assert_eq!(
21476 via_owned_from, via_method_bytes,
21477 "From<DepList> for Vec<u8> impl must byte-equal \
21478 DepList::as_str().as_bytes().to_vec() on DepList::\
21479 {variant:?} — divergence signals a silent detour off \
21480 the substrate-primitive accessor"
21481 );
21482 assert_eq!(
21483 via_borrowed_from, via_method_bytes,
21484 "From<&DepList> for Vec<u8> impl must byte-equal \
21485 DepList::as_str().as_bytes().to_vec() on DepList::\
21486 {variant:?} — divergence signals a silent detour off \
21487 the substrate-primitive accessor"
21488 );
21489 assert_eq!(
21490 via_owned_from, via_borrowed_from,
21491 "From<DepList> for Vec<u8> and From<&DepList> for \
21492 Vec<u8> must byte-equal each other on DepList::\
21493 {variant:?} — divergence signals the owned-input and \
21494 borrowed-input paths have drifted off the same \
21495 substrate-primitive as_str accessor"
21496 );
21497 // Cross-axis witness against the paired [`AsRef<[u8]>`]
21498 // borrowed byte-view axis: the byte-owned reverse-
21499 // projection axis must byte-equal the paired borrowed
21500 // byte-view axis by construction — locking the byte-view
21501 // and byte-owned axes together at the substrate-primitive
21502 // accessor.
21503 let borrowed_bytes: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21504 assert_eq!(
21505 via_owned_from,
21506 borrowed_bytes.to_vec(),
21507 "From<DepList> for Vec<u8> and AsRef<[u8]> for DepList \
21508 must resolve to byte-equal byte-tails on DepList::\
21509 {variant:?} — divergence signals the byte-owned and \
21510 byte-view axes have drifted off the same substrate-\
21511 primitive as_str accessor"
21512 );
21513 // Cross-axis witness against the str-owned reverse-
21514 // projection family's `.into_bytes()` / `.as_bytes().to_vec()`
21515 // byte-tails: every one of `{String, Cow<'static, str>,
21516 // Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
21517 // allocates (or borrows) the same `:`-prefixed kebab byte-
21518 // string the substrate-primitive accessor emits, so the
21519 // byte-owned axis must byte-equal each of their owned
21520 // byte-tails by construction.
21521 let owned_string: String = <String as From<super::DepList>>::from(variant);
21522 assert_eq!(
21523 via_owned_from,
21524 owned_string.into_bytes(),
21525 "From<DepList> for Vec<u8> and \
21526 String::from(list).into_bytes() must resolve to byte-\
21527 equal byte-tails on DepList::{variant:?}"
21528 );
21529 let owned_cow: std::borrow::Cow<'static, str> =
21530 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
21531 assert_eq!(
21532 via_owned_from,
21533 owned_cow.as_bytes().to_vec(),
21534 "From<DepList> for Vec<u8> and From<DepList> for \
21535 Cow<'static, str> must resolve to byte-equal byte-\
21536 tails on DepList::{variant:?}"
21537 );
21538 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
21539 assert_eq!(
21540 via_owned_from,
21541 owned_box.as_bytes().to_vec(),
21542 "From<DepList> for Vec<u8> and From<DepList> for \
21543 Box<str> must resolve to byte-equal byte-tails on \
21544 DepList::{variant:?}"
21545 );
21546 let owned_arc: std::sync::Arc<str> =
21547 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
21548 assert_eq!(
21549 via_owned_from,
21550 owned_arc.as_bytes().to_vec(),
21551 "From<DepList> for Vec<u8> and From<DepList> for \
21552 std::sync::Arc<str> must resolve to byte-equal byte-\
21553 tails on DepList::{variant:?}"
21554 );
21555 let owned_rc_str: std::rc::Rc<str> =
21556 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
21557 assert_eq!(
21558 via_owned_from,
21559 owned_rc_str.as_bytes().to_vec(),
21560 "From<DepList> for Vec<u8> and From<DepList> for \
21561 std::rc::Rc<str> must resolve to byte-equal byte-\
21562 tails on DepList::{variant:?}"
21563 );
21564 }
21565 // `<T: Into<Vec<u8>>>`-bound-consumer witness on both owned
21566 // and borrowed input shapes: the generic owned-byte-input
21567 // function `generic_owned_bytes_sink` (lifted above per
21568 // `clippy::items_after_statements`) accepts a
21569 // [`super::DepList`] and a `&DepList` directly through the
21570 // trait bound, without the caller open-coding the three-hop
21571 // `list.as_str().as_bytes().to_vec()` composition.
21572 for &variant in super::DepList::ALL {
21573 let via_generic_owned = generic_owned_bytes_sink(variant);
21574 // Bind the borrowed-input path through an explicit
21575 // `&DepList` local so the generic-consumer witness routes
21576 // through `From<&DepList> for Vec<u8>` (T binds to
21577 // `&DepList`) rather than clippy-collapsing the borrow
21578 // onto the owned-input `From<DepList> for Vec<u8>` peer.
21579 let variant_ref: &super::DepList = &variant;
21580 let via_generic_borrowed = generic_owned_bytes_sink(variant_ref);
21581 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21582 assert_eq!(
21583 via_generic_owned, via_method_bytes,
21584 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21585 DepList::{variant:?} must yield the same byte-tail \
21586 DepList::as_str().as_bytes().to_vec() returns — \
21587 divergence signals the byte-owned axis fails to \
21588 bridge a generic owned-byte-input trait bound to the \
21589 substrate-primitive accessor"
21590 );
21591 assert_eq!(
21592 via_generic_borrowed, via_method_bytes,
21593 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21594 &DepList::{variant:?} must yield the same byte-tail \
21595 DepList::as_str().as_bytes().to_vec() returns — the \
21596 borrowed-input surface must resolve to the same \
21597 as_str dispatch"
21598 );
21599 }
21600 // `std::io::Write::write_all`-shape owned-byte-sink surface
21601 // witness: the `MockOwnedByteSink` (lifted above per
21602 // `clippy::items_after_statements`) mirrors
21603 // `std::io::Write::write_all` /
21604 // `bytes::BytesMut::extend_from_slice`'s `impl Into<Vec<u8>>`-
21605 // bound owned-byte input signature and accepts a
21606 // [`super::DepList`] directly on both owned and borrowed input
21607 // shapes, routing its byte-tail through the substrate-
21608 // primitive `as_str` accessor — the shape a future per-caixa
21609 // per-`:deps`/`:deps-dev` audit-log emit composes to fold a
21610 // dep-list discriminator byte-tag into a downstream owned-
21611 // byte-sink surface so a partition of the runtime-closure
21612 // `:deps` from the dev-only-closure `:deps-dev` reaches the
21613 // sink through this axis and no other.
21614 for &variant in super::DepList::ALL {
21615 let mut owned_sink = MockOwnedByteSink::new();
21616 owned_sink.write_all(variant);
21617 let owned_folded = owned_sink.finalize();
21618 assert_eq!(
21619 owned_folded,
21620 variant.as_str().as_bytes(),
21621 "`sink.write_all(list)`-shape composition on DepList::\
21622 {variant:?} must fold the same byte-tail DepList::\
21623 as_str().as_bytes() returns"
21624 );
21625 let mut borrowed_sink = MockOwnedByteSink::new();
21626 // Same explicit `&DepList` binding as the generic-consumer
21627 // witness above: routes the owned-byte-sink surface
21628 // through `From<&DepList> for Vec<u8>` (T binds to
21629 // `&DepList`) rather than clippy-collapsing the borrow
21630 // onto the owned-input peer.
21631 let variant_ref: &super::DepList = &variant;
21632 borrowed_sink.write_all(variant_ref);
21633 let borrowed_folded = borrowed_sink.finalize();
21634 assert_eq!(
21635 borrowed_folded,
21636 variant.as_str().as_bytes(),
21637 "`sink.write_all(&list)`-shape composition on \
21638 &DepList::{variant:?} must fold the same byte-tail \
21639 DepList::as_str().as_bytes() returns — the borrowed-\
21640 input surface must resolve to the same as_str dispatch"
21641 );
21642 }
21643 }
21644
21645 #[test]
21646 fn dep_list_try_from_bytes_routes_through_from_wire_accessor() {
21647 // Fail-before-pass-after byte-parity pin on the newly lifted
21648 // `impl TryFrom<&[u8]> for DepList` — asserts the trait-
21649 // idiomatic byte-view reverse-projection standard-library impl
21650 // and the substrate-primitive [`super::DepList::from_wire`]
21651 // `Option<Self>` accessor resolve to the same two-arm
21652 // `:`-prefixed kebab-case wire accept-set across every arm the
21653 // exhaustive [`super::DepList::ALL`] slice enumerates. Extends
21654 // the substrate-wide trait-idiomatic byte-view reverse-
21655 // projection axis onto the third caixa-core-internal closed-set
21656 // fieldless typed enum peer — mirror of the paired
21657 // [`TryFrom<&str> for DepList`] str-view reverse-projection
21658 // axis on the same enum, and the byte-view companion of the
21659 // pre-existing byte-owned reverse-projection family
21660 // ([`AsRef<[u8]>`], [`From<DepList> for Vec<u8>`],
21661 // [`From<&DepList> for Vec<u8>`]) on this same enum. Peer of
21662 // the sibling
21663 // [`crate::kind::tests::caixa_kind_try_from_bytes_routes_through_from_wire_accessor`]
21664 // (18d1940) on the first-mover [`crate::CaixaKind`] closed-set
21665 // typed-enum peer and the sibling
21666 // [`crate::dialeto::tests::caixa_dialeto_try_from_bytes_routes_through_from_wire_accessor`]
21667 // (d102cb8) on the second-mover [`crate::CaixaDialeto`] peer —
21668 // tracks the "route through `from_wire` via `std::str::from_utf8`"
21669 // discipline the first-mover established.
21670 //
21671 // Rust's standard library carries no blanket
21672 // `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so
21673 // a two-hop composition through [`std::str::from_utf8`] + the
21674 // paired [`TryFrom<&str>`] axis is reachable through the pre-
21675 // existing str-view reverse-projection axis alone. But that
21676 // two-hop shape has no compile-time link back to the byte-view
21677 // reverse-projection axis, forces every downstream
21678 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer to open-code
21679 // the composition at every call site, and admits a silent split
21680 // whenever a future call site takes a sibling byte-projection
21681 // axis whose parse arm-set carries no compile-time byte-view
21682 // surface. This impl closes the byte-view reverse-projection
21683 // axis at the substrate-primitive
21684 // [`super::DepList::from_wire`] accessor so every future
21685 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer reaches the
21686 // same two-arm `:`-prefixed kebab-case wire accept-set through
21687 // one trait dispatch.
21688 for &variant in super::DepList::ALL {
21689 let wire_bytes: &[u8] = variant.as_str().as_bytes();
21690 assert_eq!(
21691 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes),
21692 Ok(variant),
21693 "TryFrom<&[u8]> impl on DepList must round-trip \
21694 DepList::{variant:?}.as_str().as_bytes() back to \
21695 Ok(DepList::{variant:?}) — divergence from \
21696 DepList::from_wire signals a silent detour off the \
21697 substrate-primitive accessor"
21698 );
21699 assert_eq!(
21700 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes).ok(),
21701 super::DepList::from_wire(variant.as_str()),
21702 "TryFrom<&[u8]> ok()-projection on \
21703 DepList::{variant:?}.as_str().as_bytes() must \
21704 byte-equal DepList::from_wire on the paired &str input"
21705 );
21706 // Cross-axis witness: the byte-view reverse-projection axis
21707 // must agree with the paired str-view reverse-projection
21708 // axis ([`TryFrom<&str>`]) on every accepted arm — the two
21709 // reverse paths share one `:`-prefixed kebab accept-set
21710 // through the substrate-primitive `from_wire` accessor.
21711 let via_str: Result<super::DepList, ()> =
21712 <super::DepList as TryFrom<&str>>::try_from(variant.as_str());
21713 let via_bytes: Result<super::DepList, ()> =
21714 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes);
21715 assert_eq!(
21716 via_bytes, via_str,
21717 "TryFrom<&[u8]> and TryFrom<&str> reverse-projection \
21718 axes on DepList must agree on DepList::{variant:?} — \
21719 divergence signals the byte-view and str-view reverse \
21720 paths have drifted off the same substrate-primitive \
21721 from_wire accessor"
21722 );
21723 // Cross-axis witness against the paired [`AsRef<[u8]>`]
21724 // borrowed byte-view axis: feeding the same byte-tail the
21725 // forward byte-view axis emits back through the reverse
21726 // byte-view axis must round-trip to the originating arm —
21727 // locks the forward and reverse byte-view axes together at
21728 // the substrate-primitive accessor.
21729 let borrowed_bytes: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21730 assert_eq!(
21731 <super::DepList as TryFrom<&[u8]>>::try_from(borrowed_bytes),
21732 Ok(variant),
21733 "TryFrom<&[u8]> fed the AsRef<[u8]>-projected byte-tail \
21734 of DepList::{variant:?} must round-trip to \
21735 Ok(DepList::{variant:?}) — divergence signals the \
21736 forward and reverse byte-view axes have drifted off \
21737 the same substrate-primitive as_str/from_wire accessor \
21738 pair"
21739 );
21740 }
21741 }
21742
21743 #[test]
21744 fn dep_list_try_from_bytes_rejects_unknown_and_non_utf8_bytes() {
21745 // Rejection witness on the `impl TryFrom<&[u8]> for DepList` —
21746 // sweeps two rejection paths the byte-view reverse-projection
21747 // axis collapses onto the single unit-error `Err(())` return:
21748 // the invalid-UTF-8 rejection path ([`std::str::from_utf8`]
21749 // returns `Err` before [`super::DepList::from_wire`] runs) and
21750 // the valid-UTF-8-but-unknown-wire rejection path
21751 // ([`super::DepList::from_wire`] returns `None` on a byte-
21752 // string outside the two-arm `:`-prefixed kebab-case accept-
21753 // set). Both must reject, so a future accidental widening of
21754 // the trait impl's accept-set (a case-fold path, a silent
21755 // acceptance of a `":packages"` rebrand alias, a
21756 // `#[serde(rename_all = "…")]` attribute drift that widens the
21757 // parse arm-set silently, a stray fallback that maps invalid
21758 // UTF-8 onto a default arm rather than the trait-idiomatic
21759 // `Err(())`) trips at caixa-core test time. Peer of the sibling
21760 // [`crate::kind::tests::caixa_kind_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
21761 // (18d1940) on the first-mover [`crate::CaixaKind`] peer and
21762 // the sibling
21763 // [`crate::dialeto::tests::caixa_dialeto_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
21764 // (d102cb8) on the second-mover [`crate::CaixaDialeto`] peer.
21765 //
21766 // Non-UTF-8 candidates:
21767 // - a lone 0xFF byte (never valid as a UTF-8 leading byte)
21768 // - a lone 0x80 continuation byte with no leading byte
21769 // - a truncated multi-byte sequence (0xC3 without its continuation)
21770 // - a UTF-16 BOM-style byte pair the UTF-8 validator rejects
21771 // - a UTF-16 surrogate half rejected by UTF-8
21772 let non_utf8_rejected: &[&[u8]] = &[
21773 &[0xFF],
21774 &[0x80],
21775 &[0xC3],
21776 &[0xFF, 0xFE],
21777 &[0xED, 0xA0, 0x80],
21778 ];
21779 for &input in non_utf8_rejected {
21780 assert_eq!(
21781 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21782 Err(()),
21783 "TryFrom<&[u8]> impl on DepList must reject the non-\
21784 UTF-8 byte-sequence {input:?} with Err(()) — silent \
21785 acceptance signals the UTF-8 validation path collapsed \
21786 onto a default arm rather than the trait-idiomatic \
21787 unit-error"
21788 );
21789 }
21790 // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
21791 // string, whitespace-only forms, case-folded variants of
21792 // accepted arms, the un-`:`-prefixed bare-kebab
21793 // ("deps"/"deps-dev") the sibling
21794 // [`super::DepList::from_wire`] doc block flags as a
21795 // `:`-prefix-discipline hazard, plausible rebrand aliases the
21796 // sibling `dep_list_try_from_str_rejects_unknown_byte_strings`
21797 // rejection witness (5b828ed) already pins on the str-view
21798 // reverse axis, and whitespace-padded/quoted forms.
21799 let unknown_wire_rejected: &[&[u8]] = &[
21800 b"",
21801 b" ",
21802 b"\t",
21803 b"\n",
21804 b":deps ",
21805 b" :deps",
21806 b":DEPS",
21807 b":Deps",
21808 b":Deps-Dev",
21809 b":deps_dev",
21810 b":deps-development",
21811 b":dev-deps",
21812 b":packages",
21813 b":packages-dev",
21814 b"deps",
21815 b"deps-dev",
21816 b"Prod",
21817 b"Dev",
21818 b"prod",
21819 b"dev",
21820 b"\":deps\"",
21821 b"\":deps-dev\"",
21822 b":deps\n",
21823 b":deps-dev\n",
21824 ];
21825 for &input in unknown_wire_rejected {
21826 assert_eq!(
21827 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21828 Err(()),
21829 "TryFrom<&[u8]> impl on DepList must reject the valid-\
21830 UTF-8-but-unknown-wire byte-string {input:?} with \
21831 Err(()) — silent acceptance signals an accept-set \
21832 widening off the paired DepList::from_wire resolver"
21833 );
21834 // Cross-axis witness: on a byte-string that is valid UTF-8,
21835 // the byte-view reverse-projection axis must agree with the
21836 // paired str-view reverse-projection axis
21837 // ([`TryFrom<&str>`]) — both route through the same
21838 // [`super::DepList::from_wire`] resolver, so the two
21839 // rejection paths align by construction.
21840 if let Ok(s) = std::str::from_utf8(input) {
21841 assert_eq!(
21842 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21843 <super::DepList as TryFrom<&str>>::try_from(s),
21844 "TryFrom<&[u8]> and TryFrom<&str> reverse-\
21845 projection axes on DepList must agree on the \
21846 valid-UTF-8 input {input:?} — divergence signals \
21847 the two reverse paths have drifted off the same \
21848 substrate-primitive from_wire accessor"
21849 );
21850 }
21851 }
21852 }
21853
21854 #[test]
21855 fn dep_list_try_from_vec_bytes_routes_through_borrowed_byte_view_axis() {
21856 // Fail-before-pass-after byte-parity pin on the newly lifted
21857 // `impl TryFrom<Vec<u8>> for DepList` — asserts the trait-
21858 // idiomatic owned-byte-vec reverse-projection standard-library
21859 // impl and the sibling borrowed-input [`TryFrom<&[u8]>`] axis
21860 // resolve to the same two-arm `:`-prefixed kebab-case wire
21861 // accept-set across every arm the exhaustive
21862 // [`super::DepList::ALL`] slice enumerates. Extends the
21863 // substrate-wide trait-idiomatic byte-owned reverse-projection
21864 // axis onto the third caixa-core-internal closed-set fieldless
21865 // typed enum peer — owned-input mirror of the paired
21866 // [`TryFrom<&[u8]>`] byte-view reverse-projection axis
21867 // (b8f25d5), and byte-owned reverse companion of the pre-
21868 // existing byte-owned *forward*-projection pair
21869 // ([`From<super::DepList> for Vec<u8>`],
21870 // [`From<&super::DepList> for Vec<u8>`]) on this same enum.
21871 // Peer of the sibling first-mover
21872 // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
21873 // (99c2849) on the [`crate::CaixaKind`] closed-set typed-enum
21874 // peer and the sibling second-mover
21875 // [`crate::dialeto::tests::caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
21876 // (83a1526) on the [`crate::CaixaDialeto`] peer — tracks the
21877 // "delegate through `TryFrom<&[u8]>` on the `Vec<u8>::as_slice`
21878 // borrow" discipline the first-mover established.
21879 //
21880 // Rust's standard library carries no blanket
21881 // `impl<T: for<'a> TryFrom<&'a [u8]>> TryFrom<Vec<u8>> for T`,
21882 // so an owned-byte-vec caller otherwise picks between an
21883 // open-coded `<T as TryFrom<&[u8]>>::try_from(bytes.as_slice())`
21884 // at every call site whose type bounds have no compile-time
21885 // link back to the byte-owned reverse-projection axis, or a
21886 // `String::from_utf8(bytes)` two-hop shape whose error surface
21887 // leaks the standard-library `FromUtf8Error` type. This impl
21888 // closes the byte-owned reverse-projection axis at the
21889 // substrate-primitive [`super::DepList::from_wire`] accessor
21890 // so every future `<T: TryFrom<Vec<u8>>>`-bound owned-byte-vec
21891 // consumer reaches the same two-arm `:`-prefixed kebab-case
21892 // wire accept-set through one trait dispatch.
21893 for &variant in super::DepList::ALL {
21894 let wire_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
21895 assert_eq!(
21896 <super::DepList as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone()),
21897 Ok(variant),
21898 "TryFrom<Vec<u8>> impl on DepList must round-trip \
21899 DepList::{variant:?}.as_str().as_bytes().to_vec() \
21900 back to Ok(DepList::{variant:?}) — divergence from \
21901 the sibling TryFrom<&[u8]> axis signals a silent \
21902 detour off the substrate-primitive from_wire accessor"
21903 );
21904 // Cross-axis witness: the owned-byte-vec reverse-projection
21905 // axis must agree with the borrowed byte-slice reverse-
21906 // projection axis on every accepted arm — the two axes
21907 // share one `:`-prefixed kebab-case wire vocabulary
21908 // through the substrate-primitive `from_wire` accessor,
21909 // and the owned-input axis delegates to the borrowed peer
21910 // by design.
21911 let via_owned: Result<super::DepList, ()> =
21912 <super::DepList as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone());
21913 let via_borrowed: Result<super::DepList, ()> =
21914 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes.as_slice());
21915 assert_eq!(
21916 via_owned, via_borrowed,
21917 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
21918 axes on DepList must agree on DepList::{variant:?} — \
21919 divergence signals the owned-input and borrowed-input \
21920 byte-view reverse paths have drifted off the same \
21921 substrate-primitive from_wire accessor"
21922 );
21923 // Cross-axis witness against the paired str-view reverse
21924 // axis ([`TryFrom<&str>`]) — the three reverse paths (str-
21925 // view, byte-view borrowed, byte-view owned) share one
21926 // substrate primitive.
21927 let via_str: Result<super::DepList, ()> =
21928 <super::DepList as TryFrom<&str>>::try_from(variant.as_str());
21929 assert_eq!(
21930 via_owned, via_str,
21931 "TryFrom<Vec<u8>> and TryFrom<&str> reverse-projection \
21932 axes on DepList must agree on DepList::{variant:?} — \
21933 divergence signals the byte-owned and str-view \
21934 reverse paths have drifted off the same substrate-\
21935 primitive from_wire accessor"
21936 );
21937 // Four-corner witness: because [`super::DepList`] carries
21938 // no wire-vs-diagnostic split (as_str and from_wire share
21939 // one `:`-prefixed kebab-case byte-vocabulary), the byte-
21940 // owned reverse-projection axis on this enum *does* round-
21941 // trip against the paired byte-owned forward-projection
21942 // pair. Pin every corner of the {owned-input, borrowed-
21943 // input} × {From<Self> → Vec<u8>, From<&Self> → Vec<u8>}
21944 // square onto the same Ok(variant) return so a future
21945 // accident that drops one corner off the substrate-
21946 // primitive accessor trips here.
21947 let owned_forward: Vec<u8> = <Vec<u8> as From<super::DepList>>::from(variant);
21948 let borrowed_forward: Vec<u8> = <Vec<u8> as From<&super::DepList>>::from(&variant);
21949 assert_eq!(
21950 owned_forward, wire_bytes,
21951 "From<DepList> for Vec<u8> forward projection on \
21952 DepList::{variant:?} must byte-equal \
21953 variant.as_str().as_bytes().to_vec() — divergence \
21954 signals the paired forward pair drifted off the \
21955 substrate-primitive as_str accessor"
21956 );
21957 assert_eq!(
21958 borrowed_forward, wire_bytes,
21959 "From<&DepList> for Vec<u8> forward projection on \
21960 &DepList::{variant:?} must byte-equal \
21961 variant.as_str().as_bytes().to_vec() — divergence \
21962 signals the paired forward pair drifted off the \
21963 substrate-primitive as_str accessor"
21964 );
21965 assert_eq!(
21966 <super::DepList as TryFrom<Vec<u8>>>::try_from(owned_forward.clone()),
21967 Ok(variant),
21968 "Four-corner round-trip on DepList::{variant:?} \
21969 through From<DepList> for Vec<u8> then \
21970 TryFrom<Vec<u8>> for DepList must return \
21971 Ok(variant) — divergence signals the byte-owned \
21972 forward pair and the byte-owned reverse axis have \
21973 drifted apart"
21974 );
21975 assert_eq!(
21976 <super::DepList as TryFrom<Vec<u8>>>::try_from(borrowed_forward),
21977 Ok(variant),
21978 "Four-corner round-trip on DepList::{variant:?} \
21979 through From<&DepList> for Vec<u8> then \
21980 TryFrom<Vec<u8>> for DepList must return \
21981 Ok(variant) — divergence signals the borrowed-input \
21982 forward corner and the owned-input reverse corner \
21983 have drifted apart"
21984 );
21985 }
21986 }
21987
21988 #[test]
21989 fn dep_list_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes() {
21990 // Rejection witness on the `impl TryFrom<Vec<u8>> for DepList`
21991 // — sweeps the same two rejection paths the sibling borrowed
21992 // `TryFrom<&[u8]>` axis collapses onto the single unit-error
21993 // return: the invalid-UTF-8 rejection path (`std::str::from_utf8`
21994 // on the underlying byte-slice returns `Err` before
21995 // [`super::DepList::from_wire`] runs) and the valid-UTF-8-
21996 // but-unknown-wire rejection path
21997 // ([`super::DepList::from_wire`] returns `None` on a byte-
21998 // string outside the two-arm `:`-prefixed kebab-case accept-
21999 // set). Both must reject so a future accidental widening of
22000 // the trait impl's accept-set (a case-fold path, a silent
22001 // acceptance of a `":packages"` rebrand alias, a
22002 // `#[serde(rename_all = "…")]` attribute drift that widens
22003 // the parse arm-set silently, a stray `String::from_utf8_lossy`
22004 // detour that widens the input surface with the U+FFFD
22005 // replacement character, an `Option::unwrap_or_default`-shape
22006 // fallback that maps invalid UTF-8 onto a default arm rather
22007 // than the trait-idiomatic `Err(())`) trips at caixa-core test
22008 // time. Peer of the sibling first-mover
22009 // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
22010 // (99c2849) on the [`crate::CaixaKind`] peer and the sibling
22011 // second-mover
22012 // [`crate::dialeto::tests::caixa_dialeto_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
22013 // (83a1526) on the [`crate::CaixaDialeto`] peer.
22014 let non_utf8_rejected: &[&[u8]] = &[
22015 &[0xFF],
22016 &[0x80],
22017 &[0xC3],
22018 &[0xFF, 0xFE],
22019 &[0xED, 0xA0, 0x80], // UTF-16 surrogate half — rejected by UTF-8
22020 ];
22021 for &input in non_utf8_rejected {
22022 let owned: Vec<u8> = input.to_vec();
22023 assert_eq!(
22024 <super::DepList as TryFrom<Vec<u8>>>::try_from(owned),
22025 Err(()),
22026 "TryFrom<Vec<u8>> impl on DepList must reject the \
22027 non-UTF-8 byte-sequence {input:?} with Err(()) — \
22028 silent acceptance signals the UTF-8 validation path \
22029 collapsed onto a default arm rather than the trait-\
22030 idiomatic unit-error"
22031 );
22032 // Cross-axis witness: the owned-input axis must agree with
22033 // the borrowed-input axis on every rejected input.
22034 assert_eq!(
22035 <super::DepList as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
22036 <super::DepList as TryFrom<&[u8]>>::try_from(input),
22037 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
22038 axes on DepList must agree on the non-UTF-8 input \
22039 {input:?} — divergence signals the owned-input and \
22040 borrowed-input byte-view reverse paths have drifted \
22041 off the same substrate-primitive from_wire accessor"
22042 );
22043 }
22044 // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
22045 // string, whitespace-only forms, case-folded variants of
22046 // accepted arms, the un-`:`-prefixed bare-kebab
22047 // ("deps"/"deps-dev") the sibling
22048 // [`super::DepList::from_wire`] doc block flags as a
22049 // `:`-prefix-discipline hazard, plausible rebrand aliases the
22050 // sibling `dep_list_try_from_str_rejects_unknown_byte_strings`
22051 // rejection witness already pins on the str-view reverse
22052 // axis, and whitespace-padded / quoted forms.
22053 let unknown_wire_rejected: &[&[u8]] = &[
22054 b"",
22055 b" ",
22056 b"\t",
22057 b"\n",
22058 b":deps ",
22059 b" :deps",
22060 b":DEPS",
22061 b":Deps",
22062 b":Deps-Dev",
22063 b":deps_dev",
22064 b":deps-development",
22065 b":dev-deps",
22066 b":packages",
22067 b":packages-dev",
22068 b"deps",
22069 b"deps-dev",
22070 b"Prod",
22071 b"Dev",
22072 b"prod",
22073 b"dev",
22074 b"\":deps\"",
22075 b"\":deps-dev\"",
22076 b":deps\n",
22077 b":deps-dev\n",
22078 ];
22079 for &input in unknown_wire_rejected {
22080 let owned: Vec<u8> = input.to_vec();
22081 assert_eq!(
22082 <super::DepList as TryFrom<Vec<u8>>>::try_from(owned),
22083 Err(()),
22084 "TryFrom<Vec<u8>> impl on DepList must reject the \
22085 valid-UTF-8-but-unknown-wire byte-string {input:?} \
22086 with Err(()) — silent acceptance signals an accept-\
22087 set widening off the paired DepList::from_wire \
22088 resolver"
22089 );
22090 // Cross-axis witness against the borrowed byte-view axis:
22091 // the two paths must agree by construction, since the owned
22092 // axis delegates to the borrowed peer.
22093 assert_eq!(
22094 <super::DepList as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
22095 <super::DepList as TryFrom<&[u8]>>::try_from(input),
22096 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
22097 axes on DepList must agree on the valid-UTF-8-but-\
22098 unknown-wire input {input:?} — divergence signals \
22099 the owned-input and borrowed-input byte-view reverse \
22100 paths have drifted off the same substrate-primitive \
22101 from_wire accessor"
22102 );
22103 }
22104 }
22105
22106 #[test]
22107 fn dep_list_try_from_owned_string_routes_through_borrowed_str_view_axis() {
22108 // Fail-before-pass-after byte-parity pin on the newly lifted
22109 // `impl TryFrom<String> for DepList` — asserts the trait-
22110 // idiomatic string-owned reverse-projection standard-library
22111 // impl and the sibling borrowed-input [`TryFrom<&str>`] axis
22112 // resolve to the same two-arm `:`-prefixed kebab-case wire
22113 // accept-set across every arm the exhaustive
22114 // [`super::DepList::ALL`] slice enumerates. Closes the
22115 // substrate-wide trait-idiomatic string-owned reverse-projection
22116 // family onto the third caixa-core-internal closed-set fieldless
22117 // typed-enum peer — owned-input mirror of the paired
22118 // [`TryFrom<&str>`] str-view reverse-projection axis, and
22119 // string-owned reverse companion of the pre-existing string-
22120 // owned *forward*-projection pair ([`From<super::DepList> for
22121 // String`], [`From<&super::DepList> for String`]) on this same
22122 // enum. Peer of the sibling first-mover
22123 // [`crate::aplicacao::tests::rate_limit_try_from_owned_string_routes_through_borrowed_str_view_axis`]
22124 // (a2e6f02) on the compound [`crate::aplicacao::RateLimit`]
22125 // primitive, and the sibling
22126 // `caixa_kind_try_from_owned_string_routes_through_borrowed_str_view_axis`
22127 // (e7df24f) / `caixa_dialeto_try_from_owned_string_routes_through_borrowed_str_view_axis`
22128 // (9e07f5c) closed-set typed-enum peers — tracks the "delegate
22129 // through `TryFrom<&str>` on the `String::as_str` borrow"
22130 // discipline the compound-primitive opener and closed-set-peer
22131 // first-mover established. This closes the string-owned
22132 // reverse-projection axis on the third and last caixa-core-
22133 // internal closed-set fieldless typed-enum peer, mirroring the
22134 // trajectory the byte-view (b8f25d5) / byte-owned (42091cb) /
22135 // str-view reverse-projection families already walked on this
22136 // same enum.
22137 for &variant in super::DepList::ALL {
22138 let wire_string: String = variant.as_str().to_string();
22139 assert_eq!(
22140 <super::DepList as TryFrom<String>>::try_from(wire_string.clone()),
22141 Ok(variant),
22142 "TryFrom<String> impl on DepList must round-trip \
22143 DepList::{variant:?}.as_str().to_string() back to \
22144 Ok(DepList::{variant:?}) — divergence from the \
22145 sibling TryFrom<&str> axis signals a silent detour \
22146 off the substrate-primitive from_wire accessor"
22147 );
22148 // Cross-axis witness: the string-owned reverse-projection
22149 // axis must agree with the borrowed `&str` reverse-projection
22150 // axis on every accepted arm — the two axes share one
22151 // `:`-prefixed kebab-case wire vocabulary through the
22152 // substrate-primitive `from_wire` accessor, and the owned-
22153 // input axis delegates to the borrowed peer by design.
22154 let via_owned: Result<super::DepList, ()> =
22155 <super::DepList as TryFrom<String>>::try_from(wire_string.clone());
22156 let via_borrowed: Result<super::DepList, ()> =
22157 <super::DepList as TryFrom<&str>>::try_from(wire_string.as_str());
22158 assert_eq!(
22159 via_owned, via_borrowed,
22160 "TryFrom<String> and TryFrom<&str> reverse-projection \
22161 axes on DepList must agree on DepList::{variant:?} — \
22162 divergence signals the owned-`String` and borrowed-\
22163 `&str` reverse paths have drifted off the same \
22164 substrate-primitive from_wire accessor"
22165 );
22166 // Cross-axis witness against the paired byte-view reverse-
22167 // projection axis ([`TryFrom<&[u8]>`]) — the four reverse
22168 // paths share one substrate primitive.
22169 let via_byte_slice: Result<super::DepList, ()> =
22170 <super::DepList as TryFrom<&[u8]>>::try_from(wire_string.as_bytes());
22171 assert_eq!(
22172 via_owned, via_byte_slice,
22173 "TryFrom<String> and TryFrom<&[u8]> reverse-projection \
22174 axes on DepList must agree on DepList::{variant:?} — \
22175 divergence signals the string-owned and byte-view \
22176 borrowed reverse paths have drifted off the same \
22177 substrate-primitive from_wire accessor"
22178 );
22179 // Cross-axis witness against the sibling byte-owned
22180 // reverse-projection axis ([`TryFrom<Vec<u8>>`]) — the two
22181 // owned-input axes share one `:`-prefixed kebab-case wire
22182 // vocabulary.
22183 let via_byte_vec: Result<super::DepList, ()> =
22184 <super::DepList as TryFrom<Vec<u8>>>::try_from(wire_string.as_bytes().to_vec());
22185 assert_eq!(
22186 via_owned, via_byte_vec,
22187 "TryFrom<String> and TryFrom<Vec<u8>> reverse-\
22188 projection axes on DepList must agree on \
22189 DepList::{variant:?} — divergence signals the string-\
22190 owned and byte-owned reverse paths have drifted off \
22191 the same substrate-primitive from_wire accessor"
22192 );
22193 // Four-corner witness: because [`super::DepList`] carries
22194 // no wire-vs-diagnostic split (as_str and from_wire share
22195 // one `:`-prefixed kebab-case byte-vocabulary), the string-
22196 // owned reverse-projection axis on this enum *does* round-
22197 // trip against the paired string-owned forward-projection
22198 // pair. Pin every corner of the {owned-input, borrowed-
22199 // input} × {`From<Self> → String`, `From<&Self> → String`}
22200 // square onto the same Ok(variant) return so a future
22201 // accident that drops one corner off the substrate-
22202 // primitive accessor trips here. Mirror of the peer four-
22203 // corner witness the sibling
22204 // [`dep_list_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
22205 // (42091cb) pins on the byte-owned reverse axis, and the
22206 // [`crate::dialeto::tests::caixa_dialeto_try_from_owned_string_routes_through_borrowed_str_view_axis`]
22207 // (9e07f5c) pins on the peer closed-set enum.
22208 let owned_forward: String = <String as From<super::DepList>>::from(variant);
22209 let borrowed_forward: String = <String as From<&super::DepList>>::from(&variant);
22210 assert_eq!(
22211 owned_forward, wire_string,
22212 "From<DepList> for String forward projection on \
22213 DepList::{variant:?} must byte-equal \
22214 variant.as_str().to_string() — divergence signals \
22215 the paired forward pair drifted off the substrate-\
22216 primitive as_str accessor"
22217 );
22218 assert_eq!(
22219 borrowed_forward, wire_string,
22220 "From<&DepList> for String forward projection on \
22221 &DepList::{variant:?} must byte-equal \
22222 variant.as_str().to_string() — divergence signals \
22223 the paired forward pair drifted off the substrate-\
22224 primitive as_str accessor"
22225 );
22226 assert_eq!(
22227 <super::DepList as TryFrom<String>>::try_from(owned_forward.clone()),
22228 Ok(variant),
22229 "Four-corner round-trip on DepList::{variant:?} \
22230 through From<DepList> for String then \
22231 TryFrom<String> for DepList must return Ok(variant) \
22232 — divergence signals the string-owned forward pair \
22233 and the string-owned reverse axis have drifted apart"
22234 );
22235 assert_eq!(
22236 <super::DepList as TryFrom<String>>::try_from(borrowed_forward),
22237 Ok(variant),
22238 "Four-corner round-trip on DepList::{variant:?} \
22239 through From<&DepList> for String then \
22240 TryFrom<String> for DepList must return Ok(variant) \
22241 — divergence signals the borrowed-input forward \
22242 corner and the owned-input reverse corner have \
22243 drifted apart"
22244 );
22245 }
22246 }
22247
22248 #[test]
22249 fn dep_list_try_from_owned_string_rejects_unknown_wire_strings() {
22250 // Rejection witness on the `impl TryFrom<String> for DepList`
22251 // — mirrors the rejection corpus the paired borrowed
22252 // [`TryFrom<&str>`] and owned [`TryFrom<Vec<u8>>`] axes
22253 // already pin on the owned-`String` surface. Every non-`:`-
22254 // prefixed-kebab-case byte-string must land on `Err(())` so a
22255 // future accidental widening of the trait impl's accept-set
22256 // (a stray `_ if s.eq_ignore_ascii_case(":Deps") => Ok(…)`
22257 // case-fold path, a silent inclusion of a rebrand alias like
22258 // `":packages"`, an English rebrand `":dev-deps"` in reverse
22259 // arm-order that would silently swap the two arms, a stray
22260 // `Option::unwrap_or_default`-shape fallback that maps unknown
22261 // inputs onto a default arm rather than the trait-idiomatic
22262 // `Err(())`) trips at caixa-core test time. Sweep mirrors the
22263 // sibling `dep_list_try_from_str_rejects_unknown_byte_strings`
22264 // (b8f25d5) and `dep_list_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`
22265 // (42091cb) rejection witnesses on the parallel str-view and
22266 // byte-owned reverse-projection axes.
22267 let rejected: &[&str] = &[
22268 "",
22269 " ",
22270 "\t",
22271 "\n",
22272 ":deps ",
22273 " :deps",
22274 ":DEPS",
22275 ":Deps",
22276 ":Deps-Dev",
22277 ":deps_dev",
22278 ":deps-development",
22279 ":dev-deps",
22280 ":packages",
22281 ":packages-dev",
22282 "deps",
22283 "deps-dev",
22284 "Prod",
22285 "Dev",
22286 "prod",
22287 "dev",
22288 "\":deps\"",
22289 "\":deps-dev\"",
22290 ":deps\n",
22291 ":deps-dev\n",
22292 ];
22293 for &input in rejected {
22294 let owned: String = input.to_string();
22295 assert_eq!(
22296 <super::DepList as TryFrom<String>>::try_from(owned),
22297 Err(()),
22298 "TryFrom<String> impl on DepList must reject the \
22299 non-wire byte-string {input:?} with Err(()) — silent \
22300 acceptance signals an accept-set widening off the \
22301 paired DepList::from_wire resolver"
22302 );
22303 // Cross-axis witness: the owned-`String` axis must agree
22304 // with the borrowed-`&str` axis on every rejected input —
22305 // the two paths share one substrate-primitive resolver by
22306 // construction.
22307 assert_eq!(
22308 <super::DepList as TryFrom<String>>::try_from(input.to_string()),
22309 <super::DepList as TryFrom<&str>>::try_from(input),
22310 "TryFrom<String> and TryFrom<&str> reverse-projection \
22311 axes on DepList must agree on the non-wire input \
22312 {input:?} — divergence signals the owned-`String` \
22313 and borrowed-`&str` reverse paths have drifted off \
22314 the same substrate-primitive from_wire accessor"
22315 );
22316 }
22317 }
22318}
22319
22320#[cfg(test)]
22321mod dep_source_is_variant_tests {
22322 use super::*;
22323
22324 fn all_variants() -> Vec<(DepSource, &'static str)> {
22325 vec![
22326 (
22327 DepSource::Git {
22328 repo: "github:pleme-io/caixa-teia".into(),
22329 tag: Some("v0.1.0".into()),
22330 rev: None,
22331 branch: None,
22332 },
22333 "Git",
22334 ),
22335 (
22336 DepSource::Path {
22337 caminho: "../caixa-teia".into(),
22338 },
22339 "Path",
22340 ),
22341 ]
22342 }
22343
22344 fn predicate_row(s: &DepSource) -> [bool; 2] {
22345 [s.is_git(), s.is_path()]
22346 }
22347
22348 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
22349 // derive-generated per-arm predicate partition — for every variant
22350 // in `all_variants()`, the observed 2-slot predicate row must equal
22351 // a one-hot row with the `true` at exactly the same index as the
22352 // variant's declaration order. Expected rows are generated live
22353 // from the enumeration rather than transcribed by hand, so a
22354 // copy-paste flip that reroutes one arm through the wrong predicate
22355 // lane trips at the identity-diagonal assertion the way every peer
22356 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
22357 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
22358 // / [`crate::upgrade::UpgradeInstruction`] /
22359 // [`crate::aplicacao::PlacementStrategy`] /
22360 // [`crate::aplicacao::RateLimitUnit`] /
22361 // [`crate::aplicacao::WitTarget`] /
22362 // [`crate::render::PathShapeViolation`] partition pin already does.
22363 #[test]
22364 fn dep_source_is_variant_predicates_partition_the_arm_set() {
22365 let variants = all_variants();
22366 for (idx, (variant, name)) in variants.iter().enumerate() {
22367 let observed = predicate_row(variant);
22368 let mut expected = [false; 2];
22369 expected[idx] = true;
22370 assert_eq!(
22371 observed, expected,
22372 "DepSource::{name} at declaration-order slot {idx} must \
22373 satisfy exactly one is_* predicate (its own); observed \
22374 row must equal the one-hot expected row — a drift \
22375 would silently reroute one `:fonte`-arm consumer \
22376 through the wrong predicate lane"
22377 );
22378 }
22379 }
22380
22381 // Byte-parity pin on the two field-agnostic `matches!` shapes the
22382 // per-arm arm-discriminator predicates replace at any future
22383 // consumer site (a `:fonte`-shape-only lint rule that flags path
22384 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
22385 // a future admission-webhook that rejects `:fonte` shapes outside
22386 // the `is_git()` accept-set, a caixa-lacre indexing pass that
22387 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
22388 // Refuses a future accidental split between the derived predicate
22389 // and its `matches!` shape — a hand-rolled shadow impl that
22390 // overrides one path, an accidental rebrand that leaves one
22391 // consumer on the raw `matches!` form — on the two load-bearing
22392 // `:fonte`-arm-discriminator axes every downstream substrate
22393 // consumer of the dep-source axis keys off.
22394 #[test]
22395 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
22396 for (variant, name) in all_variants() {
22397 let via_matches_git = matches!(variant, DepSource::Git { .. });
22398 let via_predicate_git = variant.is_git();
22399 assert_eq!(
22400 via_predicate_git, via_matches_git,
22401 "DepSource::{name}.is_git() must byte-equal \
22402 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
22403 future converged consumer site would silently \
22404 disagree with its pre-lift shape"
22405 );
22406 let via_matches_path = matches!(variant, DepSource::Path { .. });
22407 let via_predicate_path = variant.is_path();
22408 assert_eq!(
22409 via_predicate_path, via_matches_path,
22410 "DepSource::{name}.is_path() must byte-equal \
22411 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
22412 future converged consumer site would silently \
22413 disagree with its pre-lift shape"
22414 );
22415 }
22416 }
22417
22418 // Cross-pin against every constructor path that materializes a
22419 // [`DepSource`] shape today (the [`DepSource::default_github`]
22420 // resolver-side fallback that materializes an unpinned
22421 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
22422 // surface constructor that materializes a pinned `:tag`-carrying
22423 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
22424 // fixture family builds inline). Every constructor's return must
22425 // satisfy the arm-discriminator predicate the constructor's
22426 // variant name matches — a future constructor addition (an
22427 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
22428 // enclosing docstring already names as a trajectory item) surfaces
22429 // as a build-time failure that names the offending drift when its
22430 // return arm doesn't route through the paired predicate.
22431 #[test]
22432 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
22433 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
22434 assert!(
22435 via_default_github.is_git(),
22436 "DepSource::default_github must materialize a Git-arm shape — \
22437 a future constructor that routed through a non-Git arm \
22438 (a registry-fetch pin, a `DepSource::Feira` promotion) \
22439 would silently split the resolver's unpinned-shorthand \
22440 materializer from the sole_pin() precedence cascade"
22441 );
22442 assert!(
22443 !via_default_github.is_path(),
22444 "DepSource::default_github must NOT materialize a Path-arm \
22445 shape — the paired negation pin"
22446 );
22447
22448 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
22449 .fonte
22450 .expect("Dep::git materializes a Some(fonte)");
22451 assert!(
22452 via_dep_git.is_git(),
22453 "Dep::git's `:fonte` materialization must land on the Git \
22454 arm — the author-surface pinned-git constructor's return \
22455 must route through the paired predicate"
22456 );
22457 assert!(!via_dep_git.is_path(), "paired negation pin");
22458
22459 let via_path = DepSource::Path {
22460 caminho: "../caixa-teia".into(),
22461 };
22462 assert!(
22463 via_path.is_path(),
22464 "the dev-mode Path-arm materialization must satisfy is_path()"
22465 );
22466 assert!(!via_path.is_git(), "paired negation pin");
22467 }
22468
22469 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
22470 // String, reason: String }` three-slot envelope on `DepError`,
22471 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
22472 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
22473 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
22474 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
22475 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
22476 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
22477
22478 #[test]
22479 fn versao_invalid_ctor_matches_struct_literal_wrap() {
22480 assert_eq!(
22481 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
22482 DepError::VersaoInvalid {
22483 nome: "caixa-teia".to_string(),
22484 versao: "^0..1".to_string(),
22485 reason: "invalid comparator".to_string(),
22486 },
22487 "versao_invalid ctor must produce byte-equal \
22488 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
22489 );
22490 }
22491
22492 #[test]
22493 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
22494 assert_eq!(
22495 DepError::fonte_repo_shape(
22496 "caixa-teia",
22497 "-upload-pack=evil",
22498 "leading dash rejected".to_string(),
22499 ),
22500 DepError::FonteRepoShape {
22501 nome: "caixa-teia".to_string(),
22502 repo: "-upload-pack=evil".to_string(),
22503 reason: "leading dash rejected".to_string(),
22504 },
22505 "fonte_repo_shape ctor must produce byte-equal \
22506 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
22507 );
22508 }
22509
22510 #[test]
22511 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
22512 assert_eq!(
22513 DepError::caracteristica_invalid(
22514 "caixa-teia",
22515 "bad feature!",
22516 "embedded space rejected".to_string(),
22517 ),
22518 DepError::CaracteristicaInvalid {
22519 nome: "caixa-teia".to_string(),
22520 caracteristica: "bad feature!".to_string(),
22521 reason: "embedded space rejected".to_string(),
22522 },
22523 "caracteristica_invalid ctor must produce byte-equal \
22524 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
22525 );
22526 }
22527
22528 #[test]
22529 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
22530 // Cross-axis routing pin: sweep the three constructor input axes
22531 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
22532 // distinct-per-axis fixtures against every generated arm in the
22533 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
22534 // lowercase / trim / truncate on the two `&str` axes — a silent
22535 // field swap between `nome`, the middle `<axis>` field, and
22536 // `reason`, or a `reason` axis silently rerouted through
22537 // `.to_string()` instead of forwarded owned — surfaces here rather
22538 // than at a downstream diagnostic-shape mismatch. Peer of the
22539 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
22540 // through_to_string` (0e35793) cross-axis routing pin on the same
22541 // envelope's `{ nome, caminho, byte }` three-slot family and of
22542 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
22543 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
22544 // — extended here onto the `{ nome, <axis>: String, reason:
22545 // String }` three-slot envelope so every substrate-primitive ctor
22546 // family in caixa-core's `DepError` envelope guarantees each field
22547 // routes the caller's value verbatim through `.to_string()` (or
22548 // owned-forward for `reason: String`) in declared field order.
22549 // Distinct-per-axis fixtures rule out any two-axis swap
22550 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
22551 // same-fixture-per-axis pin.
22552 let nome = "sibling-teia";
22553 let axis = "distinct-axis-value";
22554 let reason = "distinct rejection sentence".to_string();
22555 assert_eq!(
22556 DepError::versao_invalid(nome, axis, reason.clone()),
22557 DepError::VersaoInvalid {
22558 nome: nome.to_string(),
22559 versao: axis.to_string(),
22560 reason: reason.clone(),
22561 },
22562 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
22563 `reason` → `reason` in declared field order",
22564 );
22565 assert_eq!(
22566 DepError::fonte_repo_shape(nome, axis, reason.clone()),
22567 DepError::FonteRepoShape {
22568 nome: nome.to_string(),
22569 repo: axis.to_string(),
22570 reason: reason.clone(),
22571 },
22572 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
22573 `reason` → `reason` in declared field order",
22574 );
22575 assert_eq!(
22576 DepError::caracteristica_invalid(nome, axis, reason.clone()),
22577 DepError::CaracteristicaInvalid {
22578 nome: nome.to_string(),
22579 caracteristica: axis.to_string(),
22580 reason: reason.clone(),
22581 },
22582 "caracteristica_invalid must route `nome` → `nome`, \
22583 `axis` → `caracteristica`, `reason` → `reason` in declared \
22584 field order",
22585 );
22586 }
22587
22588 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
22589 // two-slot envelope on `DepError`, missing rung between
22590 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
22591 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
22592 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
22593 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
22594 // two-slot `{ nome, list: &'static str }` envelope (same slot
22595 // count, `&'static str` axis instead of owned `String` axis).
22596
22597 #[test]
22598 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
22599 assert_eq!(
22600 DepError::fonte_pin_empty("caixa-teia", ":tag"),
22601 DepError::FontePinEmpty {
22602 nome: "caixa-teia".to_string(),
22603 pin: ":tag".to_string(),
22604 },
22605 "fonte_pin_empty ctor must produce byte-equal \
22606 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
22607 on the same `(&str, &str)` fixture",
22608 );
22609 }
22610
22611 #[test]
22612 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
22613 assert_eq!(
22614 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
22615 DepError::FontePinAmbiguous {
22616 nome: "caixa-teia".to_string(),
22617 pins: ":tag, :rev".to_string(),
22618 },
22619 "fonte_pin_ambiguous ctor must produce byte-equal \
22620 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
22621 wrap on the same `(&str, &str)` fixture",
22622 );
22623 }
22624
22625 #[test]
22626 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
22627 assert_eq!(
22628 DepError::caracteristica_duplicate("caixa-teia", "http"),
22629 DepError::CaracteristicaDuplicate {
22630 nome: "caixa-teia".to_string(),
22631 caracteristica: "http".to_string(),
22632 },
22633 "caracteristica_duplicate ctor must produce byte-equal \
22634 `DepError::CaracteristicaDuplicate` to the pre-lift \
22635 struct-literal wrap on the same `(&str, &str)` fixture",
22636 );
22637 }
22638
22639 #[test]
22640 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
22641 // Owned-`String` routing pin: thread the real
22642 // `set.join(", ")` `String` carrier through the ctor's
22643 // `&str`-parameter Deref coercion, so the ambiguity-arm
22644 // wire-up site's actual `&set.join(", ")` shape stays
22645 // byte-equal to a direct `":tag, :rev"` literal. A future
22646 // parameter-shape change silently dropping the Deref
22647 // coercion route (e.g., a switch to `impl Into<String>`)
22648 // surfaces here rather than at the wire-up's compile
22649 // error far from the ctor definition.
22650 let set: Vec<&'static str> = vec![":tag", ":rev"];
22651 let joined: String = set.join(", ");
22652 assert_eq!(
22653 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
22654 DepError::FontePinAmbiguous {
22655 nome: "caixa-teia".to_string(),
22656 pins: ":tag, :rev".to_string(),
22657 },
22658 "fonte_pin_ambiguous ctor must accept an owned-`String` \
22659 `&set.join(\", \")` carrier via Deref coercion — the exact \
22660 shape the ambiguity-arm wire-up site passes into it",
22661 );
22662 }
22663
22664 #[test]
22665 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
22666 // Cross-axis routing pin: sweep the two constructor input axes
22667 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
22668 // fixtures against every generated arm in the
22669 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
22670 // trim / truncate at codegen time — a silent field swap between
22671 // `nome` and the middle `<axis>` field, or a `<axis>` axis
22672 // silently rerouted through the wrong field on any one variant
22673 // — surfaces here rather than at a downstream diagnostic-shape
22674 // mismatch. Peer of the sibling
22675 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
22676 // (6f5e0cd) pin on the same envelope's peer two-slot family
22677 // (`{ nome, list: &'static str }`) and of the sibling
22678 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
22679 // (5621f8a) pin on the same envelope's three-slot `{ nome,
22680 // <axis>: String, reason: String }` family — extended here onto
22681 // the `{ nome, <axis>: String }` two-slot envelope so the last
22682 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
22683 // ladder guarantees each field routes the caller's value
22684 // verbatim through `.to_string()` in declared field order.
22685 // Distinct-per-axis fixtures rule out any two-axis swap
22686 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
22687 // per-axis pin.
22688 let nome = "sibling-teia";
22689 let axis = "distinct-axis-value";
22690 assert_eq!(
22691 DepError::fonte_pin_empty(nome, axis),
22692 DepError::FontePinEmpty {
22693 nome: nome.to_string(),
22694 pin: axis.to_string(),
22695 },
22696 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
22697 in declared field order",
22698 );
22699 assert_eq!(
22700 DepError::fonte_pin_ambiguous(nome, axis),
22701 DepError::FontePinAmbiguous {
22702 nome: nome.to_string(),
22703 pins: axis.to_string(),
22704 },
22705 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
22706 in declared field order",
22707 );
22708 assert_eq!(
22709 DepError::caracteristica_duplicate(nome, axis),
22710 DepError::CaracteristicaDuplicate {
22711 nome: nome.to_string(),
22712 caracteristica: axis.to_string(),
22713 },
22714 "caracteristica_duplicate must route `nome` → `nome`, \
22715 `axis` → `caracteristica` in declared field order",
22716 );
22717 }
22718
22719 #[test]
22720 fn nome_invalid_ctor_matches_struct_literal_wrap() {
22721 // Equivalence pin: the ctor produces byte-equal
22722 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
22723 // literal that cloned the offending `:deps :nome` verbatim and
22724 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
22725 // owned `reason` payload at the caller site inside
22726 // [`Dep::validate`]. Guards any future field-addition /
22727 // reordering / accessor-return tweak on the variant. Sibling of
22728 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
22729 // (below) and the sibling three-slot
22730 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
22731 // pin on the same envelope's three-slot `{ nome, <axis>: String,
22732 // reason: String }` family.
22733 let nome = "Caixa-Teia";
22734 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
22735 let via_ctor = DepError::nome_invalid(nome, reason.clone());
22736 let via_literal = DepError::NomeInvalid {
22737 nome: nome.to_string(),
22738 reason,
22739 };
22740 assert_eq!(
22741 via_ctor, via_literal,
22742 "nome_invalid(nome, reason) must byte-equal the open-coded \
22743 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
22744 );
22745 assert_eq!(
22746 via_ctor.to_string(),
22747 via_literal.to_string(),
22748 "Display byte-string must byte-equal the open-coded struct-literal"
22749 );
22750 }
22751
22752 #[test]
22753 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
22754 // Boundary-sweep pin on the ctor's two-slot projection: sweep
22755 // the two ctor input axes (`nome: &str`, `reason: String`)
22756 // through distinct-per-axis fixtures against a representative
22757 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
22758 // wrapper-side silent lowercase / trim / truncate at codegen
22759 // time — a silent field swap between `nome` and `reason`, an
22760 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
22761 // divergence on the `reason` axis — surfaces at caixa-core
22762 // build time rather than at a downstream diagnostic consumer
22763 // that reads `err.nome` / `err.reason` back and gets a different
22764 // value than the one it stored. Peer of the sibling
22765 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
22766 // (7f7c950) pin on the same envelope's peer two-slot family
22767 // (`{ nome, <axis>: String }`) — extended here onto the
22768 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
22769 // variant carries. Distinct-per-axis fixtures rule out any
22770 // two-axis swap (`nome` ↔ `reason`) that would still pass a
22771 // same-fixture-per-axis pin. The sweep list carries a mixed
22772 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
22773 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
22774 // over-63-byte) so a future silent per-input normalization
22775 // surfaces on the arm that diverges.
22776 for nome in [
22777 "Caixa-Teia",
22778 "caixa_teia",
22779 "caixa.teia",
22780 "-caixa-teia",
22781 "caixa-teia-",
22782 "caixa/teia",
22783 &"a".repeat(64),
22784 ] {
22785 let reason = crate::render::is_dns_1123_label(nome)
22786 .expect_err("fixture must be a DNS-1123-refused label");
22787 let via_ctor = DepError::nome_invalid(nome, reason.clone());
22788 let DepError::NomeInvalid {
22789 nome: stored_nome,
22790 reason: stored_reason,
22791 } = via_ctor
22792 else {
22793 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
22794 };
22795 assert_eq!(
22796 stored_nome, nome,
22797 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
22798 );
22799 assert_eq!(
22800 stored_reason, reason,
22801 "reason slot must forward the owned `String` verbatim for {nome:?}"
22802 );
22803 }
22804 }
22805
22806 #[test]
22807 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
22808 // End-to-end pin: the sole in-crate wire-up site
22809 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
22810 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
22811 // the ctor's output on the same DNS-1123-refused `:deps :nome`
22812 // fixture, with identical `Display` rendering. A future silent
22813 // de-lift of the wire-up back to the open-coded struct-literal
22814 // trips this test at caixa-core build time rather than at a
22815 // downstream diagnostic consumer far from the wire-up commit.
22816 // Sibling of the peer
22817 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
22818 // pin on the same wire-up — extended here from a `matches!`
22819 // shape check to a byte-identity + Display parity route through
22820 // the ctor.
22821 let d = Dep::simple("Caixa_Teia", "^0.1");
22822 let observed = d.validate().unwrap_err();
22823 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
22824 .expect_err("fixture must be DNS-1123-refused");
22825 let expected = DepError::nome_invalid("Caixa_Teia", reason);
22826 assert_eq!(
22827 observed, expected,
22828 "Dep::validate's DNS-1123 refusal arm must byte-equal \
22829 nome_invalid(nome, reason)"
22830 );
22831 assert_eq!(
22832 observed.to_string(),
22833 expected.to_string(),
22834 "Display byte-string parity"
22835 );
22836 }
22837}