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/// Errors raised by [`Dep::validate`].
4850///
4851/// Mirrors the per-axis error families the other `:versao`-carrying
4852/// typed surfaces expose
4853/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4854/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4855/// [`crate::SupervisorError::EmptyChildVersion`] /
4856/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4857/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4858#[derive(Debug, Error, PartialEq, Eq)]
4859pub enum DepError {
4860 #[error(
4861 ":deps entry has empty :nome (every dep must name a target caixa; \
4862 omit the entry instead of carrying an empty name)"
4863 )]
4864 NomeEmpty,
4865 #[error(
4866 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4867 (the value flows verbatim as the target caixa's `:nome`, the rendered \
4868 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4869 value, and the resolver's checkout-directory leaf — each apiserver-side \
4870 schema rejects non-DNS-1123 names at admission time; use a lowercase \
4871 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4872 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4873 )]
4874 NomeInvalid { nome: String, reason: String },
4875 #[error(
4876 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4877 constraint that resolves through the lacre pipeline)"
4878 )]
4879 VersaoEmpty { nome: String },
4880 #[error(
4881 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4882 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4883 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4884 and `:children :versao` carry; the lacre pipeline resolves all three \
4885 through the same parser)"
4886 )]
4887 VersaoInvalid {
4888 nome: String,
4889 versao: String,
4890 reason: String,
4891 },
4892 #[error(
4893 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4894 (every git source must name a repo — use a `github:org/repo` \
4895 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4896 entire :fonte block to fall back to the default-host resolver \
4897 convention)"
4898 )]
4899 FonteRepoEmpty { nome: String },
4900 #[error(
4901 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4902 invalid value-shape: {reason} (the value flows verbatim into the \
4903 caixa-resolver's `git clone <repo>` subprocess invocation; every \
4904 documented form carries a `:` separator and no whitespace / \
4905 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4906 an `https://host/path` / `ssh://[user@]host/path` / \
4907 `git://host/path` / `file:///path` URL, or the `git@host:path` \
4908 scp-style SSH form)"
4909 )]
4910 FonteRepoShape {
4911 nome: String,
4912 repo: String,
4913 reason: String,
4914 },
4915 #[error(
4916 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4917 (set exactly one of :tag, :rev, or :branch so the resolver \
4918 can pick a reproducible commit; omit the entire :fonte block \
4919 to fall back to the default-host resolver convention, which \
4920 resolves the latest tag matching :versao)"
4921 )]
4922 FontePinMissing { nome: String },
4923 #[error(
4924 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4925 set ({pins}); exactly one of :tag, :rev, or :branch must be \
4926 set so the resolver's checkout target is unambiguous (the \
4927 resolver's silent precedence is :rev > :tag > :branch — if \
4928 you intended one specifically, drop the others)"
4929 )]
4930 FontePinAmbiguous { nome: String, pins: String },
4931 #[error(
4932 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4933 (a set pin must name a non-empty git ref; drop the {pin} key \
4934 entirely to fall through to another pin axis)"
4935 )]
4936 FontePinEmpty { nome: String, pin: String },
4937 #[error(
4938 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4939 value-shape: {reason} (the git porcelain enforces the same shape at \
4940 `git fetch` / `git checkout` time on every pin; use a leaf refname \
4941 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4942 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4943 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4944 prepends at clone time, and avoid abbreviated SHAs which are \
4945 ambiguous across repository history)"
4946 )]
4947 FontePinShape {
4948 nome: String,
4949 pin: String,
4950 value: String,
4951 reason: String,
4952 },
4953 #[error(
4954 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4955 (every path source must name a non-empty filesystem path; \
4956 omit the entire :fonte block to fall back to the default-host \
4957 resolver convention)"
4958 )]
4959 FonteCaminhoEmpty { nome: String },
4960 #[error(
4961 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4962 absolute (the lacre pipeline embeds the value verbatim in its \
4963 per-dep content-address `path:{caminho}` at \
4964 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4965 BLAKE3 closure differ across machines — defeating the \
4966 reproducibility contract that's load-bearing for CSE; express \
4967 the path relative to the caixa.lisp location, e.g. \
4968 \"../caixa-teia\" for a sibling workspace dep)"
4969 )]
4970 FonteCaminhoAbsolute { nome: String, caminho: String },
4971 #[error(
4972 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4973 with `~` (the leading-tilde is a shell-expansion convention, not a \
4974 POSIX path component — `Path::is_absolute` returns false on it, so \
4975 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4976 pipeline embeds the value verbatim in its per-dep content-address \
4977 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4978 caixa-resolver folds it through `Path::join` without `~`-expansion, \
4979 so the build looks for a literal `./{caminho}` subdirectory and \
4980 fails at resolve time far from the source caixa.lisp; even worse, a \
4981 future caixa-resolver pass that *does* expand `~` would silently \
4982 re-open the host-layout-leak the b94fd83 absolute gate closes — \
4983 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4984 runners with different `$HOME` layouts resolve to two distinct paths \
4985 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4986 determinism contract; express the path relative to the caixa.lisp \
4987 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4988 spell out the full relative path explicitly if a workstation-rooted \
4989 dep is genuinely intended)"
4990 )]
4991 FonteCaminhoTildeExpansion { nome: String, caminho: String },
4992 #[error(
4993 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4994 with `$` (the leading-`$` is a shell-variable-expansion convention, \
4995 not a POSIX path component — `Path::is_absolute` returns false on it \
4996 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4997 embeds the value verbatim in its per-dep content-address \
4998 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4999 caixa-resolver folds it through `Path::join` without `$`-expansion, \
5000 so the build looks for a literal `./{caminho}` subdirectory and \
5001 fails at resolve time far from the source caixa.lisp; even worse, a \
5002 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
5003 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
5004 invites) would silently re-open the host-layout-leak the b94fd83 \
5005 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
5006 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
5007 layouts resolve to two distinct paths for the byte-identical caixa, \
5008 defeating the THEORY.md §V.2 render-determinism contract; express \
5009 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
5010 for a sibling workspace dep, or spell out the full relative path \
5011 explicitly if a workstation-rooted dep is genuinely intended)"
5012 )]
5013 FonteCaminhoVarExpansion { nome: String, caminho: String },
5014 #[error(
5015 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5016 with a space (the leading ASCII space `0x20` is the orthogonal \
5017 paste-from-aligned-doc footgun that silently passes \
5018 `Path::is_absolute` and every prior leading-byte arm — \
5019 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
5020 `./ ../caixa-teia` subdirectory the resolver fails to find at \
5021 resolve time with a non-self-locating `No such file or directory` \
5022 error far from the source caixa.lisp; the lacre pipeline embeds \
5023 the value verbatim in its per-dep content-address `path:{caminho}` \
5024 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
5025 semantic-identical caixa values (` ../caixa-teia` vs \
5026 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
5027 workstations whose authors differ only in paste-from-aligned- \
5028 caixa.lisp-doc whitespace habits — the most insidious failure \
5029 mode the typed slot can carry (no error surfaces; the divergence \
5030 is invisible until two machines compare lacres), defeating the \
5031 THEORY.md §V.2 render-determinism contract. The canonical \
5032 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
5033 a multi-entry `:deps` block sits at the same column — an author \
5034 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
5035 the rendered alignment into a fresh entry preserves the leading \
5036 whitespace verbatim); peer `:fonte :repo` axis already rejects \
5037 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
5038 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
5039 `is_chart_description_shape`, `:licenca` via \
5040 `is_spdx_expression_shape`. Drop the leading space; express the \
5041 path as a bare relative single-token like \"../caixa-teia\")"
5042 )]
5043 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
5044 #[error(
5045 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
5046 with `-` (the canonical CLI-argument-injection footgun on the \
5047 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
5048 its per-dep content-address `path:{caminho}` at \
5049 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
5050 through `Path::join` looking for a literal `./{caminho}` \
5051 subdirectory. Every downstream subprocess that consumes the resolved \
5052 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
5053 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
5054 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
5055 value as a CLI flag rather than a positional path when the invocation \
5056 does not carry a `--` argument-list terminator between the flag block \
5057 and the path (the common case at every porcelain entry point). The \
5058 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
5059 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
5060 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
5061 CLI-arg-injection vector at every git porcelain entry point that \
5062 consumes a path or URL argument, peer with is_git_repo_url's \
5063 leading-`-` arm on the sibling `:fonte :repo` axis), \
5064 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
5065 POSIX `std::path::Path` treats a leading `-` as a literal filename \
5066 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
5067 for a literal `./-rf` subdirectory that fails at resolve time with a \
5068 non-self-locating `No such file or directory` error far from the \
5069 source caixa.lisp — but on any downstream shell-out without `--` the \
5070 reinterpretation is silent and the failure mode is arbitrary-\
5071 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
5072 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
5073 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
5074 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
5075 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
5076 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
5077 `:children :caixa`, `:deps :nome`, cluster names); \
5078 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
5079 the feira `init` / `add <nome>` positional gate (868c191) rejects \
5080 leading `-` on the CLI positional itself. Express the path as a bare \
5081 relative single-token like \"../caixa-teia\" — the sibling-workspace \
5082 directory name carries no leading-hyphen semantic, and `./` / `../` \
5083 prefixes structurally partition the leading-byte set to safe values.)"
5084 )]
5085 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
5086 #[error(
5087 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
5088 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
5089 every `std::fs` syscall routes the path through `CString::new` which \
5090 fails with `NulError` at resolve time; the lacre pipeline embeds the \
5091 value verbatim in its per-dep content-address `path:{caminho}` at \
5092 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
5093 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
5094 determinism contract — the canonical paste-from-multiline-doc \
5095 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
5096 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
5097 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
5098 already gates against. Express the path as a relative single-line ASCII \
5099 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
5100 )]
5101 FonteCaminhoControlChar {
5102 nome: String,
5103 caminho: String,
5104 byte: u8,
5105 },
5106 #[error(
5107 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
5108 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
5109 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
5110 not the parent's sibling — and the caixa-resolver folds the value through \
5111 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
5112 resolve time with a non-self-locating `No such file or directory` error far \
5113 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
5114 primary path separator equal to `/`, so byte-identical caixa.lisp values \
5115 resolve to two distinct directories across runner OSes — the lacre pipeline \
5116 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5117 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
5118 determinism contract via the cross-host-OS-separator divergence vector. The \
5119 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
5120 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
5121 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
5122 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
5123 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
5124 \"../caixa-teia\" for a sibling workspace dep)"
5125 )]
5126 FonteCaminhoBackslash { nome: String, caminho: String },
5127 #[error(
5128 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5129 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
5130 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
5131 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
5132 paste-from-shell-pipeline footgun where an author copies a `command > log` \
5133 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
5134 as literal path-component bytes, so the resolver folds the value through \
5135 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5136 subdirectory and fails at resolve time with a non-self-locating `No such \
5137 file or directory` error far from the source caixa.lisp. The lacre pipeline \
5138 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
5139 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
5140 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5141 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5142 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
5143 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
5144 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
5145 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
5146 RFC-3986-reserved set. Express the path as a bare relative single-token like \
5147 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5148 redirection semantic.",
5149 ch = *byte as char
5150 )]
5151 FonteCaminhoShellRedirection {
5152 nome: String,
5153 caminho: String,
5154 byte: u8,
5155 },
5156 #[error(
5157 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
5158 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
5159 `|` as the pipe operator that wires one command's stdout to the next command's \
5160 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
5161 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
5162 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
5163 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
5164 treats `|` as a literal path-component byte, so the resolver folds the value \
5165 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5166 subdirectory and fails at resolve time with a non-self-locating `No such file or \
5167 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
5168 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
5169 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
5170 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
5171 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
5172 subprocess-argument / shell-metachar injection surface every peer single-token-\
5173 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
5174 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5175 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5176 workspace directory name carries no shell-pipe semantic."
5177 )]
5178 FonteCaminhoShellPipe { nome: String, caminho: String },
5179 #[error(
5180 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5181 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
5182 / nushell — lexes `;` as the sequential-command terminator that fires the next \
5183 command regardless of the prior command's exit status, so `:caminho \
5184 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
5185 footgun where an author copies a `cd path; do-thing` chain without trimming \
5186 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
5187 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
5188 literal path-component byte, so the resolver folds the value through \
5189 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5190 subdirectory and fails at resolve time with a non-self-locating `No such file \
5191 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5192 the value verbatim in its per-dep content-address `path:{caminho}` at \
5193 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5194 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5195 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
5196 canonical shell-metachar injection surface every peer single-token-shaped \
5197 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
5198 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
5199 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5200 workspace directory name carries no shell-command-separator semantic."
5201 )]
5202 FonteCaminhoShellSemicolon { nome: String, caminho: String },
5203 #[error(
5204 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5205 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
5206 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
5207 terminator detaching the prior command and returning control immediately to \
5208 the prompt, double `&&` as the logical-AND list operator firing the next \
5209 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
5210 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
5211 sleep 1` background-launch one-liner or a `cd path && make install` build-\
5212 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
5213 05c358e closed the sequential-command-separator vector, this arm closes the \
5214 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
5215 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
5216 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5217 byte lands in the BLAKE3 closure and rides into every shell-spawned \
5218 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5219 future operator-side `nix` spawn) as the canonical shell-metachar injection \
5220 surface every peer single-token-shaped typed slot already closes. The peer \
5221 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
5222 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
5223 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
5224 shell-background / logical-AND semantic."
5225 )]
5226 FonteCaminhoShellBackground { nome: String, caminho: String },
5227 #[error(
5228 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5229 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
5230 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
5231 wrapper that runs the enclosed command and substitutes its standard-output \
5232 verbatim into the surrounding word, so a backticked `whoami` expands to the \
5233 current user's name and a backticked `cat /etc/passwd` expands to the file's \
5234 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
5235 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
5236 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
5237 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
5238 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
5239 background / logical-AND vector, this arm closes the orthogonal command-\
5240 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
5241 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
5242 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
5243 value verbatim in its per-dep content-address `path:{caminho}` at \
5244 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5245 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
5246 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5247 shell-metachar injection surface every peer single-token-shaped typed slot \
5248 already closes. The peer `:entrada :paths` axis rejects the byte via \
5249 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
5250 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5251 directory name carries no shell-command-substitution semantic."
5252 )]
5253 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
5254 #[error(
5255 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5256 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
5257 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
5258 expansion wildcards: `*` matches any sequence of characters in a path component \
5259 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
5260 canonical paste-from-shell-listing footgun where an author copies a \
5261 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
5262 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
5263 `std::path::Path` treats both bytes as literal path-component bytes, so the \
5264 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
5265 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
5266 locating `No such file or directory` error far from the source caixa.lisp. The \
5267 lacre pipeline embeds the value verbatim in its per-dep content-address \
5268 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
5269 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
5270 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
5271 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
5272 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
5273 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
5274 reserved set. Express the path as a bare relative single-token like \
5275 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
5276 / pathname-expansion semantic.",
5277 ch = *byte as char
5278 )]
5279 FonteCaminhoShellGlob {
5280 nome: String,
5281 caminho: String,
5282 byte: u8,
5283 },
5284 #[error(
5285 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5286 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
5287 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
5288 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
5289 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
5290 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
5291 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
5292 arm closes the leading byte of — together the two arms now structurally exclude the \
5293 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
5294 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5295 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
5296 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
5297 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
5298 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
5299 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
5300 self-locating `No such file or directory` error far from the source caixa.lisp. The \
5301 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
5302 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
5303 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5304 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5305 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
5306 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
5307 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
5308 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
5309 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
5310 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5311 subshell-grouping semantic.",
5312 ch = *byte as char
5313 )]
5314 FonteCaminhoShellSubshellGrouping {
5315 nome: String,
5316 caminho: String,
5317 byte: u8,
5318 },
5319 #[error(
5320 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5321 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
5322 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
5323 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
5324 comma-separated members and `{{1..10}}` expands to the integer range — the \
5325 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
5326 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
5327 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
5328 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
5329 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
5330 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
5331 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
5332 `std::path::Path` treats the byte as a literal path-component byte, so a \
5333 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
5334 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
5335 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
5336 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
5337 silently passes every prior arm and the resolver folds the value through \
5338 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5339 resolve time with a non-self-locating `No such file or directory` error far from \
5340 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
5341 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5342 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5343 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5344 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
5345 expansion / URI-Template-placeholder surface every peer single-token-shaped \
5346 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
5347 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
5348 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
5349 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5350 directory name carries no shell-brace-expansion / URI-Template-placeholder \
5351 semantic; if two siblings actually need pinning, author two separate `:deps` \
5352 entries rather than one brace-expanded `:caminho` value.",
5353 ch = *byte as char
5354 )]
5355 FonteCaminhoShellBraceExpansion {
5356 nome: String,
5357 caminho: String,
5358 byte: u8,
5359 },
5360 #[error(
5361 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5362 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
5363 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
5364 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
5365 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
5366 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
5367 glob every shell-history block carries; the bracket pair additionally carries the \
5368 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
5369 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
5370 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
5371 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
5372 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
5373 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
5374 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5375 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
5376 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
5377 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
5378 leak) silently passes every prior arm and the resolver folds the value through \
5379 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5380 resolve time with a non-self-locating `No such file or directory` error far from \
5381 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5382 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5383 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5384 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5385 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
5386 surface every peer single-token-shaped typed slot already closes. Express the path \
5387 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5388 directory name carries no shell-bracket-expansion / glob-character-class / array-\
5389 literal semantic; if a family of sibling caixas actually needs pinning, author \
5390 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
5391 ch = *byte as char
5392 )]
5393 FonteCaminhoShellBracketExpansion {
5394 nome: String,
5395 caminho: String,
5396 byte: u8,
5397 },
5398 #[error(
5399 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5400 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
5401 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5402 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
5403 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
5404 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
5405 every path-with-embedded-whitespace paste block carries and the symmetric \
5406 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
5407 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
5408 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
5409 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
5410 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
5411 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
5412 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
5413 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
5414 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
5415 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
5416 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
5417 production. POSIX `std::path::Path` treats the byte as a literal path-component \
5418 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
5419 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
5420 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
5421 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
5422 shape) silently passes every prior arm and the resolver folds the value through \
5423 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5424 resolve time with a non-self-locating `No such file or directory` error far from \
5425 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5426 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5427 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5428 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5429 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
5430 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5431 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
5432 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
5433 `is_git_repo_url`). Express the path as a bare relative single-token like \
5434 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
5435 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
5436 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
5437 quoting on the outer syntactic layer, so an inner quote pair would nest and \
5438 desugar to a broken layer).",
5439 ch = *byte as char
5440 )]
5441 FonteCaminhoShellQuoteGrouping {
5442 nome: String,
5443 caminho: String,
5444 byte: u8,
5445 },
5446 #[error(
5447 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5448 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
5449 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5450 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
5451 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
5452 discarding the byte and everything after it to the end of the physical line \
5453 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
5454 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
5455 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
5456 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
5457 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
5458 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
5459 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
5460 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
5461 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
5462 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
5463 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
5464 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
5465 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
5466 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
5467 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
5468 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
5469 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
5470 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
5471 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
5472 fails at resolve time with a non-self-locating `No such file or directory` \
5473 error far from the source caixa.lisp — while every downstream shell / YAML / \
5474 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
5475 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
5476 scalar disagree with the resolver on which directory the value names. The \
5477 lacre pipeline embeds the value verbatim in its per-dep content-address \
5478 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
5479 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5480 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
5481 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
5482 fragment-delimiter surface every peer single-token-shaped typed slot already \
5483 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
5484 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
5485 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5486 workspace directory name carries no shell-comment / URL-fragment / YAML-\
5487 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
5488 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
5489 and drop any `#fragment` tail entirely (fragment identifiers select \
5490 renderings, not directories, and `:caminho` names a directory).",
5491 ch = *byte as char
5492 )]
5493 FonteCaminhoShellComment {
5494 nome: String,
5495 caminho: String,
5496 byte: u8,
5497 },
5498 #[error(
5499 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
5500 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
5501 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
5502 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
5503 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
5504 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
5505 literally inside a URL value. The canonical paste-from-browser-address-bar \
5506 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
5507 encoded README hyperlink / browser address bar / percent-encoded permalink \
5508 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
5509 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
5510 what the author intended as the byte-identical sibling-workspace dep. POSIX \
5511 `std::path::Path` treats the byte as a literal path-component byte, so \
5512 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
5513 resolve time with a non-self-locating `No such file or directory` error far \
5514 from the source caixa.lisp — while every downstream URL parser / shell printf \
5515 builtin / YAML directive parser silently reinterprets the byte to a different \
5516 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
5517 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
5518 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
5519 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
5520 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
5521 recent job whose command started with `foo`\" — a future `kill %1` invocation \
5522 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
5523 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
5524 directive block cross-idiom leak); and the Windows-shell env-var-reference \
5525 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
5526 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
5527 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5528 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
5529 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5530 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
5531 printf-format-specifier / job-control-specifier surface every peer single-\
5532 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
5533 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
5534 `is_git_repo_url`). Express the path as a bare relative single-token like \
5535 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
5536 percent-encoding-escape / format-specifier / job-control semantic; substitute \
5537 any `%20` percent-encoded-space with a literal space then reject the whole \
5538 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5539 directory name never carries an embedded space in practice); drop any \
5540 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5541 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5542 ch = *byte as char
5543 )]
5544 FonteCaminhoUrlPercentEncoding {
5545 nome: String,
5546 caminho: String,
5547 byte: u8,
5548 },
5549 #[error(
5550 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5551 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5552 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5553 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5554 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5555 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5556 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5557 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5558 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5559 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5560 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5561 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5562 the byte is a first-class parser byte in nearly every config / templating / \
5563 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5564 `std::path::Path` treats the byte as a literal path-component byte, so the \
5565 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5566 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5567 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5568 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5569 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5570 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5571 subdirectory that fails at resolve time with a non-self-locating `No such file \
5572 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5573 the value verbatim in its per-dep content-address `path:{caminho}` at \
5574 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5575 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5576 time lock to two distinct BLAKE3 closures across two workstations whose \
5577 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5578 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5579 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5580 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5581 is the canonical CWE-78 shell-command-injection surface every peer single-\
5582 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5583 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5584 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5585 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5586 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5587 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5588 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5589 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5590 so every position — leading and embedded — is structurally rejected. Substitute \
5591 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5592 time, or express the path as a bare relative single-token like \
5593 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5594 variable-expansion / command-substitution / arithmetic-expansion semantic.",
5595 ch = *byte as char
5596 )]
5597 FonteCaminhoShellVariableExpansion {
5598 nome: String,
5599 caminho: String,
5600 byte: u8,
5601 },
5602 #[error(
5603 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5604 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5605 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5606 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5607 reference §9.3: `!command` re-runs the most recent history entry beginning with \
5608 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5609 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5610 and the substitution fires at every history-expansion-enabled shell context — \
5611 `set -o histexpand` is bash's default for interactive sessions and the layer \
5612 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5613 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5614 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5615 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5616 encodes it inside a query component via the 'special-query percent-encode set' \
5617 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5618 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5619 prefix — the paste-from-source-code idiom where an author copies \
5620 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5621 the string-literal boundary); the canonical English-typography emphasis / \
5622 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5623 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5624 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5625 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5626 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5627 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5628 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5629 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5630 repeat-prior-command paste idiom), the English-typography `:caminho \
5631 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5632 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5633 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5634 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5635 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5636 subdirectory that fails at resolve time with a non-self-locating `No such file \
5637 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5638 the value verbatim in its per-dep content-address `path:{caminho}` at \
5639 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5640 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5641 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5642 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5643 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5644 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5645 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5646 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5647 name carries no shell-history-expansion / bang-operator semantic; drop any \
5648 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5649 idiom; and drop any trailing English-typography exclamation mark that pasted \
5650 from prose.",
5651 ch = *byte as char
5652 )]
5653 FonteCaminhoShellHistoryExpansion {
5654 nome: String,
5655 caminho: String,
5656 byte: u8,
5657 },
5658 #[error(
5659 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5660 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5661 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5662 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5663 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5664 substitution' history operator that rewrites the prior command's `old` string to \
5665 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5666 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5667 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5668 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5669 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5670 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5671 literal value diverges from every downstream `feira tofu` curl-invocation / \
5672 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5673 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5674 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5675 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5676 `std::path::Path` treats `^` as a literal path-component byte, so \
5677 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5678 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5679 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5680 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5681 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5682 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5683 that fails at resolve time with a non-self-locating `No such file or directory` \
5684 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5685 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5686 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5687 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5688 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5689 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5690 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5691 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5692 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5693 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5694 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5695 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5696 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5697 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5698 drop any trailing `^` history-substitution-open fragment.",
5699 ch = *byte as char
5700 )]
5701 FonteCaminhoShellHistorySubstitution {
5702 nome: String,
5703 caminho: String,
5704 byte: u8,
5705 },
5706 #[error(
5707 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5708 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5709 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5710 value verbatim in its per-dep content-address `path:{caminho}` at \
5711 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5712 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5713 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5714 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5715 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5716 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5717 trailing `/`; every `:caminho` value names a sibling-workspace directory \
5718 already, so the trailing separator carries no information. Use \
5719 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5720 )]
5721 FonteCaminhoTrailingSlash { nome: String, caminho: String },
5722 #[error(
5723 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5724 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5725 apply the same set-not-multiset discipline; one package per table), and \
5726 two entries naming the same caixa carry two version constraints / source \
5727 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5728 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5729 silently overwrites the first at the resolver-side `concrete_versao` step, \
5730 and the dropped entry's pin / features never reach the closure — far from \
5731 the source caixa.lisp, with no field naming which `:deps` entry was the \
5732 silent loser. If two version constraints are genuinely needed (the rare \
5733 multi-version closure case the lacre pipeline doesn't yet support), the \
5734 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5735 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5736 )]
5737 DuplicateNome { nome: String, list: &'static str },
5738 #[error(
5739 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5740 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5741 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5742 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5743 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5744 with the canonical kebab-case feature name the target caixa declares."
5745 )]
5746 CaracteristicaEmpty { nome: String },
5747 #[error(
5748 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5749 feature name: {reason} (the value flows verbatim into Cargo's \
5750 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5751 parser enforces the same shape at `cargo metadata` time; use a single-token \
5752 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5753 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5754 an ASCII alphanumeric or `_`)"
5755 )]
5756 CaracteristicaInvalid {
5757 nome: String,
5758 caracteristica: String,
5759 reason: String,
5760 },
5761 #[error(
5762 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5763 every feature-flag list keys its entries by name (Cargo's \
5764 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5765 per feature per dep), and two entries naming the same feature are a redundant \
5766 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5767 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5768 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5769 feature once regardless of declaration count, so the duplicate's pin / position never \
5770 reaches the closure with no field naming the silent loser. One entry per feature per \
5771 dep; if two distinct features are intended, name each verbatim."
5772 )]
5773 CaracteristicaDuplicate {
5774 nome: String,
5775 caracteristica: String,
5776 },
5777 #[error(
5778 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5779 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5780 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5781 rejects mid-traversal far from the source caixa.lisp or recurses on until \
5782 it exhausts its stack). Every :nome is globally-unique substrate identity, \
5783 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5784 *is* the parent itself, not a coincidentally-named peer. Drop the \
5785 self-referential dep entry — to reference code from this caixa, use \
5786 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5787 referencing the caixa's own code surface) instead."
5788 )]
5789 DepIsSelf { nome: String, list: &'static str },
5790}
5791
5792// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5793// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5794// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5795// variant — the paired `{ nome: String, caminho: String }` two-slot family
5796// on [`DepError`], sibling of the peer
5797// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5798// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5799// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5800// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5801// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5802// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5803// `{ de, para, wit, expected }`), and
5804// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5805// variants on `{ de, para, <field>: String, reason: String }`) on the
5806// `AplicacaoError` envelopes, the peer
5807// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5808// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5809// (0419438, 4 variants on `{ caixa, kind, slots }`),
5810// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5811// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5812// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5813// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5814// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5815// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5816// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5817// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5818//
5819// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5820// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5821// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5822// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5823// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5824// CommandSubstitution}` on the four single-byte shell operators; and the
5825// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5826// opened the identical `DepError::FonteCaminho<Variant> { nome:
5827// nome.to_string(), caminho: caminho.to_string() }` four-line
5828// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5829// — the exact "same block re-inlined at every consumer" shape the PRIME
5830// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5831// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5832// families each closed on their sibling envelopes. The eleven variants
5833// share one `{ nome: String, caminho: String }` shape, so the fold routes
5834// each wire-up site through one dispatch per typed variant.
5835//
5836// The macro below generates one `#[must_use]` inherent constructor per
5837// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5838// wire-up site collapses onto one dispatch:
5839// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5840// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5841// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5842// once — inside the macro — rather than at every wire-up site.
5843//
5844// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5845// shapes at the per-byte-classification arms — the
5846// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5847// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5848// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5849// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5850// cluster — carry an additional `byte: u8` naming the offending byte and
5851// so would break the uniform-two-field routing this macro promises. They
5852// instead fold onto the sibling three-field envelope through
5853// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5854// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5855// two-slot family is the `byte: u8` classification the arms carry. The
5856// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5857// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5858// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5859// envelope.
5860//
5861// Every future consumer that wants to construct one of these eleven
5862// variants outside the current in-crate [`DepSource::validate_caminho`]
5863// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5864// at lacre-resolve time re-checking the same value-shape axes the resolver
5865// consumes, a future `feira validate --deps` per-caixa admission verb
5866// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5867// rejecting a `:caminho` value against a cluster-local snapshot) now
5868// reaches each variant through one call rather than re-inlining the
5869// four-line struct-literal in lockstep with the eleven in-crate wire-up
5870// sites.
5871macro_rules! fonte_caminho_ctors {
5872 ($($ctor:ident => $variant:ident),* $(,)?) => {
5873 impl DepError {
5874 $(
5875 #[doc = concat!(
5876 "Construct a [`DepError::",
5877 stringify!($variant),
5878 "`] naming the offending `:deps :nome` + `:fonte ",
5879 "(:tipo path …) :caminho` pair. Folds the uniform ",
5880 "`Self::",
5881 stringify!($variant),
5882 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5883 "two-slot struct-literal onto one substrate primitive so ",
5884 "every [`DepSource::validate_caminho`] wire-up on this ",
5885 "variant reads through one dispatch rather than the ",
5886 "pre-lift four-line open-coded block."
5887 )]
5888 #[must_use]
5889 pub fn $ctor(nome: &str, caminho: &str) -> Self {
5890 Self::$variant {
5891 nome: nome.to_string(),
5892 caminho: caminho.to_string(),
5893 }
5894 }
5895 )*
5896 }
5897 };
5898}
5899
5900fonte_caminho_ctors! {
5901 fonte_caminho_absolute => FonteCaminhoAbsolute,
5902 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5903 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5904 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5905 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5906 fonte_caminho_backslash => FonteCaminhoBackslash,
5907 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5908 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5909 fonte_caminho_shell_background => FonteCaminhoShellBackground,
5910 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5911 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5912}
5913
5914// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5915// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5916// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5917// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5918// three-slot family on [`DepError`], strict sibling of the peer
5919// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5920// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5921// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5922// axis broke its uniform-two-field routing — the exact "future compounding
5923// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5924// here. Third fold family on this `DepError` envelope, sibling of the peer
5925// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5926// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5927// same enum.
5928//
5929// Each of the twelve wire-up sites on this shape (the control-byte arm
5930// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5931// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5932// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5933// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5934// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5935// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5936// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5937// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5938// `FonteCaminhoShellHistoryExpansion` on `!`, and
5939// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5940// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5941// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5942// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5943// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5944// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5945// closed on the sibling two-field envelope of this same enum. The twelve
5946// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5947// the fold routes each wire-up site through one dispatch per typed variant.
5948//
5949// The macro below generates one `#[must_use]` inherent constructor per
5950// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5951// so every wire-up site collapses onto one dispatch:
5952// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5953// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5954// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5955// `byte`) is spelled once — inside the macro — rather than at every wire-up
5956// site.
5957//
5958// Every future consumer that wants to construct one of these twelve
5959// variants outside the current in-crate [`DepSource::validate_caminho`]
5960// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5961// at lacre-resolve time re-checking the same value-shape axes the resolver
5962// consumes, a future `feira validate --deps` per-caixa admission verb
5963// re-checking the `:fonte :caminho` axis against the shell-metachar
5964// classification bytes this cluster catches, a per-lacre overlay resolver
5965// rejecting a `:caminho` value against a cluster-local snapshot) now
5966// reaches each variant through one call rather than re-inlining the
5967// five-line struct-literal in lockstep with the twelve in-crate wire-up
5968// sites.
5969macro_rules! fonte_caminho_byte_ctors {
5970 ($($ctor:ident => $variant:ident),* $(,)?) => {
5971 impl DepError {
5972 $(
5973 #[doc = concat!(
5974 "Construct a [`DepError::",
5975 stringify!($variant),
5976 "`] naming the offending `:deps :nome` + `:fonte ",
5977 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5978 "classification. Folds the uniform `Self::",
5979 stringify!($variant),
5980 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5981 "byte }` three-slot struct-literal onto one substrate ",
5982 "primitive so every [`DepSource::validate_caminho`] wire-up ",
5983 "on this variant reads through one dispatch rather than ",
5984 "the pre-lift five-line open-coded block."
5985 )]
5986 #[must_use]
5987 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5988 Self::$variant {
5989 nome: nome.to_string(),
5990 caminho: caminho.to_string(),
5991 byte,
5992 }
5993 }
5994 )*
5995 }
5996 };
5997}
5998
5999fonte_caminho_byte_ctors! {
6000 fonte_caminho_control_char => FonteCaminhoControlChar,
6001 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
6002 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
6003 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
6004 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
6005 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
6006 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
6007 fonte_caminho_shell_comment => FonteCaminhoShellComment,
6008 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
6009 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
6010 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
6011 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
6012}
6013
6014// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
6015// single-slot struct-variant wire-up sites scattered across
6016// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
6017// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
6018// substrate primitive per typed variant — the paired `{ nome: String }`
6019// single-slot family on [`DepError`], sibling of the peer
6020// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
6021// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
6022// the same enum, and of the peer
6023// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
6024// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
6025// axis. Second fold family on this `DepError` envelope, and the first on
6026// the single-`{ nome }` shape.
6027//
6028// The five wire-up sites this fold closes each opened the identical
6029// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
6030// struct-literal against the same `nome: &str` (or `self.nome: &String`)
6031// local — the exact "same block re-inlined at every consumer" shape the
6032// PRIME DIRECTIVE names as a bug. The five variants share one
6033// `{ nome: String }` shape, so the fold routes each wire-up site through
6034// one dispatch per typed variant.
6035//
6036// The macro below generates one `#[must_use]` inherent constructor per
6037// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
6038// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
6039// pre-lift struct-literal on the same `&str` fixture. The uniform
6040// one-field construction (`nome.to_string()`) is spelled once — inside
6041// the macro — rather than at every wire-up site. Callers that hold a
6042// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
6043// and lets the macro-owned `.to_string()` produce the fresh owning copy
6044// the enum variant needs; the semantics collapse onto the same
6045// `.clone()`-equivalent one this fold replaces at every site.
6046//
6047// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
6048// on the same envelope stays on its pre-lift open-coded wire-up shape —
6049// it carries no `nome` field (the offending `:nome` value *is* the empty
6050// string this variant catches) so the uniform `fn(nome: &str) -> Self`
6051// signature this macro promises does not apply. Every future consumer
6052// that wants to construct one of these five variants outside the current
6053// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
6054// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
6055// re-validator at lacre-resolve time, a future `feira validate --deps`
6056// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
6057// these empty-value shapes against a cluster-local snapshot) now reaches
6058// each variant through one call rather than re-inlining the three-line
6059// struct-literal in lockstep with the five in-crate wire-up sites.
6060macro_rules! dep_nome_only_ctors {
6061 ($($ctor:ident => $variant:ident),* $(,)?) => {
6062 impl DepError {
6063 $(
6064 #[doc = concat!(
6065 "Construct a [`DepError::",
6066 stringify!($variant),
6067 "`] naming the offending `:deps :nome`. Folds the ",
6068 "uniform `Self::",
6069 stringify!($variant),
6070 " { nome: nome.to_string() }` one-field ",
6071 "struct-literal onto one substrate primitive so every ",
6072 "in-crate wire-up on this variant reads through one ",
6073 "dispatch rather than the pre-lift three-line ",
6074 "open-coded block."
6075 )]
6076 #[must_use]
6077 pub fn $ctor(nome: &str) -> Self {
6078 Self::$variant { nome: nome.to_string() }
6079 }
6080 )*
6081 }
6082 };
6083}
6084
6085dep_nome_only_ctors! {
6086 versao_empty => VersaoEmpty,
6087 fonte_repo_empty => FonteRepoEmpty,
6088 fonte_pin_missing => FontePinMissing,
6089 fonte_caminho_empty => FonteCaminhoEmpty,
6090 caracteristica_empty => CaracteristicaEmpty,
6091}
6092
6093// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
6094// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
6095// [`crate::manifest::Caixa::validate_deps`] +
6096// [`validate_no_self_dep`] onto one substrate-primitive family per
6097// typed variant — the `DepError`-side siblings of the peer
6098// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
6099// on the `SupervisorError { caixa: String }` one-slot envelope and of
6100// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
6101// `DepError { nome: String }` one-slot envelope. The two variants
6102// carry the same `{ nome: String, list: &'static str }` two-slot
6103// shape: the `nome` field names the offending dep the diagnostic
6104// points the author back at, and the `list` field carries the
6105// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
6106// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
6107// [`validate_deps`] arms, and via the paired
6108// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
6109// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
6110// canonicals on the [`validate_no_self_dep`] arm) so the author can
6111// grep their caixa.lisp for the offending list block in one edit.
6112//
6113// Each of the four wire-up sites opened the same struct-literal
6114// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
6115// two-line block — the exact "same block re-inlined at every
6116// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
6117// altitude the peer `DepError` / `SupervisorError` /
6118// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
6119// already closed on their sibling envelopes. The two `#[must_use]`
6120// inherent constructors below fold each wire-up onto one dispatch:
6121// `DepError::duplicate_nome(<nome>, <list>)` and
6122// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
6123// pre-lift struct-literal on the same scalar fixtures. The `list:
6124// &'static str` parameter (not `impl Into<String>`) preserves the
6125// exact wire tag every consumer already passes verbatim — no
6126// downstream diagnostic reshaping at the lift, matching the peer
6127// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
6128// contract each wire-up site already keys off.
6129macro_rules! dep_nome_list_ctors {
6130 ($($ctor:ident => $variant:ident),* $(,)?) => {
6131 impl DepError {
6132 $(
6133 #[doc = concat!(
6134 "Construct a [`DepError::",
6135 stringify!($variant),
6136 "`] naming the offending `:deps :nome` and the ",
6137 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
6138 "the diagnostic points the author back at. Folds ",
6139 "the uniform `Self::",
6140 stringify!($variant),
6141 " { nome: nome.to_string(), list }` two-field ",
6142 "struct-literal onto one substrate primitive so ",
6143 "every in-crate wire-up on this variant reads ",
6144 "through one dispatch rather than the pre-lift ",
6145 "open-coded struct-literal block."
6146 )]
6147 #[must_use]
6148 pub fn $ctor(nome: &str, list: &'static str) -> Self {
6149 Self::$variant { nome: nome.to_string(), list }
6150 }
6151 )*
6152 }
6153 };
6154}
6155
6156dep_nome_list_ctors! {
6157 duplicate_nome => DuplicateNome,
6158 dep_is_self => DepIsSelf,
6159}
6160
6161// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
6162// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
6163// <value>.to_string(), reason }` struct-variant wire-up sites at
6164// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
6165// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
6166// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
6167// primitive family per typed variant — the `DepError`-side siblings of the
6168// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
6169// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
6170// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
6171// the two-slot `{ nome, caminho }` envelope, and
6172// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
6173// caminho, byte }` envelope. The three variants share the same
6174// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
6175// the `nome` field names the offending dep the diagnostic points the
6176// author back at, the middle `<axis>: String` field carries the offending
6177// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
6178// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
6179// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
6180// field carries the parser-shaped rejection sentence the paired
6181// [`crate::render::require_valid_versao_requirement`] /
6182// [`crate::render::is_git_repo_url`] /
6183// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
6184// axis-field name differs across variants (`versao` / `repo` /
6185// `caracteristica`) so the ctor family below takes the axis field name as
6186// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
6187// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
6188// -> Self` inherent constructor per typed variant that spells the uniform
6189// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
6190// `reason` forwarded owned) exactly once. Peer of the sibling
6191// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
6192// family on the `AplicacaoError` envelope's mirror-symmetric
6193// `{ <field>: String, reason: String }` two-slot shape — same
6194// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
6195// one `nome`-axis added at the per-dep-owned altitude the `DepError`
6196// envelope keys off (every `DepError` variant carries the offending
6197// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
6198// offending block in one edit).
6199//
6200// The three wire-up sites this fold closes are:
6201// - [`DepSource::validate`]'s `:repo` value-shape arm
6202// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
6203// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
6204// rejects the offending URL);
6205// - [`Dep::validate`]'s `:versao` requirement-shape arm
6206// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
6207// self.versao_requirement().to_string(), reason }` inside the
6208// [`crate::render::require_valid_versao_requirement`] callback pair);
6209// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
6210// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
6211// caracteristica: c.clone(), reason })` after
6212// [`crate::render::is_cargo_feature_name`] rejects the offending
6213// feature-name).
6214//
6215// Each opened the identical five-line struct-literal against the same
6216// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
6217// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6218// same altitude the peer four already-lifted `DepError` ctor families
6219// closed on their sibling shape-envelopes. The three variant / axis-field
6220// discriminators are the only things that vary between them; the rest of
6221// the struct-literal is a byte-for-byte re-inline.
6222//
6223// Every future consumer wanting to raise one of these three diagnostics
6224// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
6225// time re-checking each declared dep against the same requirement +
6226// git-URL + feature-name value-shape cascade, a future `feira validate
6227// --deps` per-caixa admission verb re-running the shape gates on demand,
6228// a per-lacre overlay resolver rejecting an author-supplied dep against a
6229// cluster-local snapshot) now reaches one dispatch rather than re-inlining
6230// the five-line struct-literal in lockstep with the three in-crate
6231// wire-up sites.
6232macro_rules! dep_nome_axis_reason_ctors {
6233 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6234 impl DepError {
6235 $(
6236 #[doc = concat!(
6237 "Construct a [`DepError::",
6238 stringify!($variant),
6239 "`] naming the offending `:deps :nome`, the offending ",
6240 "`:", stringify!($axis), "` axis value, and the ",
6241 "parser-shaped rejection `reason`. Folds the uniform ",
6242 "`Self::",
6243 stringify!($variant),
6244 " { nome: nome.to_string(), ",
6245 stringify!($axis),
6246 ": ",
6247 stringify!($axis),
6248 ".to_string(), reason }` three-field struct-literal ",
6249 "onto one substrate primitive so every in-crate ",
6250 "wire-up on this variant reads through one dispatch ",
6251 "rather than the pre-lift five-line open-coded block. ",
6252 "The `nome: &str` and `",
6253 stringify!($axis),
6254 ": &str` parameters accept `&str` literals and ",
6255 "`&String` (via Deref coercion) so every existing ",
6256 "wire-up threads through the ctor without a ",
6257 "pre-conversion; the `reason: String` parameter takes ",
6258 "an owned `String` (not `impl Into<String>`) matching ",
6259 "the paired `crate::render::*` predicate's ",
6260 "`Result<(), String>` return shape every wire-up ",
6261 "already holds owned at the call site."
6262 )]
6263 #[must_use]
6264 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
6265 Self::$variant {
6266 nome: nome.to_string(),
6267 $axis: $axis.to_string(),
6268 reason,
6269 }
6270 }
6271 )*
6272 }
6273 };
6274}
6275
6276dep_nome_axis_reason_ctors! {
6277 versao_invalid => VersaoInvalid { versao },
6278 fonte_repo_shape => FonteRepoShape { repo },
6279 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
6280}
6281
6282// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
6283// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
6284// <value>.to_string() }` struct-variant wire-up sites at
6285// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
6286// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
6287// per-entry set-not-multiset dedup closure onto one substrate-primitive
6288// family per typed variant — the missing two-slot rung on the
6289// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
6290// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
6291// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
6292// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
6293// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
6294// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
6295// symmetric sibling of the peer
6296// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
6297// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
6298// envelope — same `<axis>: <value>.to_string()` owned-forward payload
6299// shape, `reason` axis removed and `nome`-axis added at the per-dep-
6300// owned altitude the `DepError` envelope keys off (every `DepError`
6301// variant carries the offending `:deps :nome` verbatim so the author
6302// can grep their caixa.lisp for the offending block in one edit). The
6303// three variants share the same `{ nome: String, <axis>: String }`
6304// two-slot shape: the `nome` field names the offending dep the
6305// diagnostic points the author back at, and the middle `<axis>:
6306// String` field carries the offending per-envelope axis value verbatim
6307// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
6308// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
6309// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
6310// The middle axis-field name differs across variants (`pin` / `pins` /
6311// `caracteristica`) so the ctor family below takes the axis field name
6312// as a macro parameter (`$axis:ident`) alongside the ctor + variant
6313// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
6314// Self` inherent constructor per typed variant that spells the
6315// uniform two-field construction (`nome.to_string()` /
6316// `<axis>.to_string()`) exactly once.
6317//
6318// The three wire-up sites this fold closes are:
6319// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
6320// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
6321// pin.to_string() });` inside the `set.len() == 1` branch after the
6322// `is_some_and(String::is_empty)` iterator);
6323// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
6324// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
6325// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
6326// - [`Dep::validate_caracteristicas`]'s per-entry
6327// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
6328// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
6329// [`crate::render::insert_first_seen`]).
6330//
6331// Each opened the identical four-line struct-literal against the same
6332// `(nome, <axis>)` local pair — the exact "same block re-inlined at
6333// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6334// same altitude the peer four already-lifted `DepError` ctor families
6335// closed on their sibling shape-envelopes. The three variant / axis-
6336// field discriminators are the only things that vary between them;
6337// the rest of the struct-literal is a byte-for-byte re-inline.
6338//
6339// Every future consumer wanting to raise one of these three
6340// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
6341// at lacre-resolve time re-checking each declared dep against the
6342// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
6343// set-not-multiset cascade, a future `feira validate --deps` per-
6344// caixa admission verb re-running the shape gates on demand, a
6345// per-lacre overlay resolver rejecting an author-supplied dep against
6346// a cluster-local snapshot the M4 CR materializer projects) now
6347// reaches one dispatch rather than re-inlining the four-line struct-
6348// literal in lockstep with the three in-crate wire-up sites.
6349macro_rules! dep_nome_axis_ctors {
6350 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6351 impl DepError {
6352 $(
6353 #[doc = concat!(
6354 "Construct a [`DepError::",
6355 stringify!($variant),
6356 "`] naming the offending `:deps :nome` and the ",
6357 "offending `:", stringify!($axis), "` axis value. ",
6358 "Folds the uniform `Self::",
6359 stringify!($variant),
6360 " { nome: nome.to_string(), ",
6361 stringify!($axis),
6362 ": ",
6363 stringify!($axis),
6364 ".to_string() }` two-field struct-literal onto one ",
6365 "substrate primitive so every in-crate wire-up on ",
6366 "this variant reads through one dispatch rather than ",
6367 "the pre-lift four-line open-coded block. Both `nome: ",
6368 "&str` and `",
6369 stringify!($axis),
6370 ": &str` parameters accept `&str` literals and ",
6371 "`&String` (via Deref coercion) so every existing ",
6372 "wire-up threads through the ctor without a pre-",
6373 "conversion."
6374 )]
6375 #[must_use]
6376 pub fn $ctor(nome: &str, $axis: &str) -> Self {
6377 Self::$variant {
6378 nome: nome.to_string(),
6379 $axis: $axis.to_string(),
6380 }
6381 }
6382 )*
6383 }
6384 };
6385}
6386
6387dep_nome_axis_ctors! {
6388 fonte_pin_empty => FontePinEmpty { pin },
6389 fonte_pin_ambiguous => FontePinAmbiguous { pins },
6390 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
6391}
6392
6393// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
6394// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
6395// struct-variant wire-up sites at [`DepSource::validate`]'s
6396// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
6397// the `DepError` envelope — the last open-coded ctor site remaining on
6398// the `:fonte (:tipo git …)` value-shape trajectory this envelope
6399// carries, and the single-variant sibling of the peer four already-
6400// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
6401// on the two-slot `{ nome, caminho }` envelope,
6402// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
6403// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
6404// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
6405// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
6406// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
6407// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
6408// `{ …, value: String, reason: String }` payload shape, one axis
6409// removed at the `nome`-only-owner altitude the `DepError` envelope
6410// keys off (no `edge_pair()` de/para pair).
6411//
6412// The two wire-up sites this fold closes are the paired refname-pin
6413// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
6414// pin: pin.to_string(), value: v.clone(), reason }` inside the
6415// `[(":tag", tag), (":branch", branch)]` iterator against
6416// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
6417// (`|| DepError::FontePinShape { nome: nome.to_string(),
6418// pin: ":rev".to_string(), value: v.clone(), reason }` against
6419// [`crate::render::is_git_oid`]) — each opened the identical
6420// `DepError::FontePinShape { … }` six-line struct-literal against the
6421// same `(nome: &str, pin: &str, v: &String, reason: String)` local
6422// tuple, the exact "same block re-inlined at every consumer" shape
6423// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
6424// the only thing that varies between them (`":tag"`/`":branch"` on
6425// the refname arm, `":rev"` on the hex-OID arm); the rest of the
6426// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
6427// route through the same ctor because their `pin` field carries the
6428// author-surface tag verbatim (matching the `FontePinEmpty` /
6429// `FontePinAmbiguous` sibling variants' `pin: String` axis
6430// convention), so the offending author can grep their caixa.lisp for
6431// the offending `:tag "<value>"` / `:branch "<value>"` /
6432// `:rev "<value>"` literal in one edit.
6433//
6434// The single ctor below folds each wire-up onto one dispatch:
6435// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
6436// the pre-lift struct-literal on the same `(&str, &str, &str,
6437// String)` fixture. The uniform four-field construction
6438// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
6439// `reason` forwarded owned) is spelled once here rather than at every
6440// wire-up site. The `reason: String` field takes an owned `String`
6441// (not `impl Into<String>`) matching the two call sites' pre-existing
6442// `let Err(reason) = crate::render::is_git_ref_name(v)` /
6443// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
6444// predicates return `Result<(), String>`, so the caller always holds
6445// an owned `String` at the wire-up site and threading it through the
6446// ctor without a `.into()` shim keeps the routing shape byte-equal to
6447// the pre-lift block. The `value: &str` parameter accepts both `&str`
6448// literals (unused today) and `&String` (from the caller-held
6449// `v: &String` on each arm, via Deref coercion), so every existing
6450// wire-up threads through the ctor without a pre-conversion.
6451//
6452// Every future consumer that wants to construct this variant outside
6453// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
6454// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
6455// re-checking the same value-shape axes the resolver consumes, a
6456// future `feira validate --deps` per-caixa admission verb re-checking
6457// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
6458// resolver rejecting a git-pin value against a cluster-local
6459// snapshot) now reaches this variant through one call rather than
6460// re-inlining the six-line struct-literal in lockstep with the two
6461// in-crate wire-up sites.
6462impl DepError {
6463 /// Construct a [`DepError::FontePinShape`] naming the offending
6464 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
6465 /// axis tag, the offending value, and the parser-shaped `reason`.
6466 /// Folds the uniform
6467 /// `Self::FontePinShape { nome: nome.to_string(),
6468 /// pin: pin.to_string(), value: value.to_string(), reason }`
6469 /// four-field struct-literal onto one substrate primitive so
6470 /// every [`DepSource::validate`] wire-up on this variant reads
6471 /// through one dispatch rather than the pre-lift six-line
6472 /// open-coded block. The `nome` string threads verbatim from
6473 /// [`Dep::nome`] at the call site; the `pin` string carries the
6474 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
6475 /// `value` string carries the offending refname / hex-OID
6476 /// verbatim; and `reason` forwards the owned `String` returned
6477 /// by [`crate::render::is_git_ref_name`] /
6478 /// [`crate::render::is_git_oid`] without a `.into()` shim.
6479 #[must_use]
6480 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
6481 Self::FontePinShape {
6482 nome: nome.to_string(),
6483 pin: pin.to_string(),
6484 value: value.to_string(),
6485 reason,
6486 }
6487 }
6488
6489 /// Construct a [`DepError::NomeInvalid`] naming the offending
6490 /// `:deps :nome` byte-string and the parser-shaped rejection
6491 /// `reason` returned by [`crate::render::is_dns_1123_label`].
6492 ///
6493 /// Folds the uniform
6494 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
6495 /// struct-literal onto one substrate primitive so every wire-up on
6496 /// this variant reads through one dispatch rather than the pre-lift
6497 /// four-line open-coded `DepError::NomeInvalid { nome:
6498 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
6499 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
6500 /// ctor-family ladder (`{ nome }` one-slot →
6501 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
6502 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
6503 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
6504 /// `{ nome, <axis>: String, reason: String }` three-slot →
6505 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
6506 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
6507 /// — the sole variant on the envelope carrying the
6508 /// `{ nome: String, reason: String }` two-slot shape without a
6509 /// middle axis, matching the peer
6510 /// [`crate::manifest::ManifestError::NomeInvalid`] +
6511 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
6512 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
6513 /// four-axis DNS-1123 caixa-identifier diagnostic family the
6514 /// existing `nome_invalid_diagnostic_carries_offending_name` test
6515 /// pins on this envelope.
6516 ///
6517 /// The `nome: &str` parameter accepts `&str` literals and `&String`
6518 /// (via Deref coercion) so the sole in-crate wire-up threads through
6519 /// the ctor without a pre-conversion; the `reason: String`
6520 /// parameter takes an owned `String` (not `impl Into<String>`)
6521 /// matching the [`crate::render::is_dns_1123_label`] predicate's
6522 /// `Result<(), String>` return shape the sole wire-up site already
6523 /// holds owned at the call site, keeping the routing byte-equal to
6524 /// the pre-lift block. Same owned-`String`-forward `reason` payload
6525 /// discipline as the sibling three-slot family
6526 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
6527 /// and the four-slot [`DepError::fonte_pin_shape`] on
6528 /// `{ nome, pin, value, reason }`.
6529 ///
6530 /// Every future consumer that raises the same diagnostic outside
6531 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
6532 /// re-validator at lacre-resolve time re-checking each declared
6533 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
6534 /// side schema uses (the `:nome` value flows verbatim as the target
6535 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
6536 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
6537 /// checkout-directory leaf), a future `feira validate --deps`
6538 /// per-caixa admission verb re-running the shape gate on demand, a
6539 /// per-lacre overlay resolver rejecting an author-supplied dep's
6540 /// `:nome` against a cluster-local snapshot the M4 CR materializer
6541 /// projects, a future authoring-surface widening the field into a
6542 /// `(String, Vec<Suggestion>)` pair carrying a
6543 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6544 /// variant through one call rather than re-inlining the four-line
6545 /// struct-literal in lockstep with the one in-crate wire-up site.
6546 #[must_use]
6547 pub fn nome_invalid(nome: &str, reason: String) -> Self {
6548 Self::NomeInvalid {
6549 nome: nome.to_string(),
6550 reason,
6551 }
6552 }
6553}
6554
6555#[allow(clippy::trivially_copy_pass_by_ref)]
6556fn is_false(b: &bool) -> bool {
6557 !*b
6558}
6559
6560#[cfg(test)]
6561mod tests {
6562 use super::*;
6563
6564 #[test]
6565 fn registry_dep_is_minimal() {
6566 let d = Dep::simple("caixa-teia", "^0.1");
6567 assert_eq!(d.nome, "caixa-teia");
6568 assert_eq!(d.versao, "^0.1");
6569 assert!(d.fonte.is_none());
6570 assert!(!d.opcional());
6571 assert!(d.caracteristicas().is_empty());
6572 }
6573
6574 #[test]
6575 fn dep_string_scalar_accessor_pair_is_const_fn() {
6576 // Fail-before-pass-after pin on [`Dep::nome`] +
6577 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6578 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6579 // entry's [`String`] storage through the `pub const fn`
6580 // [`String::as_str`] (const-stable since Rust 1.87, well
6581 // within the workspace MSRV) — any future accidental
6582 // downgrade to non-`const` fails the corresponding
6583 // `<name>_via_const_fn` wrapper at caixa-core build time with
6584 // E0015 (`cannot call non-const method`), strictly stronger
6585 // than a runtime `assert!`. Sibling of the peer
6586 // per-M2/M3/universal-axis `String → &str` scalar-accessor
6587 // family pins on the sibling `const`-eval-surface passes
6588 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6589 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6590 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6591 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6592 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6593 // [`crate::aplicacao::Entrada::destination`] at the M3
6594 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6595 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6596 // M2 supervisor-tree axis,
6597 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6598 // M2 upgrade axis, and the per-`:contratos`
6599 // [`crate::aplicacao::WitContract::source`] /
6600 // [`crate::aplicacao::WitContract::destination`] /
6601 // [`crate::aplicacao::WitContract::world_ref`] trio the
6602 // sibling pin at 279823b already anchors).
6603 const fn nome_via_const_fn(d: &Dep) -> &str {
6604 d.nome()
6605 }
6606 const fn versao_via_const_fn(d: &Dep) -> &str {
6607 d.versao_requirement()
6608 }
6609 for (nome, versao) in [
6610 ("caixa-teia", "^0.1"),
6611 ("caixa-mesh", "~0.2.3"),
6612 ("caixa-helm", "*"),
6613 ] {
6614 let d = Dep::simple(nome, versao);
6615 assert_eq!(nome_via_const_fn(&d), d.nome());
6616 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6617 assert_eq!(d.nome(), nome);
6618 assert_eq!(d.versao_requirement(), versao);
6619 }
6620 }
6621
6622 #[test]
6623 fn dep_outer_accessor_family_is_const_fn() {
6624 // Fail-before-pass-after pin on [`Dep::fonte`] +
6625 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6626 // Each accessor projects the per-`:deps` / per-`:deps-dev`
6627 // entry's composite / list storage through a `pub const fn`
6628 // stdlib method (`Option::<DepSource>::as_ref` /
6629 // `Vec::<String>::as_slice`, both const-stable since Rust
6630 // 1.83, well within the workspace MSRV). Any future
6631 // accidental downgrade to non-`const` fails the corresponding
6632 // `<name>_via_const_fn` wrapper at caixa-core build time with
6633 // E0015 (`cannot call non-const method`), strictly stronger
6634 // than a runtime `assert!` and side-stepping the destructor-
6635 // in-const restriction the `Dep` fixture's `String` /
6636 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6637 // direct-`const _: () = assert!(...)` residence.
6638 //
6639 // Peer of the sibling per-`Dep` scalar-accessor pair pin
6640 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6641 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6642 // the `const`-eval-surface discipline onto the composite-
6643 // reference and slice-return arms of the outer-`Dep` accessor
6644 // family, closing the four-slot outer surface (`:nome` +
6645 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6646 // posture. The `:opcional` `bool` arm already carries the
6647 // posture through [`Dep::opcional`]'s prior `pub const fn`
6648 // declaration, so this pin lands the last two unlifted
6649 // outer-`Dep` accessors and closes the family.
6650 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6651 d.fonte()
6652 }
6653 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6654 d.caracteristicas()
6655 }
6656 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6657 let empty = Dep::simple("caixa-teia", "^0.1");
6658 assert!(fonte_via_const_fn(&empty).is_none());
6659 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6660 assert!(caracteristicas_via_const_fn(&empty).is_empty());
6661 assert_eq!(
6662 caracteristicas_via_const_fn(&empty),
6663 empty.caracteristicas()
6664 );
6665 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6666 // still empty.
6667 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6668 assert!(fonte_via_const_fn(&git).is_some());
6669 assert_eq!(fonte_via_const_fn(&git), git.fonte());
6670 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6671 // Populated `:caracteristicas` — exercise the non-empty
6672 // slice-view arm to pin the accessor's borrow shape against
6673 // both a `Vec::new()` empty backing buffer and a populated one.
6674 let mut with_features = Dep::simple("caixa-teia", "^0.1");
6675 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6676 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6677 assert_eq!(
6678 caracteristicas_via_const_fn(&with_features),
6679 with_features.caracteristicas()
6680 );
6681 }
6682
6683 #[test]
6684 fn git_dep_carries_tag() {
6685 let d = Dep::git("t", "*", "github:o/r", "v1");
6686 match d.fonte {
6687 Some(DepSource::Git {
6688 ref repo, ref tag, ..
6689 }) => {
6690 assert_eq!(repo, "github:o/r");
6691 assert_eq!(tag.as_deref(), Some("v1"));
6692 }
6693 _ => panic!("expected Git source"),
6694 }
6695 }
6696
6697 #[test]
6698 fn validate_accepts_simple_dep() {
6699 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6700 }
6701
6702 #[test]
6703 fn validate_rejects_empty_nome() {
6704 // The fail-before-pass-after pin for `:nome ""`: the empty-name
6705 // arm fires first so the per-entry parse-side diagnostic doesn't
6706 // emit a useless `nome: ""` reference.
6707 let mut d = Dep::simple("placeholder", "^0.1");
6708 d.nome = String::new();
6709 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6710 }
6711
6712 #[test]
6713 fn validate_rejects_empty_versao() {
6714 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6715 // semver crate accepts the empty string as a wildcard match),
6716 // so the empty-`:versao` arm is structurally necessary even
6717 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6718 // `EmptyChildVersion` ordering on the other two `:versao` axes.
6719 let mut d = Dep::simple("caixa-teia", "ignored");
6720 d.versao = String::new();
6721 let err = d.validate().unwrap_err();
6722 assert!(
6723 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6724 "got {err:?}"
6725 );
6726 }
6727
6728 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6729
6730 #[test]
6731 fn validate_rejects_nome_with_uppercase() {
6732 // The fail-before-pass-after pin: a non-empty but uppercase
6733 // `:nome` silently passed `validate()` on every pre-gate
6734 // codebase because the prior shape only refused the empty
6735 // string. The DNS-1123 violation surfaced far downstream at
6736 // lacre-resolve time when the *target* caixa's `:nome` failed
6737 // its own gate — far from the `:deps` entry, with a diagnostic
6738 // naming the target rather than the dep entry that referenced
6739 // it. Same fail-before-pass-after fixture pinned for
6740 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6741 // and Caixa `:nome` (6c992f8).
6742 let d = Dep::simple("Caixa-Teia", "^0.1");
6743 let err = d.validate().unwrap_err();
6744 assert!(
6745 matches!(
6746 err,
6747 DepError::NomeInvalid { ref nome, ref reason }
6748 if nome == "Caixa-Teia" && reason.contains("uppercase")
6749 ),
6750 "got {err:?}"
6751 );
6752 }
6753
6754 #[test]
6755 fn validate_rejects_nome_with_underscore() {
6756 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6757 // "I'm thinking of Go module names / Python identifiers" leak.
6758 // Same fixture pinned for the peer caixa-identifier axes.
6759 let d = Dep::simple("caixa_teia", "^0.1");
6760 let err = d.validate().unwrap_err();
6761 assert!(
6762 matches!(
6763 err,
6764 DepError::NomeInvalid { ref nome, ref reason }
6765 if nome == "caixa_teia" && reason.contains('_')
6766 ),
6767 "got {err:?}"
6768 );
6769 }
6770
6771 #[test]
6772 fn validate_rejects_nome_with_dot() {
6773 // A `:deps :nome` is a single DNS-1123 *label*, not a
6774 // subdomain — dots are rejected. The `"caixa.teia"` shape is
6775 // the canonical "I confused the dep name with the FQDN /
6776 // namespace" footgun, distinct from the legitimate
6777 // `:fonte :repo "github:org/caixa-teia"` axis.
6778 let d = Dep::simple("caixa.teia", "^0.1");
6779 let err = d.validate().unwrap_err();
6780 assert!(
6781 matches!(
6782 err,
6783 DepError::NomeInvalid { ref nome, ref reason }
6784 if nome == "caixa.teia" && reason.contains('.')
6785 ),
6786 "got {err:?}"
6787 );
6788 }
6789
6790 #[test]
6791 fn validate_rejects_nome_with_leading_hyphen() {
6792 // RFC 1123 requires alphanumeric at both label boundaries.
6793 // Pinned in parity with the peer DNS-1123 fixtures.
6794 let d = Dep::simple("-caixa-teia", "^0.1");
6795 let err = d.validate().unwrap_err();
6796 assert!(
6797 matches!(
6798 err,
6799 DepError::NomeInvalid { ref nome, ref reason }
6800 if nome == "-caixa-teia" && reason.contains("alphanumeric")
6801 ),
6802 "got {err:?}"
6803 );
6804 }
6805
6806 #[test]
6807 fn validate_rejects_nome_with_trailing_hyphen() {
6808 let d = Dep::simple("caixa-teia-", "^0.1");
6809 let err = d.validate().unwrap_err();
6810 assert!(
6811 matches!(
6812 err,
6813 DepError::NomeInvalid { ref nome, ref reason }
6814 if nome == "caixa-teia-" && reason.contains("alphanumeric")
6815 ),
6816 "got {err:?}"
6817 );
6818 }
6819
6820 #[test]
6821 fn validate_rejects_nome_with_slash() {
6822 // The canonical "I copied the GitHub repo path into `:nome`
6823 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6824 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6825 // the local-name slot. Same fixture pinned for `:membros
6826 // :caixa` (3f9d7a0).
6827 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6828 let err = d.validate().unwrap_err();
6829 assert!(
6830 matches!(
6831 err,
6832 DepError::NomeInvalid { ref nome, ref reason }
6833 if nome == "pleme-io/caixa-teia" && reason.contains('/')
6834 ),
6835 "got {err:?}"
6836 );
6837 }
6838
6839 #[test]
6840 fn validate_rejects_nome_too_long() {
6841 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6842 // Built from a valid character set so the length-bound
6843 // diagnostic surfaces before any per-character check (the
6844 // order pin parallel to the per-character predicates inside
6845 // [`crate::render::is_dns_1123_label`]).
6846 let long = "a".repeat(64);
6847 let d = Dep::simple(&long, "^0.1");
6848 let err = d.validate().unwrap_err();
6849 assert!(
6850 matches!(
6851 err,
6852 DepError::NomeInvalid { ref nome, ref reason }
6853 if nome.len() == 64 && reason.contains("max length of 63")
6854 ),
6855 "got {err:?}"
6856 );
6857 }
6858
6859 #[test]
6860 fn validate_accepts_canonical_nome_labels() {
6861 // Positive-control sweep — every form the K8s apiserver
6862 // accepts as a DNS-1123 label must round-trip through
6863 // validate. Covers a hyphen-bearing label, a numeric-suffix
6864 // label, a leading-digit label, a single-character label, and
6865 // a 63-byte (exactly the cap) label — the same fixture set
6866 // the peer `:membros :caixa` / `:children :caixa` positive
6867 // controls pin.
6868 for nome in [
6869 "caixa-teia",
6870 "caixa-resolver2",
6871 "2nd-tier-cache",
6872 "x",
6873 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6874 ] {
6875 Dep::simple(nome, "^0.1")
6876 .validate()
6877 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6878 }
6879 }
6880
6881 #[test]
6882 fn nome_empty_takes_precedence_over_nome_invalid() {
6883 // Ordering pin: `NomeEmpty` is the more self-locating
6884 // diagnostic on `""` and must lead — `is_dns_1123_label` is
6885 // only reached after the empty-check fires at the call site.
6886 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6887 // (3f9d7a0) on the peer caixa-identifier axis.
6888 let mut d = Dep::simple("placeholder", "^0.1");
6889 d.nome = String::new();
6890 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6891 }
6892
6893 #[test]
6894 fn nome_invalid_fires_before_versao_empty() {
6895 // Ordering pin: a malformed `:nome` fires before any `:versao`
6896 // axis check on the *same* entry — the per-entry shape gates
6897 // run top-to-bottom (nome empty → nome shape → versao empty →
6898 // versao parse → fonte shape), so a one-entry caixa.lisp with
6899 // both wrong sees the name-side diagnostic first (the name is
6900 // the self-locating axis — without a valid name, the parse
6901 // diagnostic can't quote `:nome "<bad>"`). Same ordering
6902 // discipline as `membro_caixa_invalid_fires_before_versao_check`
6903 // (3f9d7a0).
6904 let mut d = Dep::simple("Caixa-Teia", "^0.1");
6905 d.versao = String::new();
6906 let err = d.validate().unwrap_err();
6907 assert!(
6908 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6909 "got {err:?}"
6910 );
6911 }
6912
6913 #[test]
6914 fn nome_invalid_fires_before_versao_invalid() {
6915 // Ordering pin: a malformed `:nome` fires before the `:versao`
6916 // parse-side check on the *same* entry. Pin separately from
6917 // the empty-versao ordering so a future re-ordering surfaces
6918 // here, parallel to the b0c8389 / c4213a4 trajectory.
6919 let d = Dep::simple("Caixa-Teia", "^^0.1");
6920 let err = d.validate().unwrap_err();
6921 assert!(
6922 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6923 "got {err:?}"
6924 );
6925 }
6926
6927 #[test]
6928 fn nome_invalid_fires_before_fonte_invalid() {
6929 // Ordering pin: a malformed `:nome` fires before the `:fonte`
6930 // shape check on the *same* entry. The `:fonte` diagnostic
6931 // names the offending dep's `:nome` verbatim (via
6932 // `DepSource::validate(&self.nome)`), so a non-self-locating
6933 // name would taint the downstream diagnostic too — the gate
6934 // ordering keeps both diagnostics individually self-locating.
6935 let mut d = Dep::simple("Caixa-Teia", "^0.1");
6936 d.fonte = Some(DepSource::Git {
6937 repo: String::new(),
6938 tag: None,
6939 rev: None,
6940 branch: None,
6941 });
6942 let err = d.validate().unwrap_err();
6943 assert!(
6944 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6945 "got {err:?}"
6946 );
6947 }
6948
6949 #[test]
6950 fn nome_invalid_diagnostic_carries_offending_name() {
6951 // The diagnostic-shape pin: the error names the offending
6952 // `:nome` value verbatim so the author can grep their
6953 // caixa.lisp without re-running the build, and carries a
6954 // non-empty `reason` from `is_dns_1123_label` so the
6955 // predicate's own wording flows through to the diagnostic.
6956 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6957 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6958 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6959 // share a structurally-equivalent diagnostic family.
6960 let d = Dep::simple("Caixa_Teia", "^0.1");
6961 let err = d.validate().unwrap_err();
6962 let DepError::NomeInvalid { nome, reason } = err else {
6963 panic!("expected NomeInvalid, got other variant");
6964 };
6965 assert_eq!(nome, "Caixa_Teia");
6966 assert!(
6967 !reason.is_empty(),
6968 "NomeInvalid `reason` must carry the predicate's wording verbatim"
6969 );
6970 }
6971
6972 #[test]
6973 fn validate_rejects_invalid_versao_requirement() {
6974 // The fail-before-pass-after pin: a non-empty but malformed
6975 // requirement (`"^bad-version"`) silently passed every pre-gate
6976 // codebase because `:deps :versao` wasn't validated. The parse
6977 // failure surfaced far downstream at lacre-resolve time with a
6978 // `semver::Error` that didn't name which `:deps` entry carried
6979 // the typo. The new gate moves the check to caixa-build time
6980 // at the source caixa.lisp.
6981 let d = Dep::simple("caixa-teia", "^bad-version");
6982 let err = d.validate().unwrap_err();
6983 assert!(
6984 matches!(
6985 err,
6986 DepError::VersaoInvalid { ref nome, ref versao, .. }
6987 if nome == "caixa-teia" && versao == "^bad-version"
6988 ),
6989 "got {err:?}"
6990 );
6991 }
6992
6993 #[test]
6994 fn validate_rejects_versao_with_double_caret_typo() {
6995 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6996 // Cargo-shaped requirement on first glance but fails the parser
6997 // because semver doesn't accept stacked operators. Pin this
6998 // adjacent-shape footgun explicitly so a future relaxation that
6999 // accepts "looks-canonical-but-isn't" forms surfaces here, in
7000 // parity with the `:membros` / `:children` fixtures.
7001 let d = Dep::simple("caixa-teia", "^^0.1");
7002 let err = d.validate().unwrap_err();
7003 assert!(
7004 matches!(
7005 err,
7006 DepError::VersaoInvalid { ref nome, ref versao, .. }
7007 if nome == "caixa-teia" && versao == "^^0.1"
7008 ),
7009 "got {err:?}"
7010 );
7011 }
7012
7013 #[test]
7014 fn validate_rejects_versao_with_v_prefixed_tag() {
7015 // `"v0.1"` is the canonical "git-tag-shape leaking into the
7016 // semver requirement slot" typo — an author copies the
7017 // publish-side git-tag string verbatim into `:versao`, but
7018 // Cargo's semver parser rejects the leading `v`. Same fixture
7019 // pinned for `:membros :versao` (9888b13) and `:children
7020 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
7021 // are *accepted* by the semver crate as an `*` wildcard on the
7022 // patch axis — they're a Cargo-side valid shape, not a typo.)
7023 let d = Dep::simple("caixa-teia", "v0.1");
7024 let err = d.validate().unwrap_err();
7025 assert!(
7026 matches!(
7027 err,
7028 DepError::VersaoInvalid { ref nome, ref versao, .. }
7029 if nome == "caixa-teia" && versao == "v0.1"
7030 ),
7031 "got {err:?}"
7032 );
7033 }
7034
7035 #[test]
7036 fn validate_accepts_canonical_versao_forms() {
7037 // The five Cargo-shaped requirement forms `:membros :versao`
7038 // and `:children :versao` already accept via
7039 // `crate::parse_requirement` must pass the deps gate without
7040 // re-validating at the resolver layer. Pin every leg so a
7041 // future tightening of the canonical set surfaces here as a
7042 // test failure.
7043 for form in [
7044 "^0.1", // caret — minor-range pin (the most common shape)
7045 "~0.1.2", // tilde — patch-range pin
7046 "0.1.0", // exact — single-version pin
7047 "*", // wildcard — explicitly any-version
7048 ">=0.1, <2", // multi-range — comma-separated comparators
7049 ] {
7050 Dep::simple("caixa-teia", form)
7051 .validate()
7052 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
7053 }
7054 }
7055
7056 #[test]
7057 fn versao_empty_takes_precedence_over_invalid() {
7058 // Order pin: the existing `VersaoEmpty` diagnostic (which
7059 // doesn't try to parse) fires before the new `VersaoInvalid`
7060 // parse-side diagnostic, so an empty `:versao` keeps its
7061 // narrower error message — `parse_requirement("")` would
7062 // otherwise return `Ok(STAR)` and silently pass, but the empty
7063 // arm catches it first.
7064 let mut d = Dep::simple("caixa-teia", "ignored");
7065 d.versao = String::new();
7066 let err = d.validate().unwrap_err();
7067 assert!(
7068 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
7069 "got {err:?}"
7070 );
7071 }
7072
7073 #[test]
7074 fn nome_empty_takes_precedence_over_versao_invalid() {
7075 // Order pin: even when `:versao` is malformed and would raise
7076 // its own diagnostic, `:nome ""` fires first because the
7077 // per-entry parse diagnostic needs a non-empty name to be
7078 // self-locating. Mirrors the
7079 // `membros_validation_runs_before_contratos_membership_check`
7080 // ordering on the typed-graph layer.
7081 let mut d = Dep::simple("placeholder", "^bad");
7082 d.nome = String::new();
7083 let err = d.validate().unwrap_err();
7084 assert_eq!(err, DepError::NomeEmpty);
7085 }
7086
7087 #[test]
7088 fn versao_invalid_diagnostic_carries_offending_versao() {
7089 // The diagnostic-shape pin: the error names the offending
7090 // `:versao` value verbatim so the author can grep their
7091 // caixa.lisp without re-running the build, and carries a
7092 // non-empty `reason` from `semver::VersionReq::parse` so the
7093 // parser's own wording flows through to the diagnostic.
7094 let d = Dep::simple("caixa-teia", "not-a-req");
7095 let err = d.validate().unwrap_err();
7096 let DepError::VersaoInvalid {
7097 nome,
7098 versao,
7099 reason,
7100 } = err
7101 else {
7102 panic!("expected VersaoInvalid, got other variant");
7103 };
7104 assert_eq!(nome, "caixa-teia");
7105 assert_eq!(versao, "not-a-req");
7106 assert!(
7107 !reason.is_empty(),
7108 "VersaoInvalid `reason` must carry the parser's wording verbatim"
7109 );
7110 }
7111
7112 // -- :fonte value-shape gate ------------------------------------------
7113
7114 fn dep_with_fonte(fonte: DepSource) -> Dep {
7115 let mut d = Dep::simple("caixa-teia", "^0.1");
7116 d.fonte = Some(fonte);
7117 d
7118 }
7119
7120 #[test]
7121 fn validate_accepts_git_fonte_with_tag() {
7122 // The positive-control pin on the canonical git source — exactly
7123 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
7124 // shape every existing caixa-resolver integration test uses.
7125 let d = dep_with_fonte(DepSource::Git {
7126 repo: "github:pleme-io/caixa-teia".into(),
7127 tag: Some("v0.1.0".into()),
7128 rev: None,
7129 branch: None,
7130 });
7131 d.validate().unwrap();
7132 }
7133
7134 #[test]
7135 fn validate_accepts_git_fonte_with_rev() {
7136 // Each of the three pin axes is independently a valid single-pin
7137 // shape; pin the :rev arm so a future relaxation that only
7138 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
7139 // OID — the canonical `git rev-parse HEAD` emission shape the
7140 // `crate::render::is_git_oid` value-shape gate now requires;
7141 // abbreviated OIDs are ambiguous across repo history and
7142 // rejected at this gate (pinned separately by
7143 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
7144 let d = dep_with_fonte(DepSource::Git {
7145 repo: "github:pleme-io/caixa-teia".into(),
7146 tag: None,
7147 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
7148 branch: None,
7149 });
7150 d.validate().unwrap();
7151 }
7152
7153 #[test]
7154 fn validate_accepts_git_fonte_with_branch() {
7155 // The :branch arm is the third valid single-pin shape — pinned
7156 // separately so the gate-accepts-all-three-pin-axes contract is
7157 // a build-error to relax.
7158 let d = dep_with_fonte(DepSource::Git {
7159 repo: "github:pleme-io/caixa-teia".into(),
7160 tag: None,
7161 rev: None,
7162 branch: Some("main".into()),
7163 });
7164 d.validate().unwrap();
7165 }
7166
7167 #[test]
7168 fn validate_accepts_path_fonte() {
7169 // The positive-control pin on the path source — non-empty
7170 // :caminho, no pin axes (paths have no commit identity). Pinned
7171 // so a future "paths must also pin a rev" tightening surfaces
7172 // here as a structural decision, not a silent break.
7173 let d = dep_with_fonte(DepSource::Path {
7174 caminho: "../caixa-teia".into(),
7175 });
7176 d.validate().unwrap();
7177 }
7178
7179 #[test]
7180 fn validate_rejects_git_fonte_with_empty_repo() {
7181 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
7182 // "v1")`: the empty-repo shape silently passed every pre-gate
7183 // codebase because `:fonte` wasn't validated. The git-clone
7184 // failure surfaced far downstream at lacre-resolve time with no
7185 // field naming which `:deps` entry carried the typo. The new
7186 // gate moves the check to caixa-build time at the source
7187 // caixa.lisp.
7188 let d = dep_with_fonte(DepSource::Git {
7189 repo: String::new(),
7190 tag: Some("v0.1.0".into()),
7191 rev: None,
7192 branch: None,
7193 });
7194 let err = d.validate().unwrap_err();
7195 assert!(
7196 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
7197 "got {err:?}"
7198 );
7199 }
7200
7201 // -- :repo value-shape gate -------------------------------------------
7202 //
7203 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
7204 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
7205 // codebase admitted any non-empty string; the new
7206 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
7207 // URL intersection-floor at validate time, peer with the three pin
7208 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
7209 // `is_git_oid`). Every test in this section is a fail-before /
7210 // pass-after pin on a specific authoring footgun.
7211
7212 #[test]
7213 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
7214 // The canonical paste-from-doc footgun on `:repo` — an author
7215 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
7216 // a doc paragraph. Until this gate landed the empty-repo arm
7217 // passed (the string isn't empty), the resolver issued
7218 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
7219 // surfaced at clone time with a quoting-confused error far from
7220 // the source caixa.lisp. Same paste-from-doc footgun the
7221 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
7222 // axis — now closed on the `:repo` URL axis too.
7223 let d = dep_with_fonte(DepSource::Git {
7224 repo: "github:pleme-io/caixa-teia ".into(),
7225 tag: Some("v0.1.0".into()),
7226 rev: None,
7227 branch: None,
7228 });
7229 let err = d.validate().unwrap_err();
7230 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7231 panic!("expected FonteRepoShape, got other variant");
7232 };
7233 assert_eq!(nome, "caixa-teia");
7234 assert_eq!(repo, "github:pleme-io/caixa-teia ");
7235 assert!(
7236 reason.contains("whitespace"),
7237 "reason must surface the whitespace arm, got {reason:?}"
7238 );
7239 }
7240
7241 #[test]
7242 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
7243 // The canonical CLI-argument-injection footgun at the `git clone`
7244 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
7245 // argv parser read the value as a CLI flag, escaping the
7246 // subprocess argument boundary. The `--` separator workaround
7247 // does not fix the typed slot's accepted set; the gate rejects
7248 // the shape upstream at validate time so the resolver never
7249 // invokes a `git clone -…` subprocess.
7250 let d = dep_with_fonte(DepSource::Git {
7251 repo: "-upload-pack=evil".into(),
7252 tag: Some("v0.1.0".into()),
7253 rev: None,
7254 branch: None,
7255 });
7256 let err = d.validate().unwrap_err();
7257 let DepError::FonteRepoShape { repo, reason, .. } = err else {
7258 panic!("expected FonteRepoShape, got other variant");
7259 };
7260 assert_eq!(repo, "-upload-pack=evil");
7261 assert!(
7262 reason.contains("must not start with `-`"),
7263 "reason must surface the leading-`-` arm, got {reason:?}"
7264 );
7265 }
7266
7267 #[test]
7268 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
7269 // The canonical paste-from-multiline-doc footgun — a `:repo`
7270 // string with an embedded `\n` silently breaks git's URL parser
7271 // and is a class of CRLF-injection at the subprocess-argument
7272 // boundary. Caught by the control-char arm (0x0A < 0x20).
7273 let d = dep_with_fonte(DepSource::Git {
7274 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
7275 tag: Some("v0.1.0".into()),
7276 rev: None,
7277 branch: None,
7278 });
7279 let err = d.validate().unwrap_err();
7280 let DepError::FonteRepoShape { reason, .. } = err else {
7281 panic!("expected FonteRepoShape, got other variant");
7282 };
7283 assert!(
7284 reason.contains("control character"),
7285 "reason must surface the control-char arm, got {reason:?}"
7286 );
7287 }
7288
7289 #[test]
7290 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
7291 // Tab is the sibling whitespace footgun (the canonical
7292 // copy-from-aligned-table paste); pinned separately from the
7293 // space arm so a future relaxation that only catches one
7294 // surfaces here.
7295 let d = dep_with_fonte(DepSource::Git {
7296 repo: "github:pleme-io/caixa-teia\t".into(),
7297 tag: Some("v0.1.0".into()),
7298 rev: None,
7299 branch: None,
7300 });
7301 let err = d.validate().unwrap_err();
7302 assert!(
7303 matches!(
7304 err,
7305 DepError::FonteRepoShape { ref reason, .. }
7306 if reason.contains("whitespace")
7307 ),
7308 "got {err:?}"
7309 );
7310 }
7311
7312 #[test]
7313 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
7314 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
7315 // non-ASCII silently breaks at git's URL parser and round-trips
7316 // inconsistently across NFC/NFD normalization on APFS /
7317 // case-folding filesystems. Same intersection-floor
7318 // [`is_git_ref_name`] enforces on the refname axes.
7319 let d = dep_with_fonte(DepSource::Git {
7320 repo: "https://github.com/pleme-io/café".into(),
7321 tag: Some("v0.1.0".into()),
7322 rev: None,
7323 branch: None,
7324 });
7325 let err = d.validate().unwrap_err();
7326 assert!(
7327 matches!(
7328 err,
7329 DepError::FonteRepoShape { ref reason, .. }
7330 if reason.contains("non-ASCII")
7331 ),
7332 "got {err:?}"
7333 );
7334 }
7335
7336 #[test]
7337 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
7338 // The fail-before-pass-after pin for the canonical paste-from-
7339 // browser-address-bar footgun on `:repo`: an author copies a
7340 // GitHub permalink to a README anchor / line-permalink and
7341 // forgets to trim the `#fragment` tail. Until this arm landed
7342 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
7343 // silently passed every prior arm (no whitespace, no control
7344 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
7345 // or `:`), libcurl's URL parser stripped the `#readme` tail
7346 // before opening the HTTPS transport, and the lacre embedded
7347 // the value verbatim in its per-dep BLAKE3 closure — two
7348 // authors whose values differ only in their fragment anchor
7349 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
7350 // `git clone` but lock to two distinct lacres, defeating the
7351 // THEORY.md §V.2 render-determinism contract. Same value-shape
7352 // axis-floor every peer typed surface enforces; peer `:fonte
7353 // :tag` / `:fonte :branch` already reject the byte-class through
7354 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
7355 // URL grammar admitted) and `:entrada :paths` rejects `#` as
7356 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
7357 let d = dep_with_fonte(DepSource::Git {
7358 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
7359 tag: Some("v0.1.0".into()),
7360 rev: None,
7361 branch: None,
7362 });
7363 let err = d.validate().unwrap_err();
7364 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7365 panic!("expected FonteRepoShape, got other variant");
7366 };
7367 assert_eq!(nome, "caixa-teia");
7368 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
7369 assert!(
7370 reason.contains("must not contain `#`"),
7371 "reason must surface the fragment-`#` arm, got {reason:?}"
7372 );
7373 assert!(
7374 reason.contains("fragment"),
7375 "reason must name the URL fragment grammar, got {reason:?}"
7376 );
7377 }
7378
7379 #[test]
7380 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
7381 // The symmetric paste-from-Nix-flake-ref footgun — an author
7382 // confuses the Nix flake-reference idiom (`github:foo/
7383 // bar#packageName`, where `#packageName` selects a flake
7384 // output) with the bare git `:repo` shape. The pleme-io
7385 // substrate authors compose flakes downstream of caixa
7386 // (caixa-flake renders a flake.nix), so the cross-idiom leak
7387 // is the canonical near-miss: the author writes the
7388 // flake-ref shape into a git `:repo` slot. Pinned separately
7389 // from the HTTPS-anchor arm so a future relaxation that
7390 // narrows to one URL scheme surfaces here.
7391 let d = dep_with_fonte(DepSource::Git {
7392 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
7393 tag: Some("v0.1.0".into()),
7394 rev: None,
7395 branch: None,
7396 });
7397 let err = d.validate().unwrap_err();
7398 let DepError::FonteRepoShape { reason, .. } = err else {
7399 panic!("expected FonteRepoShape, got other variant");
7400 };
7401 assert!(
7402 reason.contains("must not contain `#`"),
7403 "reason must surface the fragment-`#` arm, got {reason:?}"
7404 );
7405 assert!(
7406 reason.contains("Nix flake"),
7407 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
7408 );
7409 }
7410
7411 #[test]
7412 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
7413 // The fail-before-pass-after pin for the canonical paste-from-
7414 // browser-address-bar footgun on `:repo` (peer with the
7415 // a68f818 fragment-`#` arm on the same axis). An author
7416 // copies a GitHub tab deep-link out of the address bar and
7417 // forgets to trim the `?tab=…` query tail. Until this arm
7418 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
7419 // silently passed every prior arm (no whitespace, no control
7420 // chars, no non-ASCII, no `#` fragment, contains a `:`,
7421 // doesn't start with `-` or `:`); GitHub silently ignored
7422 // the `?query` tail and served the same repo regardless;
7423 // the lacre embedded the value verbatim in its per-dep
7424 // BLAKE3 closure — two authors whose values differ only in
7425 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
7426 // `?utm_source=twitter`) resolve to the byte-identical
7427 // upstream `git clone` but lock to two distinct lacres,
7428 // defeating the THEORY.md §V.2 render-determinism contract
7429 // on the same axis the `#` fragment arm closes. Same value-
7430 // shape axis-floor every peer typed surface enforces; peer
7431 // `:fonte :tag` / `:fonte :branch` already reject the byte-
7432 // class through `is_git_ref_name`'s alphabet (refspec glob
7433 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
7434 // :paths` rejects `?` as the query separator in
7435 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
7436 let d = dep_with_fonte(DepSource::Git {
7437 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
7438 tag: Some("v0.1.0".into()),
7439 rev: None,
7440 branch: None,
7441 });
7442 let err = d.validate().unwrap_err();
7443 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7444 panic!("expected FonteRepoShape, got other variant");
7445 };
7446 assert_eq!(nome, "caixa-teia");
7447 assert_eq!(
7448 repo,
7449 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
7450 );
7451 assert!(
7452 reason.contains("must not contain `?`"),
7453 "reason must surface the query-`?` arm, got {reason:?}"
7454 );
7455 assert!(
7456 reason.contains("query"),
7457 "reason must name the URL query grammar, got {reason:?}"
7458 );
7459 }
7460
7461 #[test]
7462 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
7463 // The symmetric paste-from-social-share footgun — an author
7464 // copies a repo URL out of a Slack unfurl / Twitter share /
7465 // newsletter link / Discord embed and forgets to trim the
7466 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
7467 // campaign-tracker tail. Every major social-share / unfurl /
7468 // newsletter platform appends these UTM parameters; the
7469 // canonical near-miss on the `:repo` axis. Pinned separately
7470 // from the GitHub-tab-deep-link arm so a future relaxation
7471 // that narrows to one query-parameter class surfaces here.
7472 let d = dep_with_fonte(DepSource::Git {
7473 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
7474 .into(),
7475 tag: Some("v0.1.0".into()),
7476 rev: None,
7477 branch: None,
7478 });
7479 let err = d.validate().unwrap_err();
7480 let DepError::FonteRepoShape { reason, .. } = err else {
7481 panic!("expected FonteRepoShape, got other variant");
7482 };
7483 assert!(
7484 reason.contains("must not contain `?`"),
7485 "reason must surface the query-`?` arm, got {reason:?}"
7486 );
7487 assert!(
7488 reason.contains("campaign-tracker"),
7489 "reason must name the campaign-tracker paste footgun, got {reason:?}"
7490 );
7491 }
7492
7493 #[test]
7494 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
7495 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
7496 // both per-byte arms inside the same `for &b in s.as_bytes()`
7497 // loop, so the byte that appears first in the value's byte
7498 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
7499 // (fragment before query — unusual URL-grammar but value-
7500 // disjoint at byte level) carries both `#` and `?`; the `#`
7501 // byte appears first, so the fragment-`#` arm fires, surfacing
7502 // the more self-locating diagnostic on the byte the author
7503 // pasted earliest in the URL. Mirrors the peer cascade
7504 // discipline `fonte_repo_control_char_fires_before_fragment`
7505 // pins on the prior `:repo` byte-class arm.
7506 let d = dep_with_fonte(DepSource::Git {
7507 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
7508 tag: Some("v0.1.0".into()),
7509 rev: None,
7510 branch: None,
7511 });
7512 let err = d.validate().unwrap_err();
7513 let DepError::FonteRepoShape { reason, .. } = err else {
7514 panic!("expected FonteRepoShape, got other variant");
7515 };
7516 assert!(
7517 reason.contains("must not contain `#`"),
7518 "reason must surface the fragment-`#` arm (fires before query-`?` when \
7519 `#` byte appears first in value), got {reason:?}"
7520 );
7521 }
7522
7523 #[test]
7524 fn fonte_repo_control_char_fires_before_fragment() {
7525 // Cascade pin: the control-char arm structurally precedes the
7526 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
7527 // positive on both arms (contains LF and `#`), but the narrower
7528 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
7529 // (`control character`) wins so the author sees the more
7530 // self-locating arm first. Mirrors the peer cascade discipline
7531 // every prior `:repo` byte-class arm establishes.
7532 let d = dep_with_fonte(DepSource::Git {
7533 repo: "github:pleme-io/caixa-teia\n#readme".into(),
7534 tag: Some("v0.1.0".into()),
7535 rev: None,
7536 branch: None,
7537 });
7538 let err = d.validate().unwrap_err();
7539 let DepError::FonteRepoShape { reason, .. } = err else {
7540 panic!("expected FonteRepoShape, got other variant");
7541 };
7542 assert!(
7543 reason.contains("control character"),
7544 "reason must surface the control-char arm, got {reason:?}"
7545 );
7546 }
7547
7548 #[test]
7549 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7550 // The fail-before-pass-after pin for the canonical Windows-
7551 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7552 // backslash arm on the sibling `:caminho` path-fonte axis).
7553 // An author pastes a Windows Explorer address-bar / PowerShell
7554 // `Get-Location` output into a `file://` URL slot, producing
7555 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7556 // value silently passed every prior arm (no whitespace, no
7557 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7558 // with `-` or `:`); libcurl's URL parser silently translates
7559 // `\` → `/` on some platforms and refuses it on others, so
7560 // the byte rides verbatim into the lacre's per-dep content-
7561 // address but is silently rewritten / rejected at the wire —
7562 // two authors whose `:repo` values differ only in backslash-
7563 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7564 // resolve to the byte-identical local clone but lock to two
7565 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7566 // render-determinism contract on the same axis the `#`
7567 // fragment and `?` query arms close. Same value-shape axis-
7568 // floor every peer typed surface enforces; the `:caminho`
7569 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7570 let d = dep_with_fonte(DepSource::Git {
7571 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7572 tag: Some("v0.1.0".into()),
7573 rev: None,
7574 branch: None,
7575 });
7576 let err = d.validate().unwrap_err();
7577 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7578 panic!("expected FonteRepoShape, got other variant");
7579 };
7580 assert_eq!(nome, "caixa-teia");
7581 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7582 assert!(
7583 reason.contains("must not contain `\\`"),
7584 "reason must surface the backslash-`\\` arm, got {reason:?}"
7585 );
7586 assert!(
7587 reason.contains("Windows"),
7588 "reason must name the Windows-path-confusion footgun, got {reason:?}"
7589 );
7590 }
7591
7592 #[test]
7593 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7594 // The symmetric Win32-shell-mangled-slashes footgun — an author
7595 // copies `https://github.com/foo/bar` into a Win32 shell that
7596 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7597 // separator-coercion bug), pastes the result into a `:repo`
7598 // slot, and produces `https:\\github.com\foo\bar`. Pinned
7599 // separately from the `file://` Explorer-paste arm so a future
7600 // relaxation that narrows to one URL scheme surfaces here.
7601 let d = dep_with_fonte(DepSource::Git {
7602 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7603 tag: Some("v0.1.0".into()),
7604 rev: None,
7605 branch: None,
7606 });
7607 let err = d.validate().unwrap_err();
7608 let DepError::FonteRepoShape { reason, .. } = err else {
7609 panic!("expected FonteRepoShape, got other variant");
7610 };
7611 assert!(
7612 reason.contains("must not contain `\\`"),
7613 "reason must surface the backslash-`\\` arm, got {reason:?}"
7614 );
7615 assert!(
7616 reason.contains("path separator") || reason.contains("path-segment separator"),
7617 "reason must name the URL path-segment separator grammar, got {reason:?}"
7618 );
7619 }
7620
7621 #[test]
7622 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7623 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7624 // are both per-byte arms inside the same `for &b in s.as_bytes()`
7625 // loop, so the byte that appears first in the value's byte order
7626 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7627 // both `#` and `\`; the `#` byte appears first, so the fragment-
7628 // `#` arm fires, surfacing the more self-locating diagnostic on
7629 // the byte the author pasted earliest in the URL. Mirrors the
7630 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7631 // pins on the prior `:repo` byte-class arm.
7632 let d = dep_with_fonte(DepSource::Git {
7633 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7634 tag: Some("v0.1.0".into()),
7635 rev: None,
7636 branch: None,
7637 });
7638 let err = d.validate().unwrap_err();
7639 let DepError::FonteRepoShape { reason, .. } = err else {
7640 panic!("expected FonteRepoShape, got other variant");
7641 };
7642 assert!(
7643 reason.contains("must not contain `#`"),
7644 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7645 `#` byte appears first in value), got {reason:?}"
7646 );
7647 }
7648
7649 #[test]
7650 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7651 // The fail-before-pass-after pin for the canonical URI Template
7652 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7653 // README quick-start snippet / OpenAPI `servers:` URL / Helm
7654 // chart `home:` template that carries unresolved
7655 // `{org}` / `{repo}` placeholders and pastes the raw template
7656 // into the `:repo` slot, expecting the substrate to resolve the
7657 // placeholder downstream. Until this arm landed the value
7658 // silently passed every prior arm (no whitespace, no control
7659 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7660 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7661 // / `%7D` on the wire, so the byte rides verbatim into the
7662 // lacre's per-dep content-address but round-trips inconsistently
7663 // between the lacre's per-dep content-address and the
7664 // resolver's `git clone <repo>` invocation, defeating the
7665 // THEORY.md §V.2 render-determinism contract on the same axis
7666 // the `#` fragment, `?` query, and `\` backslash arms close;
7667 // every git porcelain entry-point additionally fetches a
7668 // nonexistent literal-`{placeholder}`-named path far from the
7669 // source caixa.lisp.
7670 let d = dep_with_fonte(DepSource::Git {
7671 repo: "https://github.com/{org}/caixa-teia".into(),
7672 tag: Some("v0.1.0".into()),
7673 rev: None,
7674 branch: None,
7675 });
7676 let err = d.validate().unwrap_err();
7677 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7678 panic!("expected FonteRepoShape, got other variant");
7679 };
7680 assert_eq!(nome, "caixa-teia");
7681 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7682 assert!(
7683 reason.contains("must not contain `{`"),
7684 "reason must surface the open-brace `{{` arm, got {reason:?}"
7685 );
7686 assert!(
7687 reason.contains("URI Template") || reason.contains("RFC 6570"),
7688 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7689 );
7690 }
7691
7692 #[test]
7693 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7694 // The symmetric Mustache / Handlebars doubled-brace
7695 // substitution-form footgun every CI / IaC templating engine
7696 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7697 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7698 // chart README quick-start snippet emits. Pinned separately
7699 // from the single-`{` `{org}` arm so a future relaxation that
7700 // narrows to one substitution-form surfaces here.
7701 let d = dep_with_fonte(DepSource::Git {
7702 repo: "https://github.com/{{org}}/caixa-teia".into(),
7703 tag: Some("v0.1.0".into()),
7704 rev: None,
7705 branch: None,
7706 });
7707 let err = d.validate().unwrap_err();
7708 let DepError::FonteRepoShape { reason, .. } = err else {
7709 panic!("expected FonteRepoShape, got other variant");
7710 };
7711 assert!(
7712 reason.contains("must not contain `{`"),
7713 "reason must surface the open-brace `{{` arm, got {reason:?}"
7714 );
7715 }
7716
7717 #[test]
7718 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7719 // Asymmetric `}`-only shape — covers the closing-brace-by-
7720 // itself footgun (an author truncated `{org}/{repo}` mid-edit
7721 // and left a trailing `}` from the prior template fragment,
7722 // or pasted a value that included a closing brace from a
7723 // surrounding shell context). Pinned to ensure the predicate
7724 // refuses each brace independently rather than only when both
7725 // appear — a future regression that ANDs the two byte tests
7726 // surfaces here.
7727 let d = dep_with_fonte(DepSource::Git {
7728 repo: "https://github.com/pleme-io/caixa-teia}".into(),
7729 tag: Some("v0.1.0".into()),
7730 rev: None,
7731 branch: None,
7732 });
7733 let err = d.validate().unwrap_err();
7734 let DepError::FonteRepoShape { reason, .. } = err else {
7735 panic!("expected FonteRepoShape, got other variant");
7736 };
7737 assert!(
7738 reason.contains("must not contain `}`"),
7739 "reason must surface the close-brace `}}` arm, got {reason:?}"
7740 );
7741 }
7742
7743 #[test]
7744 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7745 // Cascade pin: the fragment-`#` arm and the template-`{` /
7746 // `}` arm are both per-byte arms inside the same
7747 // `for &b in s.as_bytes()` loop, so the byte that appears
7748 // first in the value's byte order wins. A `:repo
7749 // "https://github.com/p/x#readme{org}"` carries both `#` and
7750 // `{`; the `#` byte appears first, so the fragment-`#` arm
7751 // fires, surfacing the more self-locating diagnostic on the
7752 // byte the author pasted earliest in the URL. Mirrors the
7753 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7754 // pins on the prior `:repo` byte-class arm.
7755 let d = dep_with_fonte(DepSource::Git {
7756 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7757 tag: Some("v0.1.0".into()),
7758 rev: None,
7759 branch: None,
7760 });
7761 let err = d.validate().unwrap_err();
7762 let DepError::FonteRepoShape { reason, .. } = err else {
7763 panic!("expected FonteRepoShape, got other variant");
7764 };
7765 assert!(
7766 reason.contains("must not contain `#`"),
7767 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7768 `#` byte appears first in value), got {reason:?}"
7769 );
7770 }
7771
7772 #[test]
7773 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7774 // The fail-before-pass-after pin for the canonical
7775 // shell-output-redirection footgun on `:repo`: an author
7776 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7777 // / `… >output.txt`) into the `:repo` slot without trimming
7778 // the redirect. Until this arm landed the value silently
7779 // passed every prior arm (no whitespace, no control chars,
7780 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7781 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7782 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7783 // percent-encode set maps `>` → `%3E` on the wire, so the
7784 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7785 // but is silently rewritten or rejected at libcurl's URL-
7786 // parser layer — two authors whose values differ only in
7787 // their redirect tail (`>build.log` vs nothing) resolve to
7788 // the byte-identical upstream `git clone` but lock to two
7789 // distinct lacres, defeating the THEORY.md §V.2 render-
7790 // determinism contract. Peer with the `:caminho` axis's
7791 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7792 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7793 // byte RFC-3986-reserved set on `:entrada :paths`.
7794 let d = dep_with_fonte(DepSource::Git {
7795 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7796 tag: Some("v0.1.0".into()),
7797 rev: None,
7798 branch: None,
7799 });
7800 let err = d.validate().unwrap_err();
7801 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7802 panic!("expected FonteRepoShape, got other variant");
7803 };
7804 assert_eq!(nome, "caixa-teia");
7805 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7806 assert!(
7807 reason.contains("must not contain `>`"),
7808 "reason must surface the output-redirection `>` arm, got {reason:?}"
7809 );
7810 assert!(
7811 reason.contains("redirection") || reason.contains("'delims'"),
7812 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7813 );
7814 }
7815
7816 #[test]
7817 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7818 // The symmetric shell-input-redirection footgun — an author
7819 // pastes a shell-pipeline head (`git clone <input.url` /
7820 // `cat <README.md`) into the `:repo` slot. Pinned separately
7821 // from the `>`-output arm so a future relaxation that only
7822 // catches one of the two redirect bytes surfaces here. Peer
7823 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7824 // arm which closes both `<` and `>` under the same banner.
7825 let d = dep_with_fonte(DepSource::Git {
7826 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7827 tag: Some("v0.1.0".into()),
7828 rev: None,
7829 branch: None,
7830 });
7831 let err = d.validate().unwrap_err();
7832 let DepError::FonteRepoShape { reason, .. } = err else {
7833 panic!("expected FonteRepoShape, got other variant");
7834 };
7835 assert!(
7836 reason.contains("must not contain `<`"),
7837 "reason must surface the input-redirection `<` arm, got {reason:?}"
7838 );
7839 assert!(
7840 reason.contains("RFC 3986") || reason.contains("'unwise'"),
7841 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7842 );
7843 }
7844
7845 #[test]
7846 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7847 // The fail-before-pass-after pin for the canonical
7848 // paste-from-shell-prompt-with-backticked-substitution footgun
7849 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7850 // `:caminho` path-fonte axis). An author pastes a URL whose
7851 // segment carries a backticked command-substitution wrapper
7852 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7853 // from a doc / README quick-start snippet that expected the
7854 // substrate to substitute the value downstream. Until this arm
7855 // landed the value silently passed every prior arm (no
7856 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7857 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7858 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7859 // 'unwise' set and the WHATWG URL spec's fragment percent-
7860 // encode set maps `` ` `` → `%60` on the wire, so the byte
7861 // rides verbatim into the lacre's per-dep BLAKE3 closure but
7862 // is silently rewritten or rejected at libcurl's URL-parser
7863 // layer — two authors whose values differ only in their
7864 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7865 // byte-identical upstream `git clone` but lock to two distinct
7866 // lacres, defeating the THEORY.md §V.2 render-determinism
7867 // contract. Peer with the `:caminho` axis's
7868 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7869 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7870 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7871 let d = dep_with_fonte(DepSource::Git {
7872 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7873 tag: Some("v0.1.0".into()),
7874 rev: None,
7875 branch: None,
7876 });
7877 let err = d.validate().unwrap_err();
7878 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7879 panic!("expected FonteRepoShape, got other variant");
7880 };
7881 assert_eq!(nome, "caixa-teia");
7882 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7883 assert!(
7884 reason.contains("must not contain `` ` ``"),
7885 "reason must surface the backtick command-substitution arm, got {reason:?}"
7886 );
7887 assert!(
7888 reason.contains("command-substitution") || reason.contains("'unwise'"),
7889 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7890 got {reason:?}"
7891 );
7892 }
7893
7894 #[test]
7895 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7896 // Cascade pin: the fragment-`#` arm and the backtick command-
7897 // substitution arm are both per-byte arms inside the same
7898 // `for &b in s.as_bytes()` loop, so the byte that appears first
7899 // in the value's byte order wins. A `:repo
7900 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7901 // and backtick; the `#` byte appears first, so the fragment-
7902 // `#` arm fires, surfacing the more self-locating diagnostic
7903 // on the byte the author pasted earliest in the URL. Mirrors
7904 // the peer cascade discipline
7905 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7906 // pins on the prior `:repo` byte-class arm.
7907 let d = dep_with_fonte(DepSource::Git {
7908 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".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 { reason, .. } = err else {
7915 panic!("expected FonteRepoShape, got other variant");
7916 };
7917 assert!(
7918 reason.contains("must not contain `#`"),
7919 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7920 appears first in value), got {reason:?}"
7921 );
7922 }
7923
7924 #[test]
7925 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7926 // Cascade pin: the shell-redirection `<` / `>` arm and the
7927 // backtick command-substitution arm are both per-byte arms
7928 // inside the same `for &b in s.as_bytes()` loop, so the byte
7929 // that appears first in the value's byte order wins. A `:repo
7930 // "https://github.com/p/x>build.log/`whoami`"` carries both
7931 // `>` and backtick; the `>` byte appears first, so the
7932 // shell-redirection arm fires, surfacing the more self-
7933 // locating diagnostic on the byte the author pasted earliest
7934 // in the URL. Pins the natural-order cascade so a future
7935 // reorder of the per-byte arms surfaces here.
7936 let d = dep_with_fonte(DepSource::Git {
7937 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7938 tag: Some("v0.1.0".into()),
7939 rev: None,
7940 branch: None,
7941 });
7942 let err = d.validate().unwrap_err();
7943 let DepError::FonteRepoShape { reason, .. } = err else {
7944 panic!("expected FonteRepoShape, got other variant");
7945 };
7946 assert!(
7947 reason.contains("must not contain `>`"),
7948 "reason must surface the shell-redirection `>` arm (fires before backtick when \
7949 `>` byte appears first in value), got {reason:?}"
7950 );
7951 }
7952
7953 #[test]
7954 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7955 // Cascade pin: the fragment-`#` arm and the shell-redirection
7956 // `<` / `>` arm are both per-byte arms inside the same
7957 // `for &b in s.as_bytes()` loop, so the byte that appears
7958 // first in the value's byte order wins. A `:repo
7959 // "https://github.com/p/x#readme>build.log"` carries both
7960 // `#` and `>`; the `#` byte appears first, so the fragment-
7961 // `#` arm fires, surfacing the more self-locating diagnostic
7962 // on the byte the author pasted earliest in the URL. Mirrors
7963 // the peer cascade discipline
7964 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7965 // pins on the prior `:repo` byte-class arm.
7966 let d = dep_with_fonte(DepSource::Git {
7967 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7968 tag: Some("v0.1.0".into()),
7969 rev: None,
7970 branch: None,
7971 });
7972 let err = d.validate().unwrap_err();
7973 let DepError::FonteRepoShape { reason, .. } = err else {
7974 panic!("expected FonteRepoShape, got other variant");
7975 };
7976 assert!(
7977 reason.contains("must not contain `#`"),
7978 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7979 `#` byte appears first in value), got {reason:?}"
7980 );
7981 }
7982
7983 #[test]
7984 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7985 // The fail-before-pass-after pin for the canonical
7986 // paste-from-shell-prompt-with-piped-pipeline footgun on
7987 // `:repo` (peer with the 124106f pipe arm on the sibling
7988 // `:caminho` path-fonte axis). An author pastes a shell
7989 // pipeline (`git clone <url> | tee build.log`,
7990 // `git ls-remote <url> | head`) into the `:repo` slot,
7991 // forgetting to trim the `| <consumer>` tail. Until this arm
7992 // landed the value silently passed every prior arm (no
7993 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7994 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7995 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7996 // 'unwise' set and the WHATWG URL spec's fragment percent-
7997 // encode set maps `|` → `%7C` on the wire, so the byte rides
7998 // verbatim into the lacre's per-dep BLAKE3 closure but is
7999 // silently rewritten or rejected at libcurl's URL-parser
8000 // layer — two authors whose values differ only in their pipe
8001 // tail (`|tee build.log` vs nothing) resolve to the byte-
8002 // identical upstream `git clone` but lock to two distinct
8003 // lacres, defeating the THEORY.md §V.2 render-determinism
8004 // contract. Peer with the `:caminho` axis's
8005 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
8006 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
8007 // RFC-3986-reserved set on `:entrada :paths`.
8008 let d = dep_with_fonte(DepSource::Git {
8009 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
8010 tag: Some("v0.1.0".into()),
8011 rev: None,
8012 branch: None,
8013 });
8014 let err = d.validate().unwrap_err();
8015 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8016 panic!("expected FonteRepoShape, got other variant");
8017 };
8018 assert_eq!(nome, "caixa-teia");
8019 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
8020 assert!(
8021 reason.contains("must not contain `|`"),
8022 "reason must surface the shell-pipe arm, got {reason:?}"
8023 );
8024 assert!(
8025 reason.contains("pipe") || reason.contains("'unwise'"),
8026 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
8027 );
8028 }
8029
8030 #[test]
8031 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
8032 // Cascade pin: the fragment-`#` arm and the pipe arm are both
8033 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8034 // so the byte that appears first in the value's byte order
8035 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
8036 // both `#` and `|`; the `#` byte appears first, so the
8037 // fragment-`#` arm fires, surfacing the more self-locating
8038 // diagnostic on the byte the author pasted earliest in the
8039 // URL. Mirrors the peer cascade discipline
8040 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
8041 // pins on the prior `:repo` byte-class arm.
8042 let d = dep_with_fonte(DepSource::Git {
8043 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
8044 tag: Some("v0.1.0".into()),
8045 rev: None,
8046 branch: None,
8047 });
8048 let err = d.validate().unwrap_err();
8049 let DepError::FonteRepoShape { reason, .. } = err else {
8050 panic!("expected FonteRepoShape, got other variant");
8051 };
8052 assert!(
8053 reason.contains("must not contain `#`"),
8054 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
8055 appears first in value), got {reason:?}"
8056 );
8057 }
8058
8059 #[test]
8060 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
8061 // Cascade pin: the backtick arm and the pipe arm are both per-
8062 // byte arms inside the same `for &b in s.as_bytes()` loop, so
8063 // the byte that appears first in the value's byte order wins.
8064 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
8065 // `` ` `` and `|`; the backtick byte appears first, so the
8066 // backtick arm fires, surfacing the more self-locating
8067 // diagnostic on the byte the author pasted earliest in the
8068 // URL. Pins the natural-order cascade so a future reorder of
8069 // the per-byte arms surfaces here.
8070 let d = dep_with_fonte(DepSource::Git {
8071 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
8072 tag: Some("v0.1.0".into()),
8073 rev: None,
8074 branch: None,
8075 });
8076 let err = d.validate().unwrap_err();
8077 let DepError::FonteRepoShape { reason, .. } = err else {
8078 panic!("expected FonteRepoShape, got other variant");
8079 };
8080 assert!(
8081 reason.contains("must not contain `` ` ``"),
8082 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
8083 appears first in value), got {reason:?}"
8084 );
8085 }
8086
8087 #[test]
8088 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
8089 // The fail-before-pass-after pin for the canonical
8090 // paste-from-shell-prompt-with-sequential-command-tail footgun
8091 // on `:repo` (peer with the 05c358e `;` arm on the sibling
8092 // `:caminho` path-fonte axis). An author pastes a shell
8093 // one-liner that chained a cleanup tail after the URL
8094 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
8095 // echo done`) into the `:repo` slot, forgetting to trim the
8096 // `; <cmd>` tail. Until this arm landed the value silently
8097 // passed every prior `is_git_repo_url` arm (no whitespace, no
8098 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
8099 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
8100 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
8101 // reserved set and the WHATWG URL spec's fragment percent-
8102 // encode set maps `;` → `%3B` on the wire, so the byte rides
8103 // verbatim into the lacre's per-dep BLAKE3 closure but is
8104 // silently rewritten at libcurl's URL-parser layer — two
8105 // authors whose values differ only in their sequential-command
8106 // tail (`; rm -rf build` vs nothing) resolve to the byte-
8107 // identical upstream `git clone` but lock to two distinct
8108 // lacres, defeating the THEORY.md §V.2 render-determinism
8109 // contract. Peer with the `:caminho` axis's
8110 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
8111 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8112 // byte RFC-3986-reserved set on `:entrada :paths`.
8113 let d = dep_with_fonte(DepSource::Git {
8114 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
8115 tag: Some("v0.1.0".into()),
8116 rev: None,
8117 branch: None,
8118 });
8119 let err = d.validate().unwrap_err();
8120 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8121 panic!("expected FonteRepoShape, got other variant");
8122 };
8123 assert_eq!(nome, "caixa-teia");
8124 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
8125 assert!(
8126 reason.contains("must not contain `;`"),
8127 "reason must surface the shell-command-separator arm, got {reason:?}"
8128 );
8129 assert!(
8130 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
8131 "reason must name the shell-command-separator / RFC-3986-sub-delims \
8132 rationale, got {reason:?}"
8133 );
8134 }
8135
8136 #[test]
8137 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
8138 // Cascade pin: the fragment-`#` arm and the semicolon arm are
8139 // both per-byte arms inside the same `for &b in s.as_bytes()`
8140 // loop, so the byte that appears first in the value's byte
8141 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
8142 // carries both `#` and `;`; the `#` byte appears first, so the
8143 // fragment-`#` arm fires, surfacing the more self-locating
8144 // diagnostic on the byte the author pasted earliest in the URL.
8145 // Mirrors the peer cascade discipline
8146 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
8147 // pins on the prior `:repo` byte-class arm.
8148 let d = dep_with_fonte(DepSource::Git {
8149 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
8150 tag: Some("v0.1.0".into()),
8151 rev: None,
8152 branch: None,
8153 });
8154 let err = d.validate().unwrap_err();
8155 let DepError::FonteRepoShape { reason, .. } = err else {
8156 panic!("expected FonteRepoShape, got other variant");
8157 };
8158 assert!(
8159 reason.contains("must not contain `#`"),
8160 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
8161 byte appears first in value), got {reason:?}"
8162 );
8163 }
8164
8165 #[test]
8166 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
8167 // Cascade pin: the pipe arm and the semicolon arm are both
8168 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8169 // so the byte that appears first in the value's byte order
8170 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
8171 // both `|` and `;`; the `|` byte appears first, so the
8172 // pipe arm fires, surfacing the more self-locating diagnostic
8173 // on the byte the author pasted earliest in the URL. Pins the
8174 // natural-order cascade so a future reorder of the per-byte
8175 // arms surfaces here.
8176 let d = dep_with_fonte(DepSource::Git {
8177 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
8178 tag: Some("v0.1.0".into()),
8179 rev: None,
8180 branch: None,
8181 });
8182 let err = d.validate().unwrap_err();
8183 let DepError::FonteRepoShape { reason, .. } = err else {
8184 panic!("expected FonteRepoShape, got other variant");
8185 };
8186 assert!(
8187 reason.contains("must not contain `|`"),
8188 "reason must surface the pipe arm (fires before semicolon when `|` byte \
8189 appears first in value), got {reason:?}"
8190 );
8191 }
8192
8193 #[test]
8194 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
8195 // The fail-before-pass-after pin for the canonical
8196 // paste-from-shell-prompt-with-background-launch-tail footgun
8197 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
8198 // `:caminho` path-fonte axis). An author pastes a shell one-
8199 // liner that detached the clone into the background
8200 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
8201 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
8202 // `&& <cmd>` tail. Until this arm landed the value silently
8203 // passed every prior `is_git_repo_url` arm (no whitespace,
8204 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
8205 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8206 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
8207 // the 'sub-delims' / reserved set and the WHATWG URL spec's
8208 // fragment percent-encode set maps `&` → `%26` on the wire,
8209 // so the byte rides verbatim into the lacre's per-dep
8210 // BLAKE3 closure but is silently rewritten at libcurl's
8211 // URL-parser layer — two authors whose values differ only
8212 // in their background-launch tail (`& sleep 1` vs nothing)
8213 // resolve to the byte-identical upstream `git clone` but
8214 // lock to two distinct lacres, defeating the THEORY.md
8215 // §V.2 render-determinism contract. Peer with the
8216 // `:caminho` axis's `FonteCaminhoShellBackground` arm
8217 // (e12e4f3) on the sibling path-fonte axis, and
8218 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
8219 // reserved set on `:entrada :paths`.
8220 let d = dep_with_fonte(DepSource::Git {
8221 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
8222 tag: Some("v0.1.0".into()),
8223 rev: None,
8224 branch: None,
8225 });
8226 let err = d.validate().unwrap_err();
8227 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8228 panic!("expected FonteRepoShape, got other variant");
8229 };
8230 assert_eq!(nome, "caixa-teia");
8231 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
8232 assert!(
8233 reason.contains("must not contain `&`"),
8234 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
8235 );
8236 assert!(
8237 reason.contains("background-task") || reason.contains("'sub-delims'"),
8238 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
8239 got {reason:?}"
8240 );
8241 }
8242
8243 #[test]
8244 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
8245 // The fail-before-pass-after pin for the symmetric `&&`
8246 // logical-AND build-chain paste footgun: an author pastes
8247 // a `git clone <url> && cd <repo>` build-chain one-liner
8248 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
8249 // is the same `&` byte twice in a row; the per-byte arm
8250 // fires on the first `&` it sees. Pinned separately from
8251 // the single-`&` background-launch shape so a future
8252 // diagnostic-surface change that special-cased the
8253 // doubled-byte form surfaces here.
8254 let d = dep_with_fonte(DepSource::Git {
8255 repo: "github:pleme-io/caixa-teia&&echo".into(),
8256 tag: Some("v0.1.0".into()),
8257 rev: None,
8258 branch: None,
8259 });
8260 let err = d.validate().unwrap_err();
8261 let DepError::FonteRepoShape { reason, .. } = err else {
8262 panic!("expected FonteRepoShape, got other variant");
8263 };
8264 assert!(
8265 reason.contains("must not contain `&`"),
8266 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
8267 shape too, got {reason:?}"
8268 );
8269 }
8270
8271 #[test]
8272 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
8273 // Cascade pin: the fragment-`#` arm and the background-`&`
8274 // arm are both per-byte arms inside the same `for &b in
8275 // s.as_bytes()` loop, so the byte that appears first in the
8276 // value's byte order wins. A `:repo
8277 // "https://github.com/p/x#readme & sleep"` carries both `#`
8278 // and `&`; the `#` byte appears first, so the fragment-`#`
8279 // arm fires, surfacing the more self-locating diagnostic on
8280 // the byte the author pasted earliest in the URL. Mirrors
8281 // the peer cascade discipline
8282 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
8283 // on the prior `:repo` byte-class arm.
8284 let d = dep_with_fonte(DepSource::Git {
8285 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
8286 tag: Some("v0.1.0".into()),
8287 rev: None,
8288 branch: None,
8289 });
8290 let err = d.validate().unwrap_err();
8291 let DepError::FonteRepoShape { reason, .. } = err else {
8292 panic!("expected FonteRepoShape, got other variant");
8293 };
8294 assert!(
8295 reason.contains("must not contain `#`"),
8296 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
8297 byte appears first in value), got {reason:?}"
8298 );
8299 }
8300
8301 #[test]
8302 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
8303 // Cascade pin: the semicolon arm and the background-`&` arm
8304 // are both per-byte arms inside the same `for &b in
8305 // s.as_bytes()` loop, so the byte that appears first in the
8306 // value's byte order wins. A `:repo
8307 // "https://github.com/p/x; rm & sleep"` carries both `;` and
8308 // `&`; the `;` byte appears first, so the semicolon arm
8309 // fires, surfacing the more self-locating diagnostic on the
8310 // byte the author pasted earliest in the URL. Pins the
8311 // natural-order cascade so a future reorder of the per-byte
8312 // arms surfaces here.
8313 let d = dep_with_fonte(DepSource::Git {
8314 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
8315 tag: Some("v0.1.0".into()),
8316 rev: None,
8317 branch: None,
8318 });
8319 let err = d.validate().unwrap_err();
8320 let DepError::FonteRepoShape { reason, .. } = err else {
8321 panic!("expected FonteRepoShape, got other variant");
8322 };
8323 assert!(
8324 reason.contains("must not contain `;`"),
8325 "reason must surface the semicolon arm (fires before background-`&` when `;` \
8326 byte appears first in value), got {reason:?}"
8327 );
8328 }
8329
8330 #[test]
8331 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
8332 // The fail-before-pass-after pin for the canonical
8333 // paste-from-shell-prompt-with-unsubstituted-variable footgun
8334 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
8335 // `:caminho` path-fonte axis). An author pastes a shell one-
8336 // liner that referenced an environment variable
8337 // (`git clone https://github.com/$ORG/x`, `git clone
8338 // github:$USER/repo`) into the `:repo` slot, forgetting to
8339 // substitute the literal value at author time. Until this arm
8340 // landed the value silently passed every prior
8341 // `is_git_repo_url` arm (no whitespace, no control chars, no
8342 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8343 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
8344 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
8345 // reserved set and the WHATWG URL spec's fragment percent-
8346 // encode set maps `$` → `%24` on the wire, so the byte rides
8347 // verbatim into the lacre's per-dep BLAKE3 closure but is
8348 // silently rewritten at libcurl's URL-parser layer — two
8349 // authors whose values differ only in their `$VAR` /
8350 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
8351 // identical upstream `git clone` but lock to two distinct
8352 // lacres, defeating the THEORY.md §V.2 render-determinism
8353 // contract. Beyond determinism, the value is a structural
8354 // host-layout leak: two authors with the same `:repo` slot
8355 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
8356 // different upstreams. Peer with the `:caminho` axis's
8357 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
8358 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8359 // byte RFC-3986-reserved set on `:entrada :paths`.
8360 let d = dep_with_fonte(DepSource::Git {
8361 repo: "https://github.com/$ORG/caixa-teia".into(),
8362 tag: Some("v0.1.0".into()),
8363 rev: None,
8364 branch: None,
8365 });
8366 let err = d.validate().unwrap_err();
8367 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8368 panic!("expected FonteRepoShape, got other variant");
8369 };
8370 assert_eq!(nome, "caixa-teia");
8371 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
8372 assert!(
8373 reason.contains("must not contain `$`"),
8374 "reason must surface the shell-variable-expansion arm, got {reason:?}"
8375 );
8376 assert!(
8377 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
8378 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
8379 rationale, got {reason:?}"
8380 );
8381 }
8382
8383 #[test]
8384 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
8385 // The fail-before-pass-after pin for the symmetric POSIX-
8386 // shell braced `${VAR}` expansion paste footgun: an author
8387 // pastes a CI-manifest line `git clone
8388 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
8389 // Actions / GitLab CI / Drone shape) and forgets to
8390 // substitute the literal value. The `${...}` shape is the
8391 // same `$` byte at the leading position of the expansion;
8392 // the per-byte arm fires on the `$`. Pinned separately from
8393 // the bare-`$VAR` shape so a future diagnostic-surface
8394 // change that special-cased the braced form surfaces here.
8395 let d = dep_with_fonte(DepSource::Git {
8396 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
8397 tag: Some("v0.1.0".into()),
8398 rev: None,
8399 branch: None,
8400 });
8401 let err = d.validate().unwrap_err();
8402 let DepError::FonteRepoShape { reason, .. } = err else {
8403 panic!("expected FonteRepoShape, got other variant");
8404 };
8405 assert!(
8406 reason.contains("must not contain `$`"),
8407 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
8408 shape too, got {reason:?}"
8409 );
8410 }
8411
8412 #[test]
8413 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
8414 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
8415 // arm are both per-byte arms inside the same `for &b in
8416 // s.as_bytes()` loop, so the byte that appears first in the
8417 // value's byte order wins. A `:repo
8418 // "https://github.com/p/x#readme$HOME"` carries both `#` and
8419 // `$`; the `#` byte appears first, so the fragment-`#` arm
8420 // fires, surfacing the more self-locating diagnostic on the
8421 // byte the author pasted earliest in the URL. Mirrors the
8422 // peer cascade discipline
8423 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
8424 // on the prior `:repo` byte-class arm.
8425 let d = dep_with_fonte(DepSource::Git {
8426 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
8427 tag: Some("v0.1.0".into()),
8428 rev: None,
8429 branch: None,
8430 });
8431 let err = d.validate().unwrap_err();
8432 let DepError::FonteRepoShape { reason, .. } = err else {
8433 panic!("expected FonteRepoShape, got other variant");
8434 };
8435 assert!(
8436 reason.contains("must not contain `#`"),
8437 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
8438 `#` byte appears first in value), got {reason:?}"
8439 );
8440 }
8441
8442 #[test]
8443 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
8444 // Cascade pin: the background-`&` arm and the
8445 // var-expansion-`$` arm are both per-byte arms inside the
8446 // same `for &b in s.as_bytes()` loop, so the byte that
8447 // appears first in the value's byte order wins. A `:repo
8448 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
8449 // `$`; the `&` byte appears first, so the background arm
8450 // fires, surfacing the more self-locating diagnostic on the
8451 // byte the author pasted earliest in the URL. Pins the
8452 // natural-order cascade so a future reorder of the per-byte
8453 // arms surfaces here — `$` is the most recent byte-class arm,
8454 // so the cascade-pin sweep extends to cover every immediately
8455 // prior byte arm (`#`, `&`) firing first when ordered ahead
8456 // of `$` in the value.
8457 let d = dep_with_fonte(DepSource::Git {
8458 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".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 { reason, .. } = err else {
8465 panic!("expected FonteRepoShape, got other variant");
8466 };
8467 assert!(
8468 reason.contains("must not contain `&`"),
8469 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
8470 `&` byte appears first in value), got {reason:?}"
8471 );
8472 }
8473
8474 #[test]
8475 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
8476 // The fail-before-pass-after pin for the canonical
8477 // paste-from-shell-prompt glob footgun on `:repo` (peer with
8478 // the cf9034b `*` / `?` arm on the sibling `:caminho`
8479 // path-fonte axis). An author pastes a shell one-liner that
8480 // referenced a glob expansion (`ls
8481 // github.com/pleme-io/caixa-*`, `git clone
8482 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
8483 // to substitute the literal repo name. Until this arm landed
8484 // the `*` byte silently passed every prior `is_git_repo_url`
8485 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
8486 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
8487 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
8488 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
8489 // the WHATWG URL spec's special-query percent-encode set maps
8490 // `*` → `%2A` on the wire, so the byte rides verbatim into
8491 // the lacre's per-dep BLAKE3 closure but is silently
8492 // rewritten at libcurl's URL-parser layer — two authors
8493 // whose values differ only in their asterisk presence
8494 // resolve to the byte-identical upstream `git clone` but
8495 // lock to two distinct lacres, defeating the THEORY.md §V.2
8496 // render-determinism contract. Peer with the `:caminho`
8497 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
8498 // sibling path-fonte axis, and the `is_git_ref_name`
8499 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
8500 // axes.
8501 let d = dep_with_fonte(DepSource::Git {
8502 repo: "https://github.com/pleme-io/caixa-*".into(),
8503 tag: Some("v0.1.0".into()),
8504 rev: None,
8505 branch: None,
8506 });
8507 let err = d.validate().unwrap_err();
8508 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8509 panic!("expected FonteRepoShape, got other variant");
8510 };
8511 assert_eq!(nome, "caixa-teia");
8512 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
8513 assert!(
8514 reason.contains("must not contain `*`"),
8515 "reason must surface the shell-glob arm, got {reason:?}"
8516 );
8517 assert!(
8518 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
8519 "reason must name the shell-glob / pathname-expansion / \
8520 RFC-3986-sub-delims rationale, got {reason:?}"
8521 );
8522 }
8523
8524 #[test]
8525 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
8526 // The fail-before-pass-after pin for the symmetric bash
8527 // `globstar` recursive-glob paste footgun: an author pastes
8528 // a `ls github.com/pleme-io/**/x` (the canonical
8529 // `globstar`-shopt-enabled recursive-listing tail) into the
8530 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
8531 // the per-byte arm fires on the first `*`. Pinned
8532 // separately from the single-`*` shape so a future
8533 // diagnostic-surface change that special-cased the
8534 // double-`*` form surfaces here.
8535 let d = dep_with_fonte(DepSource::Git {
8536 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
8537 tag: Some("v0.1.0".into()),
8538 rev: None,
8539 branch: None,
8540 });
8541 let err = d.validate().unwrap_err();
8542 let DepError::FonteRepoShape { reason, .. } = err else {
8543 panic!("expected FonteRepoShape, got other variant");
8544 };
8545 assert!(
8546 reason.contains("must not contain `*`"),
8547 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8548 got {reason:?}"
8549 );
8550 }
8551
8552 #[test]
8553 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8554 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8555 // both per-byte arms inside the same `for &b in s.as_bytes()`
8556 // loop, so the byte that appears first in the value's byte
8557 // order wins. A `:repo
8558 // "https://github.com/p/x#readme*tail"` carries both `#` and
8559 // `*`; the `#` byte appears first, so the fragment-`#` arm
8560 // fires, surfacing the more self-locating diagnostic on the
8561 // byte the author pasted earliest in the URL. Mirrors the
8562 // peer cascade discipline
8563 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8564 // on the prior `:repo` byte-class arm.
8565 let d = dep_with_fonte(DepSource::Git {
8566 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8567 tag: Some("v0.1.0".into()),
8568 rev: None,
8569 branch: None,
8570 });
8571 let err = d.validate().unwrap_err();
8572 let DepError::FonteRepoShape { reason, .. } = err else {
8573 panic!("expected FonteRepoShape, got other variant");
8574 };
8575 assert!(
8576 reason.contains("must not contain `#`"),
8577 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8578 appears first in value), got {reason:?}"
8579 );
8580 }
8581
8582 #[test]
8583 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8584 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8585 // arm are both per-byte arms inside the same `for &b in
8586 // s.as_bytes()` loop, so the byte that appears first in the
8587 // value's byte order wins. A `:repo
8588 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8589 // the `$` byte appears first, so the var-expansion arm
8590 // fires, surfacing the more self-locating diagnostic on the
8591 // byte the author pasted earliest in the URL. Pins the
8592 // natural-order cascade so a future reorder of the per-byte
8593 // arms surfaces here — `*` is the most recent byte-class
8594 // arm, so the cascade-pin sweep extends to cover the
8595 // immediately prior `$` byte arm firing first when ordered
8596 // ahead of `*` in the value.
8597 let d = dep_with_fonte(DepSource::Git {
8598 repo: "https://github.com/pleme-io/$ORG-caixa-*".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 { reason, .. } = err else {
8605 panic!("expected FonteRepoShape, got other variant");
8606 };
8607 assert!(
8608 reason.contains("must not contain `$`"),
8609 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8610 byte appears first in value), got {reason:?}"
8611 );
8612 }
8613
8614 #[test]
8615 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8616 // The fail-before-pass-after pin for the canonical paste-from-
8617 // shell-prompt subshell-grouping footgun on `:repo`. An author
8618 // pastes a doc / README snippet carrying a regex-alternation
8619 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8620 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8621 // `:repo` slot, forgetting to substitute one literal org name.
8622 // Until this arm landed the `(` byte silently passed every
8623 // prior `is_git_repo_url` arm (no whitespace, no control
8624 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8625 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8626 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8627 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8628 // URL spec's special-query percent-encode set maps `(` →
8629 // `%28` and `)` → `%29` on the wire, so the byte rides
8630 // verbatim into the lacre's per-dep BLAKE3 closure but is
8631 // silently rewritten at libcurl's URL-parser layer —
8632 // defeating the THEORY.md §V.2 render-determinism contract on
8633 // the same axis the prior twelve byte-class arms close.
8634 let d = dep_with_fonte(DepSource::Git {
8635 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8636 tag: Some("v0.1.0".into()),
8637 rev: None,
8638 branch: None,
8639 });
8640 let err = d.validate().unwrap_err();
8641 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8642 panic!("expected FonteRepoShape, got other variant");
8643 };
8644 assert_eq!(nome, "caixa-teia");
8645 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8646 assert!(
8647 reason.contains("must not contain `(`"),
8648 "reason must surface the subshell-open-paren arm, got {reason:?}"
8649 );
8650 assert!(
8651 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8652 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8653 got {reason:?}"
8654 );
8655 }
8656
8657 #[test]
8658 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8659 // The symmetric arm pin on the closing `)` byte: an author
8660 // pastes a `$(date)` command-substitution wrapper or a
8661 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8662 // Pinned separately from the opening `(` shape so a future
8663 // diagnostic-surface change that only checked one boundary
8664 // surfaces here. The `(` byte appears earlier in the
8665 // canonical regex / subshell wrapper so the per-byte loop
8666 // fires on `(` first; this test exercises a `:repo` value
8667 // carrying only the closing `)` byte (no opening paren) so
8668 // the `)` arm fires directly — pinning the byte-class arm
8669 // independent of order.
8670 let d = dep_with_fonte(DepSource::Git {
8671 repo: "github:pleme-io/caixa-teia)tail".into(),
8672 tag: Some("v0.1.0".into()),
8673 rev: None,
8674 branch: None,
8675 });
8676 let err = d.validate().unwrap_err();
8677 let DepError::FonteRepoShape { reason, .. } = err else {
8678 panic!("expected FonteRepoShape, got other variant");
8679 };
8680 assert!(
8681 reason.contains("must not contain `)`"),
8682 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8683 got {reason:?}"
8684 );
8685 }
8686
8687 #[test]
8688 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8689 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8690 // are both per-byte arms inside the same `for &b in
8691 // s.as_bytes()` loop, so the byte that appears first in the
8692 // value's byte order wins. A `:repo
8693 // "https://github.com/p/x#readme(tail)"` carries both `#` and
8694 // `(`; the `#` byte appears first, so the fragment-`#` arm
8695 // fires, surfacing the more self-locating diagnostic on the
8696 // byte the author pasted earliest in the URL. Mirrors the
8697 // peer cascade discipline
8698 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8699 // on the prior `:repo` byte-class arm.
8700 let d = dep_with_fonte(DepSource::Git {
8701 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8702 tag: Some("v0.1.0".into()),
8703 rev: None,
8704 branch: None,
8705 });
8706 let err = d.validate().unwrap_err();
8707 let DepError::FonteRepoShape { reason, .. } = err else {
8708 panic!("expected FonteRepoShape, got other variant");
8709 };
8710 assert!(
8711 reason.contains("must not contain `#`"),
8712 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8713 byte appears first in value), got {reason:?}"
8714 );
8715 }
8716
8717 #[test]
8718 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8719 // Cascade pin: the glob-`*` arm (the immediate-predecessor
8720 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8721 // per-byte arms inside the same `for &b in s.as_bytes()`
8722 // loop, so the byte that appears first in the value's byte
8723 // order wins. A `:repo
8724 // "https://github.com/p/x-*-(date)"` carries both `*` and
8725 // `(`; the `*` byte appears first, so the glob arm fires,
8726 // surfacing the more self-locating diagnostic on the byte
8727 // the author pasted earliest in the URL. Pins the natural-
8728 // order cascade so a future reorder of the per-byte arms
8729 // surfaces here — `(` is the most recent byte-class arm,
8730 // so the cascade-pin sweep extends to cover the immediately
8731 // prior `*` byte arm firing first when ordered ahead of `(`
8732 // in the value.
8733 let d = dep_with_fonte(DepSource::Git {
8734 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8735 tag: Some("v0.1.0".into()),
8736 rev: None,
8737 branch: None,
8738 });
8739 let err = d.validate().unwrap_err();
8740 let DepError::FonteRepoShape { reason, .. } = err else {
8741 panic!("expected FonteRepoShape, got other variant");
8742 };
8743 assert!(
8744 reason.contains("must not contain `*`"),
8745 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8746 appears first in value), got {reason:?}"
8747 );
8748 }
8749
8750 #[test]
8751 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8752 // The fail-before-pass-after pin for the canonical paste-from-
8753 // doc-shell-quoting footgun on `:repo`. An author copies a
8754 // README quick-start snippet (`$ git clone "https://github.com/
8755 // foo/bar"`) and keeps the surrounding double-quote bytes when
8756 // pasting into the `:repo` slot — the doc wraps the URL in
8757 // double quotes so the shell doesn't re-lex metachars inside,
8758 // but the typed slot is itself a byte-level string parser, not
8759 // a shell context, so the quote bytes ride into the value
8760 // verbatim. Until this arm landed the `"` byte silently passed
8761 // every prior `is_git_repo_url` arm (no whitespace, no control
8762 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8763 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8764 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8765 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8766 // `` ` ``) every URL parser is required to refuse or percent-
8767 // encode, and the WHATWG URL spec's 'C0 control percent-encode
8768 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8769 // into the lacre's per-dep BLAKE3 closure but is silently
8770 // rewritten at libcurl's URL-parser layer, defeating the
8771 // THEORY.md §V.2 render-determinism contract.
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 { nome, repo, reason } = err else {
8780 panic!("expected FonteRepoShape, got other variant");
8781 };
8782 assert_eq!(nome, "caixa-teia");
8783 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8784 assert!(
8785 reason.contains("must not contain `\"`"),
8786 "reason must surface the shell-double-quote arm, got {reason:?}"
8787 );
8788 assert!(
8789 reason.contains("double-quote") || reason.contains("'delims'"),
8790 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8791 got {reason:?}"
8792 );
8793 }
8794
8795 #[test]
8796 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8797 // The symmetric stray-quote tail pin: an author pastes only a
8798 // closing `"` from a shell-history line like `git clone
8799 // "https://github.com/foo/bar" && cd …` (the trim went too
8800 // far in one direction but not the other) into the `:repo`
8801 // slot. Pinned separately from the wrapped-quote shape so a
8802 // future diagnostic-surface change that only checked one
8803 // boundary (only leading, only trailing, only paired) surfaces
8804 // here — the per-byte arm fires anywhere `"` appears.
8805 let d = dep_with_fonte(DepSource::Git {
8806 repo: "github:pleme-io/caixa-teia\"".into(),
8807 tag: Some("v0.1.0".into()),
8808 rev: None,
8809 branch: None,
8810 });
8811 let err = d.validate().unwrap_err();
8812 let DepError::FonteRepoShape { reason, .. } = err else {
8813 panic!("expected FonteRepoShape, got other variant");
8814 };
8815 assert!(
8816 reason.contains("must not contain `\"`"),
8817 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8818 got {reason:?}"
8819 );
8820 }
8821
8822 #[test]
8823 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8824 // Cascade pin: the fragment-`#` arm and the double-quote arm
8825 // are both per-byte arms inside the same `for &b in
8826 // s.as_bytes()` loop, so the byte that appears first in the
8827 // value's byte order wins. A `:repo
8828 // "https://github.com/p/x#readme\"tail"` carries both `#` and
8829 // `"`; the `#` byte appears first, so the fragment-`#` arm
8830 // fires, surfacing the more self-locating diagnostic on the
8831 // byte the author pasted earliest in the URL.
8832 let d = dep_with_fonte(DepSource::Git {
8833 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8834 tag: Some("v0.1.0".into()),
8835 rev: None,
8836 branch: None,
8837 });
8838 let err = d.validate().unwrap_err();
8839 let DepError::FonteRepoShape { reason, .. } = err else {
8840 panic!("expected FonteRepoShape, got other variant");
8841 };
8842 assert!(
8843 reason.contains("must not contain `#`"),
8844 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8845 byte appears first in value), got {reason:?}"
8846 );
8847 }
8848
8849 #[test]
8850 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8851 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8852 // byte-class arm, 3b99147) and the double-quote arm are both
8853 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8854 // so the byte that appears first in the value's byte order
8855 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8856 // and `"`; the `(` byte appears first, so the subshell arm
8857 // fires, surfacing the more self-locating diagnostic on the
8858 // byte the author pasted earliest in the URL. Pins the natural-
8859 // order cascade so a future reorder of the per-byte arms
8860 // surfaces here — `"` is the most recent byte-class arm, so
8861 // the cascade-pin sweep extends to cover the immediately prior
8862 // `(` byte arm firing first when ordered ahead of `"` in the
8863 // value.
8864 let d = dep_with_fonte(DepSource::Git {
8865 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8866 tag: Some("v0.1.0".into()),
8867 rev: None,
8868 branch: None,
8869 });
8870 let err = d.validate().unwrap_err();
8871 let DepError::FonteRepoShape { reason, .. } = err else {
8872 panic!("expected FonteRepoShape, got other variant");
8873 };
8874 assert!(
8875 reason.contains("must not contain `(`"),
8876 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8877 byte appears first in value), got {reason:?}"
8878 );
8879 }
8880
8881 #[test]
8882 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8883 // The fail-before-pass-after pin for the canonical paste-from-
8884 // doc-strong-quoting footgun on `:repo`. An author copies a
8885 // security-conscious README quick-start snippet (`$ git clone
8886 // 'https://github.com/foo/bar'`) and keeps the surrounding
8887 // single-quote bytes when pasting into the `:repo` slot — the
8888 // doc strong-quotes the URL so the shell suppresses every form
8889 // of expansion on the bytes inside (no `$`, no backtick, no
8890 // glob, no word-splitting), but the typed slot is itself a
8891 // byte-level string parser, not a shell context, so the quote
8892 // bytes ride into the value verbatim. Until this arm landed the
8893 // `'` byte silently passed every prior `is_git_repo_url` arm
8894 // (no whitespace, no control chars, no non-ASCII, no `#`, no
8895 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8896 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8897 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8898 // set, peer with the `\"` 'delims' double-quote arm and the
8899 // partner ASCII shell-string-delimiter byte every byte-level
8900 // string parser sharing a value-shape with a shell argument
8901 // must refuse on a URL-shaped slot.
8902 let d = dep_with_fonte(DepSource::Git {
8903 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8904 tag: Some("v0.1.0".into()),
8905 rev: None,
8906 branch: None,
8907 });
8908 let err = d.validate().unwrap_err();
8909 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8910 panic!("expected FonteRepoShape, got other variant");
8911 };
8912 assert_eq!(nome, "caixa-teia");
8913 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8914 assert!(
8915 reason.contains("must not contain `'`"),
8916 "reason must surface the shell-single-quote arm, got {reason:?}"
8917 );
8918 assert!(
8919 reason.contains("single-quote") || reason.contains("strong-quote"),
8920 "reason must name the shell-single-quote / strong-quote rationale, \
8921 got {reason:?}"
8922 );
8923 }
8924
8925 #[test]
8926 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8927 // The symmetric English-typography pin: an author writes
8928 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8929 // from-prose idiom every README / commit-message / chat-thread
8930 // reference to a repo carries) expecting the substrate to
8931 // coerce it to a kebab-case slug — but the byte rides into the
8932 // lacre verbatim. Pinned separately from the wrapped-quote
8933 // shape so a future diagnostic-surface change that only checked
8934 // the boundary positions (only leading, only trailing, only
8935 // paired) surfaces here — the per-byte arm fires anywhere `'`
8936 // appears in the value.
8937 let d = dep_with_fonte(DepSource::Git {
8938 repo: "github:pleme-io/repo's-fork".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 shell-single-quote arm on the mid-string \
8950 apostrophe shape, got {reason:?}"
8951 );
8952 }
8953
8954 #[test]
8955 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8956 // Cascade pin: the fragment-`#` arm and the single-quote arm
8957 // are both per-byte arms inside the same `for &b in
8958 // s.as_bytes()` loop, so the byte that appears first in the
8959 // value's byte order wins. A `:repo
8960 // "https://github.com/p/x#readme'tail"` carries both `#` and
8961 // `'`; the `#` byte appears first, so the fragment-`#` arm
8962 // fires, surfacing the more self-locating diagnostic on the
8963 // byte the author pasted earliest in the URL.
8964 let d = dep_with_fonte(DepSource::Git {
8965 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8966 tag: Some("v0.1.0".into()),
8967 rev: None,
8968 branch: None,
8969 });
8970 let err = d.validate().unwrap_err();
8971 let DepError::FonteRepoShape { reason, .. } = err else {
8972 panic!("expected FonteRepoShape, got other variant");
8973 };
8974 assert!(
8975 reason.contains("must not contain `#`"),
8976 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8977 byte appears first in value), got {reason:?}"
8978 );
8979 }
8980
8981 #[test]
8982 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8983 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8984 // byte-class arm, 4267d8b) and the single-quote arm are both
8985 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8986 // so the byte that appears first in the value's byte order
8987 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8988 // `'`; the `"` byte appears first, so the double-quote arm
8989 // fires, surfacing the more self-locating diagnostic on the
8990 // byte the author pasted earliest in the URL. Pins the natural-
8991 // order cascade so a future reorder of the per-byte arms
8992 // surfaces here — `'` is the most recent byte-class arm, so
8993 // the cascade-pin sweep extends to cover the immediately prior
8994 // `"` byte arm firing first when ordered ahead of `'` in the
8995 // value.
8996 let d = dep_with_fonte(DepSource::Git {
8997 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8998 tag: Some("v0.1.0".into()),
8999 rev: None,
9000 branch: None,
9001 });
9002 let err = d.validate().unwrap_err();
9003 let DepError::FonteRepoShape { reason, .. } = err else {
9004 panic!("expected FonteRepoShape, got other variant");
9005 };
9006 assert!(
9007 reason.contains("must not contain `\"`"),
9008 "reason must surface the double-quote arm (fires before single-quote when `\"` \
9009 byte appears first in value), got {reason:?}"
9010 );
9011 }
9012
9013 #[test]
9014 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
9015 // The fail-before-pass-after pin for the canonical paste-from-
9016 // shell-history footgun on `:repo`. An author copies a `git
9017 // clone <url>!sudo make install` one-liner from a README's
9018 // quick-start snippet, intending the trailing `!sudo` as a
9019 // shell-history-expansion reference but the typed slot is itself
9020 // a byte-level string parser, not a shell context, so the byte
9021 // rides into the value verbatim. Until this arm landed the `!`
9022 // byte silently passed every prior `is_git_repo_url` arm (no
9023 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
9024 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
9025 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
9026 // start with `-` or `:`); bash with the default `histexpand`
9027 // mode rewrites `!command` to the most recent history entry
9028 // beginning with `command`, the canonical RCE-class injection
9029 // vector when the byte rides into a shell argument.
9030 let d = dep_with_fonte(DepSource::Git {
9031 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
9032 tag: Some("v0.1.0".into()),
9033 rev: None,
9034 branch: None,
9035 });
9036 let err = d.validate().unwrap_err();
9037 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9038 panic!("expected FonteRepoShape, got other variant");
9039 };
9040 assert_eq!(nome, "caixa-teia");
9041 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
9042 assert!(
9043 reason.contains("must not contain `!`"),
9044 "reason must surface the shell-history-expansion arm, got {reason:?}"
9045 );
9046 assert!(
9047 reason.contains("history-expansion") || reason.contains("bang"),
9048 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
9049 );
9050 }
9051
9052 #[test]
9053 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
9054 // The symmetric `!!` repeat-prior-command pin: an author paste-
9055 // trims a `git clone <url>` retry idiom from shell history that
9056 // expands to the previous command via `!!`. Pinned separately
9057 // from the wrapped `!command` shape so a future diagnostic-
9058 // surface change that only checked the leading or paired-bang
9059 // position surfaces here — the per-byte arm fires anywhere `!`
9060 // appears in the value.
9061 let d = dep_with_fonte(DepSource::Git {
9062 repo: "github:pleme-io/caixa-teia!!".into(),
9063 tag: Some("v0.1.0".into()),
9064 rev: None,
9065 branch: None,
9066 });
9067 let err = d.validate().unwrap_err();
9068 let DepError::FonteRepoShape { reason, .. } = err else {
9069 panic!("expected FonteRepoShape, got other variant");
9070 };
9071 assert!(
9072 reason.contains("must not contain `!`"),
9073 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
9074 got {reason:?}"
9075 );
9076 }
9077
9078 #[test]
9079 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
9080 // Cascade pin: the fragment-`#` arm and the bang arm are both
9081 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9082 // so the byte that appears first in the value's byte order
9083 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
9084 // both `#` and `!`; the `#` byte appears first, so the
9085 // fragment-`#` arm fires, surfacing the more self-locating
9086 // diagnostic on the byte the author pasted earliest in the URL.
9087 let d = dep_with_fonte(DepSource::Git {
9088 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
9089 tag: Some("v0.1.0".into()),
9090 rev: None,
9091 branch: None,
9092 });
9093 let err = d.validate().unwrap_err();
9094 let DepError::FonteRepoShape { reason, .. } = err else {
9095 panic!("expected FonteRepoShape, got other variant");
9096 };
9097 assert!(
9098 reason.contains("must not contain `#`"),
9099 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
9100 appears first in value), got {reason:?}"
9101 );
9102 }
9103
9104 #[test]
9105 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
9106 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
9107 // byte-class arm, e7a109f) and the bang arm are both per-byte
9108 // arms inside the same `for &b in s.as_bytes()` loop, so the
9109 // byte that appears first in the value's byte order wins. A
9110 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
9111 // `'` byte appears first, so the single-quote arm fires,
9112 // surfacing the more self-locating diagnostic on the byte the
9113 // author pasted earliest in the URL. Pins the natural-order
9114 // cascade so a future reorder of the per-byte arms surfaces
9115 // here — `!` is the most recent byte-class arm, so the
9116 // cascade-pin sweep extends to cover the immediately prior `'`
9117 // byte arm firing first when ordered ahead of `!` in the value.
9118 let d = dep_with_fonte(DepSource::Git {
9119 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
9120 tag: Some("v0.1.0".into()),
9121 rev: None,
9122 branch: None,
9123 });
9124 let err = d.validate().unwrap_err();
9125 let DepError::FonteRepoShape { reason, .. } = err else {
9126 panic!("expected FonteRepoShape, got other variant");
9127 };
9128 assert!(
9129 reason.contains("must not contain `'`"),
9130 "reason must surface the single-quote arm (fires before bang when `'` byte \
9131 appears first in value), got {reason:?}"
9132 );
9133 }
9134
9135 #[test]
9136 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
9137 // The fail-before-pass-after pin for the canonical
9138 // list-separator-belongs-to-list-grammar footgun on `:repo`.
9139 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
9140 // one-liner from a multi-repo bootstrap doc, intending the
9141 // comma to separate multiple repo entries but the typed
9142 // `:repo` slot names *one* repo (the list-separator belongs
9143 // to the `:deps` list grammar, not to the value). Until this
9144 // arm landed the `,` byte silently passed every prior
9145 // `is_git_repo_url` arm (no whitespace, no control chars, no
9146 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
9147 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
9148 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
9149 // `:`); the byte rode into the lacre's per-dep content-
9150 // address and the resolver's `git clone <repo>` subprocess
9151 // invocation, where no host's repo registry resolved the
9152 // comma-bearing slug.
9153 let d = dep_with_fonte(DepSource::Git {
9154 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
9155 tag: Some("v0.1.0".into()),
9156 rev: None,
9157 branch: None,
9158 });
9159 let err = d.validate().unwrap_err();
9160 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9161 panic!("expected FonteRepoShape, got other variant");
9162 };
9163 assert_eq!(nome, "caixa-teia");
9164 assert_eq!(
9165 repo,
9166 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
9167 );
9168 assert!(
9169 reason.contains("must not contain `,`"),
9170 "reason must surface the list-separator-comma arm, got {reason:?}"
9171 );
9172 assert!(
9173 reason.contains("list-separator") || reason.contains("sub-delims"),
9174 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
9175 got {reason:?}"
9176 );
9177 }
9178
9179 #[test]
9180 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
9181 // The symmetric trailing-`,` paste-from-prose pin: an author
9182 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
9183 // comma every README-prose list-of-projects sentence carries,
9184 // mistakenly retained when the slug is pasted mid-sentence)
9185 // expecting the substrate to coerce it to a kebab-case slug.
9186 // Pinned separately from the wrapped mid-token shape so a
9187 // future diagnostic-surface change that only checked the
9188 // leading or paired-comma position surfaces here — the
9189 // per-byte arm fires anywhere `,` appears in the value.
9190 let d = dep_with_fonte(DepSource::Git {
9191 repo: "github:pleme-io/caixa-feira,".into(),
9192 tag: Some("v0.1.0".into()),
9193 rev: None,
9194 branch: None,
9195 });
9196 let err = d.validate().unwrap_err();
9197 let DepError::FonteRepoShape { reason, .. } = err else {
9198 panic!("expected FonteRepoShape, got other variant");
9199 };
9200 assert!(
9201 reason.contains("must not contain `,`"),
9202 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
9203 got {reason:?}"
9204 );
9205 }
9206
9207 #[test]
9208 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
9209 // Cascade pin: the fragment-`#` arm and the comma arm are
9210 // both per-byte arms inside the same `for &b in s.as_bytes()`
9211 // loop, so the byte that appears first in the value's byte
9212 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
9213 // carries both `#` and `,`; the `#` byte appears first, so
9214 // the fragment-`#` arm fires, surfacing the more self-
9215 // locating diagnostic on the byte the author pasted earliest
9216 // in the URL.
9217 let d = dep_with_fonte(DepSource::Git {
9218 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
9219 tag: Some("v0.1.0".into()),
9220 rev: None,
9221 branch: None,
9222 });
9223 let err = d.validate().unwrap_err();
9224 let DepError::FonteRepoShape { reason, .. } = err else {
9225 panic!("expected FonteRepoShape, got other variant");
9226 };
9227 assert!(
9228 reason.contains("must not contain `#`"),
9229 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
9230 appears first in value), got {reason:?}"
9231 );
9232 }
9233
9234 #[test]
9235 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
9236 // Cascade pin: the bang-`!` arm (the immediate-predecessor
9237 // byte-class arm, 7d53c68) and the comma arm are both
9238 // per-byte arms inside the same `for &b in s.as_bytes()`
9239 // loop, so the byte that appears first in the value's byte
9240 // order wins. A `:repo "github:p/x!mid,tail"` carries both
9241 // `!` and `,`; the `!` byte appears first, so the bang arm
9242 // fires, surfacing the more self-locating diagnostic on the
9243 // byte the author pasted earliest in the URL. Pins the
9244 // natural-order cascade so a future reorder of the per-byte
9245 // arms surfaces here — `,` is the most recent byte-class
9246 // arm, so the cascade-pin sweep extends to cover the
9247 // immediately prior `!` byte arm firing first when ordered
9248 // ahead of `,` in the value.
9249 let d = dep_with_fonte(DepSource::Git {
9250 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
9251 tag: Some("v0.1.0".into()),
9252 rev: None,
9253 branch: None,
9254 });
9255 let err = d.validate().unwrap_err();
9256 let DepError::FonteRepoShape { reason, .. } = err else {
9257 panic!("expected FonteRepoShape, got other variant");
9258 };
9259 assert!(
9260 reason.contains("must not contain `!`"),
9261 "reason must surface the bang arm (fires before comma when `!` byte \
9262 appears first in value), got {reason:?}"
9263 );
9264 }
9265
9266 #[test]
9267 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
9268 // The fail-before-pass-after pin for the canonical
9269 // shell-env-var-assignment-belongs-to-shell-grammar footgun
9270 // on `:repo`. An author copies
9271 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
9272 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
9273 // git clone <url>`, etc. — the canonical
9274 // git-troubleshooting README idiom for a one-shot env-var
9275 // scoped to the `git clone` invocation) from a shell-prompt
9276 // one-liner, intending the `KEY=VALUE` prefix as a shell-
9277 // grammar env-var assignment but the typed `:repo` slot is
9278 // a value parser, not a shell context, so the bytes ride
9279 // into the value verbatim. Until this arm landed the `=`
9280 // byte silently passed every prior `is_git_repo_url` arm
9281 // (no whitespace, no control chars, no non-ASCII, no `#`,
9282 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
9283 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
9284 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
9285 // the byte rode into the lacre's per-dep content-address
9286 // and the resolver's `git clone <repo>` subprocess
9287 // invocation, where the upstream host's git porcelain
9288 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
9289 // path that no host's repo registry resolves.
9290 let d = dep_with_fonte(DepSource::Git {
9291 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
9292 tag: Some("v0.1.0".into()),
9293 rev: None,
9294 branch: None,
9295 });
9296 let err = d.validate().unwrap_err();
9297 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9298 panic!("expected FonteRepoShape, got other variant");
9299 };
9300 assert_eq!(nome, "caixa-teia");
9301 assert_eq!(
9302 repo,
9303 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
9304 );
9305 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
9306 // appears before the ` ` byte at position 21, so the `=`
9307 // arm fires (not the whitespace arm) — both arms guard
9308 // the slot, but the per-byte for-loop scans left-to-right
9309 // and the first matching byte wins.
9310 assert!(
9311 reason.contains("must not contain `=`"),
9312 "reason must surface the equals-`=` arm on the env-var-assignment \
9313 paste shape, got {reason:?}"
9314 );
9315 assert!(
9316 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
9317 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
9318 );
9319 }
9320
9321 #[test]
9322 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
9323 // The symmetric paste-from-gitconfig pin: an author copies
9324 // `url=https://github.com/p/x` from `git config --get-all
9325 // remote.origin.url` output, a `.gitconfig` `[remote
9326 // "origin"] url = https://…` ini-stanza paste, or a
9327 // `git config remote.origin.url <value>` doc snippet,
9328 // intending the `url=` prefix as the ini-key but the typed
9329 // `:repo` slot is a URL value parser, not a gitconfig
9330 // grammar. With no leading whitespace and no earlier-arm
9331 // bytes in the value, the `=` arm itself fires (rather
9332 // than cascading to the whitespace arm as in the env-var
9333 // paste shape). Pinned separately so a future diagnostic-
9334 // surface change that only checked the whitespace-leading
9335 // shape surfaces here — the per-byte arm fires anywhere
9336 // `=` appears in the value.
9337 let d = dep_with_fonte(DepSource::Git {
9338 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
9339 tag: Some("v0.1.0".into()),
9340 rev: None,
9341 branch: None,
9342 });
9343 let err = d.validate().unwrap_err();
9344 let DepError::FonteRepoShape { reason, .. } = err else {
9345 panic!("expected FonteRepoShape, got other variant");
9346 };
9347 assert!(
9348 reason.contains("must not contain `=`"),
9349 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
9350 paste shape, got {reason:?}"
9351 );
9352 assert!(
9353 reason.contains("key-value-separator") || reason.contains("sub-delims"),
9354 "reason must name the key-value-separator / RFC-3986-sub-delims \
9355 rationale, got {reason:?}"
9356 );
9357 }
9358
9359 #[test]
9360 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
9361 // Cascade pin: the fragment-`#` arm and the `=` arm are
9362 // both per-byte arms inside the same `for &b in s.as_bytes()`
9363 // loop, so the byte that appears first in the value's byte
9364 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
9365 // carries both `#` and `=`; the `#` byte appears first, so
9366 // the fragment-`#` arm fires, surfacing the more self-
9367 // locating diagnostic on the byte the author pasted earliest
9368 // in the URL.
9369 let d = dep_with_fonte(DepSource::Git {
9370 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
9371 tag: Some("v0.1.0".into()),
9372 rev: None,
9373 branch: None,
9374 });
9375 let err = d.validate().unwrap_err();
9376 let DepError::FonteRepoShape { reason, .. } = err else {
9377 panic!("expected FonteRepoShape, got other variant");
9378 };
9379 assert!(
9380 reason.contains("must not contain `#`"),
9381 "reason must surface the fragment-`#` arm (fires before equals when \
9382 `#` byte appears first in value), got {reason:?}"
9383 );
9384 }
9385
9386 #[test]
9387 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
9388 // Cascade pin: the comma-`,` arm (the immediate-predecessor
9389 // byte-class arm, 775b80e) and the `=` arm are both per-byte
9390 // arms inside the same `for &b in s.as_bytes()` loop, so
9391 // the byte that appears first in the value's byte order
9392 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
9393 // and `=`; the `,` byte appears first, so the comma arm
9394 // fires, surfacing the more self-locating diagnostic on
9395 // the byte the author pasted earliest in the URL. Pins the
9396 // natural-order cascade so a future reorder of the per-byte
9397 // arms surfaces here — `=` is the most recent byte-class
9398 // arm, so the cascade-pin sweep extends to cover the
9399 // immediately prior `,` byte arm firing first when ordered
9400 // ahead of `=` in the value.
9401 let d = dep_with_fonte(DepSource::Git {
9402 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
9403 tag: Some("v0.1.0".into()),
9404 rev: None,
9405 branch: None,
9406 });
9407 let err = d.validate().unwrap_err();
9408 let DepError::FonteRepoShape { reason, .. } = err else {
9409 panic!("expected FonteRepoShape, got other variant");
9410 };
9411 assert!(
9412 reason.contains("must not contain `,`"),
9413 "reason must surface the comma arm (fires before equals when `,` byte \
9414 appears first in value), got {reason:?}"
9415 );
9416 }
9417
9418 #[test]
9419 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
9420 // The fail-before-pass-after pin for the canonical paste-from-
9421 // browser-address-bar percent-encoded-space footgun on `:repo`.
9422 // An author copies `https://github.com/p/x%20test` from a
9423 // browser address bar (or a percent-encoded README hyperlink,
9424 // or a `curl --data-urlencode` shell-pipeline output)
9425 // intending `%20` as the URL encoding of a literal space; the
9426 // typed `:repo` slot already rejects the literal space byte
9427 // (the whitespace arm at the top of `is_git_repo_url`), so an
9428 // author trying to express "I really meant a space" reaches
9429 // for percent-encoding. Until this arm landed the `%` byte
9430 // silently passed every prior `is_git_repo_url` arm and rode
9431 // verbatim into the lacre's per-dep content-address — but
9432 // libcurl re-percent-encodes `%` to `%25` on the wire (since
9433 // `%` is reserved as the escape-sequence lead-in), so the
9434 // wire request becomes `https://github.com/p/x%2520test`, a
9435 // path the lacre's content-address never names. The classic
9436 // render-determinism violation on the encoding-mechanism axis
9437 // itself.
9438 let d = dep_with_fonte(DepSource::Git {
9439 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
9440 tag: Some("v0.1.0".into()),
9441 rev: None,
9442 branch: None,
9443 });
9444 let err = d.validate().unwrap_err();
9445 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9446 panic!("expected FonteRepoShape, got other variant");
9447 };
9448 assert_eq!(nome, "caixa-teia");
9449 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
9450 assert!(
9451 reason.contains("must not contain `%`"),
9452 "reason must surface the percent-`%` arm on the percent-encoded-space \
9453 paste shape, got {reason:?}"
9454 );
9455 assert!(
9456 reason.contains("percent-encoding") || reason.contains("%25"),
9457 "reason must name the percent-encoding / `%25` re-encoding rationale, \
9458 got {reason:?}"
9459 );
9460 }
9461
9462 #[test]
9463 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
9464 // The symmetric over-encoded-path-separator pin: an author
9465 // writes `:repo "https://github.com/p%2Fx"` intending the
9466 // `%2F` as the URL encoding of `/` (the canonical
9467 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
9468 // footgun every API client library and OAuth redirect-URI
9469 // documentation surfaces — the `/` is the URL-path-separator
9470 // and some templates percent-encode it to escape interpretation
9471 // as a path separator). The GitHub Smart-HTTP transport
9472 // resolves the URL's path-segment grammar before the
9473 // percent-decoding pass, so the value identifies a different
9474 // resource on the wire than the literal-`/` form the lacre's
9475 // content-address must agree with — two authors whose `:repo`
9476 // values differ only in their `/` vs `%2F` presence lock to
9477 // two distinct BLAKE3 closures for the byte-identical upstream
9478 // `git clone`. Pinned separately so a future diagnostic
9479 // surface that only catches the `%20` shape surfaces here too.
9480 let d = dep_with_fonte(DepSource::Git {
9481 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
9482 tag: Some("v0.1.0".into()),
9483 rev: None,
9484 branch: None,
9485 });
9486 let err = d.validate().unwrap_err();
9487 let DepError::FonteRepoShape { reason, .. } = err else {
9488 panic!("expected FonteRepoShape, got other variant");
9489 };
9490 assert!(
9491 reason.contains("must not contain `%`"),
9492 "reason must surface the percent-`%` arm on the over-encoded-path \
9493 shape, got {reason:?}"
9494 );
9495 assert!(
9496 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9497 "reason must name the render-determinism / BLAKE3-closure rationale, \
9498 got {reason:?}"
9499 );
9500 }
9501
9502 #[test]
9503 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
9504 // Cascade pin: the fragment-`#` arm and the `%` arm are both
9505 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9506 // so the byte that appears first in the value's byte order
9507 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
9508 // both `#` and `%`; the `#` byte appears first, so the
9509 // fragment-`#` arm fires, surfacing the more self-locating
9510 // diagnostic on the byte the author pasted earliest in the URL.
9511 let d = dep_with_fonte(DepSource::Git {
9512 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
9513 tag: Some("v0.1.0".into()),
9514 rev: None,
9515 branch: None,
9516 });
9517 let err = d.validate().unwrap_err();
9518 let DepError::FonteRepoShape { reason, .. } = err else {
9519 panic!("expected FonteRepoShape, got other variant");
9520 };
9521 assert!(
9522 reason.contains("must not contain `#`"),
9523 "reason must surface the fragment-`#` arm (fires before percent when \
9524 `#` byte appears first in value), got {reason:?}"
9525 );
9526 }
9527
9528 #[test]
9529 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
9530 // Cascade pin: the equals-`=` arm (the immediate-predecessor
9531 // byte-class arm, acf99af) and the `%` arm are both per-byte
9532 // arms inside the same `for &b in s.as_bytes()` loop, so the
9533 // byte that appears first in the value's byte order wins.
9534 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
9535 // the `=` byte appears first, so the equals arm fires,
9536 // surfacing the more self-locating diagnostic on the byte the
9537 // author pasted earliest in the URL. Pins the natural-order
9538 // cascade so a future reorder of the per-byte arms surfaces
9539 // here — `%` is the most recent byte-class arm, so the
9540 // cascade-pin sweep extends to cover the immediately prior
9541 // `=` byte arm firing first when ordered ahead of `%` in the
9542 // value.
9543 let d = dep_with_fonte(DepSource::Git {
9544 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9545 tag: Some("v0.1.0".into()),
9546 rev: None,
9547 branch: None,
9548 });
9549 let err = d.validate().unwrap_err();
9550 let DepError::FonteRepoShape { reason, .. } = err else {
9551 panic!("expected FonteRepoShape, got other variant");
9552 };
9553 assert!(
9554 reason.contains("must not contain `=`"),
9555 "reason must surface the equals arm (fires before percent when `=` byte \
9556 appears first in value), got {reason:?}"
9557 );
9558 }
9559
9560 #[test]
9561 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9562 // The fail-before-pass-after pin for the canonical paste-from-
9563 // shell-history footgun on `:repo`. An author copies a
9564 // `git clone <url>` line from their terminal followed by a
9565 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9566 // history shorthand (the `^old^new^` form re-runs the prior
9567 // history entry with the first `old` substituted by `new`,
9568 // bash's default behavior on interactive sessions with
9569 // `set -o histexpand`), forgetting to trim the trailing
9570 // `^...^...` shell-history fragment from the URL value. The
9571 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9572 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9573 // classes), the WHATWG URL spec's 'fragment percent-encode
9574 // set' maps `^` → `%5E` on the wire, so the byte rides
9575 // verbatim into the lacre's per-dep content-address but
9576 // libcurl re-encodes it to `%5E` at `git clone` time — the
9577 // classic render-determinism violation on the same axis the
9578 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9579 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9580 // `#` arms close.
9581 let d = dep_with_fonte(DepSource::Git {
9582 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9583 tag: Some("v0.1.0".into()),
9584 rev: None,
9585 branch: None,
9586 });
9587 let err = d.validate().unwrap_err();
9588 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9589 panic!("expected FonteRepoShape, got other variant");
9590 };
9591 assert_eq!(nome, "caixa-teia");
9592 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9593 assert!(
9594 reason.contains("must not contain `^`"),
9595 "reason must surface the caret-`^` arm on the paste-from-shell-history \
9596 shape, got {reason:?}"
9597 );
9598 assert!(
9599 reason.contains("history-substitution") || reason.contains("%5E"),
9600 "reason must name the shell-history-substitution / `%5E` wire-encoding \
9601 rationale, got {reason:?}"
9602 );
9603 }
9604
9605 #[test]
9606 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9607 // The symmetric paste-from-doc-grep-pipeline footgun: an
9608 // author writes `:repo "github:p/^archived"` after copying a
9609 // `grep '^archived'` regex-anchor / negation idiom from a
9610 // doc / README quick-listing snippet, expecting the substrate
9611 // to coerce it to a literal repo name. The byte rides
9612 // verbatim into the lacre's per-dep content-address and
9613 // diverges from the byte-identical literal `archived` form
9614 // every other author authored — the canonical render-
9615 // determinism violation pin on the second footgun shape the
9616 // caret-`^` arm closes.
9617 let d = dep_with_fonte(DepSource::Git {
9618 repo: "github:pleme-io/^archived".into(),
9619 tag: Some("v0.1.0".into()),
9620 rev: None,
9621 branch: None,
9622 });
9623 let err = d.validate().unwrap_err();
9624 let DepError::FonteRepoShape { reason, .. } = err else {
9625 panic!("expected FonteRepoShape, got other variant");
9626 };
9627 assert!(
9628 reason.contains("must not contain `^`"),
9629 "reason must surface the caret-`^` arm on the regex-anchor shape, \
9630 got {reason:?}"
9631 );
9632 assert!(
9633 reason.contains("render-determinism") || reason.contains("BLAKE3"),
9634 "reason must name the render-determinism / BLAKE3-closure rationale, \
9635 got {reason:?}"
9636 );
9637 }
9638
9639 #[test]
9640 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9641 // Cascade pin: the `%` arm (the immediate-predecessor byte-
9642 // class arm, a323db8) and the `^` arm are both per-byte arms
9643 // inside the same `for &b in s.as_bytes()` loop, so the byte
9644 // that appears first in the value's byte order wins. A
9645 // `:repo "https://github.com/p/x%20mid^tail"` carries both
9646 // `%` and `^`; the `%` byte appears first, so the percent
9647 // arm fires, surfacing the more self-locating diagnostic on
9648 // the byte the author pasted earliest in the URL. Pins the
9649 // natural-order cascade so a future reorder of the per-byte
9650 // arms surfaces here — `^` is the most recent byte-class arm,
9651 // so the cascade-pin sweep extends to cover the immediately
9652 // prior `%` byte arm firing first when ordered ahead of `^`
9653 // in the value.
9654 let d = dep_with_fonte(DepSource::Git {
9655 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9656 tag: Some("v0.1.0".into()),
9657 rev: None,
9658 branch: None,
9659 });
9660 let err = d.validate().unwrap_err();
9661 let DepError::FonteRepoShape { reason, .. } = err else {
9662 panic!("expected FonteRepoShape, got other variant");
9663 };
9664 assert!(
9665 reason.contains("must not contain `%`"),
9666 "reason must surface the percent arm (fires before caret when `%` byte \
9667 appears first in value), got {reason:?}"
9668 );
9669 }
9670
9671 #[test]
9672 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9673 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9674 // (no `github:` prefix, no scheme). Every documented form
9675 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9676 // `file://`, or `git@host:path`); a bare `org/repo` is
9677 // ambiguous (`git clone` reads as a relative filesystem path
9678 // rather than the GitHub-shorthand expansion the author
9679 // probably intended) and the gate rejects the shape upstream.
9680 let d = dep_with_fonte(DepSource::Git {
9681 repo: "pleme-io/caixa-teia".into(),
9682 tag: Some("v0.1.0".into()),
9683 rev: None,
9684 branch: None,
9685 });
9686 let err = d.validate().unwrap_err();
9687 let DepError::FonteRepoShape { reason, .. } = err else {
9688 panic!("expected FonteRepoShape, got other variant");
9689 };
9690 assert!(
9691 reason.contains("must contain a `:`"),
9692 "reason must surface the missing-`:` arm, got {reason:?}"
9693 );
9694 assert!(
9695 reason.contains("github:"),
9696 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9697 );
9698 }
9699
9700 #[test]
9701 fn validate_rejects_git_fonte_with_repo_leading_colon() {
9702 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9703 // scheme that no git porcelain entry-point accepts. Pinned
9704 // separately from the missing-`:` arm because a value with a
9705 // leading `:` does technically contain a `:` separator; the
9706 // shape gate rejects on a dedicated arm so the diagnostic
9707 // names the specific footgun.
9708 let d = dep_with_fonte(DepSource::Git {
9709 repo: ":pleme-io/caixa-teia".into(),
9710 tag: Some("v0.1.0".into()),
9711 rev: None,
9712 branch: None,
9713 });
9714 let err = d.validate().unwrap_err();
9715 let DepError::FonteRepoShape { reason, .. } = err else {
9716 panic!("expected FonteRepoShape, got other variant");
9717 };
9718 assert!(
9719 reason.contains("must not start with `:`"),
9720 "reason must surface the leading-`:` arm, got {reason:?}"
9721 );
9722 }
9723
9724 #[test]
9725 fn validate_rejects_git_fonte_with_repo_too_long() {
9726 // The cap arm — a `:repo` value longer than
9727 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9728 // structurally untenable on every realistic landing site (the
9729 // resolver's `git clone` invocation, the future M4 CR
9730 // materializer's per-dep `repo:` axis); a value of that length
9731 // is almost certainly a paste-from-binary slug.
9732 let too_long = format!(
9733 "github:pleme-io/{}",
9734 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9735 );
9736 let d = dep_with_fonte(DepSource::Git {
9737 repo: too_long.clone(),
9738 tag: Some("v0.1.0".into()),
9739 rev: None,
9740 branch: None,
9741 });
9742 let err = d.validate().unwrap_err();
9743 let DepError::FonteRepoShape { reason, .. } = err else {
9744 panic!("expected FonteRepoShape, got other variant");
9745 };
9746 assert!(
9747 reason.contains("2048"),
9748 "reason must name the cap, got {reason:?}"
9749 );
9750 }
9751
9752 #[test]
9753 fn validate_accepts_canonical_git_fonte_repo_shapes() {
9754 // The positive-control sweep: every documented author shape on
9755 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9756 // must pass the value-shape gate. Pinned so a future tightening
9757 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9758 // here as a structural decision. Each form is exercised with the
9759 // same canonical `:tag` pin so only the `:repo` axis varies.
9760 for repo in [
9761 // The pleme-io registry-shorthand convention — `github:org/repo`.
9762 "github:pleme-io/caixa-teia",
9763 // Other host-aliased shorthands (the resolver's pluggable
9764 // host-prefix table).
9765 "gitlab:pleme-io/caixa-teia",
9766 "codeberg:pleme-io/caixa-teia",
9767 "sourcehut:~pleme-io/caixa-teia",
9768 // Full HTTPS URL with and without `.git` suffix.
9769 "https://github.com/pleme-io/caixa-teia",
9770 "https://github.com/pleme-io/caixa-teia.git",
9771 // HTTP (rare; dev / mirror).
9772 "http://example.com/pleme-io/caixa-teia.git",
9773 // SSH URL.
9774 "ssh://git@github.com/pleme-io/caixa-teia.git",
9775 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9776 // Scp-style SSH — the canonical `git@host:path` short form.
9777 "git@github.com:pleme-io/caixa-teia.git",
9778 "git@git.example.com:team/private.git",
9779 // Anonymous git protocol.
9780 "git://git.example.com/pleme-io/caixa-teia.git",
9781 // Local file URL (dev path).
9782 "file:///tmp/caixa-teia",
9783 ] {
9784 let d = dep_with_fonte(DepSource::Git {
9785 repo: repo.into(),
9786 tag: Some("v0.1.0".into()),
9787 rev: None,
9788 branch: None,
9789 });
9790 d.validate()
9791 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9792 }
9793 }
9794
9795 #[test]
9796 fn fonte_repo_empty_takes_precedence_over_shape() {
9797 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9798 // diagnostic; doesn't try to parse the URL shape) fires before
9799 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9800 // keeps its narrower error message. Mirrors
9801 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9802 // on the ordering layer.
9803 let d = dep_with_fonte(DepSource::Git {
9804 repo: String::new(),
9805 tag: Some("v0.1.0".into()),
9806 rev: None,
9807 branch: None,
9808 });
9809 let err = d.validate().unwrap_err();
9810 assert!(
9811 matches!(err, DepError::FonteRepoEmpty { .. }),
9812 "got {err:?}"
9813 );
9814 }
9815
9816 #[test]
9817 fn fonte_repo_shape_fires_before_pin_missing() {
9818 // Order pin: a malformed `:repo` value on a dep with no pin set
9819 // surfaces the `:repo` shape diagnostic (the more self-locating
9820 // axis — the `:repo` is the load-bearing identity of the source;
9821 // a missing pin is downstream from "do we even know the repo")
9822 // rather than collapsing onto the pin-missing diagnostic. The
9823 // shape gate runs inline before the pin enumeration in
9824 // `DepSource::validate`.
9825 let d = dep_with_fonte(DepSource::Git {
9826 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9827 tag: None,
9828 rev: None,
9829 branch: None,
9830 });
9831 let err = d.validate().unwrap_err();
9832 assert!(
9833 matches!(err, DepError::FonteRepoShape { .. }),
9834 "got {err:?}"
9835 );
9836 }
9837
9838 #[test]
9839 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9840 // The diagnostic-shape pin: the error names the offending
9841 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9842 // so the author can grep their caixa.lisp without re-running
9843 // the build. Mirrors the diagnostic-shape sweep on every prior
9844 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9845 let d = dep_with_fonte(DepSource::Git {
9846 repo: "pleme-io/caixa-teia".into(),
9847 tag: Some("v0.1.0".into()),
9848 rev: None,
9849 branch: None,
9850 });
9851 let err = d.validate().unwrap_err();
9852 let DepError::FonteRepoShape { nome, repo, reason } = err else {
9853 panic!("expected FonteRepoShape, got other variant");
9854 };
9855 assert_eq!(nome, "caixa-teia");
9856 assert_eq!(repo, "pleme-io/caixa-teia");
9857 assert!(
9858 !reason.is_empty(),
9859 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9860 );
9861 }
9862
9863 #[test]
9864 fn validate_rejects_git_fonte_with_no_pin() {
9865 // The fail-before-pass-after pin for the canonical
9866 // `(:tipo git :repo "github:pleme-io/x")` shape with no
9867 // :tag/:rev/:branch — until this gate landed the resolver's
9868 // ResolveError::MissingPin surfaced at fetch time, far from the
9869 // source caixa.lisp. The new gate moves the check to validate
9870 // time and names the offending dep.
9871 let d = dep_with_fonte(DepSource::Git {
9872 repo: "github:pleme-io/caixa-teia".into(),
9873 tag: None,
9874 rev: None,
9875 branch: None,
9876 });
9877 let err = d.validate().unwrap_err();
9878 assert!(
9879 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9880 "got {err:?}"
9881 );
9882 }
9883
9884 #[test]
9885 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9886 // The canonical "pin drift" footgun: an author writes
9887 // `:tag "v1"` and later adds `:branch "main"` without removing
9888 // the :tag, and the resolver silently picks :tag (precedence
9889 // :rev > :tag > :branch). The :branch was dropped with no
9890 // diagnostic. The gate now rejects multi-pin shapes so the
9891 // author makes the precedence explicit at the source.
9892 let d = dep_with_fonte(DepSource::Git {
9893 repo: "github:pleme-io/caixa-teia".into(),
9894 tag: Some("v0.1.0".into()),
9895 rev: None,
9896 branch: Some("main".into()),
9897 });
9898 let err = d.validate().unwrap_err();
9899 let DepError::FontePinAmbiguous { nome, pins } = err else {
9900 panic!("expected FontePinAmbiguous");
9901 };
9902 assert_eq!(nome, "caixa-teia");
9903 assert!(pins.contains(":tag"));
9904 assert!(pins.contains(":branch"));
9905 assert!(!pins.contains(":rev"));
9906 }
9907
9908 #[test]
9909 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9910 // Sibling arm of the pin-drift footgun: :tag + :rev set
9911 // simultaneously. Pinned separately so a future relaxation
9912 // that only catches the (:tag, :branch) pair surfaces here.
9913 let d = dep_with_fonte(DepSource::Git {
9914 repo: "github:pleme-io/caixa-teia".into(),
9915 tag: Some("v0.1.0".into()),
9916 rev: Some("c0ffee".into()),
9917 branch: None,
9918 });
9919 let err = d.validate().unwrap_err();
9920 let DepError::FontePinAmbiguous { nome, pins } = err else {
9921 panic!("expected FontePinAmbiguous");
9922 };
9923 assert_eq!(nome, "caixa-teia");
9924 assert!(pins.contains(":tag"));
9925 assert!(pins.contains(":rev"));
9926 }
9927
9928 #[test]
9929 fn validate_rejects_git_fonte_with_all_three_pins() {
9930 // The maximal ambiguity case — every pin axis set. Pinned so a
9931 // future relaxation that only catches pairs surfaces here. The
9932 // diagnostic must enumerate every offending axis so the author
9933 // sees the full set, not just the first match.
9934 let d = dep_with_fonte(DepSource::Git {
9935 repo: "github:pleme-io/caixa-teia".into(),
9936 tag: Some("v0.1.0".into()),
9937 rev: Some("c0ffee".into()),
9938 branch: Some("main".into()),
9939 });
9940 let err = d.validate().unwrap_err();
9941 let DepError::FontePinAmbiguous { nome, pins } = err else {
9942 panic!("expected FontePinAmbiguous");
9943 };
9944 assert_eq!(nome, "caixa-teia");
9945 assert!(pins.contains(":tag"));
9946 assert!(pins.contains(":rev"));
9947 assert!(pins.contains(":branch"));
9948 }
9949
9950 #[test]
9951 fn validate_rejects_git_fonte_with_empty_tag_pin() {
9952 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9953 // inner string is empty. Distinct from FontePinMissing (where
9954 // every axis is None) — pinned separately so a future
9955 // tightening collapsing them surfaces here as a structural
9956 // decision.
9957 let d = dep_with_fonte(DepSource::Git {
9958 repo: "github:pleme-io/caixa-teia".into(),
9959 tag: Some(String::new()),
9960 rev: None,
9961 branch: None,
9962 });
9963 let err = d.validate().unwrap_err();
9964 let DepError::FontePinEmpty { nome, pin } = err else {
9965 panic!("expected FontePinEmpty");
9966 };
9967 assert_eq!(nome, "caixa-teia");
9968 assert_eq!(pin, ":tag");
9969 }
9970
9971 #[test]
9972 fn validate_rejects_git_fonte_with_empty_rev_pin() {
9973 // Sibling arm — the empty-pin diagnostic names which axis
9974 // carries the empty value, so the author's grep target is
9975 // unambiguous.
9976 let d = dep_with_fonte(DepSource::Git {
9977 repo: "github:pleme-io/caixa-teia".into(),
9978 tag: None,
9979 rev: Some(String::new()),
9980 branch: None,
9981 });
9982 let err = d.validate().unwrap_err();
9983 let DepError::FontePinEmpty { nome, pin } = err else {
9984 panic!("expected FontePinEmpty");
9985 };
9986 assert_eq!(nome, "caixa-teia");
9987 assert_eq!(pin, ":rev");
9988 }
9989
9990 #[test]
9991 fn validate_rejects_path_fonte_with_empty_caminho() {
9992 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9993 // until this gate landed the resolver's
9994 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9995 // fetch time — not actionable. The new gate moves the check to
9996 // validate time and names the offending dep.
9997 let d = dep_with_fonte(DepSource::Path {
9998 caminho: String::new(),
9999 });
10000 let err = d.validate().unwrap_err();
10001 assert!(
10002 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
10003 "got {err:?}"
10004 );
10005 }
10006
10007 #[test]
10008 fn validate_rejects_path_fonte_with_absolute_caminho() {
10009 // The fail-before-pass-after pin for the absolute-`:caminho`
10010 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
10011 // Until this gate landed an absolute `:caminho` silently
10012 // passed validate; the lacre pipeline embedded the
10013 // host-specific filesystem path verbatim in its
10014 // content-address (`conteudo: format!("path:{caminho}")`,
10015 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
10016 // differed per machine — the build succeeded but two CI
10017 // runners with different `${HOME}` layouts emitted two
10018 // distinct lacres for the byte-identical caixa, silently
10019 // breaking the THEORY.md §V.2 render-determinism contract
10020 // far from the source caixa.lisp. The new gate moves the
10021 // check to validate time and names the offending dep +
10022 // caminho verbatim.
10023 let d = dep_with_fonte(DepSource::Path {
10024 caminho: "/home/me/work/caixa-teia".into(),
10025 });
10026 let err = d.validate().unwrap_err();
10027 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
10028 panic!("expected FonteCaminhoAbsolute, got other variant");
10029 };
10030 assert_eq!(nome, "caixa-teia");
10031 assert_eq!(caminho, "/home/me/work/caixa-teia");
10032 }
10033
10034 #[test]
10035 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
10036 // The canonical sibling-workspace dep form
10037 // (`:caminho "../caixa-teia"`) remains accepted. The
10038 // absolute-path gate above is specifically narrower than the
10039 // shared [`crate::render::is_sandboxed_relative_path`]
10040 // predicate (which additionally forbids `..` traversal): a
10041 // local-path dep's canonical author surface is the in-tree
10042 // sibling-workspace path, so a full sandboxed-relative-path
10043 // lift would structurally reject every legitimate path-fonte
10044 // dep. Pinned so a future tightening to the full predicate
10045 // surfaces here as a structural decision, not a silent break.
10046 let d = dep_with_fonte(DepSource::Path {
10047 caminho: "../caixa-teia".into(),
10048 });
10049 d.validate().unwrap();
10050 }
10051
10052 #[test]
10053 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
10054 // A multi-segment relative `:caminho`
10055 // (`"vendor/forks/caixa-teia"`) remains accepted — the
10056 // absolute-path gate brackets the host-layout-leaking shape
10057 // at the leading-`/` boundary only; every relative shape past
10058 // the empty arm continues to pass. Pinned alongside the
10059 // `..`-traversal positive control so a future tightening
10060 // surfaces the full set of legitimate relative forms here
10061 // rather than at a downstream consumer.
10062 let d = dep_with_fonte(DepSource::Path {
10063 caminho: "vendor/forks/caixa-teia".into(),
10064 });
10065 d.validate().unwrap();
10066 }
10067
10068 #[test]
10069 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
10070 // The fail-before-pass-after pin for the tilde-expansion
10071 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
10072 // Until this gate landed the b94fd83 absolute arm let `~/foo`
10073 // through (`Path::is_absolute` returns false on a leading `~`
10074 // — the tilde is a shell-expansion convention, not a POSIX
10075 // path component), so the lacre embedded the value verbatim
10076 // and the resolver folded it through `Path::join` without
10077 // expansion, looking for a literal `./~/work/caixa-teia`
10078 // subdirectory and failing at resolve time with a
10079 // `No such file or directory` error far from the source
10080 // caixa.lisp. The new gate moves the check to validate time
10081 // and names the offending dep + caminho verbatim.
10082 let d = dep_with_fonte(DepSource::Path {
10083 caminho: "~/work/caixa-teia".into(),
10084 });
10085 let err = d.validate().unwrap_err();
10086 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
10087 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
10088 };
10089 assert_eq!(nome, "caixa-teia");
10090 assert_eq!(caminho, "~/work/caixa-teia");
10091 }
10092
10093 #[test]
10094 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
10095 // The bare `~` form (canonical "I meant `$HOME` and forgot
10096 // the rest"): both the leading-tilde arm catches it and the
10097 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
10098 // sweeps through the same arm. Pinned both to ensure the
10099 // gate doesn't narrow to `~/` only.
10100 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
10101 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10102 let err = d.validate().unwrap_err();
10103 assert!(
10104 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10105 "{s:?} → {err:?}",
10106 );
10107 }
10108 }
10109
10110 #[test]
10111 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
10112 // The leading-`~` is the canonical shell-expansion footgun —
10113 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
10114 // backup-file-suffix idiom) is a legitimate POSIX path byte
10115 // with no shell-expansion semantic at the leading position.
10116 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
10117 // sweep that would break every legitimate-shape backup-file
10118 // path.
10119 let d = dep_with_fonte(DepSource::Path {
10120 caminho: "../foo~bar/caixa-teia".into(),
10121 });
10122 d.validate().unwrap();
10123 }
10124
10125 #[test]
10126 fn fonte_caminho_empty_fires_before_tilde_expansion() {
10127 // Cascade pin: the empty arm structurally precedes the
10128 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
10129 // pin establishes the precedence at the diagnostic-shape
10130 // level should a future codec round-trip ever produce a
10131 // probe-as-both value. Mirrors the peer
10132 // `fonte_repo_empty_fires_before_pin_missing` cascade
10133 // discipline.
10134 let d = dep_with_fonte(DepSource::Path {
10135 caminho: String::new(),
10136 });
10137 let err = d.validate().unwrap_err();
10138 assert!(
10139 matches!(err, DepError::FonteCaminhoEmpty { .. }),
10140 "got {err:?}",
10141 );
10142 }
10143
10144 #[test]
10145 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
10146 // Diagnostic-shape pin (peer with
10147 // `validate_rejects_path_fonte_with_absolute_caminho`'s
10148 // payload assertion): the error's Display surfaces both the
10149 // offending `:nome` and the offending `:caminho` verbatim
10150 // so a `feira lint` run can render the diagnostic without
10151 // re-parsing.
10152 let d = dep_with_fonte(DepSource::Path {
10153 caminho: "~alice/dev/caixa-teia".into(),
10154 });
10155 let rendered = d.validate().unwrap_err().to_string();
10156 assert!(
10157 rendered.contains("caixa-teia"),
10158 "diagnostic must name the offending dep: {rendered}",
10159 );
10160 assert!(
10161 rendered.contains("~alice/dev/caixa-teia"),
10162 "diagnostic must quote the offending caminho: {rendered}",
10163 );
10164 assert!(
10165 rendered.contains('~'),
10166 "diagnostic must reference the tilde footgun: {rendered}",
10167 );
10168 }
10169
10170 #[test]
10171 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
10172 // The fail-before-pass-after pin for the shell-variable-
10173 // expansion `:caminho` shape: `(:tipo path :caminho
10174 // "$HOME/work/caixa-teia")`. Until this gate landed the
10175 // b94fd83 absolute arm + the a5c248e tilde arm both let
10176 // `$HOME/foo` through (`Path::is_absolute` returns false on
10177 // a leading `$` — the `$` is a shell convention, not a POSIX
10178 // path component; `starts_with('~')` returns false too), so
10179 // the lacre embedded the value verbatim and the resolver
10180 // folded it through `Path::join` without `$`-expansion,
10181 // looking for a literal `./$HOME/work/caixa-teia`
10182 // subdirectory and failing at resolve time with a
10183 // `No such file or directory` error far from the source
10184 // caixa.lisp. The new gate moves the check to validate time
10185 // and names the offending dep + caminho verbatim.
10186 let d = dep_with_fonte(DepSource::Path {
10187 caminho: "$HOME/work/caixa-teia".into(),
10188 });
10189 let err = d.validate().unwrap_err();
10190 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
10191 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
10192 };
10193 assert_eq!(nome, "caixa-teia");
10194 assert_eq!(caminho, "$HOME/work/caixa-teia");
10195 }
10196
10197 #[test]
10198 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
10199 // Sweep over every leading-`$` shape: the `${VAR}`-braced
10200 // form (canonical "paste-from-CI-manifest" footgun every
10201 // GitHub Actions / GitLab CI / Drone manifest carries on
10202 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
10203 // canonical "I'm referencing a per-user config dir"),
10204 // and the bare `$` (canonical "I meant `$HOME` and forgot
10205 // the rest"). All shapes route through the same gate's
10206 // byte check. Pinned so the gate doesn't narrow to a
10207 // single shape (e.g. `$HOME/` only).
10208 for s in [
10209 "${HOME}/work/caixa-teia",
10210 "${WORKSPACE}/caixa-teia",
10211 "$XDG_CONFIG_HOME/caixa",
10212 "$",
10213 ] {
10214 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
10215 let err = d.validate().unwrap_err();
10216 assert!(
10217 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10218 "{s:?} → {err:?}",
10219 );
10220 }
10221 }
10222
10223 #[test]
10224 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
10225 // The `$` byte is the canonical shell-variable-expansion /
10226 // command-substitution / arithmetic-expansion sentinel and
10227 // is rejected at *every* position on the `:caminho` axis: the
10228 // leading arm surfaces `FonteCaminhoVarExpansion`, the
10229 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
10230 // (6620f39). Pinned so a future arm doesn't narrow the gate
10231 // back to the leading position and re-open the paste-from-
10232 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
10233 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
10234 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
10235 // the lacre content-address (`path:{caminho}`,
10236 // caixa-resolver/src/resolve.rs:189).
10237 let d = dep_with_fonte(DepSource::Path {
10238 caminho: "../foo$bar/caixa-teia".into(),
10239 });
10240 let err = d.validate().unwrap_err();
10241 assert!(
10242 matches!(
10243 err,
10244 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
10245 ),
10246 "got {err:?}",
10247 );
10248 }
10249
10250 #[test]
10251 fn fonte_caminho_tilde_fires_before_var_expansion() {
10252 // Cascade pin: the tilde arm structurally precedes the var
10253 // arm (the bytes `~` and `$` don't overlap at the leading
10254 // position), but the pin establishes the precedence at the
10255 // diagnostic-shape level should a future codec round-trip
10256 // ever produce a probe-as-both value. Mirrors the peer
10257 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
10258 // discipline on the immediate-predecessor arm.
10259 let d = dep_with_fonte(DepSource::Path {
10260 caminho: "~/work/caixa-teia".into(),
10261 });
10262 let err = d.validate().unwrap_err();
10263 assert!(
10264 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10265 "got {err:?}",
10266 );
10267 }
10268
10269 #[test]
10270 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
10271 // Diagnostic-shape pin (peer with
10272 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
10273 // payload assertion on the immediate-predecessor arm): the
10274 // error's Display surfaces both the offending `:nome` and
10275 // the offending `:caminho` verbatim plus the `$` footgun
10276 // character itself so a `feira lint` run can render the
10277 // diagnostic without re-parsing.
10278 let d = dep_with_fonte(DepSource::Path {
10279 caminho: "${WORKSPACE}/caixa-teia".into(),
10280 });
10281 let rendered = d.validate().unwrap_err().to_string();
10282 assert!(
10283 rendered.contains("caixa-teia"),
10284 "diagnostic must name the offending dep: {rendered}",
10285 );
10286 assert!(
10287 rendered.contains("${WORKSPACE}/caixa-teia"),
10288 "diagnostic must quote the offending caminho: {rendered}",
10289 );
10290 assert!(
10291 rendered.contains('$'),
10292 "diagnostic must reference the dollar footgun: {rendered}",
10293 );
10294 }
10295
10296 #[test]
10297 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
10298 // The fail-before-pass-after pin for the load-bearing NUL byte:
10299 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
10300 // routes the path through `CString::new` which fails with
10301 // `NulError`); until this gate landed a `:caminho
10302 // "../caixa\0teia"` silently passed validate, the lacre
10303 // pipeline embedded the value verbatim, and the failure
10304 // surfaced at the resolver's `Path::join` → `CString::new`
10305 // boundary with a non-self-locating `NulError` far from the
10306 // source caixa.lisp. The new gate moves the check to validate
10307 // time and names the offending dep + caminho + offending byte
10308 // verbatim.
10309 let d = dep_with_fonte(DepSource::Path {
10310 caminho: "../caixa\0teia".into(),
10311 });
10312 let err = d.validate().unwrap_err();
10313 let DepError::FonteCaminhoControlChar {
10314 nome,
10315 caminho,
10316 byte,
10317 } = err
10318 else {
10319 panic!("expected FonteCaminhoControlChar, got {err:?}");
10320 };
10321 assert_eq!(nome, "caixa-teia");
10322 assert_eq!(caminho, "../caixa\0teia");
10323 assert_eq!(byte, 0x00);
10324 }
10325
10326 #[test]
10327 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
10328 // The canonical paste-from-multiline-doc footgun on `:caminho`
10329 // — author copies `"../caixa-teia\n"` (trailing newline) out
10330 // of a multi-line code-fence or, worse, a `:caminho
10331 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
10332 // injection sibling on the path axis the `is_git_repo_url`
10333 // control-char arm already closes on `:repo`). Pinned
10334 // separately from the NUL arm so a future relaxation that
10335 // catches one but not the other surfaces here.
10336 let d = dep_with_fonte(DepSource::Path {
10337 caminho: "../caixa-teia\n".into(),
10338 });
10339 let err = d.validate().unwrap_err();
10340 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10341 panic!("expected FonteCaminhoControlChar, got {err:?}");
10342 };
10343 assert_eq!(byte, 0x0A);
10344 }
10345
10346 #[test]
10347 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
10348 // The CRLF sibling of the LF arm — Windows-line-ending
10349 // paste-from-multiline-doc on a `\r\n`-terminated buffer
10350 // leaves a stray `\r` mid-string after the LF strip. Pinned
10351 // separately from the LF arm so a future relaxation that
10352 // only catches LF surfaces here.
10353 let d = dep_with_fonte(DepSource::Path {
10354 caminho: "../caixa-teia\r".into(),
10355 });
10356 let err = d.validate().unwrap_err();
10357 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10358 panic!("expected FonteCaminhoControlChar, got {err:?}");
10359 };
10360 assert_eq!(byte, 0x0D);
10361 }
10362
10363 #[test]
10364 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
10365 // The canonical paste-from-aligned-table footgun — a `\t`
10366 // mid-`:caminho` is invisible in most editors but rides
10367 // through the lacre's content-address verbatim, so two
10368 // paste-from-distinct-tables (one editor strips tabs, one
10369 // preserves them) yield divergent lacres for the byte-
10370 // identical-looking caixa. Pinned separately from the
10371 // whitespace-shaped LF/CR arms so a future relaxation that
10372 // narrows to line-terminator-only surfaces here.
10373 let d = dep_with_fonte(DepSource::Path {
10374 caminho: "../caixa\tteia".into(),
10375 });
10376 let err = d.validate().unwrap_err();
10377 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10378 panic!("expected FonteCaminhoControlChar, got {err:?}");
10379 };
10380 assert_eq!(byte, 0x09);
10381 }
10382
10383 #[test]
10384 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
10385 // The DEL byte (`0x7F`) closes the upper-end paste-from-
10386 // binary-blob footgun — the gate's contract is `b < 0x20 ||
10387 // b == 0x7F`, matching the `is_git_repo_url` /
10388 // `is_git_ref_name` predicates' control-char arms. Pinned
10389 // separately from the lower-range arms so a future narrowing
10390 // to `< 0x20` only surfaces here.
10391 let d = dep_with_fonte(DepSource::Path {
10392 caminho: "../caixa\x7fteia".into(),
10393 });
10394 let err = d.validate().unwrap_err();
10395 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10396 panic!("expected FonteCaminhoControlChar, got {err:?}");
10397 };
10398 assert_eq!(byte, 0x7F);
10399 }
10400
10401 #[test]
10402 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
10403 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
10404 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
10405 // are opaque byte sequences and UTF-8 multi-byte sequences
10406 // are a legitimate filename shape (the `café-teia/foo` idiom).
10407 // Pinned so the gate doesn't widen to a full ASCII-only sweep
10408 // that would break every legitimate-shape UTF-8 path.
10409 let d = dep_with_fonte(DepSource::Path {
10410 caminho: "../café-teia/foo".into(),
10411 });
10412 d.validate().unwrap();
10413 }
10414
10415 #[test]
10416 fn fonte_caminho_var_fires_before_control_char() {
10417 // Cascade pin: the var-expansion arm structurally precedes the
10418 // control-char arm. A value like `"$\n"` probes positive on
10419 // both arms (`starts_with('$')` and contains LF), but the
10420 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
10421 // wins so the author sees the more self-locating shell-
10422 // expansion arm first. Mirrors the
10423 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10424 // discipline on the immediate-predecessor arm.
10425 let d = dep_with_fonte(DepSource::Path {
10426 caminho: "$HOME\n".into(),
10427 });
10428 let err = d.validate().unwrap_err();
10429 assert!(
10430 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10431 "got {err:?}",
10432 );
10433 }
10434
10435 #[test]
10436 fn validate_rejects_path_fonte_with_leading_space_caminho() {
10437 // The fail-before-pass-after pin for the leading ASCII space
10438 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
10439 // Until this gate landed the b94fd83 absolute arm + the a5c248e
10440 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
10441 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
10442 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
10443 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
10444 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
10445 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
10446 // are caught, but the most common whitespace `0x20` space is
10447 // not). The lacre embedded the value verbatim and the resolver
10448 // folded it through `Path::join` looking for a literal `./ ../
10449 // caixa-teia` subdirectory and failing at resolve time with a
10450 // non-self-locating `No such file or directory` error far from
10451 // the source caixa.lisp. The new gate moves the check to
10452 // validate time and names the offending dep + caminho verbatim.
10453 let d = dep_with_fonte(DepSource::Path {
10454 caminho: " ../caixa-teia".into(),
10455 });
10456 let err = d.validate().unwrap_err();
10457 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
10458 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
10459 };
10460 assert_eq!(nome, "caixa-teia");
10461 assert_eq!(caminho, " ../caixa-teia");
10462 }
10463
10464 #[test]
10465 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
10466 // The aligned-doc paste footgun sweep: more than one leading
10467 // space (`" ../caixa-teia"` — the canonical "I selected the
10468 // aligned column from a four-`:fonte`-entry `:deps` block"
10469 // paste) routes through the same gate's `starts_with(' ')`
10470 // byte check. Pinned so the gate doesn't narrow to a
10471 // single-space prefix.
10472 let d = dep_with_fonte(DepSource::Path {
10473 caminho: " ../caixa-teia".into(),
10474 });
10475 let err = d.validate().unwrap_err();
10476 assert!(
10477 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10478 "got {err:?}",
10479 );
10480 }
10481
10482 #[test]
10483 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
10484 // The leading-space is the canonical paste-from-aligned-doc
10485 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
10486 // canonical "I have a directory with a space in its name"
10487 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
10488 // legitimate path with no whitespace-leak semantic at the
10489 // non-leading position. Pinned so the gate doesn't widen to a
10490 // full no-space-anywhere sweep that would break every
10491 // legitimate-shape space-in-filename path.
10492 let d = dep_with_fonte(DepSource::Path {
10493 caminho: "../my dir/caixa-teia".into(),
10494 });
10495 d.validate().unwrap();
10496 }
10497
10498 #[test]
10499 fn fonte_caminho_var_fires_before_leading_whitespace() {
10500 // Cascade pin: the var-expansion arm structurally precedes the
10501 // leading-whitespace arm. A value like `"$ "` would probe positive
10502 // on var (`starts_with('$')`) but the leading-byte arms walk
10503 // left-to-right so the var arm fires on the leading `$` before
10504 // the leading-whitespace arm probes. Mirrors the
10505 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10506 // discipline on the immediate-predecessor arms.
10507 let d = dep_with_fonte(DepSource::Path {
10508 caminho: "$VAR".into(),
10509 });
10510 let err = d.validate().unwrap_err();
10511 assert!(
10512 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10513 "got {err:?}",
10514 );
10515 }
10516
10517 #[test]
10518 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
10519 // Cascade pin: the leading-whitespace arm structurally precedes
10520 // the control-char arm. A value like `" ../foo\n"` probes
10521 // positive on both (starts with space AND contains LF), but
10522 // the narrower leading-byte diagnostic
10523 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
10524 // more self-locating paste-from-aligned-doc arm first. Mirrors
10525 // the `fonte_caminho_var_fires_before_control_char` cascade
10526 // discipline on the immediate-predecessor arm.
10527 let d = dep_with_fonte(DepSource::Path {
10528 caminho: " ../foo\n".into(),
10529 });
10530 let err = d.validate().unwrap_err();
10531 assert!(
10532 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10533 "got {err:?}",
10534 );
10535 }
10536
10537 #[test]
10538 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10539 // Diagnostic-shape pin (peer with
10540 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10541 // payload assertion on the immediate-predecessor arm): the
10542 // error's Display surfaces both the offending `:nome` and the
10543 // offending `:caminho` verbatim, so a `feira lint` run can
10544 // render the diagnostic without re-parsing and the author can
10545 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10546 // one edit.
10547 let d = dep_with_fonte(DepSource::Path {
10548 caminho: " ../caixa-teia".into(),
10549 });
10550 let rendered = d.validate().unwrap_err().to_string();
10551 assert!(
10552 rendered.contains("caixa-teia"),
10553 "diagnostic must name the offending dep: {rendered}",
10554 );
10555 assert!(
10556 rendered.contains(" ../caixa-teia"),
10557 "diagnostic must quote the offending caminho: {rendered}",
10558 );
10559 assert!(
10560 rendered.contains("space"),
10561 "diagnostic must name the space footgun: {rendered}",
10562 );
10563 }
10564
10565 #[test]
10566 fn fonte_caminho_absolute_fires_before_control_char() {
10567 // Cascade pin on the sibling leading-byte arm: a leading `/`
10568 // value with embedded control byte (`"/etc/passwd\n"`) routes
10569 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10570 // — the host-layout-leak diagnostic is the load-bearing axis,
10571 // the control byte is the secondary observation. Same precedence
10572 // logic on every prior leading-byte arm.
10573 let d = dep_with_fonte(DepSource::Path {
10574 caminho: "/etc/passwd\n".into(),
10575 });
10576 let err = d.validate().unwrap_err();
10577 assert!(
10578 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10579 "got {err:?}",
10580 );
10581 }
10582
10583 #[test]
10584 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10585 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10586 // injection `:caminho` shape sweep. Until this gate landed
10587 // every prior leading-byte arm passed a leading-`-` value
10588 // through: `Path::is_absolute` returns false on `-` (the
10589 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10590 // `starts_with('$')` / `starts_with(' ')` all return false,
10591 // and `0x2D` sits outside the control-byte set. The lacre
10592 // embedded the value verbatim and the resolver folded it
10593 // through `Path::join` looking for a literal `./-rf` /
10594 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10595 // `Path::join` time is non-self-locating but harmless, while
10596 // the failure at every downstream `git -C {caminho}` /
10597 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10598 // is arbitrary-CLI-arg-injection because none of those
10599 // porcelains carry a `--` argument-list terminator between
10600 // the flag block and the path argument. The new arm moves the
10601 // rejection to `Caixa::from_lisp` boundary time and names
10602 // the offending dep + caminho verbatim.
10603 //
10604 // Sweep spans the canonical CLI-arg-injection shapes matching
10605 // the peer sweep on the sibling `is_git_ref_name` /
10606 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10607 // `find -rf` reinterpretation vector), `-C` (the `git -C`
10608 // change-directory-config-injection paste), long-flag
10609 // `--upload-pack=cat /etc/passwd` (the canonical
10610 // arbitrary-command-execution vector on every git porcelain
10611 // entry point), git-config-injection `--config=core.merge=ours`,
10612 // and the degenerate single-byte `-` value.
10613 for caminho in [
10614 "-rf",
10615 "-C",
10616 "--upload-pack=cat /etc/passwd",
10617 "--config=core.merge=ours",
10618 "-",
10619 ] {
10620 let d = dep_with_fonte(DepSource::Path {
10621 caminho: caminho.into(),
10622 });
10623 let err = d.validate().unwrap_err();
10624 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10625 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10626 };
10627 assert_eq!(nome, "caixa-teia");
10628 assert_eq!(got, caminho);
10629 }
10630 }
10631
10632 #[test]
10633 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10634 // The leading-`-` is the canonical CLI-arg-injection footgun
10635 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10636 // canonical kebab-separator-between-alphanumeric-segments
10637 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10638 // — a mid-path segment starting with `-`, still a legitimate
10639 // POSIX filename byte at that non-leading position because the
10640 // subprocess reads the whole `{caminho}` value as one positional
10641 // argument, so only the very first byte of the composite path
10642 // string is at the CLI-arg-injection boundary) is a legitimate
10643 // path with no CLI-flag-reinterpretation semantic at the non-
10644 // leading position of the top-level value. Pinned so the gate
10645 // doesn't widen to a full no-`-`-anywhere sweep that would
10646 // break every legitimate-shape kebab-in-filename path (i.e.
10647 // essentially every sibling-workspace caixa dep).
10648 for caminho in [
10649 "../caixa-teia",
10650 "../caixa-teia/-hidden",
10651 "./my-lib",
10652 "../foo-bar/baz",
10653 ] {
10654 let d = dep_with_fonte(DepSource::Path {
10655 caminho: caminho.into(),
10656 });
10657 d.validate()
10658 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10659 }
10660 }
10661
10662 #[test]
10663 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10664 // Cascade pin: the leading-whitespace arm structurally precedes
10665 // the leading-hyphen arm. A value like `" -rf"` probes positive
10666 // on both (leading space AND, one byte in, a `-` — though the
10667 // leading-hyphen arm probes only the very first byte so it
10668 // wouldn't fire on this value; the pin instead documents the
10669 // arm order on the more common "leading space then a hyphen"
10670 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10671 // The narrower leading-space diagnostic (the paste-from-aligned-
10672 // doc footgun) wins so the author sees the more self-locating
10673 // whitespace arm first. Mirrors the
10674 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10675 // discipline on the immediate-predecessor arm.
10676 let d = dep_with_fonte(DepSource::Path {
10677 caminho: " -rf".into(),
10678 });
10679 let err = d.validate().unwrap_err();
10680 assert!(
10681 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10682 "got {err:?}",
10683 );
10684 }
10685
10686 #[test]
10687 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10688 // Cascade pin: the leading-hyphen arm structurally precedes
10689 // the control-char arm. A value like `"-rf\n"` probes positive
10690 // on both (starts with `-` AND contains LF), but the narrower
10691 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10692 // the author sees the more self-locating CLI-arg-injection arm
10693 // first. Mirrors the
10694 // `fonte_caminho_leading_whitespace_fires_before_control_char`
10695 // cascade discipline on the immediate-predecessor arm.
10696 let d = dep_with_fonte(DepSource::Path {
10697 caminho: "-rf\n".into(),
10698 });
10699 let err = d.validate().unwrap_err();
10700 assert!(
10701 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10702 "got {err:?}",
10703 );
10704 }
10705
10706 #[test]
10707 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10708 // Diagnostic-shape pin (peer with
10709 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10710 // payload assertion on the immediate-predecessor arm): the
10711 // error's Display surfaces both the offending `:nome` and the
10712 // offending `:caminho` verbatim plus the CLI-argument-injection
10713 // vocabulary, so a `feira lint` run can render the diagnostic
10714 // without re-parsing and the author can grep their caixa.lisp
10715 // for `:caminho "<value>"` and fix it in one edit.
10716 let d = dep_with_fonte(DepSource::Path {
10717 caminho: "--upload-pack=cat /etc/passwd".into(),
10718 });
10719 let rendered = d.validate().unwrap_err().to_string();
10720 assert!(
10721 rendered.contains("caixa-teia"),
10722 "diagnostic must name the offending dep: {rendered}",
10723 );
10724 assert!(
10725 rendered.contains("--upload-pack=cat /etc/passwd"),
10726 "diagnostic must quote the offending caminho: {rendered}",
10727 );
10728 assert!(
10729 rendered.contains("CLI-argument-injection"),
10730 "diagnostic must name the CLI-argument-injection vector: {rendered}",
10731 );
10732 assert!(
10733 rendered.contains("`-`"),
10734 "diagnostic must name the offending byte: {rendered}",
10735 );
10736 }
10737
10738 #[test]
10739 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10740 // Diagnostic-shape pin (peer with
10741 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10742 // payload assertion on the immediate-predecessor arm): the
10743 // error's Display surfaces the offending `:nome`, the
10744 // offending `:caminho` verbatim, and the offending byte in
10745 // hex form (`0x09` for tab) so a `feira lint` run can render
10746 // the diagnostic without re-parsing.
10747 let d = dep_with_fonte(DepSource::Path {
10748 caminho: "../caixa\tteia".into(),
10749 });
10750 let rendered = d.validate().unwrap_err().to_string();
10751 assert!(
10752 rendered.contains("caixa-teia"),
10753 "diagnostic must name the offending dep: {rendered}",
10754 );
10755 assert!(
10756 rendered.contains("../caixa\tteia"),
10757 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10758 );
10759 assert!(
10760 rendered.contains("0x09"),
10761 "diagnostic must name the offending byte in hex: {rendered:?}",
10762 );
10763 }
10764
10765 #[test]
10766 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10767 // The fail-before-pass-after pin for the canonical Windows-
10768 // path-separator paste footgun: an author who pastes a path
10769 // from Windows-Explorer's `Copy as path`, PowerShell's
10770 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10771 // produces `..\caixa-teia`-shape values that silently passed
10772 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10773 // false; `\` is neither a leading-byte sentinel nor a
10774 // control byte). On POSIX resolvers the value rides through
10775 // `Path::join` as a literal directory name and fails at
10776 // resolve time with `No such file or directory`; on Windows
10777 // resolvers the value resolves to the parent's sibling — two
10778 // distinct directories for the byte-identical caixa.lisp.
10779 // The new arm moves the rejection to validate time and names
10780 // the offending dep + caminho verbatim.
10781 let d = dep_with_fonte(DepSource::Path {
10782 caminho: "..\\caixa-teia".into(),
10783 });
10784 let err = d.validate().unwrap_err();
10785 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10786 panic!("expected FonteCaminhoBackslash, got {err:?}");
10787 };
10788 assert_eq!(nome, "caixa-teia");
10789 assert_eq!(caminho, "..\\caixa-teia");
10790 }
10791
10792 #[test]
10793 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10794 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10795 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10796 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10797 // false (POSIX absolute paths start with `/`, drive letters
10798 // are not a POSIX concept), so the b94fd83 absolute arm
10799 // doesn't fire; the value contains `\` bytes that this arm
10800 // now catches with the more self-locating Windows-path-
10801 // separator diagnostic. Pinned separately from the bare
10802 // `..\caixa-teia` shape so a future arm that targets only
10803 // leading-`..\` doesn't regress the drive-letter coverage.
10804 let d = dep_with_fonte(DepSource::Path {
10805 caminho: "C:\\work\\caixa-teia".into(),
10806 });
10807 let err = d.validate().unwrap_err();
10808 assert!(
10809 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10810 "got {err:?}",
10811 );
10812 }
10813
10814 #[test]
10815 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10816 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10817 // PowerShell tab-completion-on-a-directory append). Pinned
10818 // separately from the embedded-`\` shape so the gate's
10819 // contract is "any `\` anywhere", not "any `\` not at end".
10820 let d = dep_with_fonte(DepSource::Path {
10821 caminho: "..\\caixa-teia\\".into(),
10822 });
10823 let err = d.validate().unwrap_err();
10824 assert!(
10825 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10826 "got {err:?}",
10827 );
10828 }
10829
10830 #[test]
10831 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10832 // The positive-control pin: the gate targets `\` only,
10833 // never `/`. The canonical relative POSIX path
10834 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10835 // so legitimate nested-directory deps aren't broken. Pinned
10836 // so the gate doesn't accidentally widen to a "no path
10837 // separators at all" sweep.
10838 let d = dep_with_fonte(DepSource::Path {
10839 caminho: "../caixa-teia/foo/bar".into(),
10840 });
10841 d.validate().unwrap();
10842 }
10843
10844 #[test]
10845 fn fonte_caminho_control_char_fires_before_backslash() {
10846 // Cascade pin: the control-char arm structurally precedes the
10847 // backslash arm. A value like `"..\caixa\0teia"` probes
10848 // positive on both (`\` byte + NUL byte), but the control-
10849 // char diagnostic wins so the author sees the more self-
10850 // locating POSIX-syscall-rejected-byte diagnostic first
10851 // (NUL outright breaks `CString::new` at every `std::fs`
10852 // syscall boundary; the `\` divergence is the cross-OS-
10853 // separator axis). Mirrors the
10854 // `fonte_caminho_var_fires_before_control_char` cascade
10855 // discipline on the immediate-predecessor arm.
10856 let d = dep_with_fonte(DepSource::Path {
10857 caminho: "..\\caixa\0teia".into(),
10858 });
10859 let err = d.validate().unwrap_err();
10860 assert!(
10861 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10862 "got {err:?}",
10863 );
10864 }
10865
10866 #[test]
10867 fn fonte_caminho_absolute_fires_before_backslash() {
10868 // Cascade pin on the load-bearing leading-byte arm: a leading
10869 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10870 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10871 // — the host-layout-leak diagnostic is the load-bearing
10872 // axis, the `\` byte is the secondary observation. Same
10873 // precedence logic as every prior leading-byte arm.
10874 let d = dep_with_fonte(DepSource::Path {
10875 caminho: "/etc/passwd\\foo".into(),
10876 });
10877 let err = d.validate().unwrap_err();
10878 assert!(
10879 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10880 "got {err:?}",
10881 );
10882 }
10883
10884 #[test]
10885 fn fonte_caminho_var_fires_before_backslash() {
10886 // Cascade pin on the var-expansion arm: a leading-`$` value
10887 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10888 // PowerShell-env-var paste-from-CI-manifest footgun) routes
10889 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10890 // The shell-expansion diagnostic is the more self-locating
10891 // axis since both the leading `$` and the embedded `\`
10892 // are Windows-shell artifacts but the `$` is the root-cause
10893 // surface (an author who removes the `$` is likely to leave
10894 // the `\` too).
10895 let d = dep_with_fonte(DepSource::Path {
10896 caminho: "$WORKSPACE\\caixa-teia".into(),
10897 });
10898 let err = d.validate().unwrap_err();
10899 assert!(
10900 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10901 "got {err:?}",
10902 );
10903 }
10904
10905 #[test]
10906 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10907 // Diagnostic-shape pin (peer with the prior
10908 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10909 // on every preceding arm): the error's Display surfaces the
10910 // offending `:nome` and the offending `:caminho` verbatim
10911 // so a `feira lint` run can render the diagnostic without
10912 // re-parsing.
10913 let d = dep_with_fonte(DepSource::Path {
10914 caminho: "..\\caixa-teia".into(),
10915 });
10916 let rendered = d.validate().unwrap_err().to_string();
10917 assert!(
10918 rendered.contains("caixa-teia"),
10919 "diagnostic must name the offending dep: {rendered}",
10920 );
10921 assert!(
10922 rendered.contains("..\\caixa-teia"),
10923 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10924 );
10925 assert!(
10926 rendered.contains('\\'),
10927 "diagnostic must reference the backslash footgun: {rendered:?}",
10928 );
10929 }
10930
10931 #[test]
10932 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10933 // The fail-before-pass-after pin for the canonical trailing-`/`
10934 // paste footgun: an author who shell-tab-completes a sibling
10935 // directory (every interactive shell — bash/zsh/fish/nushell —
10936 // appends `/` on tab-completing a directory) produces
10937 // `"../caixa-teia/"`-shape values that silently passed every
10938 // prior arm (the leading byte is `.`, no control bytes, no
10939 // backslash). `Path::join` resolves both shapes to the same
10940 // directory at the resolver, but the lacre embeds the value
10941 // verbatim and the BLAKE3 closures diverge across two
10942 // workstations whose authors differ only in tab-completion
10943 // habits.
10944 let d = dep_with_fonte(DepSource::Path {
10945 caminho: "../caixa-teia/".into(),
10946 });
10947 let err = d.validate().unwrap_err();
10948 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10949 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10950 };
10951 assert_eq!(nome, "caixa-teia");
10952 assert_eq!(caminho, "../caixa-teia/");
10953 }
10954
10955 #[test]
10956 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10957 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10958 // directory and tab-completed it" footgun). Pinned separately
10959 // from the canonical `"../caixa-teia/"` shape so the gate's
10960 // contract is "any trailing `/`", not "trailing `/` after a leaf
10961 // name".
10962 let d = dep_with_fonte(DepSource::Path {
10963 caminho: "./".into(),
10964 });
10965 let err = d.validate().unwrap_err();
10966 assert!(
10967 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10968 "got {err:?}",
10969 );
10970 }
10971
10972 #[test]
10973 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10974 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10975 // that double-templated `${VAR}/` over an already-`/`-suffixed
10976 // path" footgun). The gate fires on the last byte being `/`
10977 // regardless of how many `/` precede it; the arm contract is
10978 // "the value ends with `/`", structurally.
10979 let d = dep_with_fonte(DepSource::Path {
10980 caminho: "../caixa-teia//".into(),
10981 });
10982 let err = d.validate().unwrap_err();
10983 assert!(
10984 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10985 "got {err:?}",
10986 );
10987 }
10988
10989 #[test]
10990 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10991 // The `"../"` shape (the canonical "I want the parent" tab-
10992 // completion footgun on a bare `..` path). Pinned separately so
10993 // the gate doesn't accidentally narrow to "trailing `/` only on
10994 // multi-segment paths".
10995 let d = dep_with_fonte(DepSource::Path {
10996 caminho: "../".into(),
10997 });
10998 let err = d.validate().unwrap_err();
10999 assert!(
11000 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
11001 "got {err:?}",
11002 );
11003 }
11004
11005 #[test]
11006 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
11007 // The positive-control pin: the gate targets the trailing byte
11008 // only, never internal `/` separators. The canonical nested
11009 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
11010 // to validate cleanly so legitimate deeply-nested deps aren't
11011 // broken. Pinned so the gate doesn't accidentally widen to a
11012 // "no `/` separators anywhere" sweep that would defeat the
11013 // entire path-fonte author surface.
11014 let d = dep_with_fonte(DepSource::Path {
11015 caminho: "../caixa-teia/foo/bar".into(),
11016 });
11017 d.validate().unwrap();
11018 }
11019
11020 #[test]
11021 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
11022 // The positive-control pin on the degenerate single-`.` shape
11023 // (the canonical "the caixa.lisp's own directory" idiom). The
11024 // gate fires on the trailing byte being `/`, not on the path
11025 // being short, so `"."` (one byte, not `/`) must continue to
11026 // validate cleanly.
11027 let d = dep_with_fonte(DepSource::Path {
11028 caminho: ".".into(),
11029 });
11030 d.validate().unwrap();
11031 }
11032
11033 #[test]
11034 fn fonte_caminho_control_char_fires_before_trailing_slash() {
11035 // Cascade pin: the control-char arm structurally precedes the
11036 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
11037 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
11038 // (control bytes are the paste-from-multiline-doc footgun the
11039 // d624c8d arm already closes). Mirrors the
11040 // `fonte_caminho_control_char_fires_before_backslash` cascade
11041 // discipline on the immediate-predecessor arm.
11042 let d = dep_with_fonte(DepSource::Path {
11043 caminho: "../foo\n/".into(),
11044 });
11045 let err = d.validate().unwrap_err();
11046 assert!(
11047 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11048 "got {err:?}",
11049 );
11050 }
11051
11052 #[test]
11053 fn fonte_caminho_backslash_fires_before_trailing_slash() {
11054 // Cascade pin on the backslash arm: a value like `"..\foo/"`
11055 // ends in `/` but the embedded `\` is the load-bearing
11056 // diagnostic (the cross-host-OS-separator divergence vector
11057 // the 3a4e1d7 arm closes). Same precedence logic as the prior
11058 // narrower-diagnostic-first cascade.
11059 let d = dep_with_fonte(DepSource::Path {
11060 caminho: "..\\caixa-teia/".into(),
11061 });
11062 let err = d.validate().unwrap_err();
11063 assert!(
11064 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11065 "got {err:?}",
11066 );
11067 }
11068
11069 #[test]
11070 fn fonte_caminho_absolute_fires_before_trailing_slash() {
11071 // Cascade pin on the load-bearing leading-byte arm: a leading
11072 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
11073 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
11074 // — the host-layout-leak diagnostic is the load-bearing axis,
11075 // the trailing `/` is the secondary observation. Same
11076 // precedence logic as every prior leading-byte arm.
11077 let d = dep_with_fonte(DepSource::Path {
11078 caminho: "/etc/passwd/".into(),
11079 });
11080 let err = d.validate().unwrap_err();
11081 assert!(
11082 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11083 "got {err:?}",
11084 );
11085 }
11086
11087 #[test]
11088 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
11089 // Diagnostic-shape pin (peer with the prior
11090 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
11091 // every preceding arm): the error's Display surfaces the
11092 // offending `:nome` and the offending `:caminho` verbatim so a
11093 // `feira lint` run can render the diagnostic without re-parsing.
11094 let d = dep_with_fonte(DepSource::Path {
11095 caminho: "../caixa-teia/".into(),
11096 });
11097 let rendered = d.validate().unwrap_err().to_string();
11098 assert!(
11099 rendered.contains("caixa-teia"),
11100 "diagnostic must name the offending dep: {rendered}",
11101 );
11102 assert!(
11103 rendered.contains("../caixa-teia/"),
11104 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11105 );
11106 assert!(
11107 rendered.contains("trailing"),
11108 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
11109 );
11110 }
11111
11112 // -- :caminho shell-redirection metacharacter arm -----------------------
11113
11114 #[test]
11115 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
11116 // The fail-before-pass-after pin for the canonical output-redirection
11117 // paste footgun: an author copies a shell pipeline tail
11118 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
11119 // line including the `> build.log` redirect" idiom) and silently
11120 // passed every prior arm (`Path::is_absolute` false on `..`, no
11121 // control bytes, no backslash, doesn't end in `/`). The lacre
11122 // embedded the value verbatim, the resolver folded it through
11123 // `Path::join` looking for a literal `./../caixa-teia>build.log`
11124 // subdirectory, and the failure surfaced at resolve time with a
11125 // non-self-locating `No such file or directory` error. The new arm
11126 // moves the rejection to validate time and names the offending dep
11127 // + caminho + byte verbatim.
11128 let d = dep_with_fonte(DepSource::Path {
11129 caminho: "../caixa-teia>build.log".into(),
11130 });
11131 let err = d.validate().unwrap_err();
11132 let DepError::FonteCaminhoShellRedirection {
11133 nome,
11134 caminho,
11135 byte,
11136 } = err
11137 else {
11138 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11139 };
11140 assert_eq!(nome, "caixa-teia");
11141 assert_eq!(caminho, "../caixa-teia>build.log");
11142 assert_eq!(byte, b'>');
11143 }
11144
11145 #[test]
11146 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
11147 // The symmetric input-redirection paste shape
11148 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
11149 // `command < input.lisp` line from a tatara-lisp REPL log"
11150 // idiom). Pinned separately from the `>` shape so the gate's
11151 // contract is "any `<` or `>` anywhere", not single-byte coverage.
11152 let d = dep_with_fonte(DepSource::Path {
11153 caminho: "../caixa-teia<input.lisp".into(),
11154 });
11155 let err = d.validate().unwrap_err();
11156 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
11157 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
11158 };
11159 assert_eq!(byte, b'<');
11160 }
11161
11162 #[test]
11163 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
11164 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
11165 // "I forgot the source side of the redirect" idiom). Pinned
11166 // separately from the embedded-byte shapes so the gate covers
11167 // every position, not only mid-path.
11168 let d = dep_with_fonte(DepSource::Path {
11169 caminho: ">../caixa-teia".into(),
11170 });
11171 let err = d.validate().unwrap_err();
11172 assert!(
11173 matches!(
11174 err,
11175 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11176 ),
11177 "got {err:?}",
11178 );
11179 }
11180
11181 #[test]
11182 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
11183 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
11184 // the canonical "I copied a `>>` append redirect" idiom). The arm
11185 // fires on the first `>` encountered; pinned so a future arm that
11186 // tries to distinguish `>` from `>>` doesn't break the broader
11187 // contract.
11188 let d = dep_with_fonte(DepSource::Path {
11189 caminho: "../caixa-teia>>build.log".into(),
11190 });
11191 let err = d.validate().unwrap_err();
11192 assert!(
11193 matches!(
11194 err,
11195 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11196 ),
11197 "got {err:?}",
11198 );
11199 }
11200
11201 #[test]
11202 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
11203 // The positive-control pin: the gate targets only `<` / `>`,
11204 // never adjacent printable ASCII or POSIX-valid bytes. The
11205 // canonical relative POSIX path (`"../caixa-teia"`) and a
11206 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
11207 // continue to validate cleanly so the gate doesn't widen to a
11208 // "no printable punctuation anywhere" sweep that would defeat
11209 // the entire path-fonte author surface.
11210 let d = dep_with_fonte(DepSource::Path {
11211 caminho: "../caixa-teia/foo/bar".into(),
11212 });
11213 d.validate().unwrap();
11214 }
11215
11216 #[test]
11217 fn fonte_caminho_backslash_fires_before_shell_redirection() {
11218 // Cascade pin on the immediate-predecessor arm: a value carrying
11219 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
11220 // canonical "I pasted a Windows-shell command with output
11221 // redirect" footgun) routes through `FonteCaminhoBackslash` not
11222 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
11223 // divergence is the load-bearing axis (an author who removes
11224 // the `\` is the root-cause edit; the `>` falls away in the
11225 // same edit since it's downstream of the Windows-shell
11226 // convention).
11227 let d = dep_with_fonte(DepSource::Path {
11228 caminho: "..\\caixa-teia>build.log".into(),
11229 });
11230 let err = d.validate().unwrap_err();
11231 assert!(
11232 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11233 "got {err:?}",
11234 );
11235 }
11236
11237 #[test]
11238 fn fonte_caminho_control_char_fires_before_shell_redirection() {
11239 // Cascade pin on the embedded-control-byte arm: a value carrying
11240 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
11241 // canonical paste-from-multiline-doc footgun where a newline
11242 // landed mid-caminho) routes through `FonteCaminhoControlChar`
11243 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
11244 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11245 // load-bearing axis on every value that probes positive for
11246 // both — mirrors the cascade discipline on every prior arm.
11247 let d = dep_with_fonte(DepSource::Path {
11248 caminho: "../foo\n>bar".into(),
11249 });
11250 let err = d.validate().unwrap_err();
11251 assert!(
11252 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11253 "got {err:?}",
11254 );
11255 }
11256
11257 #[test]
11258 fn fonte_caminho_absolute_fires_before_shell_redirection() {
11259 // Cascade pin on the load-bearing leading-byte arm: a leading
11260 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
11261 // routes through `FonteCaminhoAbsolute` not
11262 // `FonteCaminhoShellRedirection` — the host-layout-leak
11263 // diagnostic is the load-bearing axis, the `>` byte is the
11264 // secondary observation. Same precedence logic as every prior
11265 // leading-byte arm.
11266 let d = dep_with_fonte(DepSource::Path {
11267 caminho: "/etc/passwd>out".into(),
11268 });
11269 let err = d.validate().unwrap_err();
11270 assert!(
11271 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11272 "got {err:?}",
11273 );
11274 }
11275
11276 #[test]
11277 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
11278 // Cascade pin on the immediate-successor arm: a value carrying
11279 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
11280 // canonical "I tab-completed a path that already had a
11281 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
11282 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11283 // the more semantic-locating axis (an author who removes the
11284 // `<` / `>` typically also drops the trailing separator since
11285 // both are paste-from-shell artifacts).
11286 let d = dep_with_fonte(DepSource::Path {
11287 caminho: "../foo></".into(),
11288 });
11289 let err = d.validate().unwrap_err();
11290 assert!(
11291 matches!(
11292 err,
11293 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11294 ),
11295 "got {err:?}",
11296 );
11297 }
11298
11299 #[test]
11300 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
11301 // Diagnostic-shape pin (peer with
11302 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
11303 // payload assertion on the closest peer arm that also carries a
11304 // `byte` field): the error's Display surfaces the offending
11305 // `:nome`, the offending `:caminho` verbatim, and the offending
11306 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
11307 // run can render the diagnostic without re-parsing.
11308 let d = dep_with_fonte(DepSource::Path {
11309 caminho: "../caixa-teia>build.log".into(),
11310 });
11311 let rendered = d.validate().unwrap_err().to_string();
11312 assert!(
11313 rendered.contains("caixa-teia"),
11314 "diagnostic must name the offending dep: {rendered}",
11315 );
11316 assert!(
11317 rendered.contains("../caixa-teia>build.log"),
11318 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11319 );
11320 assert!(
11321 rendered.contains("0x3e"),
11322 "diagnostic must name the offending byte in hex: {rendered:?}",
11323 );
11324 assert!(
11325 rendered.contains("redirection"),
11326 "diagnostic must name the shell-redirection footgun: {rendered:?}",
11327 );
11328 }
11329
11330 // -- :caminho shell-pipe metacharacter arm ----------------------------
11331
11332 #[test]
11333 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
11334 // The fail-before-pass-after pin for the canonical shell-pipe
11335 // paste footgun: an author copies a shell-history line
11336 // (`"../caixa-teia | grep foo"` — the canonical "I selected
11337 // the whole `ls dir | grep` line out of zsh history") and
11338 // silently passed every prior arm (`Path::is_absolute` false
11339 // on `..`, no control bytes, no backslash, no `<` / `>`,
11340 // doesn't end in `/`). The lacre embedded the value verbatim,
11341 // the resolver folded it through `Path::join` looking for a
11342 // literal `./../caixa-teia | grep foo` subdirectory, and the
11343 // failure surfaced at resolve time with a non-self-locating
11344 // `No such file or directory` error. The new arm moves the
11345 // rejection to validate time and names the offending dep +
11346 // caminho verbatim.
11347 let d = dep_with_fonte(DepSource::Path {
11348 caminho: "../caixa-teia | grep foo".into(),
11349 });
11350 let err = d.validate().unwrap_err();
11351 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
11352 panic!("expected FonteCaminhoShellPipe, got {err:?}");
11353 };
11354 assert_eq!(nome, "caixa-teia");
11355 assert_eq!(caminho, "../caixa-teia | grep foo");
11356 }
11357
11358 #[test]
11359 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
11360 // Leading-position `|` shape (`"|../caixa-teia"` — the
11361 // degenerate "I forgot the source side of the pipe" idiom).
11362 // Pinned separately from the embedded-byte shape so the gate
11363 // covers every position, not only mid-path.
11364 let d = dep_with_fonte(DepSource::Path {
11365 caminho: "|../caixa-teia".into(),
11366 });
11367 let err = d.validate().unwrap_err();
11368 assert!(
11369 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11370 "got {err:?}",
11371 );
11372 }
11373
11374 #[test]
11375 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
11376 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
11377 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
11378 // idiom). The arm fires on the first `|` encountered; pinned
11379 // so a future arm that tries to distinguish `|` from `||`
11380 // doesn't break the broader contract.
11381 let d = dep_with_fonte(DepSource::Path {
11382 caminho: "../caixa-teia||fallback".into(),
11383 });
11384 let err = d.validate().unwrap_err();
11385 assert!(
11386 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11387 "got {err:?}",
11388 );
11389 }
11390
11391 #[test]
11392 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
11393 // The positive-control pin: the gate targets only `|`, never
11394 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11395 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11396 // pathed variant with adjacent printable punctuation
11397 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11398 // cleanly so the gate doesn't widen to a "no printable
11399 // punctuation anywhere" sweep that would defeat the entire
11400 // path-fonte author surface.
11401 let d = dep_with_fonte(DepSource::Path {
11402 caminho: "../caixa-teia/sub-dir.v2".into(),
11403 });
11404 d.validate().unwrap();
11405 }
11406
11407 #[test]
11408 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
11409 // Cascade pin on the immediate-predecessor arm: a value carrying
11410 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
11411 // canonical "I pasted a `cmd < input | tee` pipeline tail"
11412 // footgun) routes through `FonteCaminhoShellRedirection` not
11413 // `FonteCaminhoShellPipe`. The input/output redirection
11414 // metachar carries the more self-locating `byte: u8` payload
11415 // (it names which of `<` or `>` triggered), so the prior arm
11416 // wins on every probe-as-both value — same cascade discipline
11417 // every prior `:caminho` arm establishes.
11418 let d = dep_with_fonte(DepSource::Path {
11419 caminho: "../caixa-teia<input|tee".into(),
11420 });
11421 let err = d.validate().unwrap_err();
11422 assert!(
11423 matches!(
11424 err,
11425 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
11426 ),
11427 "got {err:?}",
11428 );
11429 }
11430
11431 #[test]
11432 fn fonte_caminho_backslash_fires_before_shell_pipe() {
11433 // Cascade pin on the upstream backslash arm: a value carrying
11434 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
11435 // "I pasted a Windows-shell command with pipe to tee"
11436 // footgun) routes through `FonteCaminhoBackslash` not
11437 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
11438 // divergence is the load-bearing axis on every probe-as-both
11439 // value (an author who removes the `\` is the root-cause edit;
11440 // the `|` falls away in the same edit since it's downstream of
11441 // the Windows-shell convention).
11442 let d = dep_with_fonte(DepSource::Path {
11443 caminho: "..\\caixa-teia|tee".into(),
11444 });
11445 let err = d.validate().unwrap_err();
11446 assert!(
11447 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11448 "got {err:?}",
11449 );
11450 }
11451
11452 #[test]
11453 fn fonte_caminho_control_char_fires_before_shell_pipe() {
11454 // Cascade pin on the embedded-control-byte arm: a value
11455 // carrying both a control byte and `|` (`"../foo\n|bar"` —
11456 // the canonical paste-from-multiline-doc footgun where a
11457 // newline landed mid-caminho) routes through
11458 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
11459 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11460 // diagnostic is the load-bearing axis on every value that
11461 // probes positive for both — mirrors the cascade discipline
11462 // on every prior arm.
11463 let d = dep_with_fonte(DepSource::Path {
11464 caminho: "../foo\n|bar".into(),
11465 });
11466 let err = d.validate().unwrap_err();
11467 assert!(
11468 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11469 "got {err:?}",
11470 );
11471 }
11472
11473 #[test]
11474 fn fonte_caminho_absolute_fires_before_shell_pipe() {
11475 // Cascade pin on the load-bearing leading-byte arm: a leading
11476 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
11477 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
11478 // — the host-layout-leak diagnostic is the load-bearing axis,
11479 // the `|` byte is the secondary observation. Same precedence
11480 // logic as every prior leading-byte arm.
11481 let d = dep_with_fonte(DepSource::Path {
11482 caminho: "/etc/passwd|tee".into(),
11483 });
11484 let err = d.validate().unwrap_err();
11485 assert!(
11486 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11487 "got {err:?}",
11488 );
11489 }
11490
11491 #[test]
11492 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
11493 // Cascade pin on the immediate-successor arm: a value carrying
11494 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
11495 // "I tab-completed a path that already had a pipeline tail"
11496 // footgun) routes through `FonteCaminhoShellPipe` not
11497 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11498 // the more semantic-locating axis (an author who removes the
11499 // `|` typically also drops the trailing separator since both
11500 // are paste-from-shell artifacts).
11501 let d = dep_with_fonte(DepSource::Path {
11502 caminho: "../foo|tee/".into(),
11503 });
11504 let err = d.validate().unwrap_err();
11505 assert!(
11506 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11507 "got {err:?}",
11508 );
11509 }
11510
11511 #[test]
11512 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
11513 // Diagnostic-shape pin (peer with
11514 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
11515 // on the closest single-byte peer arm): the error's Display
11516 // surfaces the offending `:nome` and the offending `:caminho`
11517 // verbatim, and names the shell-pipe footgun explicitly so a
11518 // `feira lint` run can render the diagnostic without
11519 // re-parsing.
11520 let d = dep_with_fonte(DepSource::Path {
11521 caminho: "../caixa-teia | grep foo".into(),
11522 });
11523 let rendered = d.validate().unwrap_err().to_string();
11524 assert!(
11525 rendered.contains("caixa-teia"),
11526 "diagnostic must name the offending dep: {rendered}",
11527 );
11528 assert!(
11529 rendered.contains("../caixa-teia | grep foo"),
11530 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11531 );
11532 assert!(
11533 rendered.contains('|'),
11534 "diagnostic must reference the pipe footgun: {rendered:?}",
11535 );
11536 assert!(
11537 rendered.contains("pipe"),
11538 "diagnostic must name the shell-pipe footgun: {rendered:?}",
11539 );
11540 }
11541
11542 // -- :caminho shell-command-separator metacharacter arm ---------------
11543
11544 #[test]
11545 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11546 // The fail-before-pass-after pin for the canonical shell-command-
11547 // separator paste footgun: an author copies a shell one-liner
11548 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11549 // whole `cd path; do-thing` chain out of a shell-history block")
11550 // and silently passed every prior arm (`Path::is_absolute` false
11551 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11552 // doesn't end in `/`). The lacre embedded the value verbatim, the
11553 // resolver folded it through `Path::join` looking for a literal
11554 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11555 // surfaced at resolve time with a non-self-locating `No such file
11556 // or directory` error. The new arm moves the rejection to validate
11557 // time and names the offending dep + caminho verbatim.
11558 let d = dep_with_fonte(DepSource::Path {
11559 caminho: "../caixa-teia; rm -rf build".into(),
11560 });
11561 let err = d.validate().unwrap_err();
11562 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11563 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11564 };
11565 assert_eq!(nome, "caixa-teia");
11566 assert_eq!(caminho, "../caixa-teia; rm -rf build");
11567 }
11568
11569 #[test]
11570 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11571 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11572 // "I forgot the prior command side of the separator" idiom).
11573 // Pinned separately from the embedded-byte shape so the gate
11574 // covers every position, not only mid-path.
11575 let d = dep_with_fonte(DepSource::Path {
11576 caminho: ";../caixa-teia".into(),
11577 });
11578 let err = d.validate().unwrap_err();
11579 assert!(
11580 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11581 "got {err:?}",
11582 );
11583 }
11584
11585 #[test]
11586 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11587 // The POSIX `case` arm `;;` terminator shape
11588 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11589 // arm tail" idiom). The arm fires on the first `;` encountered;
11590 // pinned so a future arm that tries to distinguish `;` from `;;`
11591 // doesn't break the broader contract.
11592 let d = dep_with_fonte(DepSource::Path {
11593 caminho: "../caixa-teia;;next".into(),
11594 });
11595 let err = d.validate().unwrap_err();
11596 assert!(
11597 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11598 "got {err:?}",
11599 );
11600 }
11601
11602 #[test]
11603 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11604 // The positive-control pin: the gate targets only `;`, never
11605 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11606 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11607 // pathed variant with adjacent printable punctuation
11608 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11609 // cleanly so the gate doesn't widen to a "no printable
11610 // punctuation anywhere" sweep that would defeat the entire
11611 // path-fonte author surface.
11612 let d = dep_with_fonte(DepSource::Path {
11613 caminho: "../caixa-teia/sub-dir.v2".into(),
11614 });
11615 d.validate().unwrap();
11616 }
11617
11618 #[test]
11619 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11620 // Cascade pin on the immediate-predecessor arm: a value carrying
11621 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11622 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11623 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11624 // pipeline-tail paste is the load-bearing root-cause edit on
11625 // every probe-as-both value (an author who removes the `|`
11626 // typically also drops the trailing `; cleanup` since both are
11627 // the same paste-from-shell-history artifact) — same cascade
11628 // discipline every prior `:caminho` arm establishes.
11629 let d = dep_with_fonte(DepSource::Path {
11630 caminho: "../caixa-teia | tee; rm".into(),
11631 });
11632 let err = d.validate().unwrap_err();
11633 assert!(
11634 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11635 "got {err:?}",
11636 );
11637 }
11638
11639 #[test]
11640 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11641 // Cascade pin on the upstream shell-redirection arm: a value
11642 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11643 // the canonical "I pasted a `cmd > log; cleanup` chain"
11644 // footgun) routes through `FonteCaminhoShellRedirection` not
11645 // `FonteCaminhoShellSemicolon`. The input/output redirection
11646 // metachar carries the more self-locating `byte: u8` payload
11647 // (it names which of `<` or `>` triggered), so the prior arm
11648 // wins on every probe-as-both value.
11649 let d = dep_with_fonte(DepSource::Path {
11650 caminho: "../caixa-teia>log; rm".into(),
11651 });
11652 let err = d.validate().unwrap_err();
11653 assert!(
11654 matches!(
11655 err,
11656 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11657 ),
11658 "got {err:?}",
11659 );
11660 }
11661
11662 #[test]
11663 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11664 // Cascade pin on the upstream backslash arm: a value carrying
11665 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11666 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11667 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11668 // The cross-host-OS-separator divergence is the load-bearing axis
11669 // on every probe-as-both value (an author who removes the `\` is
11670 // the root-cause edit; the `;` falls away in the same edit since
11671 // it's downstream of the Windows-shell convention).
11672 let d = dep_with_fonte(DepSource::Path {
11673 caminho: "..\\caixa-teia;rm".into(),
11674 });
11675 let err = d.validate().unwrap_err();
11676 assert!(
11677 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11678 "got {err:?}",
11679 );
11680 }
11681
11682 #[test]
11683 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11684 // Cascade pin on the embedded-control-byte arm: a value carrying
11685 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11686 // paste-from-multiline-doc footgun where a newline landed mid-
11687 // caminho) routes through `FonteCaminhoControlChar` not
11688 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11689 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11690 // on every value that probes positive for both — mirrors the
11691 // cascade discipline on every prior arm.
11692 let d = dep_with_fonte(DepSource::Path {
11693 caminho: "../foo\n;bar".into(),
11694 });
11695 let err = d.validate().unwrap_err();
11696 assert!(
11697 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11698 "got {err:?}",
11699 );
11700 }
11701
11702 #[test]
11703 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11704 // Cascade pin on the load-bearing leading-byte arm: a leading
11705 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11706 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11707 // — the host-layout-leak diagnostic is the load-bearing axis,
11708 // the `;` byte is the secondary observation. Same precedence
11709 // logic as every prior leading-byte arm.
11710 let d = dep_with_fonte(DepSource::Path {
11711 caminho: "/etc/passwd;rm".into(),
11712 });
11713 let err = d.validate().unwrap_err();
11714 assert!(
11715 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11716 "got {err:?}",
11717 );
11718 }
11719
11720 #[test]
11721 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11722 // Cascade pin on the immediate-successor arm: a value carrying
11723 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11724 // "I tab-completed a path that already had a `; cleanup` tail"
11725 // footgun) routes through `FonteCaminhoShellSemicolon` not
11726 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11727 // the more semantic-locating axis (an author who removes the
11728 // `;` typically also drops the trailing separator since both
11729 // are paste-from-shell artifacts).
11730 let d = dep_with_fonte(DepSource::Path {
11731 caminho: "../foo;rm/".into(),
11732 });
11733 let err = d.validate().unwrap_err();
11734 assert!(
11735 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11736 "got {err:?}",
11737 );
11738 }
11739
11740 #[test]
11741 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11742 // Diagnostic-shape pin (peer with
11743 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11744 // on the closest single-byte peer arm): the error's Display
11745 // surfaces the offending `:nome` and the offending `:caminho`
11746 // verbatim, and names the shell-command-separator footgun
11747 // explicitly so a `feira lint` run can render the diagnostic
11748 // without re-parsing.
11749 let d = dep_with_fonte(DepSource::Path {
11750 caminho: "../caixa-teia; rm -rf build".into(),
11751 });
11752 let rendered = d.validate().unwrap_err().to_string();
11753 assert!(
11754 rendered.contains("caixa-teia"),
11755 "diagnostic must name the offending dep: {rendered}",
11756 );
11757 assert!(
11758 rendered.contains("../caixa-teia; rm -rf build"),
11759 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11760 );
11761 assert!(
11762 rendered.contains(';'),
11763 "diagnostic must reference the semicolon footgun: {rendered:?}",
11764 );
11765 assert!(
11766 rendered.contains("command-separator"),
11767 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11768 );
11769 }
11770
11771 #[test]
11772 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11773 // The fail-before-pass-after pin for the canonical shell-
11774 // background-task paste footgun: an author copies a shell one-
11775 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11776 // the whole `cd path & sleep 1` background-launch out of a
11777 // shell-history block") and silently passed every prior arm
11778 // (`Path::is_absolute` false on `..`, no control bytes, no
11779 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11780 // The lacre embedded the value verbatim, the resolver folded it
11781 // through `Path::join` looking for a literal `./../caixa-teia &
11782 // sleep 1` subdirectory, and the failure surfaced at resolve
11783 // time with a non-self-locating `No such file or directory`
11784 // error. The new arm moves the rejection to validate time and
11785 // names the offending dep + caminho verbatim.
11786 let d = dep_with_fonte(DepSource::Path {
11787 caminho: "../caixa-teia & sleep 1".into(),
11788 });
11789 let err = d.validate().unwrap_err();
11790 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11791 panic!("expected FonteCaminhoShellBackground, got {err:?}");
11792 };
11793 assert_eq!(nome, "caixa-teia");
11794 assert_eq!(caminho, "../caixa-teia & sleep 1");
11795 }
11796
11797 #[test]
11798 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11799 // Leading-position `&` shape (`"&../caixa-teia"` — the
11800 // degenerate "I forgot the prior command side of the
11801 // background terminator" idiom). Pinned separately from the
11802 // embedded-byte shape so the gate covers every position, not
11803 // only mid-path.
11804 let d = dep_with_fonte(DepSource::Path {
11805 caminho: "&../caixa-teia".into(),
11806 });
11807 let err = d.validate().unwrap_err();
11808 assert!(
11809 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11810 "got {err:?}",
11811 );
11812 }
11813
11814 #[test]
11815 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11816 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11817 // canonical "I copied a `cd path && make` build chain" idiom
11818 // every Makefile / shell-script wraps). The arm fires on the
11819 // first `&` encountered; pinned so a future arm that tries to
11820 // distinguish `&` from `&&` doesn't break the broader contract.
11821 let d = dep_with_fonte(DepSource::Path {
11822 caminho: "../caixa-teia && make".into(),
11823 });
11824 let err = d.validate().unwrap_err();
11825 assert!(
11826 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11827 "got {err:?}",
11828 );
11829 }
11830
11831 #[test]
11832 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11833 // The positive-control pin: the gate targets only `&`, never
11834 // adjacent printable ASCII or POSIX-valid bytes. The canonical
11835 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11836 // pathed variant with adjacent printable punctuation
11837 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11838 // cleanly so the gate doesn't widen to a "no printable
11839 // punctuation anywhere" sweep that would defeat the entire
11840 // path-fonte author surface.
11841 let d = dep_with_fonte(DepSource::Path {
11842 caminho: "../caixa-teia/sub-dir.v2".into(),
11843 });
11844 d.validate().unwrap();
11845 }
11846
11847 #[test]
11848 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11849 // Cascade pin on the immediate-predecessor arm: a value carrying
11850 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11851 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11852 // routes through `FonteCaminhoShellSemicolon` not
11853 // `FonteCaminhoShellBackground`. The sequential-command-
11854 // separator paste is the more common shell-history paste idiom
11855 // on every probe-as-both value (an author who removes the `;`
11856 // typically also drops the trailing `& sleep` since both are
11857 // paste-from-shell-history artifacts) — same cascade discipline
11858 // every prior `:caminho` arm establishes.
11859 let d = dep_with_fonte(DepSource::Path {
11860 caminho: "../caixa-teia; rm & sleep".into(),
11861 });
11862 let err = d.validate().unwrap_err();
11863 assert!(
11864 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11865 "got {err:?}",
11866 );
11867 }
11868
11869 #[test]
11870 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11871 // Cascade pin on the upstream shell-pipe arm: a value carrying
11872 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11873 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11874 // chain" footgun) routes through `FonteCaminhoShellPipe` not
11875 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11876 // load-bearing root-cause edit on every probe-as-both value.
11877 let d = dep_with_fonte(DepSource::Path {
11878 caminho: "../caixa-teia | tee & sleep".into(),
11879 });
11880 let err = d.validate().unwrap_err();
11881 assert!(
11882 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11883 "got {err:?}",
11884 );
11885 }
11886
11887 #[test]
11888 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11889 // Cascade pin on the upstream shell-redirection arm: a value
11890 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11891 // the canonical "I pasted a `cmd > log & sleep` background-
11892 // redirect chain" footgun) routes through
11893 // `FonteCaminhoShellRedirection` not
11894 // `FonteCaminhoShellBackground`. The input/output redirection
11895 // metachar carries the more self-locating `byte: u8` payload
11896 // (it names which of `<` or `>` triggered), so the prior arm
11897 // wins on every probe-as-both value.
11898 let d = dep_with_fonte(DepSource::Path {
11899 caminho: "../caixa-teia>log & sleep".into(),
11900 });
11901 let err = d.validate().unwrap_err();
11902 assert!(
11903 matches!(
11904 err,
11905 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11906 ),
11907 "got {err:?}",
11908 );
11909 }
11910
11911 #[test]
11912 fn fonte_caminho_backslash_fires_before_shell_background() {
11913 // Cascade pin on the upstream backslash arm: a value carrying
11914 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11915 // "I pasted a Windows-shell `cd ..\path & sleep` background-
11916 // launch chain") routes through `FonteCaminhoBackslash` not
11917 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11918 // divergence is the load-bearing axis on every probe-as-both
11919 // value (an author who removes the `\` is the root-cause edit;
11920 // the `&` falls away in the same edit since it's downstream of
11921 // the Windows-shell convention).
11922 let d = dep_with_fonte(DepSource::Path {
11923 caminho: "..\\caixa-teia & sleep".into(),
11924 });
11925 let err = d.validate().unwrap_err();
11926 assert!(
11927 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11928 "got {err:?}",
11929 );
11930 }
11931
11932 #[test]
11933 fn fonte_caminho_control_char_fires_before_shell_background() {
11934 // Cascade pin on the embedded-control-byte arm: a value
11935 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11936 // the canonical paste-from-multiline-doc footgun where a
11937 // newline landed mid-caminho) routes through
11938 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11939 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11940 // diagnostic is the load-bearing axis on every value that
11941 // probes positive for both — mirrors the cascade discipline on
11942 // every prior arm.
11943 let d = dep_with_fonte(DepSource::Path {
11944 caminho: "../foo\n&sleep".into(),
11945 });
11946 let err = d.validate().unwrap_err();
11947 assert!(
11948 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11949 "got {err:?}",
11950 );
11951 }
11952
11953 #[test]
11954 fn fonte_caminho_absolute_fires_before_shell_background() {
11955 // Cascade pin on the load-bearing leading-byte arm: a leading
11956 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11957 // through `FonteCaminhoAbsolute` not
11958 // `FonteCaminhoShellBackground` — the host-layout-leak
11959 // diagnostic is the load-bearing axis, the `&` byte is the
11960 // secondary observation. Same precedence logic as every prior
11961 // leading-byte arm.
11962 let d = dep_with_fonte(DepSource::Path {
11963 caminho: "/etc/passwd & sleep".into(),
11964 });
11965 let err = d.validate().unwrap_err();
11966 assert!(
11967 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11968 "got {err:?}",
11969 );
11970 }
11971
11972 #[test]
11973 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11974 // Cascade pin on the immediate-successor arm: a value carrying
11975 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11976 // canonical "I tab-completed a path that already had a `&
11977 // sleep` background-launch tail" footgun) routes through
11978 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11979 // The embedded shell-metachar is the more semantic-locating
11980 // axis (an author who removes the `&` typically also drops
11981 // the trailing separator since both are paste-from-shell
11982 // artifacts).
11983 let d = dep_with_fonte(DepSource::Path {
11984 caminho: "../foo&sleep/".into(),
11985 });
11986 let err = d.validate().unwrap_err();
11987 assert!(
11988 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11989 "got {err:?}",
11990 );
11991 }
11992
11993 #[test]
11994 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11995 // Diagnostic-shape pin (peer with
11996 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11997 // on the closest single-byte peer arm): the error's Display
11998 // surfaces the offending `:nome` and the offending `:caminho`
11999 // verbatim, and names the shell-background / logical-AND
12000 // footgun explicitly so a `feira lint` run can render the
12001 // diagnostic without re-parsing.
12002 let d = dep_with_fonte(DepSource::Path {
12003 caminho: "../caixa-teia & sleep 1".into(),
12004 });
12005 let rendered = d.validate().unwrap_err().to_string();
12006 assert!(
12007 rendered.contains("caixa-teia"),
12008 "diagnostic must name the offending dep: {rendered}",
12009 );
12010 assert!(
12011 rendered.contains("../caixa-teia & sleep 1"),
12012 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12013 );
12014 assert!(
12015 rendered.contains('&'),
12016 "diagnostic must reference the ampersand footgun: {rendered:?}",
12017 );
12018 assert!(
12019 rendered.contains("background") || rendered.contains("list-AND"),
12020 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
12021 );
12022 }
12023
12024 #[test]
12025 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
12026 // The fail-before-pass-after pin for the canonical shell-
12027 // command-substitution paste footgun: an author copies a
12028 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
12029 // — the canonical "I pasted a path that included a `pwd`
12030 // / `whoami` / `date` legacy command-substitution expansion
12031 // out of a shell-history block") and silently passed every
12032 // prior arm (`Path::is_absolute` false on `..`, no control
12033 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
12034 // end in `/`). The lacre embedded the value verbatim, the
12035 // resolver folded it through `Path::join` looking for a
12036 // literal `./../caixa-teia/`whoami`` subdirectory, and the
12037 // failure surfaced at resolve time with a non-self-locating
12038 // `No such file or directory` error. The new arm moves the
12039 // rejection to validate time and names the offending dep +
12040 // caminho verbatim.
12041 let d = dep_with_fonte(DepSource::Path {
12042 caminho: "../caixa-teia/`whoami`".into(),
12043 });
12044 let err = d.validate().unwrap_err();
12045 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
12046 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
12047 };
12048 assert_eq!(nome, "caixa-teia");
12049 assert_eq!(caminho, "../caixa-teia/`whoami`");
12050 }
12051
12052 #[test]
12053 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
12054 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
12055 // the canonical `<backtick>pwd<backtick>/path` working-
12056 // directory expansion shape every shell-side path-composition
12057 // idiom carries). Pinned separately from the embedded-byte
12058 // shape so the gate covers every position, not only mid-path.
12059 let d = dep_with_fonte(DepSource::Path {
12060 caminho: "`pwd`/caixa-teia".into(),
12061 });
12062 let err = d.validate().unwrap_err();
12063 assert!(
12064 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12065 "got {err:?}",
12066 );
12067 }
12068
12069 #[test]
12070 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
12071 // Trailing-position backtick shape (`"../caixa-teia`"` — the
12072 // degenerate "I selected an unbalanced backtick out of a
12073 // shell-history block" idiom that probes for the cascade's
12074 // last-byte handling). The trailing-`/` arm fires only on
12075 // last-byte `/`; an unbalanced trailing backtick must route
12076 // through this arm regardless of position.
12077 let d = dep_with_fonte(DepSource::Path {
12078 caminho: "../caixa-teia`".into(),
12079 });
12080 let err = d.validate().unwrap_err();
12081 assert!(
12082 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12083 "got {err:?}",
12084 );
12085 }
12086
12087 #[test]
12088 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
12089 // The canonical balanced-pair shape (``"../<backtick>cat
12090 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
12091 // command-injection paste idiom every shell-side hardening
12092 // guide enumerates first). The arm fires on the first
12093 // backtick encountered; pinned so a future arm that tries to
12094 // distinguish the opening from the closing byte doesn't break
12095 // the broader contract.
12096 let d = dep_with_fonte(DepSource::Path {
12097 caminho: "../`cat /etc/passwd`".into(),
12098 });
12099 let err = d.validate().unwrap_err();
12100 assert!(
12101 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12102 "got {err:?}",
12103 );
12104 }
12105
12106 #[test]
12107 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
12108 // The positive-control pin: the gate targets only the
12109 // backtick byte, never adjacent printable ASCII or POSIX-
12110 // valid bytes. The canonical relative POSIX path
12111 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
12112 // adjacent printable punctuation
12113 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
12114 // cleanly so the gate doesn't widen to a "no printable
12115 // punctuation anywhere" sweep that would defeat the entire
12116 // path-fonte author surface.
12117 let d = dep_with_fonte(DepSource::Path {
12118 caminho: "../caixa-teia/sub-dir.v2".into(),
12119 });
12120 d.validate().unwrap();
12121 }
12122
12123 #[test]
12124 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
12125 // Cascade pin on the immediate-predecessor arm: a value
12126 // carrying both `&` and a backtick (``"../caixa-teia &
12127 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
12128 // `cmd & <backtick>sleep N<backtick>` background-launch +
12129 // command-substitution chain" footgun) routes through
12130 // `FonteCaminhoShellBackground` not
12131 // `FonteCaminhoShellCommandSubstitution`. The background-
12132 // launch tail is the more common shell-history paste idiom
12133 // on every probe-as-both value — same cascade discipline
12134 // every prior `:caminho` arm establishes.
12135 let d = dep_with_fonte(DepSource::Path {
12136 caminho: "../caixa-teia & `sleep 1`".into(),
12137 });
12138 let err = d.validate().unwrap_err();
12139 assert!(
12140 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12141 "got {err:?}",
12142 );
12143 }
12144
12145 #[test]
12146 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
12147 // Cascade pin on the upstream shell-semicolon arm: a value
12148 // carrying both `;` and a backtick (``"../caixa-teia;
12149 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12150 // `cmd; <backtick>follow-up<backtick>` sequential-chain
12151 // footgun) routes through `FonteCaminhoShellSemicolon` not
12152 // `FonteCaminhoShellCommandSubstitution`. The sequential-
12153 // command-separator paste is the load-bearing root-cause
12154 // edit on every probe-as-both value.
12155 let d = dep_with_fonte(DepSource::Path {
12156 caminho: "../caixa-teia; `whoami`".into(),
12157 });
12158 let err = d.validate().unwrap_err();
12159 assert!(
12160 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12161 "got {err:?}",
12162 );
12163 }
12164
12165 #[test]
12166 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
12167 // Cascade pin on the upstream shell-pipe arm: a value
12168 // carrying both `|` and a backtick (``"../caixa-teia |
12169 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
12170 // command-substitution paste idiom) routes through
12171 // `FonteCaminhoShellPipe` not
12172 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
12173 // paste is the load-bearing root-cause edit on every
12174 // probe-as-both value.
12175 let d = dep_with_fonte(DepSource::Path {
12176 caminho: "../caixa-teia | `tee log`".into(),
12177 });
12178 let err = d.validate().unwrap_err();
12179 assert!(
12180 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12181 "got {err:?}",
12182 );
12183 }
12184
12185 #[test]
12186 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
12187 // Cascade pin on the upstream shell-redirection arm: a value
12188 // carrying both `>` and a backtick (``"../caixa-teia>log
12189 // <backtick>date<backtick>"`` — the canonical "I pasted a
12190 // `cmd > log <backtick>date<backtick>` redirect-plus-
12191 // substitution chain" footgun) routes through
12192 // `FonteCaminhoShellRedirection` not
12193 // `FonteCaminhoShellCommandSubstitution`. The input/output
12194 // redirection metachar carries the more self-locating `byte`
12195 // payload (it names which of `<` or `>` triggered), so the
12196 // prior arm wins on every probe-as-both value.
12197 let d = dep_with_fonte(DepSource::Path {
12198 caminho: "../caixa-teia>log `date`".into(),
12199 });
12200 let err = d.validate().unwrap_err();
12201 assert!(
12202 matches!(
12203 err,
12204 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12205 ),
12206 "got {err:?}",
12207 );
12208 }
12209
12210 #[test]
12211 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
12212 // Cascade pin on the upstream backslash arm: a value
12213 // carrying both `\` and a backtick (``"..\caixa-teia
12214 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
12215 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
12216 // chain") routes through `FonteCaminhoBackslash` not
12217 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
12218 // separator divergence is the load-bearing axis on every
12219 // probe-as-both value (an author who removes the `\` is the
12220 // root-cause edit; the backtick falls away in the same edit
12221 // since it's downstream of the Windows-shell convention).
12222 let d = dep_with_fonte(DepSource::Path {
12223 caminho: "..\\caixa-teia `whoami`".into(),
12224 });
12225 let err = d.validate().unwrap_err();
12226 assert!(
12227 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12228 "got {err:?}",
12229 );
12230 }
12231
12232 #[test]
12233 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
12234 // Cascade pin on the embedded-control-byte arm: a value
12235 // carrying both a control byte and a backtick (`"../foo\n
12236 // `whoami`"` — the canonical paste-from-multiline-doc
12237 // footgun where a newline landed mid-caminho between two
12238 // paste fragments) routes through `FonteCaminhoControlChar`
12239 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
12240 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
12241 // is the load-bearing axis on every value that probes
12242 // positive for both — mirrors the cascade discipline on
12243 // every prior arm.
12244 let d = dep_with_fonte(DepSource::Path {
12245 caminho: "../foo\n`whoami`".into(),
12246 });
12247 let err = d.validate().unwrap_err();
12248 assert!(
12249 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12250 "got {err:?}",
12251 );
12252 }
12253
12254 #[test]
12255 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
12256 // Cascade pin on the load-bearing leading-byte arm: a
12257 // leading `/` value with embedded backtick (``"/etc/passwd
12258 // <backtick>whoami<backtick>"``) routes through
12259 // `FonteCaminhoAbsolute` not
12260 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
12261 // leak diagnostic is the load-bearing axis, the backtick
12262 // byte is the secondary observation. Same precedence logic
12263 // as every prior leading-byte arm.
12264 let d = dep_with_fonte(DepSource::Path {
12265 caminho: "/etc/passwd `whoami`".into(),
12266 });
12267 let err = d.validate().unwrap_err();
12268 assert!(
12269 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12270 "got {err:?}",
12271 );
12272 }
12273
12274 #[test]
12275 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
12276 // Cascade pin on the immediate-successor arm: a value
12277 // carrying both a backtick and a trailing `/`
12278 // (``"../`whoami`/"`` — the canonical "I tab-completed a
12279 // path that already had a backticked `whoami` substitution
12280 // tail" footgun) routes through
12281 // `FonteCaminhoShellCommandSubstitution` not
12282 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12283 // is the more semantic-locating axis (an author who removes
12284 // the backtick typically also drops the trailing separator
12285 // since both are paste-from-shell artifacts).
12286 let d = dep_with_fonte(DepSource::Path {
12287 caminho: "../`whoami`/".into(),
12288 });
12289 let err = d.validate().unwrap_err();
12290 assert!(
12291 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12292 "got {err:?}",
12293 );
12294 }
12295
12296 #[test]
12297 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
12298 // Diagnostic-shape pin (peer with
12299 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
12300 // on the closest single-byte peer arm): the error's Display
12301 // surfaces the offending `:nome` and the offending `:caminho`
12302 // verbatim, and names the shell-command-substitution footgun
12303 // explicitly so a `feira lint` run can render the diagnostic
12304 // without re-parsing.
12305 let d = dep_with_fonte(DepSource::Path {
12306 caminho: "../caixa-teia/`whoami`".into(),
12307 });
12308 let rendered = d.validate().unwrap_err().to_string();
12309 assert!(
12310 rendered.contains("caixa-teia"),
12311 "diagnostic must name the offending dep: {rendered}",
12312 );
12313 assert!(
12314 rendered.contains("../caixa-teia/`whoami`"),
12315 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12316 );
12317 assert!(
12318 rendered.contains('`'),
12319 "diagnostic must reference the backtick footgun: {rendered:?}",
12320 );
12321 assert!(
12322 rendered.contains("command-substitution"),
12323 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
12324 );
12325 }
12326
12327 #[test]
12328 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
12329 // The fail-before-pass-after pin for the canonical pathname-
12330 // expansion paste footgun: an author copies an `ls
12331 // ../caixa-teia/*` shell-listing tail into the `:caminho`
12332 // slot and silently passes every prior arm
12333 // (`Path::is_absolute` false on `..`, no control bytes, no
12334 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
12335 // doesn't end in `/`). The lacre embedded the value
12336 // verbatim, the resolver folded it through `Path::join`
12337 // looking for a literal `./../caixa-teia/*` subdirectory,
12338 // and the failure surfaced at resolve time with a non-self-
12339 // locating `No such file or directory` error. The new arm
12340 // moves the rejection to validate time and names the
12341 // offending dep + caminho + byte verbatim.
12342 let d = dep_with_fonte(DepSource::Path {
12343 caminho: "../caixa-teia/*".into(),
12344 });
12345 let err = d.validate().unwrap_err();
12346 let DepError::FonteCaminhoShellGlob {
12347 nome,
12348 caminho,
12349 byte,
12350 } = err
12351 else {
12352 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12353 };
12354 assert_eq!(nome, "caixa-teia");
12355 assert_eq!(caminho, "../caixa-teia/*");
12356 assert_eq!(byte, b'*');
12357 }
12358
12359 #[test]
12360 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
12361 // The symmetric single-char-wildcard paste shape
12362 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
12363 // out of shell history" idiom). Pinned separately from the
12364 // `*` shape so the gate's contract is "any `*` or `?`
12365 // anywhere", not single-byte coverage.
12366 let d = dep_with_fonte(DepSource::Path {
12367 caminho: "../foo?".into(),
12368 });
12369 let err = d.validate().unwrap_err();
12370 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
12371 panic!("expected FonteCaminhoShellGlob, got {err:?}");
12372 };
12373 assert_eq!(byte, b'?');
12374 }
12375
12376 #[test]
12377 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
12378 // Leading-position `*` shape (`"*/caixa-teia"` — the
12379 // degenerate "I selected only the wildcard prefix out of a
12380 // shell-glob expression" idiom). Pinned separately from the
12381 // embedded-byte shapes so the gate covers every position,
12382 // not only mid-path.
12383 let d = dep_with_fonte(DepSource::Path {
12384 caminho: "*/caixa-teia".into(),
12385 });
12386 let err = d.validate().unwrap_err();
12387 assert!(
12388 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12389 "got {err:?}",
12390 );
12391 }
12392
12393 #[test]
12394 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
12395 // The bash/zsh `globstar` recursive-glob shape
12396 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
12397 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
12398 // The arm fires on the first `*` encountered; pinned so a
12399 // future arm that tries to distinguish single `*` from
12400 // double `**` doesn't break the broader contract.
12401 let d = dep_with_fonte(DepSource::Path {
12402 caminho: "../caixa-teia/**/foo".into(),
12403 });
12404 let err = d.validate().unwrap_err();
12405 assert!(
12406 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12407 "got {err:?}",
12408 );
12409 }
12410
12411 #[test]
12412 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
12413 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
12414 // — the "I selected `*.lisp` to mean every Lisp source file
12415 // in the dep root" footgun the prior arms structurally
12416 // cannot catch since `.` is a POSIX-valid path-component
12417 // byte). Pinned so the gate's contract covers the most
12418 // idiomatic glob-paste shape every author meets first.
12419 let d = dep_with_fonte(DepSource::Path {
12420 caminho: "../caixa-teia/*.lisp".into(),
12421 });
12422 let err = d.validate().unwrap_err();
12423 assert!(
12424 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12425 "got {err:?}",
12426 );
12427 }
12428
12429 #[test]
12430 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
12431 // The positive-control pin: the gate targets only `*` /
12432 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
12433 // The canonical relative POSIX path (`"../caixa-teia"`) and
12434 // a nested deeply-pathed variant with adjacent printable
12435 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12436 // to validate cleanly so the gate doesn't widen to a "no
12437 // printable punctuation anywhere" sweep that would defeat
12438 // the entire path-fonte author surface.
12439 let d = dep_with_fonte(DepSource::Path {
12440 caminho: "../caixa-teia/sub-dir.v2".into(),
12441 });
12442 d.validate().unwrap();
12443 }
12444
12445 #[test]
12446 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
12447 // Cascade pin on the immediate-predecessor arm: a value
12448 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
12449 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
12450 // command-substitution + glob chain") routes through
12451 // `FonteCaminhoShellCommandSubstitution` not
12452 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
12453 // injection vector is the load-bearing root-cause edit on
12454 // every probe-as-both value — same cascade discipline every
12455 // prior `:caminho` arm establishes.
12456 let d = dep_with_fonte(DepSource::Path {
12457 caminho: "../`whoami`/*".into(),
12458 });
12459 let err = d.validate().unwrap_err();
12460 assert!(
12461 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12462 "got {err:?}",
12463 );
12464 }
12465
12466 #[test]
12467 fn fonte_caminho_shell_background_fires_before_shell_glob() {
12468 // Cascade pin on the upstream shell-background arm: a value
12469 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
12470 // canonical "I pasted a `cmd & ls /*` background + glob
12471 // chain" footgun) routes through `FonteCaminhoShellBackground`
12472 // not `FonteCaminhoShellGlob`. The background-launch tail is
12473 // the load-bearing root-cause edit on every probe-as-both
12474 // value.
12475 let d = dep_with_fonte(DepSource::Path {
12476 caminho: "../caixa-teia & ls /*".into(),
12477 });
12478 let err = d.validate().unwrap_err();
12479 assert!(
12480 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12481 "got {err:?}",
12482 );
12483 }
12484
12485 #[test]
12486 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
12487 // Cascade pin on the upstream shell-semicolon arm: a value
12488 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
12489 // canonical sequential-cleanup + glob paste idiom) routes
12490 // through `FonteCaminhoShellSemicolon` not
12491 // `FonteCaminhoShellGlob`. The sequential-command-separator
12492 // paste is the load-bearing root-cause edit on every
12493 // probe-as-both value.
12494 let d = dep_with_fonte(DepSource::Path {
12495 caminho: "../caixa-teia; rm *".into(),
12496 });
12497 let err = d.validate().unwrap_err();
12498 assert!(
12499 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12500 "got {err:?}",
12501 );
12502 }
12503
12504 #[test]
12505 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
12506 // Cascade pin on the upstream shell-pipe arm: a value
12507 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
12508 // canonical pipeline-to-glob paste idiom) routes through
12509 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
12510 // pipeline-tail paste is the load-bearing root-cause edit
12511 // on every probe-as-both value.
12512 let d = dep_with_fonte(DepSource::Path {
12513 caminho: "../caixa-teia | ls *".into(),
12514 });
12515 let err = d.validate().unwrap_err();
12516 assert!(
12517 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12518 "got {err:?}",
12519 );
12520 }
12521
12522 #[test]
12523 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
12524 // Cascade pin on the upstream shell-redirection arm: a value
12525 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
12526 // canonical "I pasted a `cmd > log *` redirect-plus-glob
12527 // chain" footgun) routes through
12528 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
12529 // The input/output redirection metachar carries the more
12530 // self-locating `byte` payload (it names which of `<` or `>`
12531 // triggered), so the prior arm wins on every probe-as-both
12532 // value.
12533 let d = dep_with_fonte(DepSource::Path {
12534 caminho: "../caixa-teia>log *".into(),
12535 });
12536 let err = d.validate().unwrap_err();
12537 assert!(
12538 matches!(
12539 err,
12540 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12541 ),
12542 "got {err:?}",
12543 );
12544 }
12545
12546 #[test]
12547 fn fonte_caminho_backslash_fires_before_shell_glob() {
12548 // Cascade pin on the upstream backslash arm: a value
12549 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12550 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12551 // expression" footgun) routes through
12552 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12553 // cross-host-OS-separator divergence is the load-bearing
12554 // axis on every probe-as-both value (an author who removes
12555 // the `\` is the root-cause edit; the `*` falls away in the
12556 // same edit since it's downstream of the Windows-shell
12557 // convention).
12558 let d = dep_with_fonte(DepSource::Path {
12559 caminho: "..\\caixa-teia\\*".into(),
12560 });
12561 let err = d.validate().unwrap_err();
12562 assert!(
12563 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12564 "got {err:?}",
12565 );
12566 }
12567
12568 #[test]
12569 fn fonte_caminho_control_char_fires_before_shell_glob() {
12570 // Cascade pin on the embedded-control-byte arm: a value
12571 // carrying both a control byte and `*` (`"../foo\n*"` — the
12572 // canonical paste-from-multiline-doc footgun where a
12573 // newline landed mid-caminho between two paste fragments)
12574 // routes through `FonteCaminhoControlChar` not
12575 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12576 // NUL-`CString::new`-fail diagnostic is the load-bearing
12577 // axis on every value that probes positive for both —
12578 // mirrors the cascade discipline on every prior arm.
12579 let d = dep_with_fonte(DepSource::Path {
12580 caminho: "../foo\n*".into(),
12581 });
12582 let err = d.validate().unwrap_err();
12583 assert!(
12584 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12585 "got {err:?}",
12586 );
12587 }
12588
12589 #[test]
12590 fn fonte_caminho_absolute_fires_before_shell_glob() {
12591 // Cascade pin on the load-bearing leading-byte arm: a
12592 // leading `/` value with embedded `*` (`"/etc/*"`) routes
12593 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12594 // — the host-layout-leak diagnostic is the load-bearing
12595 // axis, the glob byte is the secondary observation. Same
12596 // precedence logic as every prior leading-byte arm.
12597 let d = dep_with_fonte(DepSource::Path {
12598 caminho: "/etc/*".into(),
12599 });
12600 let err = d.validate().unwrap_err();
12601 assert!(
12602 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12603 "got {err:?}",
12604 );
12605 }
12606
12607 #[test]
12608 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12609 // Cascade pin on the immediate-successor arm: a value
12610 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12611 // canonical "I tab-completed a path that already had a
12612 // glob-expansion tail" footgun) routes through
12613 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12614 // The embedded shell-metachar is the more semantic-locating
12615 // axis (an author who removes the `*` typically also drops
12616 // the trailing separator since both are paste-from-shell
12617 // artifacts).
12618 let d = dep_with_fonte(DepSource::Path {
12619 caminho: "../foo*/".into(),
12620 });
12621 let err = d.validate().unwrap_err();
12622 assert!(
12623 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12624 "got {err:?}",
12625 );
12626 }
12627
12628 #[test]
12629 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12630 // Diagnostic-shape pin (peer with
12631 // `fonte_caminho_shell_redirection_diagnostic_*` on the
12632 // closest two-byte peer arm): the error's Display surfaces
12633 // the offending `:nome`, the offending `:caminho` verbatim,
12634 // the offending byte's hex / character form, and names the
12635 // shell-glob / pathname-expansion footgun explicitly so a
12636 // `feira lint` run can render the diagnostic without
12637 // re-parsing.
12638 let d = dep_with_fonte(DepSource::Path {
12639 caminho: "../caixa-teia/*.lisp".into(),
12640 });
12641 let rendered = d.validate().unwrap_err().to_string();
12642 assert!(
12643 rendered.contains("caixa-teia"),
12644 "diagnostic must name the offending dep: {rendered}",
12645 );
12646 assert!(
12647 rendered.contains("../caixa-teia/*.lisp"),
12648 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12649 );
12650 assert!(
12651 rendered.contains("0x2a"),
12652 "diagnostic must surface the offending byte hex: {rendered:?}",
12653 );
12654 assert!(
12655 rendered.contains("glob"),
12656 "diagnostic must name the shell-glob footgun: {rendered:?}",
12657 );
12658 assert!(
12659 rendered.contains("pathname-expansion"),
12660 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12661 );
12662 }
12663
12664 #[test]
12665 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12666 // The fail-before-pass-after pin for the canonical modern-Bourne
12667 // command-substitution paste footgun: an author copies a
12668 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12669 // `$(<cmd>)` expansion would land the current date as a
12670 // subdirectory name and silently passed every prior arm
12671 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12672 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12673 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12674 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12675 // sits mid-path). The lacre embedded the value verbatim, the
12676 // resolver folded it through `Path::join` looking for a literal
12677 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12678 // surfaced at resolve time with a non-self-locating `No such
12679 // file or directory` error. The new arm moves the rejection to
12680 // validate time and names the offending dep + caminho + byte
12681 // verbatim. The arm fires on the first `(` encountered (the
12682 // opening byte of `$(date)`).
12683 let d = dep_with_fonte(DepSource::Path {
12684 caminho: "../caixa-teia/$(date)/build".into(),
12685 });
12686 let err = d.validate().unwrap_err();
12687 let DepError::FonteCaminhoShellSubshellGrouping {
12688 nome,
12689 caminho,
12690 byte,
12691 } = err
12692 else {
12693 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12694 };
12695 assert_eq!(nome, "caixa-teia");
12696 assert_eq!(caminho, "../caixa-teia/$(date)/build");
12697 assert_eq!(byte, b'(');
12698 }
12699
12700 #[test]
12701 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12702 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12703 // the degenerate "I selected an unbalanced closing paren out of
12704 // a shell-history block" idiom that probes for the cascade's
12705 // last-byte handling on a value carrying only the closing byte).
12706 // Pinned separately from the open-paren shape so the gate's
12707 // contract is "any `(` or `)` anywhere", not single-byte
12708 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12709 // caminho_carrying_question_glob` shape on the immediate-
12710 // predecessor `FonteCaminhoShellGlob` arm.
12711 let d = dep_with_fonte(DepSource::Path {
12712 caminho: "../caixa-teia)".into(),
12713 });
12714 let err = d.validate().unwrap_err();
12715 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12716 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12717 };
12718 assert_eq!(byte, b')');
12719 }
12720
12721 #[test]
12722 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12723 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12724 // canonical "I selected a `(cd foo)` subshell-grouping prefix
12725 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12726 // Pinned separately from the embedded-byte shape so the gate
12727 // covers every position, not only mid-path.
12728 let d = dep_with_fonte(DepSource::Path {
12729 caminho: "(cd foo)/caixa-teia".into(),
12730 });
12731 let err = d.validate().unwrap_err();
12732 assert!(
12733 matches!(
12734 err,
12735 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12736 ),
12737 "got {err:?}",
12738 );
12739 }
12740
12741 #[test]
12742 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12743 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12744 // — the canonical "I copied a `(pwd)` working-directory-probe
12745 // subshell-grouping idiom every shell-history block carries"
12746 // footgun). The value carries no other cascade-preceding
12747 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12748 // `*` / `?`) so the arm fires on the first `(` encountered;
12749 // pinned so a future arm that tries to distinguish the
12750 // opening from the closing byte doesn't break the broader
12751 // contract. Mirrors the peer
12752 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12753 // backtick_pair` shape on the upstream `FonteCaminhoShell\
12754 // CommandSubstitution` arm.
12755 let d = dep_with_fonte(DepSource::Path {
12756 caminho: "../(pwd)/caixa-teia".into(),
12757 });
12758 let err = d.validate().unwrap_err();
12759 assert!(
12760 matches!(
12761 err,
12762 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12763 ),
12764 "got {err:?}",
12765 );
12766 }
12767
12768 #[test]
12769 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12770 // The positive-control pin: the gate targets only `(` / `)`,
12771 // never adjacent printable ASCII or POSIX-valid bytes. The
12772 // canonical relative POSIX path (`"../caixa-teia"`) and a
12773 // nested deeply-pathed variant with adjacent printable
12774 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12775 // validate cleanly so the gate doesn't widen to a "no printable
12776 // punctuation anywhere" sweep that would defeat the entire
12777 // path-fonte author surface.
12778 let d = dep_with_fonte(DepSource::Path {
12779 caminho: "../caixa-teia/sub-dir.v2".into(),
12780 });
12781 d.validate().unwrap();
12782 }
12783
12784 #[test]
12785 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12786 // Cascade pin on the immediate-predecessor arm: a value
12787 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12788 // canonical "I pasted a glob expansion followed by a
12789 // subshell-grouping tail" footgun) routes through
12790 // `FonteCaminhoShellGlob` not
12791 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12792 // shape is the more common shell-history paste idiom on every
12793 // probe-as-both value — same cascade discipline every prior
12794 // `:caminho` arm establishes.
12795 let d = dep_with_fonte(DepSource::Path {
12796 caminho: "../caixa-teia/*(date)".into(),
12797 });
12798 let err = d.validate().unwrap_err();
12799 assert!(
12800 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12801 "got {err:?}",
12802 );
12803 }
12804
12805 #[test]
12806 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12807 // Cascade pin on the upstream shell-command-substitution arm: a
12808 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12809 // — the canonical "I pasted a legacy-backtick + modern-paren
12810 // command-substitution chain" footgun) routes through
12811 // `FonteCaminhoShellCommandSubstitution` not
12812 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12813 // command-injection vector is the load-bearing root-cause edit
12814 // on every probe-as-both value.
12815 let d = dep_with_fonte(DepSource::Path {
12816 caminho: "../`whoami`/$(date)".into(),
12817 });
12818 let err = d.validate().unwrap_err();
12819 assert!(
12820 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12821 "got {err:?}",
12822 );
12823 }
12824
12825 #[test]
12826 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12827 // Cascade pin on the upstream shell-background arm: a value
12828 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12829 // the canonical "I pasted a `cmd & (cd foo)` background-launch
12830 // + subshell-grouping chain" footgun) routes through
12831 // `FonteCaminhoShellBackground` not
12832 // `FonteCaminhoShellSubshellGrouping`. The background-launch
12833 // tail is the load-bearing root-cause edit on every probe-as-
12834 // both value.
12835 let d = dep_with_fonte(DepSource::Path {
12836 caminho: "../caixa-teia & (cd foo)".into(),
12837 });
12838 let err = d.validate().unwrap_err();
12839 assert!(
12840 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12841 "got {err:?}",
12842 );
12843 }
12844
12845 #[test]
12846 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12847 // Cascade pin on the upstream shell-semicolon arm: a value
12848 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12849 // the canonical sequential-cleanup + subshell-grouping paste
12850 // idiom) routes through `FonteCaminhoShellSemicolon` not
12851 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12852 // separator paste is the load-bearing root-cause edit on
12853 // every probe-as-both value.
12854 let d = dep_with_fonte(DepSource::Path {
12855 caminho: "../caixa-teia; (cd foo)".into(),
12856 });
12857 let err = d.validate().unwrap_err();
12858 assert!(
12859 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12860 "got {err:?}",
12861 );
12862 }
12863
12864 #[test]
12865 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12866 // Cascade pin on the upstream shell-pipe arm: a value carrying
12867 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12868 // canonical pipeline-to-subshell-grouping paste idiom) routes
12869 // through `FonteCaminhoShellPipe` not
12870 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12871 // is the load-bearing root-cause edit on every probe-as-both
12872 // value.
12873 let d = dep_with_fonte(DepSource::Path {
12874 caminho: "../caixa-teia | (tee log)".into(),
12875 });
12876 let err = d.validate().unwrap_err();
12877 assert!(
12878 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12879 "got {err:?}",
12880 );
12881 }
12882
12883 #[test]
12884 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12885 // Cascade pin on the upstream shell-redirection arm: a value
12886 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12887 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12888 // plus-subshell-grouping chain" footgun) routes through
12889 // `FonteCaminhoShellRedirection` not
12890 // `FonteCaminhoShellSubshellGrouping`. The input/output
12891 // redirection metachar carries the more self-locating `byte`
12892 // payload (it names which of `<` or `>` triggered), so the
12893 // prior arm wins on every probe-as-both value.
12894 let d = dep_with_fonte(DepSource::Path {
12895 caminho: "../caixa-teia>log (cd foo)".into(),
12896 });
12897 let err = d.validate().unwrap_err();
12898 assert!(
12899 matches!(
12900 err,
12901 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12902 ),
12903 "got {err:?}",
12904 );
12905 }
12906
12907 #[test]
12908 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12909 // Cascade pin on the upstream backslash arm: a value carrying
12910 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12911 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12912 // through `FonteCaminhoBackslash` not
12913 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12914 // separator divergence is the load-bearing axis on every
12915 // probe-as-both value (an author who removes the `\` is the
12916 // root-cause edit; the `(` falls away in the same edit since
12917 // it's downstream of the Windows-shell convention).
12918 let d = dep_with_fonte(DepSource::Path {
12919 caminho: "..\\caixa-teia\\(cd foo)".into(),
12920 });
12921 let err = d.validate().unwrap_err();
12922 assert!(
12923 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12924 "got {err:?}",
12925 );
12926 }
12927
12928 #[test]
12929 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12930 // Cascade pin on the embedded-control-byte arm: a value
12931 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12932 // the canonical paste-from-multiline-doc footgun where a
12933 // newline landed mid-caminho between two paste fragments)
12934 // routes through `FonteCaminhoControlChar` not
12935 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12936 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12937 // load-bearing axis on every value that probes positive for
12938 // both — mirrors the cascade discipline on every prior arm.
12939 let d = dep_with_fonte(DepSource::Path {
12940 caminho: "../foo\n(cd bar)".into(),
12941 });
12942 let err = d.validate().unwrap_err();
12943 assert!(
12944 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12945 "got {err:?}",
12946 );
12947 }
12948
12949 #[test]
12950 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12951 // Cascade pin on the load-bearing leading-byte arm: a leading
12952 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12953 // through `FonteCaminhoAbsolute` not
12954 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12955 // diagnostic is the load-bearing axis, the subshell-grouping
12956 // byte is the secondary observation. Same precedence logic as
12957 // every prior leading-byte arm.
12958 let d = dep_with_fonte(DepSource::Path {
12959 caminho: "/etc/(cd foo)".into(),
12960 });
12961 let err = d.validate().unwrap_err();
12962 assert!(
12963 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12964 "got {err:?}",
12965 );
12966 }
12967
12968 #[test]
12969 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12970 // Cascade pin on the upstream leading-`$` var-expansion arm: a
12971 // value carrying both a leading `$` and a `(` (`"$(date)/\
12972 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12973 // command-substitution at the head of a sibling-workspace
12974 // path" footgun) routes through `FonteCaminhoVarExpansion` not
12975 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12976 // shell-variable-expansion is the more self-locating diagnostic
12977 // on values that probe as both — same load-bearing-leading-
12978 // byte cascade discipline every prior `:caminho` arm
12979 // establishes. Closing both halves of `$(<cmd>)` structurally
12980 // (leading `$` here, trailing `)` on the new arm) excludes the
12981 // entire modern Bourne command-substitution surface from the
12982 // typed `:caminho` accepted set; the cascade preserves the
12983 // narrower leading-byte diagnostic on values that probe both
12984 // halves at the canonical leading position.
12985 let d = dep_with_fonte(DepSource::Path {
12986 caminho: "$(date)/caixa-teia".into(),
12987 });
12988 let err = d.validate().unwrap_err();
12989 assert!(
12990 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12991 "got {err:?}",
12992 );
12993 }
12994
12995 #[test]
12996 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12997 // Cascade pin on the immediate-successor arm: a value carrying
12998 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12999 // "I tab-completed a path that already had a subshell-grouping
13000 // expansion tail" footgun) routes through
13001 // `FonteCaminhoShellSubshellGrouping` not
13002 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
13003 // the more semantic-locating axis (an author who removes the
13004 // `(` typically also drops the trailing separator since both
13005 // are paste-from-shell artifacts).
13006 let d = dep_with_fonte(DepSource::Path {
13007 caminho: "../(cd foo)/".into(),
13008 });
13009 let err = d.validate().unwrap_err();
13010 assert!(
13011 matches!(
13012 err,
13013 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13014 ),
13015 "got {err:?}",
13016 );
13017 }
13018
13019 #[test]
13020 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13021 // Diagnostic-shape pin (peer with
13022 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
13023 // on the closest two-byte peer arm): the error's Display
13024 // surfaces the offending `:nome`, the offending `:caminho`
13025 // verbatim, the offending byte's hex / character form, and
13026 // names the shell-subshell-grouping footgun explicitly so a
13027 // `feira lint` run can render the diagnostic without re-
13028 // parsing.
13029 let d = dep_with_fonte(DepSource::Path {
13030 caminho: "../caixa-teia/$(date)/build".into(),
13031 });
13032 let rendered = d.validate().unwrap_err().to_string();
13033 assert!(
13034 rendered.contains("caixa-teia"),
13035 "diagnostic must name the offending dep: {rendered}",
13036 );
13037 assert!(
13038 rendered.contains("../caixa-teia/$(date)/build"),
13039 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13040 );
13041 assert!(
13042 rendered.contains("0x28"),
13043 "diagnostic must surface the offending byte hex: {rendered:?}",
13044 );
13045 assert!(
13046 rendered.contains("subshell-grouping"),
13047 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
13048 );
13049 assert!(
13050 rendered.contains("command-substitution"),
13051 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
13052 {rendered:?}",
13053 );
13054 }
13055
13056 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
13057 //
13058 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
13059 // `)`) byte-pair arm: the same per-byte cascade with the same
13060 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
13061 // `}` brace-expansion / URI-Template placeholder axis. The peer
13062 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
13063 // byte pair on the sibling `:fonte :repo` axis under the same
13064 // banner.
13065
13066 #[test]
13067 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
13068 // The fail-before-pass-after pin for the canonical paste-from-
13069 // shell-history brace-expansion footgun: an author copies a
13070 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
13071 // liner whose `{a,b}` brace expansion fans across two siblings
13072 // and silently passed every prior arm (`Path::is_absolute`
13073 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
13074 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
13075 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
13076 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13077 // value starts with `..` not `$`). The lacre embedded the
13078 // value verbatim, the resolver folded it through `Path::join`
13079 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
13080 // subdirectory, and the failure surfaced at resolve time with
13081 // a non-self-locating `No such file or directory` error. The
13082 // new arm moves the rejection to validate time and names the
13083 // offending dep + caminho + byte verbatim. The arm fires on
13084 // the first `{` encountered.
13085 let d = dep_with_fonte(DepSource::Path {
13086 caminho: "../{caixa-teia,caixa-helm}/build".into(),
13087 });
13088 let err = d.validate().unwrap_err();
13089 let DepError::FonteCaminhoShellBraceExpansion {
13090 nome,
13091 caminho,
13092 byte,
13093 } = err
13094 else {
13095 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13096 };
13097 assert_eq!(nome, "caixa-teia");
13098 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
13099 assert_eq!(byte, b'{');
13100 }
13101
13102 #[test]
13103 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
13104 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
13105 // the degenerate "I selected an unbalanced closing brace out
13106 // of a shell-history block" idiom that probes for the
13107 // cascade's last-byte handling on a value carrying only the
13108 // closing byte). Pinned separately from the open-brace shape
13109 // so the gate's contract is "any `{` or `}` anywhere", not
13110 // single-byte coverage. Mirrors the peer
13111 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
13112 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
13113 // arm.
13114 let d = dep_with_fonte(DepSource::Path {
13115 caminho: "../caixa-teia}".into(),
13116 });
13117 let err = d.validate().unwrap_err();
13118 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
13119 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
13120 };
13121 assert_eq!(byte, b'}');
13122 }
13123
13124 #[test]
13125 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
13126 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
13127 // — the canonical "I selected a `{a,b}` brace-expansion prefix
13128 // out of a shell-history one-liner" idiom). Pinned separately
13129 // from the embedded-byte shape so the gate covers every
13130 // position, not only mid-path.
13131 let d = dep_with_fonte(DepSource::Path {
13132 caminho: "{caixa-teia,caixa-helm}/build".into(),
13133 });
13134 let err = d.validate().unwrap_err();
13135 assert!(
13136 matches!(
13137 err,
13138 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13139 ),
13140 "got {err:?}",
13141 );
13142 }
13143
13144 #[test]
13145 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
13146 // The canonical URI-Template / Mustache / Helm doubled-brace
13147 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
13148 // "I copied a `https://github.com/{{org}}/caixa-teia` README
13149 // quick-start / OpenAPI spec / Helm chart `home:` template
13150 // and forgot to substitute the placeholder" footgun). The arm
13151 // fires on the first `{` encountered; pinned so the gate's
13152 // coverage extends from the bare-brace shell-history shape to
13153 // the doubled-brace URI-Template / templating-engine shape.
13154 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
13155 // sibling `:fonte :repo` axis.
13156 let d = dep_with_fonte(DepSource::Path {
13157 caminho: "../{{org}}/caixa-teia".into(),
13158 });
13159 let err = d.validate().unwrap_err();
13160 assert!(
13161 matches!(
13162 err,
13163 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13164 ),
13165 "got {err:?}",
13166 );
13167 }
13168
13169 #[test]
13170 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
13171 // The canonical bash brace-range-expansion shape (`"../caixa-
13172 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
13173 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
13174 // sequence-range form to the `{a,b,c}` comma-separated form).
13175 // The arm fires on the first `{` encountered; pinned so the
13176 // gate's coverage extends from the comma-separated form to
13177 // the integer-range form.
13178 let d = dep_with_fonte(DepSource::Path {
13179 caminho: "../caixa-v{1..10}".into(),
13180 });
13181 let err = d.validate().unwrap_err();
13182 assert!(
13183 matches!(
13184 err,
13185 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13186 ),
13187 "got {err:?}",
13188 );
13189 }
13190
13191 #[test]
13192 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
13193 // The positive-control pin: the gate targets only `{` / `}`,
13194 // never adjacent printable ASCII or POSIX-valid bytes. The
13195 // canonical relative POSIX path (`"../caixa-teia"`) and a
13196 // nested deeply-pathed variant with adjacent printable
13197 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
13198 // validate cleanly so the gate doesn't widen to a "no
13199 // printable punctuation anywhere" sweep that would defeat
13200 // the entire path-fonte author surface. Peer with
13201 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
13202 // on the immediate-predecessor arm.
13203 let d = dep_with_fonte(DepSource::Path {
13204 caminho: "../caixa-teia/sub-dir.v2".into(),
13205 });
13206 d.validate().unwrap();
13207 }
13208
13209 #[test]
13210 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
13211 // Cascade pin on the immediate-predecessor arm: a value
13212 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
13213 // canonical "I pasted a subshell-grouping followed by a
13214 // brace-expansion tail" footgun) routes through
13215 // `FonteCaminhoShellSubshellGrouping` not
13216 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
13217 // shape is the more semantic-locating axis on every probe-
13218 // as-both value because it closes both halves of the modern
13219 // Bourne `$(<cmd>)` command-substitution surface — same
13220 // cascade discipline every prior `:caminho` arm establishes.
13221 let d = dep_with_fonte(DepSource::Path {
13222 caminho: "../(cd foo)/{a,b}".into(),
13223 });
13224 let err = d.validate().unwrap_err();
13225 assert!(
13226 matches!(
13227 err,
13228 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13229 ),
13230 "got {err:?}",
13231 );
13232 }
13233
13234 #[test]
13235 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
13236 // Cascade pin on the upstream shell-glob arm: a value carrying
13237 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
13238 // "I pasted a glob expansion followed by a brace-expansion
13239 // tail" footgun) routes through `FonteCaminhoShellGlob` not
13240 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
13241 // shape is the load-bearing root-cause edit on every
13242 // probe-as-both value.
13243 let d = dep_with_fonte(DepSource::Path {
13244 caminho: "../caixa-teia/*{a,b}".into(),
13245 });
13246 let err = d.validate().unwrap_err();
13247 assert!(
13248 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13249 "got {err:?}",
13250 );
13251 }
13252
13253 #[test]
13254 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
13255 // Cascade pin on the upstream shell-command-substitution arm:
13256 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
13257 // — the canonical "I pasted a legacy-backtick command-
13258 // substitution followed by a brace-expansion fan-out" footgun)
13259 // routes through `FonteCaminhoShellCommandSubstitution` not
13260 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
13261 // command-injection vector is the load-bearing root-cause
13262 // edit on every probe-as-both value.
13263 let d = dep_with_fonte(DepSource::Path {
13264 caminho: "../`whoami`/{a,b}".into(),
13265 });
13266 let err = d.validate().unwrap_err();
13267 assert!(
13268 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13269 "got {err:?}",
13270 );
13271 }
13272
13273 #[test]
13274 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
13275 // Cascade pin on the upstream shell-background arm: a value
13276 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
13277 // canonical "I pasted a `cmd & {fork-fan}` background-launch
13278 // + brace-expansion chain" footgun) routes through
13279 // `FonteCaminhoShellBackground` not
13280 // `FonteCaminhoShellBraceExpansion`. The background-launch
13281 // tail is the load-bearing root-cause edit on every
13282 // probe-as-both value.
13283 let d = dep_with_fonte(DepSource::Path {
13284 caminho: "../caixa-teia & {a,b}".into(),
13285 });
13286 let err = d.validate().unwrap_err();
13287 assert!(
13288 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13289 "got {err:?}",
13290 );
13291 }
13292
13293 #[test]
13294 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
13295 // Cascade pin on the upstream shell-semicolon arm: a value
13296 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
13297 // canonical sequential-cleanup + brace-expansion paste
13298 // idiom) routes through `FonteCaminhoShellSemicolon` not
13299 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
13300 // separator paste is the load-bearing root-cause edit on
13301 // every probe-as-both value.
13302 let d = dep_with_fonte(DepSource::Path {
13303 caminho: "../caixa-teia; {a,b}".into(),
13304 });
13305 let err = d.validate().unwrap_err();
13306 assert!(
13307 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13308 "got {err:?}",
13309 );
13310 }
13311
13312 #[test]
13313 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
13314 // Cascade pin on the upstream shell-pipe arm: a value
13315 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
13316 // — the canonical pipeline-to-brace-expansion paste idiom)
13317 // routes through `FonteCaminhoShellPipe` not
13318 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
13319 // is the load-bearing root-cause edit on every probe-as-
13320 // both value.
13321 let d = dep_with_fonte(DepSource::Path {
13322 caminho: "../caixa-teia | {tee,cat}".into(),
13323 });
13324 let err = d.validate().unwrap_err();
13325 assert!(
13326 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13327 "got {err:?}",
13328 );
13329 }
13330
13331 #[test]
13332 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
13333 // Cascade pin on the upstream shell-redirection arm: a value
13334 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
13335 // the canonical "I pasted a `cmd > log {a,b}` redirect-
13336 // plus-brace-expansion chain" footgun) routes through
13337 // `FonteCaminhoShellRedirection` not
13338 // `FonteCaminhoShellBraceExpansion`. The input/output
13339 // redirection metachar carries the more self-locating
13340 // `byte` payload, so the prior arm wins on every probe-
13341 // as-both value.
13342 let d = dep_with_fonte(DepSource::Path {
13343 caminho: "../caixa-teia>log {a,b}".into(),
13344 });
13345 let err = d.validate().unwrap_err();
13346 assert!(
13347 matches!(
13348 err,
13349 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13350 ),
13351 "got {err:?}",
13352 );
13353 }
13354
13355 #[test]
13356 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
13357 // Cascade pin on the upstream backslash arm: a value
13358 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
13359 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
13360 // chain") routes through `FonteCaminhoBackslash` not
13361 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
13362 // separator divergence is the load-bearing axis on every
13363 // probe-as-both value.
13364 let d = dep_with_fonte(DepSource::Path {
13365 caminho: "..\\caixa-teia\\{a,b}".into(),
13366 });
13367 let err = d.validate().unwrap_err();
13368 assert!(
13369 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13370 "got {err:?}",
13371 );
13372 }
13373
13374 #[test]
13375 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
13376 // Cascade pin on the embedded-control-byte arm: a value
13377 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
13378 // the canonical paste-from-multiline-doc footgun where a
13379 // newline landed mid-caminho between two paste fragments)
13380 // routes through `FonteCaminhoControlChar` not
13381 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
13382 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13383 // load-bearing axis on every value that probes positive for
13384 // both — mirrors the cascade discipline on every prior arm.
13385 let d = dep_with_fonte(DepSource::Path {
13386 caminho: "../foo\n{a,b}".into(),
13387 });
13388 let err = d.validate().unwrap_err();
13389 assert!(
13390 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13391 "got {err:?}",
13392 );
13393 }
13394
13395 #[test]
13396 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
13397 // Cascade pin on the load-bearing leading-byte arm: a
13398 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
13399 // routes through `FonteCaminhoAbsolute` not
13400 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
13401 // diagnostic is the load-bearing axis, the brace-expansion
13402 // byte is the secondary observation. Same precedence logic
13403 // as every prior leading-byte arm.
13404 let d = dep_with_fonte(DepSource::Path {
13405 caminho: "/etc/{a,b}".into(),
13406 });
13407 let err = d.validate().unwrap_err();
13408 assert!(
13409 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13410 "got {err:?}",
13411 );
13412 }
13413
13414 #[test]
13415 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
13416 // Cascade pin on the upstream leading-`$` var-expansion
13417 // arm: a value carrying both a leading `$` and a `{`
13418 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
13419 // `${ORG}` shell-variable + curly-brace expansion at the
13420 // head of a sibling-workspace path" footgun) routes through
13421 // `FonteCaminhoVarExpansion` not
13422 // `FonteCaminhoShellBraceExpansion`. The leading-byte
13423 // shell-variable-expansion is the more self-locating
13424 // diagnostic on values that probe as both — same
13425 // load-bearing-leading-byte cascade discipline every prior
13426 // `:caminho` arm establishes.
13427 let d = dep_with_fonte(DepSource::Path {
13428 caminho: "${ORG}/caixa-teia".into(),
13429 });
13430 let err = d.validate().unwrap_err();
13431 assert!(
13432 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13433 "got {err:?}",
13434 );
13435 }
13436
13437 #[test]
13438 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
13439 // Cascade pin on the immediate-successor arm: a value
13440 // carrying both `{` and a trailing `/`
13441 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
13442 // tab-completed a path that already had a brace-expansion
13443 // expansion tail" footgun) routes through
13444 // `FonteCaminhoShellBraceExpansion` not
13445 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13446 // is the more semantic-locating axis (an author who removes
13447 // the `{` typically also drops the trailing separator since
13448 // both are paste-from-shell artifacts).
13449 let d = dep_with_fonte(DepSource::Path {
13450 caminho: "../{caixa-teia,caixa-helm}/".into(),
13451 });
13452 let err = d.validate().unwrap_err();
13453 assert!(
13454 matches!(
13455 err,
13456 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13457 ),
13458 "got {err:?}",
13459 );
13460 }
13461
13462 #[test]
13463 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13464 // Diagnostic-shape pin (peer with
13465 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13466 // on the closest two-byte peer arm): the error's Display
13467 // surfaces the offending `:nome`, the offending `:caminho`
13468 // verbatim, the offending byte's hex / character form, and
13469 // names the shell-brace-expansion / URI-Template footgun
13470 // explicitly so a `feira lint` run can render the diagnostic
13471 // without re-parsing.
13472 let d = dep_with_fonte(DepSource::Path {
13473 caminho: "../{caixa-teia,caixa-helm}/build".into(),
13474 });
13475 let rendered = d.validate().unwrap_err().to_string();
13476 assert!(
13477 rendered.contains("caixa-teia"),
13478 "diagnostic must name the offending dep: {rendered}",
13479 );
13480 assert!(
13481 rendered.contains("../{caixa-teia,caixa-helm}/build"),
13482 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13483 );
13484 assert!(
13485 rendered.contains("0x7b"),
13486 "diagnostic must surface the offending byte hex: {rendered:?}",
13487 );
13488 assert!(
13489 rendered.contains("brace-expansion"),
13490 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
13491 );
13492 assert!(
13493 rendered.contains("URI Template"),
13494 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
13495 {rendered:?}",
13496 );
13497 }
13498
13499 #[test]
13500 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
13501 // The canonical paste-from-shell-history bracket-glob /
13502 // character-class footgun: an author copies a
13503 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
13504 // `[a-z]` POSIX glob character-class matches every lowercase-
13505 // ASCII-suffix sibling caixa directory and silently passed
13506 // every prior arm (`Path::is_absolute` false on `..`, no
13507 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
13508 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
13509 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
13510 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13511 // value starts with `..` not `$`). The lacre embedded the
13512 // value verbatim, the resolver folded it through
13513 // `Path::join` looking for a literal `./../caixa-[a-z]/
13514 // build` subdirectory, and the failure surfaced at resolve
13515 // time with a non-self-locating `No such file or directory`
13516 // error. The new arm moves the rejection to validate time
13517 // and names the offending dep + caminho + byte verbatim.
13518 // The arm fires on the first `[` encountered.
13519 let d = dep_with_fonte(DepSource::Path {
13520 caminho: "../caixa-[a-z]/build".into(),
13521 });
13522 let err = d.validate().unwrap_err();
13523 let DepError::FonteCaminhoShellBracketExpansion {
13524 nome,
13525 caminho,
13526 byte,
13527 } = err
13528 else {
13529 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13530 };
13531 assert_eq!(nome, "caixa-teia");
13532 assert_eq!(caminho, "../caixa-[a-z]/build");
13533 assert_eq!(byte, b'[');
13534 }
13535
13536 #[test]
13537 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13538 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13539 // — the degenerate "I selected an unbalanced closing bracket
13540 // out of a glob character-class block" idiom that probes for
13541 // the cascade's last-byte handling on a value carrying only
13542 // the closing byte). Pinned separately from the open-bracket
13543 // shape so the gate's contract is "any `[` or `]` anywhere",
13544 // not single-byte coverage. Mirrors the peer
13545 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13546 // shape on the immediate-predecessor
13547 // `FonteCaminhoShellBraceExpansion` arm.
13548 let d = dep_with_fonte(DepSource::Path {
13549 caminho: "../caixa-teia]".into(),
13550 });
13551 let err = d.validate().unwrap_err();
13552 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13553 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13554 };
13555 assert_eq!(byte, b']');
13556 }
13557
13558 #[test]
13559 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13560 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13561 // canonical "I selected a `[caixa-teia]` TOML-table-header /
13562 // glob-character-class prefix out of an aligned config /
13563 // shell-history one-liner" idiom). Pinned separately from
13564 // the embedded-byte shape so the gate covers every position,
13565 // not only mid-path.
13566 let d = dep_with_fonte(DepSource::Path {
13567 caminho: "[caixa-teia]/build".into(),
13568 });
13569 let err = d.validate().unwrap_err();
13570 assert!(
13571 matches!(
13572 err,
13573 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13574 ),
13575 "got {err:?}",
13576 );
13577 }
13578
13579 #[test]
13580 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13581 // The canonical TOML inline-array / YAML flow-sequence
13582 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13583 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13584 // inline-array out of a sibling-Cargo manifest" cross-idiom
13585 // leak; the symmetric YAML flow-sequence form `paths: [/a,
13586 // /b]` paste-from-values.yaml shape carries the same
13587 // bracket pair). The arm fires on the first `[` encountered;
13588 // pinned so the gate's coverage extends from the bare-
13589 // bracket glob-character-class shape to the TOML / YAML /
13590 // JSON array-literal shape.
13591 let d = dep_with_fonte(DepSource::Path {
13592 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13593 });
13594 let err = d.validate().unwrap_err();
13595 assert!(
13596 matches!(
13597 err,
13598 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13599 ),
13600 "got {err:?}",
13601 );
13602 }
13603
13604 #[test]
13605 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13606 // The canonical POSIX `test` / `[` builtin command paste
13607 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13608 // script conditional every paste-from-shell-script idiom
13609 // carries; bash's `[[ <expr> ]]` extended-test grammar
13610 // would surface the same byte pair). The arm fires on the
13611 // first `[` encountered; pinned so the gate's coverage
13612 // extends from the embedded-glob-character-class shape to
13613 // the leading-`test`-builtin / extended-test form.
13614 let d = dep_with_fonte(DepSource::Path {
13615 caminho: "../[ -d caixa-teia ]".into(),
13616 });
13617 let err = d.validate().unwrap_err();
13618 assert!(
13619 matches!(
13620 err,
13621 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13622 ),
13623 "got {err:?}",
13624 );
13625 }
13626
13627 #[test]
13628 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13629 // The positive-control pin: the gate targets only `[` /
13630 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13631 // The canonical relative POSIX path (`"../caixa-teia"`) and
13632 // a nested deeply-pathed variant with adjacent printable
13633 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13634 // to validate cleanly so the gate doesn't widen to a "no
13635 // printable punctuation anywhere" sweep that would defeat
13636 // the entire path-fonte author surface. Peer with
13637 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13638 // on the immediate-predecessor arm.
13639 let d = dep_with_fonte(DepSource::Path {
13640 caminho: "../caixa-teia/sub-dir.v2".into(),
13641 });
13642 d.validate().unwrap();
13643 }
13644
13645 #[test]
13646 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13647 // Cascade pin on the immediate-predecessor arm: a value
13648 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13649 // canonical "I pasted a brace-expansion fan followed by a
13650 // glob-character-class tail" footgun) routes through
13651 // `FonteCaminhoShellBraceExpansion` not
13652 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13653 // fan is the load-bearing root-cause edit on every
13654 // probe-as-both value because the bracket-class tail
13655 // typically rides on a prior brace-expansion expansion;
13656 // same cascade discipline every prior `:caminho` arm
13657 // establishes.
13658 let d = dep_with_fonte(DepSource::Path {
13659 caminho: "../{a,b}[ch]".into(),
13660 });
13661 let err = d.validate().unwrap_err();
13662 assert!(
13663 matches!(
13664 err,
13665 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13666 ),
13667 "got {err:?}",
13668 );
13669 }
13670
13671 #[test]
13672 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13673 // Cascade pin on the upstream shell-subshell-grouping arm:
13674 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13675 // the canonical "I pasted a subshell-grouping followed by
13676 // a glob-character-class tail" footgun) routes through
13677 // `FonteCaminhoShellSubshellGrouping` not
13678 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13679 // `$(<cmd>)` command-substitution boundary is the load-
13680 // bearing axis on every probe-as-both value.
13681 let d = dep_with_fonte(DepSource::Path {
13682 caminho: "../(cd foo)/[ch]".into(),
13683 });
13684 let err = d.validate().unwrap_err();
13685 assert!(
13686 matches!(
13687 err,
13688 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13689 ),
13690 "got {err:?}",
13691 );
13692 }
13693
13694 #[test]
13695 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13696 // Cascade pin on the upstream shell-glob arm: a value
13697 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13698 // canonical "I pasted a `*.[ch]` C-source-file glob whose
13699 // unbounded `*` precedes the bracket character-class"
13700 // footgun) routes through `FonteCaminhoShellGlob` not
13701 // `FonteCaminhoShellBracketExpansion`. The unbounded
13702 // pathname-expansion sentinel is the load-bearing root-
13703 // cause edit on every probe-as-both value — the unbounded
13704 // `*` carries the more aggressive expansion vector than
13705 // the bounded `[ch]` class, so the prior arm wins.
13706 let d = dep_with_fonte(DepSource::Path {
13707 caminho: "../caixa-teia/*[ch]".into(),
13708 });
13709 let err = d.validate().unwrap_err();
13710 assert!(
13711 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13712 "got {err:?}",
13713 );
13714 }
13715
13716 #[test]
13717 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13718 // Cascade pin on the upstream shell-command-substitution
13719 // arm: a value carrying both a backtick and `[`
13720 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13721 // legacy-backtick command-substitution followed by a
13722 // glob-character-class tail" footgun) routes through
13723 // `FonteCaminhoShellCommandSubstitution` not
13724 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13725 // command-injection vector is the load-bearing root-cause
13726 // edit on every probe-as-both value.
13727 let d = dep_with_fonte(DepSource::Path {
13728 caminho: "../`whoami`/[ch]".into(),
13729 });
13730 let err = d.validate().unwrap_err();
13731 assert!(
13732 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13733 "got {err:?}",
13734 );
13735 }
13736
13737 #[test]
13738 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13739 // Cascade pin on the upstream shell-background arm: a
13740 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13741 // — the canonical "I pasted a `cmd & [glob]` background-
13742 // launch + bracket-class chain" footgun) routes through
13743 // `FonteCaminhoShellBackground` not
13744 // `FonteCaminhoShellBracketExpansion`. The background-
13745 // launch tail is the load-bearing root-cause edit on
13746 // every probe-as-both value.
13747 let d = dep_with_fonte(DepSource::Path {
13748 caminho: "../caixa-teia & [ch]".into(),
13749 });
13750 let err = d.validate().unwrap_err();
13751 assert!(
13752 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13753 "got {err:?}",
13754 );
13755 }
13756
13757 #[test]
13758 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13759 // Cascade pin on the upstream shell-semicolon arm: a value
13760 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13761 // canonical sequential-cleanup + bracket-class paste
13762 // idiom) routes through `FonteCaminhoShellSemicolon` not
13763 // `FonteCaminhoShellBracketExpansion`. The sequential-
13764 // command-separator paste is the load-bearing root-cause
13765 // edit on every probe-as-both value.
13766 let d = dep_with_fonte(DepSource::Path {
13767 caminho: "../caixa-teia; [ch]".into(),
13768 });
13769 let err = d.validate().unwrap_err();
13770 assert!(
13771 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13772 "got {err:?}",
13773 );
13774 }
13775
13776 #[test]
13777 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13778 // Cascade pin on the upstream shell-pipe arm: a value
13779 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13780 // the canonical pipeline-to-bracket-class paste idiom)
13781 // routes through `FonteCaminhoShellPipe` not
13782 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13783 // paste is the load-bearing root-cause edit on every
13784 // probe-as-both value.
13785 let d = dep_with_fonte(DepSource::Path {
13786 caminho: "../caixa-teia | [tee]".into(),
13787 });
13788 let err = d.validate().unwrap_err();
13789 assert!(
13790 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13791 "got {err:?}",
13792 );
13793 }
13794
13795 #[test]
13796 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13797 // Cascade pin on the upstream shell-redirection arm: a
13798 // value carrying both `>` and `[` (`"../caixa-teia>log
13799 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13800 // redirect-plus-bracket chain" footgun) routes through
13801 // `FonteCaminhoShellRedirection` not
13802 // `FonteCaminhoShellBracketExpansion`. The input/output
13803 // redirection metachar carries the more self-locating
13804 // `byte` payload, so the prior arm wins on every
13805 // probe-as-both value.
13806 let d = dep_with_fonte(DepSource::Path {
13807 caminho: "../caixa-teia>log [ch]".into(),
13808 });
13809 let err = d.validate().unwrap_err();
13810 assert!(
13811 matches!(
13812 err,
13813 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13814 ),
13815 "got {err:?}",
13816 );
13817 }
13818
13819 #[test]
13820 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13821 // Cascade pin on the upstream backslash arm: a value
13822 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13823 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13824 // chain") routes through `FonteCaminhoBackslash` not
13825 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13826 // separator divergence is the load-bearing axis on every
13827 // probe-as-both value.
13828 let d = dep_with_fonte(DepSource::Path {
13829 caminho: "..\\caixa-teia\\[ch]".into(),
13830 });
13831 let err = d.validate().unwrap_err();
13832 assert!(
13833 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13834 "got {err:?}",
13835 );
13836 }
13837
13838 #[test]
13839 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13840 // Cascade pin on the embedded-control-byte arm: a value
13841 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13842 // the canonical paste-from-multiline-doc footgun where a
13843 // newline landed mid-caminho between two paste fragments)
13844 // routes through `FonteCaminhoControlChar` not
13845 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13846 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13847 // the load-bearing axis on every value that probes
13848 // positive for both — mirrors the cascade discipline on
13849 // every prior arm.
13850 let d = dep_with_fonte(DepSource::Path {
13851 caminho: "../foo\n[ch]".into(),
13852 });
13853 let err = d.validate().unwrap_err();
13854 assert!(
13855 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13856 "got {err:?}",
13857 );
13858 }
13859
13860 #[test]
13861 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13862 // Cascade pin on the load-bearing leading-byte arm: a
13863 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13864 // routes through `FonteCaminhoAbsolute` not
13865 // `FonteCaminhoShellBracketExpansion` — the host-layout-
13866 // leak diagnostic is the load-bearing axis, the bracket-
13867 // expansion byte is the secondary observation. Same
13868 // precedence logic as every prior leading-byte arm.
13869 let d = dep_with_fonte(DepSource::Path {
13870 caminho: "/etc/[ch]".into(),
13871 });
13872 let err = d.validate().unwrap_err();
13873 assert!(
13874 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13875 "got {err:?}",
13876 );
13877 }
13878
13879 #[test]
13880 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13881 // Cascade pin on the upstream leading-`$` var-expansion
13882 // arm: a value carrying both a leading `$` and a `[`
13883 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13884 // variable + bracket-class at the head of a sibling-
13885 // workspace path" footgun) routes through
13886 // `FonteCaminhoVarExpansion` not
13887 // `FonteCaminhoShellBracketExpansion`. The leading-byte
13888 // shell-variable-expansion is the more self-locating
13889 // diagnostic on values that probe as both — same
13890 // load-bearing-leading-byte cascade discipline every
13891 // prior `:caminho` arm establishes.
13892 let d = dep_with_fonte(DepSource::Path {
13893 caminho: "$DIR/[ch]".into(),
13894 });
13895 let err = d.validate().unwrap_err();
13896 assert!(
13897 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13898 "got {err:?}",
13899 );
13900 }
13901
13902 #[test]
13903 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13904 // Cascade pin on the immediate-successor arm: a value
13905 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13906 // the canonical "I tab-completed a path that already had
13907 // a bracket-glob-character-class expansion tail" footgun)
13908 // routes through `FonteCaminhoShellBracketExpansion` not
13909 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13910 // is the more semantic-locating axis (an author who
13911 // removes the `[` typically also drops the trailing
13912 // separator since both are paste-from-shell artifacts).
13913 let d = dep_with_fonte(DepSource::Path {
13914 caminho: "../[a-z]/".into(),
13915 });
13916 let err = d.validate().unwrap_err();
13917 assert!(
13918 matches!(
13919 err,
13920 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13921 ),
13922 "got {err:?}",
13923 );
13924 }
13925
13926 #[test]
13927 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13928 // Diagnostic-shape pin (peer with
13929 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13930 // on the closest two-byte peer arm): the error's Display
13931 // surfaces the offending `:nome`, the offending `:caminho`
13932 // verbatim, the offending byte's hex / character form, and
13933 // names the shell-bracket-expansion / glob-character-class
13934 // footgun explicitly so a `feira lint` run can render the
13935 // diagnostic without re-parsing.
13936 let d = dep_with_fonte(DepSource::Path {
13937 caminho: "../caixa-[a-z]/build".into(),
13938 });
13939 let rendered = d.validate().unwrap_err().to_string();
13940 assert!(
13941 rendered.contains("caixa-teia"),
13942 "diagnostic must name the offending dep: {rendered}",
13943 );
13944 assert!(
13945 rendered.contains("../caixa-[a-z]/build"),
13946 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13947 );
13948 assert!(
13949 rendered.contains("0x5b"),
13950 "diagnostic must surface the offending byte hex: {rendered:?}",
13951 );
13952 assert!(
13953 rendered.contains("bracket-expansion"),
13954 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13955 );
13956 assert!(
13957 rendered.contains("glob-character-class"),
13958 "diagnostic must reference the POSIX glob-character-class vocabulary: \
13959 {rendered:?}",
13960 );
13961 }
13962
13963 #[test]
13964 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13965 // The canonical paste-from-shell-history strong-quoted
13966 // sibling-workspace-path footgun: an author copies a
13967 // `cd '../caixa-teia'` shell-history one-liner whose strong-
13968 // quoting preserved the path across a whitespace paste
13969 // boundary and silently passed every prior arm
13970 // (`Path::is_absolute` false on `'..`, no control bytes, no
13971 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13972 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13973 // doesn't end in `/`; the leading-`$` f4efe9c
13974 // `FonteCaminhoVarExpansion` arm doesn't fire because the
13975 // value starts with `'` not `$`). The lacre embedded the
13976 // value verbatim, the resolver folded it through
13977 // `Path::join` looking for a literal `./'../caixa-teia'`
13978 // subdirectory, and the failure surfaced at resolve time
13979 // with a non-self-locating `No such file or directory`
13980 // error. The new arm moves the rejection to validate time
13981 // and names the offending dep + caminho + byte verbatim.
13982 // The arm fires on the first `'` encountered.
13983 let d = dep_with_fonte(DepSource::Path {
13984 caminho: "'../caixa-teia'".into(),
13985 });
13986 let err = d.validate().unwrap_err();
13987 let DepError::FonteCaminhoShellQuoteGrouping {
13988 nome,
13989 caminho,
13990 byte,
13991 } = err
13992 else {
13993 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13994 };
13995 assert_eq!(nome, "caixa-teia");
13996 assert_eq!(caminho, "'../caixa-teia'");
13997 assert_eq!(byte, b'\'');
13998 }
13999
14000 #[test]
14001 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
14002 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
14003 // — the canonical paste-from-JSON-config / paste-from-YAML-
14004 // flow-scalar / paste-from-TOML-basic-string / paste-from-
14005 // tatara-lisp-string-literal cross-idiom leak). Pinned
14006 // separately from the single-quote shape so the gate's
14007 // contract is "any `'` or `\"` anywhere", not single-byte
14008 // coverage. Mirrors the peer
14009 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
14010 // shape on the immediate-predecessor
14011 // `FonteCaminhoShellBracketExpansion` arm.
14012 let d = dep_with_fonte(DepSource::Path {
14013 caminho: "\"../caixa-teia\"".into(),
14014 });
14015 let err = d.validate().unwrap_err();
14016 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
14017 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
14018 };
14019 assert_eq!(byte, b'"');
14020 }
14021
14022 #[test]
14023 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
14024 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
14025 // canonical "I pasted a JSON key-value pair fragment into
14026 // the middle of the path" idiom). Pinned separately from
14027 // the leading-byte shape so the gate covers every position,
14028 // not only leading.
14029 let d = dep_with_fonte(DepSource::Path {
14030 caminho: "../\"caixa-teia\"".into(),
14031 });
14032 let err = d.validate().unwrap_err();
14033 assert!(
14034 matches!(
14035 err,
14036 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
14037 ),
14038 "got {err:?}",
14039 );
14040 }
14041
14042 #[test]
14043 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
14044 // The canonical YAML double-quoted flow-scalar cross-idiom
14045 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
14046 // `path: \"...\"` YAML flow-scalar entry out of an aligned
14047 // values.yaml / K8s manifest and dropped it verbatim into
14048 // the `:caminho` slot including the `path: ` key prefix"
14049 // paste-idiom). The arm fires on the first `"` encountered;
14050 // pinned so the gate's coverage extends from the bare-quote
14051 // paste shape to the aligned-YAML-manifest cross-idiom-leak
14052 // shape.
14053 let d = dep_with_fonte(DepSource::Path {
14054 caminho: "path: \"../caixa-teia\"".into(),
14055 });
14056 let err = d.validate().unwrap_err();
14057 assert!(
14058 matches!(
14059 err,
14060 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
14061 ),
14062 "got {err:?}",
14063 );
14064 }
14065
14066 #[test]
14067 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
14068 // The positive-control pin: the gate targets only `'` /
14069 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
14070 // The canonical relative POSIX path (`"../caixa-teia"`) and
14071 // a nested deeply-pathed variant with adjacent printable
14072 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14073 // to validate cleanly so the gate doesn't widen to a "no
14074 // printable punctuation anywhere" sweep that would defeat
14075 // the entire path-fonte author surface. Peer with
14076 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
14077 // on the immediate-predecessor arm.
14078 let d = dep_with_fonte(DepSource::Path {
14079 caminho: "../caixa-teia/sub-dir.v2".into(),
14080 });
14081 d.validate().unwrap();
14082 }
14083
14084 #[test]
14085 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
14086 // Cascade pin on the immediate-predecessor arm: a value
14087 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
14088 // "I pasted a glob-character-class followed by a strong-
14089 // quoted literal tail" footgun) routes through
14090 // `FonteCaminhoShellBracketExpansion` not
14091 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
14092 // expansion is the load-bearing root-cause edit on every
14093 // probe-as-both value; same cascade discipline every prior
14094 // `:caminho` arm establishes.
14095 let d = dep_with_fonte(DepSource::Path {
14096 caminho: "../[a-z]'x'".into(),
14097 });
14098 let err = d.validate().unwrap_err();
14099 assert!(
14100 matches!(
14101 err,
14102 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14103 ),
14104 "got {err:?}",
14105 );
14106 }
14107
14108 #[test]
14109 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
14110 // Cascade pin on the upstream shell-brace-expansion arm: a
14111 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
14112 // canonical "I pasted a brace-expansion fan followed by a
14113 // strong-quoted literal tail" footgun) routes through
14114 // `FonteCaminhoShellBraceExpansion` not
14115 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
14116 // is the load-bearing root-cause edit on every probe-as-
14117 // both value.
14118 let d = dep_with_fonte(DepSource::Path {
14119 caminho: "../{a,b}'x'".into(),
14120 });
14121 let err = d.validate().unwrap_err();
14122 assert!(
14123 matches!(
14124 err,
14125 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14126 ),
14127 "got {err:?}",
14128 );
14129 }
14130
14131 #[test]
14132 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
14133 // Cascade pin on the upstream shell-subshell-grouping arm:
14134 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
14135 // the canonical "I pasted a subshell-grouping followed by
14136 // a strong-quoted literal tail" footgun) routes through
14137 // `FonteCaminhoShellSubshellGrouping` not
14138 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
14139 // `$(<cmd>)` command-substitution boundary is the load-
14140 // bearing axis on every probe-as-both value.
14141 let d = dep_with_fonte(DepSource::Path {
14142 caminho: "../(cd foo)/'x'".into(),
14143 });
14144 let err = d.validate().unwrap_err();
14145 assert!(
14146 matches!(
14147 err,
14148 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14149 ),
14150 "got {err:?}",
14151 );
14152 }
14153
14154 #[test]
14155 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
14156 // Cascade pin on the upstream shell-glob arm: a value
14157 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
14158 // canonical "I pasted a `*` unbounded pathname-expansion
14159 // followed by a strong-quoted literal tail" footgun) routes
14160 // through `FonteCaminhoShellGlob` not
14161 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
14162 // expansion sentinel is the load-bearing root-cause edit
14163 // on every probe-as-both value.
14164 let d = dep_with_fonte(DepSource::Path {
14165 caminho: "../caixa-teia/*'x'".into(),
14166 });
14167 let err = d.validate().unwrap_err();
14168 assert!(
14169 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14170 "got {err:?}",
14171 );
14172 }
14173
14174 #[test]
14175 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
14176 // Cascade pin on the upstream shell-command-substitution
14177 // arm: a value carrying both a backtick and `'`
14178 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
14179 // legacy-backtick command-substitution followed by a
14180 // strong-quoted literal tail" footgun) routes through
14181 // `FonteCaminhoShellCommandSubstitution` not
14182 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
14183 // command-injection vector is the load-bearing root-cause
14184 // edit on every probe-as-both value.
14185 let d = dep_with_fonte(DepSource::Path {
14186 caminho: "../`whoami`/'x'".into(),
14187 });
14188 let err = d.validate().unwrap_err();
14189 assert!(
14190 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14191 "got {err:?}",
14192 );
14193 }
14194
14195 #[test]
14196 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
14197 // Cascade pin on the upstream shell-background arm: a value
14198 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
14199 // canonical "I pasted a `cmd & 'literal'` background-launch
14200 // + quote chain" footgun) routes through
14201 // `FonteCaminhoShellBackground` not
14202 // `FonteCaminhoShellQuoteGrouping`. The background-launch
14203 // tail is the load-bearing root-cause edit on every
14204 // probe-as-both value.
14205 let d = dep_with_fonte(DepSource::Path {
14206 caminho: "../caixa-teia & 'x'".into(),
14207 });
14208 let err = d.validate().unwrap_err();
14209 assert!(
14210 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14211 "got {err:?}",
14212 );
14213 }
14214
14215 #[test]
14216 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
14217 // Cascade pin on the upstream shell-semicolon arm: a value
14218 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
14219 // canonical sequential-cleanup + quote paste idiom) routes
14220 // through `FonteCaminhoShellSemicolon` not
14221 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
14222 // separator paste is the load-bearing root-cause edit on
14223 // every probe-as-both value.
14224 let d = dep_with_fonte(DepSource::Path {
14225 caminho: "../caixa-teia; 'x'".into(),
14226 });
14227 let err = d.validate().unwrap_err();
14228 assert!(
14229 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14230 "got {err:?}",
14231 );
14232 }
14233
14234 #[test]
14235 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
14236 // Cascade pin on the upstream shell-pipe arm: a value
14237 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
14238 // canonical pipeline-to-quoted-literal paste idiom) routes
14239 // through `FonteCaminhoShellPipe` not
14240 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
14241 // is the load-bearing root-cause edit on every probe-as-
14242 // both value.
14243 let d = dep_with_fonte(DepSource::Path {
14244 caminho: "../caixa-teia | 'x'".into(),
14245 });
14246 let err = d.validate().unwrap_err();
14247 assert!(
14248 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14249 "got {err:?}",
14250 );
14251 }
14252
14253 #[test]
14254 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
14255 // Cascade pin on the upstream shell-redirection arm: a
14256 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
14257 // — the canonical "I pasted a `cmd > log 'literal'`
14258 // redirect-plus-quote chain" footgun) routes through
14259 // `FonteCaminhoShellRedirection` not
14260 // `FonteCaminhoShellQuoteGrouping`. The input/output
14261 // redirection metachar carries the more self-locating
14262 // `byte` payload, so the prior arm wins on every probe-as-
14263 // both value.
14264 let d = dep_with_fonte(DepSource::Path {
14265 caminho: "../caixa-teia>log 'x'".into(),
14266 });
14267 let err = d.validate().unwrap_err();
14268 assert!(
14269 matches!(
14270 err,
14271 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14272 ),
14273 "got {err:?}",
14274 );
14275 }
14276
14277 #[test]
14278 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
14279 // Cascade pin on the upstream backslash arm: a value
14280 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
14281 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
14282 // chain" footgun) routes through `FonteCaminhoBackslash`
14283 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
14284 // separator divergence is the load-bearing axis on every
14285 // probe-as-both value.
14286 let d = dep_with_fonte(DepSource::Path {
14287 caminho: "..\\caixa-teia\\'x'".into(),
14288 });
14289 let err = d.validate().unwrap_err();
14290 assert!(
14291 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14292 "got {err:?}",
14293 );
14294 }
14295
14296 #[test]
14297 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
14298 // Cascade pin on the embedded-control-byte arm: a value
14299 // carrying both a control byte and `'` (`"../foo\n'x'"` —
14300 // the canonical paste-from-multiline-doc footgun where a
14301 // newline landed mid-caminho between two paste fragments)
14302 // routes through `FonteCaminhoControlChar` not
14303 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
14304 // rejected-byte / NUL-`CString::new`-fail diagnostic is
14305 // the load-bearing axis on every value that probes
14306 // positive for both — mirrors the cascade discipline on
14307 // every prior arm.
14308 let d = dep_with_fonte(DepSource::Path {
14309 caminho: "../foo\n'x'".into(),
14310 });
14311 let err = d.validate().unwrap_err();
14312 assert!(
14313 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14314 "got {err:?}",
14315 );
14316 }
14317
14318 #[test]
14319 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
14320 // Cascade pin on the load-bearing leading-byte arm: a
14321 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
14322 // through `FonteCaminhoAbsolute` not
14323 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
14324 // diagnostic is the load-bearing axis, the quote byte is
14325 // the secondary observation. Same precedence logic as every
14326 // prior leading-byte arm.
14327 let d = dep_with_fonte(DepSource::Path {
14328 caminho: "/etc/'x'".into(),
14329 });
14330 let err = d.validate().unwrap_err();
14331 assert!(
14332 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14333 "got {err:?}",
14334 );
14335 }
14336
14337 #[test]
14338 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
14339 // Cascade pin on the upstream leading-`$` var-expansion
14340 // arm: a value carrying both a leading `$` and a `'`
14341 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
14342 // variable + quoted literal at the head of a sibling-
14343 // workspace path" footgun) routes through
14344 // `FonteCaminhoVarExpansion` not
14345 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
14346 // shell-variable-expansion is the more self-locating
14347 // diagnostic on values that probe as both — same
14348 // load-bearing-leading-byte cascade discipline every
14349 // prior `:caminho` arm establishes.
14350 let d = dep_with_fonte(DepSource::Path {
14351 caminho: "$DIR/'x'".into(),
14352 });
14353 let err = d.validate().unwrap_err();
14354 assert!(
14355 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14356 "got {err:?}",
14357 );
14358 }
14359
14360 #[test]
14361 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
14362 // Cascade pin on the immediate-successor arm: a value
14363 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
14364 // — the canonical "I tab-completed a path whose strong-
14365 // quoted body already carried the quoting from a shell-
14366 // history paste" footgun) routes through
14367 // `FonteCaminhoShellQuoteGrouping` not
14368 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14369 // is the more semantic-locating axis (an author who removes
14370 // the `'` typically also drops the trailing separator since
14371 // both are paste-from-shell artifacts).
14372 let d = dep_with_fonte(DepSource::Path {
14373 caminho: "../'caixa-teia'/".into(),
14374 });
14375 let err = d.validate().unwrap_err();
14376 assert!(
14377 matches!(
14378 err,
14379 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14380 ),
14381 "got {err:?}",
14382 );
14383 }
14384
14385 #[test]
14386 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
14387 // Diagnostic-shape pin (peer with
14388 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14389 // on the closest two-byte peer arm): the error's Display
14390 // surfaces the offending `:nome`, the offending `:caminho`
14391 // verbatim, the offending byte's hex / character form, and
14392 // names the shell-quote-grouping / cross-config-DSL-string-
14393 // literal-delimiter footgun explicitly so a `feira lint`
14394 // run can render the diagnostic without re-parsing.
14395 let d = dep_with_fonte(DepSource::Path {
14396 caminho: "'../caixa-teia'".into(),
14397 });
14398 let rendered = d.validate().unwrap_err().to_string();
14399 assert!(
14400 rendered.contains("caixa-teia"),
14401 "diagnostic must name the offending dep: {rendered}",
14402 );
14403 assert!(
14404 rendered.contains("'../caixa-teia'"),
14405 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14406 );
14407 assert!(
14408 rendered.contains("0x27"),
14409 "diagnostic must surface the offending byte hex: {rendered:?}",
14410 );
14411 assert!(
14412 rendered.contains("quote-grouping"),
14413 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
14414 );
14415 assert!(
14416 rendered.contains("string-literal"),
14417 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
14418 vocabulary: {rendered:?}",
14419 );
14420 }
14421
14422 #[test]
14423 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
14424 // The canonical paste-from-shell-history-with-trailing-
14425 // annotation footgun: an author pastes a `cd ../caixa-teia
14426 // # legacy sibling` shell-history one-liner whose unquoted `#`
14427 // comment-lead separates the path from an inline annotation.
14428 // The POSIX shell trims the annotation to `../caixa-teia`
14429 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
14430 // `Path::is_absolute` returns false on `..`, `#` is neither
14431 // a leading-byte sentinel nor a control byte nor `\` nor
14432 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
14433 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
14434 // `"`, and the value's last byte isn't `/` — so the value
14435 // silently passed every prior arm. The resolver folded the
14436 // value through `Path::join` looking for a literal
14437 // `./../caixa-teia # legacy sibling` subdirectory and the
14438 // failure surfaced at resolve time with a non-self-locating
14439 // `No such file or directory` error. The new arm moves the
14440 // rejection to validate time and names the offending dep +
14441 // caminho + byte verbatim.
14442 let d = dep_with_fonte(DepSource::Path {
14443 caminho: "../caixa-teia # legacy sibling".into(),
14444 });
14445 let err = d.validate().unwrap_err();
14446 let DepError::FonteCaminhoShellComment {
14447 nome,
14448 caminho,
14449 byte,
14450 } = err
14451 else {
14452 panic!("expected FonteCaminhoShellComment, got {err:?}");
14453 };
14454 assert_eq!(nome, "caixa-teia");
14455 assert_eq!(caminho, "../caixa-teia # legacy sibling");
14456 assert_eq!(byte, b'#');
14457 }
14458
14459 #[test]
14460 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
14461 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
14462 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
14463 // canonical "I copied a `path: ../caixa-teia # pin` YAML
14464 // scalar-plus-comment entry out of an aligned values.yaml and
14465 // dropped it verbatim into the `:caminho` slot" paste-idiom).
14466 // Pinned separately from the shell-history shape so the
14467 // gate's coverage extends from the single-space `#` shape to
14468 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
14469 // requires the `#` to be preceded by whitespace to lex as a
14470 // comment (bare `foo#bar` is a single scalar); the double-
14471 // space paste from an aligned manifest is the canonical
14472 // shape.
14473 let d = dep_with_fonte(DepSource::Path {
14474 caminho: "../caixa-teia # pin".into(),
14475 });
14476 let err = d.validate().unwrap_err();
14477 assert!(
14478 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14479 "got {err:?}",
14480 );
14481 }
14482
14483 #[test]
14484 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
14485 // The URL-fragment-identifier paste shape
14486 // (`"../caixa-teia#readme"` — the canonical
14487 // paste-from-browser-address-bar permalink shape where the
14488 // browser preserved the `#anchor` tail on the copy). Pinned
14489 // separately from the whitespace-separated shell / YAML
14490 // comment shapes so the gate covers the unpadded RFC 3986
14491 // §3.5 fragment-delimiter position too, not only positions
14492 // preceded by unquoted whitespace. Peer with the immediate-
14493 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
14494 // (a68f818) which closes the same byte under the same URL-
14495 // fragment-identifier banner.
14496 let d = dep_with_fonte(DepSource::Path {
14497 caminho: "../caixa-teia#readme".into(),
14498 });
14499 let err = d.validate().unwrap_err();
14500 assert!(
14501 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14502 "got {err:?}",
14503 );
14504 }
14505
14506 #[test]
14507 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
14508 // Leading-position `#` shape (`"#../caixa-teia"` — the
14509 // "I copied a shell-comment-out entry from a commented-out
14510 // dep row" footgun). Pinned separately from the embedded
14511 // shapes so the gate covers every position, not only
14512 // whitespace-preceded / mid-value.
14513 let d = dep_with_fonte(DepSource::Path {
14514 caminho: "#../caixa-teia".into(),
14515 });
14516 let err = d.validate().unwrap_err();
14517 assert!(
14518 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14519 "got {err:?}",
14520 );
14521 }
14522
14523 #[test]
14524 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
14525 // The positive-control pin: the gate targets only `#`,
14526 // never adjacent printable ASCII or POSIX-valid bytes. The
14527 // canonical relative POSIX path (`"../caixa-teia"`) and a
14528 // nested deeply-pathed variant with adjacent printable
14529 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14530 // to validate cleanly so the gate doesn't widen to a "no
14531 // printable punctuation anywhere" sweep that would defeat
14532 // the entire path-fonte author surface. Peer with
14533 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
14534 // on the immediate-predecessor arm.
14535 let d = dep_with_fonte(DepSource::Path {
14536 caminho: "../caixa-teia/sub-dir.v2".into(),
14537 });
14538 d.validate().unwrap();
14539 }
14540
14541 #[test]
14542 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14543 // Cascade pin on the immediate-predecessor arm: a value
14544 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14545 // "I pasted a strong-quoted literal followed by a URL-
14546 // fragment permalink tail" footgun) routes through
14547 // `FonteCaminhoShellQuoteGrouping` not
14548 // `FonteCaminhoShellComment`. The shell-string-literal-
14549 // delimiter is the load-bearing root-cause edit on every
14550 // probe-as-both value; same cascade discipline every prior
14551 // `:caminho` arm establishes.
14552 let d = dep_with_fonte(DepSource::Path {
14553 caminho: "../'x'#pin".into(),
14554 });
14555 let err = d.validate().unwrap_err();
14556 assert!(
14557 matches!(
14558 err,
14559 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14560 ),
14561 "got {err:?}",
14562 );
14563 }
14564
14565 #[test]
14566 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14567 // Cascade pin on the upstream shell-bracket-expansion arm:
14568 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14569 // canonical "I pasted a glob-character-class followed by a
14570 // URL-fragment tail" footgun) routes through
14571 // `FonteCaminhoShellBracketExpansion` not
14572 // `FonteCaminhoShellComment`. The glob-character-class
14573 // expansion is the load-bearing root-cause edit on every
14574 // probe-as-both value.
14575 let d = dep_with_fonte(DepSource::Path {
14576 caminho: "../[a-z]#pin".into(),
14577 });
14578 let err = d.validate().unwrap_err();
14579 assert!(
14580 matches!(
14581 err,
14582 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14583 ),
14584 "got {err:?}",
14585 );
14586 }
14587
14588 #[test]
14589 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14590 // Cascade pin on the upstream shell-brace-expansion arm: a
14591 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14592 // canonical "I pasted a brace-expansion fan followed by a
14593 // URL-fragment tail" footgun) routes through
14594 // `FonteCaminhoShellBraceExpansion` not
14595 // `FonteCaminhoShellComment`. The brace-expansion fan is the
14596 // load-bearing root-cause edit on every probe-as-both value.
14597 let d = dep_with_fonte(DepSource::Path {
14598 caminho: "../{a,b}#pin".into(),
14599 });
14600 let err = d.validate().unwrap_err();
14601 assert!(
14602 matches!(
14603 err,
14604 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14605 ),
14606 "got {err:?}",
14607 );
14608 }
14609
14610 #[test]
14611 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14612 // Cascade pin on the upstream shell-subshell-grouping arm:
14613 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14614 // the canonical "I pasted a subshell-grouping followed by a
14615 // URL-fragment tail" footgun) routes through
14616 // `FonteCaminhoShellSubshellGrouping` not
14617 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14618 // command-substitution boundary is the load-bearing axis on
14619 // every probe-as-both value.
14620 let d = dep_with_fonte(DepSource::Path {
14621 caminho: "../(cd foo)#pin".into(),
14622 });
14623 let err = d.validate().unwrap_err();
14624 assert!(
14625 matches!(
14626 err,
14627 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14628 ),
14629 "got {err:?}",
14630 );
14631 }
14632
14633 #[test]
14634 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14635 // Cascade pin on the upstream shell-glob arm: a value
14636 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14637 // canonical "I pasted a `*` unbounded pathname-expansion
14638 // followed by a URL-fragment tail" footgun) routes through
14639 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14640 // The unbounded pathname-expansion sentinel is the load-
14641 // bearing root-cause edit on every probe-as-both value.
14642 let d = dep_with_fonte(DepSource::Path {
14643 caminho: "../caixa-teia/*#pin".into(),
14644 });
14645 let err = d.validate().unwrap_err();
14646 assert!(
14647 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14648 "got {err:?}",
14649 );
14650 }
14651
14652 #[test]
14653 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14654 // Cascade pin on the upstream shell-command-substitution
14655 // arm: a value carrying both a backtick and `#`
14656 // (``"../`whoami`#pin"`` — the canonical "I pasted a
14657 // legacy-backtick command-substitution followed by a URL-
14658 // fragment tail" footgun) routes through
14659 // `FonteCaminhoShellCommandSubstitution` not
14660 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14661 // injection vector is the load-bearing root-cause edit on
14662 // every probe-as-both value.
14663 let d = dep_with_fonte(DepSource::Path {
14664 caminho: "../`whoami`#pin".into(),
14665 });
14666 let err = d.validate().unwrap_err();
14667 assert!(
14668 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14669 "got {err:?}",
14670 );
14671 }
14672
14673 #[test]
14674 fn fonte_caminho_shell_background_fires_before_shell_comment() {
14675 // Cascade pin on the upstream shell-background arm: a value
14676 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14677 // the canonical "I pasted a `cmd &` background-launch
14678 // followed by a URL-fragment tail" footgun) routes through
14679 // `FonteCaminhoShellBackground` not
14680 // `FonteCaminhoShellComment`. The background-launch tail is
14681 // the load-bearing root-cause edit on every probe-as-both
14682 // value.
14683 let d = dep_with_fonte(DepSource::Path {
14684 caminho: "../caixa-teia&pin#tail".into(),
14685 });
14686 let err = d.validate().unwrap_err();
14687 assert!(
14688 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14689 "got {err:?}",
14690 );
14691 }
14692
14693 #[test]
14694 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14695 // Cascade pin on the upstream shell-semicolon arm: a value
14696 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14697 // the canonical sequential-cleanup + URL-fragment paste
14698 // idiom) routes through `FonteCaminhoShellSemicolon` not
14699 // `FonteCaminhoShellComment`. The sequential-command-
14700 // separator paste is the load-bearing root-cause edit on
14701 // every probe-as-both value.
14702 let d = dep_with_fonte(DepSource::Path {
14703 caminho: "../caixa-teia;pin#tail".into(),
14704 });
14705 let err = d.validate().unwrap_err();
14706 assert!(
14707 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14708 "got {err:?}",
14709 );
14710 }
14711
14712 #[test]
14713 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14714 // Cascade pin on the upstream shell-pipe arm: a value
14715 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14716 // the canonical pipeline-to-URL-fragment paste idiom) routes
14717 // through `FonteCaminhoShellPipe` not
14718 // `FonteCaminhoShellComment`. The pipeline-tail paste is
14719 // the load-bearing root-cause edit on every probe-as-both
14720 // value.
14721 let d = dep_with_fonte(DepSource::Path {
14722 caminho: "../caixa-teia|pin#tail".into(),
14723 });
14724 let err = d.validate().unwrap_err();
14725 assert!(
14726 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14727 "got {err:?}",
14728 );
14729 }
14730
14731 #[test]
14732 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14733 // Cascade pin on the upstream shell-redirection arm: a
14734 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14735 // — the canonical "I pasted a `cmd > log` redirect followed
14736 // by a URL-fragment tail" footgun) routes through
14737 // `FonteCaminhoShellRedirection` not
14738 // `FonteCaminhoShellComment`. The input/output redirection
14739 // metachar carries the more self-locating `byte` payload,
14740 // so the prior arm wins on every probe-as-both value.
14741 let d = dep_with_fonte(DepSource::Path {
14742 caminho: "../caixa-teia>log#pin".into(),
14743 });
14744 let err = d.validate().unwrap_err();
14745 assert!(
14746 matches!(
14747 err,
14748 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14749 ),
14750 "got {err:?}",
14751 );
14752 }
14753
14754 #[test]
14755 fn fonte_caminho_backslash_fires_before_shell_comment() {
14756 // Cascade pin on the upstream backslash arm: a value
14757 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14758 // canonical "I pasted a Windows-shell path followed by a
14759 // URL-fragment tail" footgun) routes through
14760 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14761 // The cross-host-OS-separator divergence is the load-
14762 // bearing axis on every probe-as-both value.
14763 let d = dep_with_fonte(DepSource::Path {
14764 caminho: "..\\caixa-teia#pin".into(),
14765 });
14766 let err = d.validate().unwrap_err();
14767 assert!(
14768 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14769 "got {err:?}",
14770 );
14771 }
14772
14773 #[test]
14774 fn fonte_caminho_control_char_fires_before_shell_comment() {
14775 // Cascade pin on the embedded-control-byte arm: a value
14776 // carrying both a control byte and `#` (`"../foo\n#pin"` —
14777 // the canonical paste-from-multiline-doc footgun where a
14778 // newline landed mid-caminho between the path and an
14779 // annotation) routes through `FonteCaminhoControlChar` not
14780 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14781 // byte diagnostic is the load-bearing axis on every value
14782 // that probes positive for both — mirrors the cascade
14783 // discipline on every prior arm.
14784 let d = dep_with_fonte(DepSource::Path {
14785 caminho: "../foo\n#pin".into(),
14786 });
14787 let err = d.validate().unwrap_err();
14788 assert!(
14789 matches!(err, DepError::FonteCaminhoControlChar { .. }),
14790 "got {err:?}",
14791 );
14792 }
14793
14794 #[test]
14795 fn fonte_caminho_absolute_fires_before_shell_comment() {
14796 // Cascade pin on the load-bearing leading-byte arm: a
14797 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14798 // routes through `FonteCaminhoAbsolute` not
14799 // `FonteCaminhoShellComment` — the host-layout-leak
14800 // diagnostic is the load-bearing axis, the fragment byte is
14801 // the secondary observation. Same precedence logic as every
14802 // prior leading-byte arm.
14803 let d = dep_with_fonte(DepSource::Path {
14804 caminho: "/etc/foo#pin".into(),
14805 });
14806 let err = d.validate().unwrap_err();
14807 assert!(
14808 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14809 "got {err:?}",
14810 );
14811 }
14812
14813 #[test]
14814 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14815 // Cascade pin on the upstream leading-`$` var-expansion
14816 // arm: a value carrying both a leading `$` and a `#`
14817 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14818 // shell-variable at the head of a sibling-workspace path
14819 // followed by a URL-fragment tail" footgun) routes through
14820 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14821 // The leading-byte shell-variable-expansion is the more
14822 // self-locating diagnostic on values that probe as both.
14823 let d = dep_with_fonte(DepSource::Path {
14824 caminho: "$DIR/foo#pin".into(),
14825 });
14826 let err = d.validate().unwrap_err();
14827 assert!(
14828 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14829 "got {err:?}",
14830 );
14831 }
14832
14833 #[test]
14834 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14835 // Cascade pin on the immediate-successor arm: a value
14836 // carrying both `#` and a trailing `/`
14837 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14838 // a URL-fragment-carrying path" footgun) routes through
14839 // `FonteCaminhoShellComment` not
14840 // `FonteCaminhoTrailingSlash`. The embedded fragment /
14841 // comment-lead byte is the more semantic-locating axis (an
14842 // author who removes the `#pin` fragment typically also
14843 // drops the trailing separator since both are paste-from-
14844 // URL / paste-from-shell-tab-completion artifacts).
14845 let d = dep_with_fonte(DepSource::Path {
14846 caminho: "../caixa-teia#pin/".into(),
14847 });
14848 let err = d.validate().unwrap_err();
14849 assert!(
14850 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14851 "got {err:?}",
14852 );
14853 }
14854
14855 #[test]
14856 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14857 // Diagnostic-shape pin (peer with
14858 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14859 // on the immediate-predecessor arm): the error's Display
14860 // surfaces the offending `:nome`, the offending `:caminho`
14861 // verbatim, the offending byte's hex / character form, and
14862 // names the shell-comment / URL-fragment-identifier /
14863 // YAML-comment cross-config-DSL footgun explicitly so a
14864 // `feira lint` run can render the diagnostic without
14865 // re-parsing.
14866 let d = dep_with_fonte(DepSource::Path {
14867 caminho: "../caixa-teia#readme".into(),
14868 });
14869 let rendered = d.validate().unwrap_err().to_string();
14870 assert!(
14871 rendered.contains("caixa-teia"),
14872 "diagnostic must name the offending dep: {rendered}",
14873 );
14874 assert!(
14875 rendered.contains("../caixa-teia#readme"),
14876 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14877 );
14878 assert!(
14879 rendered.contains("0x23"),
14880 "diagnostic must surface the offending byte hex: {rendered:?}",
14881 );
14882 assert!(
14883 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14884 "diagnostic must name the shell-comment footgun: {rendered:?}",
14885 );
14886 assert!(
14887 rendered.contains("fragment") || rendered.contains("URL-fragment"),
14888 "diagnostic must reference the URL-fragment-identifier vocabulary: \
14889 {rendered:?}",
14890 );
14891 }
14892
14893 #[test]
14894 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14895 // The canonical paste-from-browser-address-bar percent-
14896 // encoded-space footgun: an author copies `../caixa%20teia`
14897 // out of a URL-encoded README hyperlink / browser address
14898 // bar / percent-encoded permalink expecting `%20` to decode
14899 // to a literal space at the filesystem layer. POSIX
14900 // `std::path::Path` treats `%` as a literal path-component
14901 // byte, so `Path::join` looks for a literal
14902 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14903 // returns false on `..`, `%` is neither a leading-byte
14904 // sentinel nor a control byte nor `\` nor `<` / `>` nor
14905 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14906 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14907 // and the value's last byte isn't `/` — so the value
14908 // silently passed every prior arm. The new arm moves the
14909 // rejection to validate time and names the offending dep +
14910 // caminho + byte verbatim.
14911 let d = dep_with_fonte(DepSource::Path {
14912 caminho: "../caixa%20teia".into(),
14913 });
14914 let err = d.validate().unwrap_err();
14915 let DepError::FonteCaminhoUrlPercentEncoding {
14916 nome,
14917 caminho,
14918 byte,
14919 } = err
14920 else {
14921 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14922 };
14923 assert_eq!(nome, "caixa-teia");
14924 assert_eq!(caminho, "../caixa%20teia");
14925 assert_eq!(byte, b'%');
14926 }
14927
14928 #[test]
14929 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14930 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14931 // intending the `%2F` as the URL encoding of `/`) locks a
14932 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14933 // the byte-identical `path:../caixa/teia` form. Pinned
14934 // separately from the space-encoded shape so the gate's
14935 // coverage extends past the single canonical `%20` example
14936 // to any two-hex-digit percent-encoded sequence.
14937 let d = dep_with_fonte(DepSource::Path {
14938 caminho: "../caixa%2Fteia".into(),
14939 });
14940 let err = d.validate().unwrap_err();
14941 assert!(
14942 matches!(
14943 err,
14944 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14945 ),
14946 "got {err:?}",
14947 );
14948 }
14949
14950 #[test]
14951 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14952 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14953 // where `%` isn't followed by two hex digits) — every
14954 // WHATWG-conformant URL parser rejects the value at parse
14955 // time per RFC 3986 §2.1, but the byte would silently ride
14956 // into the lacre before the resolver subprocess crosses the
14957 // URL-parser boundary. Pinned separately from the well-
14958 // formed `%HH` shapes so the gate covers every percent-
14959 // occurrence, not only strictly-conformant escapes.
14960 let d = dep_with_fonte(DepSource::Path {
14961 caminho: "../caixa-teia%foo".into(),
14962 });
14963 let err = d.validate().unwrap_err();
14964 assert!(
14965 matches!(
14966 err,
14967 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14968 ),
14969 "got {err:?}",
14970 );
14971 }
14972
14973 #[test]
14974 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14975 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14976 // — the canonical paste-from-top-of-doc YAML directive
14977 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14978 // separately from embedded shapes so the gate covers the
14979 // leading-position `%` too, not only mid-value occurrences.
14980 let d = dep_with_fonte(DepSource::Path {
14981 caminho: "%YAML/../caixa-teia".into(),
14982 });
14983 let err = d.validate().unwrap_err();
14984 assert!(
14985 matches!(
14986 err,
14987 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14988 ),
14989 "got {err:?}",
14990 );
14991 }
14992
14993 #[test]
14994 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14995 // The printf-format-specifier paste shape
14996 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14997 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14998 // 134 format-string-injection vector). Pinned separately
14999 // from the URL-encoding shapes so the gate's rationale
15000 // extends past the RFC 3986 axis to the C / POSIX printf
15001 // format-directive-lead axis.
15002 let d = dep_with_fonte(DepSource::Path {
15003 caminho: "../caixa-%s-teia".into(),
15004 });
15005 let err = d.validate().unwrap_err();
15006 assert!(
15007 matches!(
15008 err,
15009 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15010 ),
15011 "got {err:?}",
15012 );
15013 }
15014
15015 #[test]
15016 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
15017 // The positive-control pin: the gate targets only `%`,
15018 // never adjacent printable ASCII or POSIX-valid bytes. The
15019 // canonical relative POSIX path (`"../caixa-teia"`) and a
15020 // nested deeply-pathed variant with adjacent printable
15021 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
15022 // to validate cleanly so the gate doesn't widen to a "no
15023 // printable punctuation anywhere" sweep that would defeat
15024 // the entire path-fonte author surface. Peer with
15025 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
15026 // on the immediate-predecessor arm.
15027 let d = dep_with_fonte(DepSource::Path {
15028 caminho: "../caixa-teia/sub-dir.v2".into(),
15029 });
15030 d.validate().unwrap();
15031 }
15032
15033 #[test]
15034 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
15035 // Cascade pin on the immediate-predecessor arm: a value
15036 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
15037 // canonical "I pasted a URL-fragment permalink followed by a
15038 // percent-encoded space tail" footgun) routes through
15039 // `FonteCaminhoShellComment` not
15040 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
15041 // identifier is the load-bearing downstream-truncation edit
15042 // on every probe-as-both value; same cascade discipline
15043 // every prior `:caminho` arm establishes.
15044 let d = dep_with_fonte(DepSource::Path {
15045 caminho: "../caixa-teia#pin%20".into(),
15046 });
15047 let err = d.validate().unwrap_err();
15048 assert!(
15049 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
15050 "got {err:?}",
15051 );
15052 }
15053
15054 #[test]
15055 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
15056 // Cascade pin on the upstream shell-quote-grouping arm: a
15057 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
15058 // canonical "I pasted a strong-quoted literal followed by
15059 // a percent-encoded space" footgun) routes through
15060 // `FonteCaminhoShellQuoteGrouping` not
15061 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
15062 // literal-delimiter is the load-bearing root-cause edit on
15063 // every probe-as-both value.
15064 let d = dep_with_fonte(DepSource::Path {
15065 caminho: "../'x'%20teia".into(),
15066 });
15067 let err = d.validate().unwrap_err();
15068 assert!(
15069 matches!(
15070 err,
15071 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
15072 ),
15073 "got {err:?}",
15074 );
15075 }
15076
15077 #[test]
15078 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
15079 // Cascade pin on the upstream backslash arm: a value
15080 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
15081 // canonical "I pasted a Windows-shell path followed by a
15082 // percent-encoded space" footgun) routes through
15083 // `FonteCaminhoBackslash` not
15084 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
15085 // separator divergence is the load-bearing root-cause edit
15086 // on every probe-as-both value.
15087 let d = dep_with_fonte(DepSource::Path {
15088 caminho: "..\\caixa%20teia".into(),
15089 });
15090 let err = d.validate().unwrap_err();
15091 assert!(
15092 matches!(err, DepError::FonteCaminhoBackslash { .. }),
15093 "got {err:?}",
15094 );
15095 }
15096
15097 #[test]
15098 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
15099 // Cascade pin on the upstream control-char arm: a value
15100 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
15101 // the canonical "I pasted a paste-from-binary-blob path
15102 // followed by a percent-encoded space" footgun) routes
15103 // through `FonteCaminhoControlChar` not
15104 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
15105 // rejected byte is the load-bearing root-cause edit on
15106 // every probe-as-both value.
15107 let d = dep_with_fonte(DepSource::Path {
15108 caminho: "../caixa\0%20teia".into(),
15109 });
15110 let err = d.validate().unwrap_err();
15111 assert!(
15112 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
15113 "got {err:?}",
15114 );
15115 }
15116
15117 #[test]
15118 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
15119 // Cascade pin on the upstream absolute-path arm: a value
15120 // that's both absolute and carries `%` (`"/etc/passwd%20"`
15121 // — the canonical "I pasted an absolute path with a
15122 // percent-encoded space tail" footgun) routes through
15123 // `FonteCaminhoAbsolute` not
15124 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
15125 // the load-bearing root-cause edit on every probe-as-both
15126 // value.
15127 let d = dep_with_fonte(DepSource::Path {
15128 caminho: "/etc/passwd%20".into(),
15129 });
15130 let err = d.validate().unwrap_err();
15131 assert!(
15132 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
15133 "got {err:?}",
15134 );
15135 }
15136
15137 #[test]
15138 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
15139 // Cascade pin on the upstream var-expansion arm: a value
15140 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
15141 // — the canonical "I pasted a `$HOME`-rooted path with a
15142 // percent-encoded space" footgun) routes through
15143 // `FonteCaminhoVarExpansion` not
15144 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
15145 // expansion is the load-bearing root-cause edit on every
15146 // probe-as-both value.
15147 let d = dep_with_fonte(DepSource::Path {
15148 caminho: "$HOME/caixa%20teia".into(),
15149 });
15150 let err = d.validate().unwrap_err();
15151 assert!(
15152 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15153 "got {err:?}",
15154 );
15155 }
15156
15157 #[test]
15158 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
15159 // Cascade pin on the immediate-successor arm: a value
15160 // carrying both `%` and a trailing `/`
15161 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
15162 // percent-encoded-space-carrying path" footgun) routes
15163 // through `FonteCaminhoUrlPercentEncoding` not
15164 // `FonteCaminhoTrailingSlash`. The embedded percent-
15165 // encoding-escape byte is the more semantic-locating axis
15166 // (an author who decodes the `%20` to a literal space is
15167 // likely to also tab-strip the trailing separator since
15168 // both are paste-from-URL / paste-from-shell-tab-completion
15169 // artifacts).
15170 let d = dep_with_fonte(DepSource::Path {
15171 caminho: "../caixa%20teia/".into(),
15172 });
15173 let err = d.validate().unwrap_err();
15174 assert!(
15175 matches!(
15176 err,
15177 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15178 ),
15179 "got {err:?}",
15180 );
15181 }
15182
15183 #[test]
15184 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
15185 // Diagnostic-shape pin (peer with
15186 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
15187 // on the immediate-predecessor arm): the error's Display
15188 // surfaces the offending `:nome`, the offending `:caminho`
15189 // verbatim, the offending byte's hex / character form, and
15190 // names the URL-percent-encoding-escape / printf-format-
15191 // specifier footgun explicitly so a `feira lint` run can
15192 // render the diagnostic without re-parsing.
15193 let d = dep_with_fonte(DepSource::Path {
15194 caminho: "../caixa%20teia".into(),
15195 });
15196 let rendered = d.validate().unwrap_err().to_string();
15197 assert!(
15198 rendered.contains("caixa-teia"),
15199 "diagnostic must name the offending dep: {rendered}",
15200 );
15201 assert!(
15202 rendered.contains("../caixa%20teia"),
15203 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15204 );
15205 assert!(
15206 rendered.contains("0x25"),
15207 "diagnostic must surface the offending byte hex: {rendered:?}",
15208 );
15209 assert!(
15210 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
15211 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
15212 );
15213 assert!(
15214 rendered.contains("printf") || rendered.contains("format-specifier"),
15215 "diagnostic must reference the printf-format-specifier vocabulary: \
15216 {rendered:?}",
15217 );
15218 }
15219
15220 #[test]
15221 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
15222 // The canonical embedded-`$` shell-variable-expansion paste
15223 // shape (`"../foo$HOME/bar"` — an author copies a partially-
15224 // substituted shell one-liner where the leading segment is a
15225 // literal `../foo` while the mid segment carries the un-
15226 // substituted `$HOME` template). The leading-`$` position is
15227 // already gated by the f4efe9c leading-byte arm which routes
15228 // through `FonteCaminhoVarExpansion`; this arm closes the
15229 // last positional gap on `$` — every position on the axis is
15230 // structurally rejected.
15231 let d = dep_with_fonte(DepSource::Path {
15232 caminho: "../foo$HOME/bar".into(),
15233 });
15234 let err = d.validate().unwrap_err();
15235 let DepError::FonteCaminhoShellVariableExpansion {
15236 nome,
15237 caminho,
15238 byte,
15239 } = err
15240 else {
15241 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
15242 };
15243 assert_eq!(nome, "caixa-teia");
15244 assert_eq!(caminho, "../foo$HOME/bar");
15245 assert_eq!(byte, b'$');
15246 }
15247
15248 #[test]
15249 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
15250 // The symmetric braced-CI-manifest paste shape
15251 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
15252 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
15253 // footgun). Pinned separately from the bare-`$VAR` shape so
15254 // the gate covers both POSIX shell §2.6 Parameter Expansion
15255 // syntactic forms, not only the unbraced variant. The
15256 // embedded `{` byte in `${...}` is also caught by the 598b770
15257 // shell-brace-expansion arm but that arm fires earlier in
15258 // the cascade — the `$` arm's coverage extends to `${...}`
15259 // structurally, so the diagnostic asserted here is the
15260 // brace-expansion one (which is a valid outcome; the point
15261 // of the pin is that the value never survives validation).
15262 let d = dep_with_fonte(DepSource::Path {
15263 caminho: "../foo${WORKSPACE}/bar".into(),
15264 });
15265 let err = d.validate().unwrap_err();
15266 assert!(
15267 matches!(
15268 err,
15269 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
15270 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15271 ),
15272 "got {err:?}",
15273 );
15274 }
15275
15276 #[test]
15277 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
15278 // The paste-from-shell-prompt command-substitution idiom
15279 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
15280 // `$VAR` shape so the gate's rationale extends to POSIX shell
15281 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
15282 // legacy `` `<cmd>` `` form is already closed by the c370458
15283 // backtick arm). The embedded `(` byte in `$(...)` is also
15284 // caught structurally by the 0633c91 shell-subshell-grouping
15285 // arm which fires earlier in the cascade — the diagnostic
15286 // asserted here is either outcome, since both structurally
15287 // reject the value; the point of the pin is that the value
15288 // never survives validation.
15289 let d = dep_with_fonte(DepSource::Path {
15290 caminho: "../foo$(whoami)/bar".into(),
15291 });
15292 let err = d.validate().unwrap_err();
15293 assert!(
15294 matches!(
15295 err,
15296 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
15297 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15298 ),
15299 "got {err:?}",
15300 );
15301 }
15302
15303 #[test]
15304 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
15305 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
15306 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
15307 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
15308 // idiom copied into a caminho template). None of the prior
15309 // shell-metachar arms cover this shape (`1` is a bare digit;
15310 // no `(` / `{` / letter follows the `$`), so the arm is the
15311 // sole gate on the shape.
15312 let d = dep_with_fonte(DepSource::Path {
15313 caminho: "../foo$1/bar".into(),
15314 });
15315 let err = d.validate().unwrap_err();
15316 assert!(
15317 matches!(
15318 err,
15319 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15320 ),
15321 "got {err:?}",
15322 );
15323 }
15324
15325 #[test]
15326 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
15327 // The positive-control pin (peer with
15328 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
15329 // on the immediate-predecessor arm): the gate targets only
15330 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
15331 // A relative POSIX path carrying dashes / dots / slashes /
15332 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15333 // validate cleanly so the gate doesn't widen to a "no
15334 // printable punctuation anywhere" sweep that would defeat
15335 // the entire path-fonte author surface.
15336 let d = dep_with_fonte(DepSource::Path {
15337 caminho: "../caixa-teia/sub-dir.v2".into(),
15338 });
15339 d.validate().unwrap();
15340 }
15341
15342 #[test]
15343 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
15344 // Cascade pin on the leading-`$` sibling arm at line 540: a
15345 // value starting with `$` and carrying an embedded `$` too
15346 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
15347 // fully-templated CI path with two un-substituted variables")
15348 // routes through `FonteCaminhoVarExpansion` not
15349 // `FonteCaminhoShellVariableExpansion`. The leading-byte
15350 // host-layout-leak is the load-bearing self-locating axis
15351 // (the leading position dominates the semantic-locating
15352 // rationale on every probe-as-both value); the embedded
15353 // arm's positional-agnostic sweep catches only values whose
15354 // leading byte doesn't route through the earlier leading-
15355 // byte arms.
15356 let d = dep_with_fonte(DepSource::Path {
15357 caminho: "$HOME/foo$WORKSPACE/bar".into(),
15358 });
15359 let err = d.validate().unwrap_err();
15360 assert!(
15361 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15362 "got {err:?}",
15363 );
15364 }
15365
15366 #[test]
15367 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
15368 // Cascade pin on the immediate-predecessor arm: a value
15369 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
15370 // — the canonical "I pasted a percent-encoded space adjacent
15371 // to a `$HOME` template") routes through
15372 // `FonteCaminhoUrlPercentEncoding` not
15373 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
15374 // encoding-escape byte is the more semantic-locating axis
15375 // (the paste-from-browser-address-bar shape is the load-
15376 // bearing self-locating edit); same cascade discipline every
15377 // prior `:caminho` arm establishes.
15378 let d = dep_with_fonte(DepSource::Path {
15379 caminho: "../foo%20$HOME/bar".into(),
15380 });
15381 let err = d.validate().unwrap_err();
15382 assert!(
15383 matches!(
15384 err,
15385 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15386 ),
15387 "got {err:?}",
15388 );
15389 }
15390
15391 #[test]
15392 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
15393 // Cascade pin on the immediate-successor arm: a value
15394 // carrying both embedded `$` and a trailing `/`
15395 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
15396 // `$HOME`-template-carrying path") routes through
15397 // `FonteCaminhoShellVariableExpansion` not
15398 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
15399 // expansion byte is the more semantic-locating axis on
15400 // probe-as-both values (an author who substitutes the
15401 // `$HOME` template with a literal value is likely to also
15402 // tab-strip the trailing separator).
15403 let d = dep_with_fonte(DepSource::Path {
15404 caminho: "../foo$HOME/bar/".into(),
15405 });
15406 let err = d.validate().unwrap_err();
15407 assert!(
15408 matches!(
15409 err,
15410 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15411 ),
15412 "got {err:?}",
15413 );
15414 }
15415
15416 #[test]
15417 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15418 // Diagnostic-shape pin (peer with
15419 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
15420 // on the immediate-predecessor arm): the error's Display
15421 // surfaces the offending `:nome`, the offending `:caminho`
15422 // verbatim, the offending byte's hex / character form, and
15423 // names the shell-variable-expansion / command-substitution
15424 // footgun explicitly so a `feira lint` run can render the
15425 // diagnostic without re-parsing.
15426 let d = dep_with_fonte(DepSource::Path {
15427 caminho: "../foo$HOME/bar".into(),
15428 });
15429 let rendered = d.validate().unwrap_err().to_string();
15430 assert!(
15431 rendered.contains("caixa-teia"),
15432 "diagnostic must name the offending dep: {rendered}",
15433 );
15434 assert!(
15435 rendered.contains("../foo$HOME/bar"),
15436 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15437 );
15438 assert!(
15439 rendered.contains("0x24"),
15440 "diagnostic must surface the offending byte hex: {rendered:?}",
15441 );
15442 assert!(
15443 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
15444 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
15445 );
15446 assert!(
15447 rendered.contains("command-substitution") || rendered.contains("command substitution"),
15448 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
15449 );
15450 }
15451
15452 #[test]
15453 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
15454 // The fail-before-pass-after pin for the canonical paste-from-
15455 // shell-history footgun on `:caminho`. An author copies a `cd
15456 // ../caixa-teia && !sudo make install` one-liner from a quick-
15457 // start README, intending the trailing `!sudo` as a shell-
15458 // history-expansion reference but the typed slot is itself a
15459 // byte-level string parser, not a shell context, so the byte
15460 // rides into the value verbatim. Until this arm landed the `!`
15461 // byte silently passed every prior `:caminho` cascade arm
15462 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
15463 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
15464 // `#` / `%` / `$`); bash with the default `histexpand` mode
15465 // rewrites `!command` to the most recent history entry
15466 // beginning with `command`, the canonical RCE-class injection
15467 // vector when the byte rides into a shell argument executed
15468 // under `bash -i` (the operator-notebook interactive shell).
15469 let d = dep_with_fonte(DepSource::Path {
15470 caminho: "../caixa-teia!sudo".into(),
15471 });
15472 let err = d.validate().unwrap_err();
15473 let DepError::FonteCaminhoShellHistoryExpansion {
15474 nome,
15475 caminho,
15476 byte,
15477 } = err
15478 else {
15479 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
15480 };
15481 assert_eq!(nome, "caixa-teia");
15482 assert_eq!(caminho, "../caixa-teia!sudo");
15483 assert_eq!(byte, b'!');
15484 }
15485
15486 #[test]
15487 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
15488 // The symmetric `!!` repeat-prior-command paste idiom (peer with
15489 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
15490 // on `is_git_repo_url`). Pinned separately from the wrapped
15491 // `!command` shape so a future diagnostic-surface change that
15492 // only checked the leading or paired-bang position surfaces
15493 // here — the per-byte arm fires anywhere `!` appears in the
15494 // value, including at consecutive positions in the middle.
15495 let d = dep_with_fonte(DepSource::Path {
15496 caminho: "../foo!!/bar".into(),
15497 });
15498 let err = d.validate().unwrap_err();
15499 assert!(
15500 matches!(
15501 err,
15502 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15503 ),
15504 "got {err:?}",
15505 );
15506 }
15507
15508 #[test]
15509 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
15510 // The English-typography enthusiasm-form paste-from-prose
15511 // idiom: an author writes `:caminho "../caixa-teia!"`
15512 // expecting the substrate to coerce it to a kebab-case slug.
15513 // Pinned separately from the `!<word>` shell-history shape so
15514 // the gate's rationale extends to the paste-from-prose surface
15515 // (the same rationale the peer `is_git_repo_url` bang arm at
15516 // 7d53c68 covers). None of the prior shell-metachar arms cover
15517 // this shape (no `!<word>` reference and no `!!` repeat), so
15518 // the arm is the sole gate on the shape.
15519 let d = dep_with_fonte(DepSource::Path {
15520 caminho: "../caixa-teia!".into(),
15521 });
15522 let err = d.validate().unwrap_err();
15523 assert!(
15524 matches!(
15525 err,
15526 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15527 ),
15528 "got {err:?}",
15529 );
15530 }
15531
15532 #[test]
15533 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
15534 // The positive-control pin (peer with
15535 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
15536 // on the immediate-predecessor arm): the gate targets only
15537 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15538 // A relative POSIX path carrying dashes / dots / slashes /
15539 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15540 // validate cleanly so the gate doesn't widen to a "no
15541 // printable punctuation anywhere" sweep that would defeat
15542 // the entire path-fonte author surface.
15543 let d = dep_with_fonte(DepSource::Path {
15544 caminho: "../caixa-teia/sub-dir.v2".into(),
15545 });
15546 d.validate().unwrap();
15547 }
15548
15549 #[test]
15550 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15551 // Cascade pin on the immediate-predecessor arm: a value
15552 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15553 // — the canonical "I pasted a `$HOME`-templated path adjacent
15554 // to a trailing `!sudo` history-expansion") routes through
15555 // `FonteCaminhoShellVariableExpansion` not
15556 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15557 // expansion byte is the more semantic-locating axis on
15558 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15559 // template shape is the load-bearing self-locating edit);
15560 // same cascade discipline every prior `:caminho` arm
15561 // establishes.
15562 let d = dep_with_fonte(DepSource::Path {
15563 caminho: "../foo$HOME/bar!sudo".into(),
15564 });
15565 let err = d.validate().unwrap_err();
15566 assert!(
15567 matches!(
15568 err,
15569 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15570 ),
15571 "got {err:?}",
15572 );
15573 }
15574
15575 #[test]
15576 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15577 // Cascade pin on the immediate-successor arm: a value carrying
15578 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15579 // — the canonical "I tab-completed a `!sudo`-carrying path")
15580 // routes through `FonteCaminhoShellHistoryExpansion` not
15581 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15582 // expansion byte is the more semantic-locating axis on probe-
15583 // as-both values (an author who removes the `!sudo` history
15584 // reference is likely to also tab-strip the trailing separator).
15585 let d = dep_with_fonte(DepSource::Path {
15586 caminho: "../caixa-teia!sudo/".into(),
15587 });
15588 let err = d.validate().unwrap_err();
15589 assert!(
15590 matches!(
15591 err,
15592 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15593 ),
15594 "got {err:?}",
15595 );
15596 }
15597
15598 #[test]
15599 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15600 // Diagnostic-shape pin (peer with
15601 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15602 // on the immediate-predecessor arm): the error's Display
15603 // surfaces the offending `:nome`, the offending `:caminho`
15604 // verbatim, the offending byte's hex / character form, and
15605 // names the shell-history-expansion / bang-operator footgun
15606 // explicitly so a `feira lint` run can render the diagnostic
15607 // without re-parsing.
15608 let d = dep_with_fonte(DepSource::Path {
15609 caminho: "../caixa-teia!sudo".into(),
15610 });
15611 let rendered = d.validate().unwrap_err().to_string();
15612 assert!(
15613 rendered.contains("caixa-teia"),
15614 "diagnostic must name the offending dep: {rendered}",
15615 );
15616 assert!(
15617 rendered.contains("../caixa-teia!sudo"),
15618 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15619 );
15620 assert!(
15621 rendered.contains("0x21"),
15622 "diagnostic must surface the offending byte hex: {rendered:?}",
15623 );
15624 assert!(
15625 rendered.contains("history-expansion") || rendered.contains("history expansion"),
15626 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15627 );
15628 assert!(
15629 rendered.contains("bang"),
15630 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15631 );
15632 }
15633
15634 #[test]
15635 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15636 // The fail-before-pass-after pin for the canonical paste-from-
15637 // shell-history-quick-substitution footgun on `:caminho`. An
15638 // author copies a `git clone <bad-url>` line from their terminal,
15639 // corrects it via bash's `^bad^good` quick-substitution history
15640 // operator (bash reference §9.3, `set -o histexpand` mode's
15641 // default for interactive sessions), and pastes the trailing
15642 // `^bad^good` substitution fragment into a `:caminho` value
15643 // without trimming the leading `git clone` prefix — the byte
15644 // rides into the manifest verbatim. Until this arm landed the
15645 // `^` byte silently passed every prior `:caminho` cascade arm
15646 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15647 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15648 // `%` / `$` / `!`); bash with the default `histexpand` mode
15649 // rewrites the prior command's `bad` string to `good` and re-
15650 // executes it, the paired-operator half of the `set -o
15651 // histexpand` feature the peer `!` arm already closes the prefix
15652 // half of. The peer `is_git_repo_url` axis rejects the byte at
15653 // 49e142f under the same shell-history-substitution / RFC-3986-
15654 // unwise banner.
15655 let d = dep_with_fonte(DepSource::Path {
15656 caminho: "../foo^bad^good".into(),
15657 });
15658 let err = d.validate().unwrap_err();
15659 let DepError::FonteCaminhoShellHistorySubstitution {
15660 nome,
15661 caminho,
15662 byte,
15663 } = err
15664 else {
15665 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15666 };
15667 assert_eq!(nome, "caixa-teia");
15668 assert_eq!(caminho, "../foo^bad^good");
15669 assert_eq!(byte, b'^');
15670 }
15671
15672 #[test]
15673 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15674 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15675 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15676 // on `is_git_repo_url`). An author copies a `grep '^archived'`
15677 // regex-anchor / negation idiom from a doc snippet and the byte
15678 // rides in verbatim. Pinned separately from the `^old^new^`
15679 // quick-substitution shape so a future diagnostic-surface change
15680 // that only checked the paired-caret history-substitution
15681 // position surfaces here — the per-byte arm fires anywhere `^`
15682 // appears in the value, including at a solitary leading-of-
15683 // segment position.
15684 let d = dep_with_fonte(DepSource::Path {
15685 caminho: "../foo/^archived".into(),
15686 });
15687 let err = d.validate().unwrap_err();
15688 assert!(
15689 matches!(
15690 err,
15691 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15692 ),
15693 "got {err:?}",
15694 );
15695 }
15696
15697 #[test]
15698 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15699 // The trailing-`^` history-substitution-open shape — an author
15700 // starts typing a `^bad^good` quick-substitution but pastes only
15701 // the leading `^` sentinel before context-switching (a bash-
15702 // reference §9.3 valid histexpand prefix on its own — even a
15703 // solitary `^` on the prior command's whole re-execution shape).
15704 // Pinned separately from the `^old^new^` full-form and the leading-
15705 // of-segment `^archived` regex-anchor shape so the gate's
15706 // rationale extends to the paste-from-shell-history-with-only-
15707 // the-first-byte-selected surface. None of the prior shell-
15708 // metachar arms cover this shape.
15709 let d = dep_with_fonte(DepSource::Path {
15710 caminho: "../caixa-teia^".into(),
15711 });
15712 let err = d.validate().unwrap_err();
15713 assert!(
15714 matches!(
15715 err,
15716 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15717 ),
15718 "got {err:?}",
15719 );
15720 }
15721
15722 #[test]
15723 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15724 // The positive-control pin (peer with
15725 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15726 // on the immediate-predecessor arm): the gate targets only
15727 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15728 // A relative POSIX path carrying dashes / dots / slashes /
15729 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15730 // continue to validate cleanly so the gate doesn't widen to
15731 // a "no printable punctuation anywhere" sweep that would
15732 // defeat the entire path-fonte author surface.
15733 let d = dep_with_fonte(DepSource::Path {
15734 caminho: "../caixa-teia/sub_v2.rc".into(),
15735 });
15736 d.validate().unwrap();
15737 }
15738
15739 #[test]
15740 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15741 // Cascade pin on the immediate-predecessor arm: a value carrying
15742 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15743 // canonical "I pasted a `!sudo` history-reference next to a
15744 // `^bad^good` quick-substitution") routes through
15745 // `FonteCaminhoShellHistoryExpansion` not
15746 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15747 // the more semantic-locating axis on probe-as-both values (an
15748 // author who removes the `!sudo` reference is likely to also
15749 // strip the paired `^` substitution fragment); same cascade
15750 // discipline every prior `:caminho` arm establishes.
15751 let d = dep_with_fonte(DepSource::Path {
15752 caminho: "../foo!sudo^bad^good".into(),
15753 });
15754 let err = d.validate().unwrap_err();
15755 assert!(
15756 matches!(
15757 err,
15758 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15759 ),
15760 "got {err:?}",
15761 );
15762 }
15763
15764 #[test]
15765 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15766 // Cascade pin on the immediate-successor arm: a value carrying
15767 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15768 // the canonical "I tab-completed a `^bad^good`-carrying path")
15769 // routes through `FonteCaminhoShellHistorySubstitution` not
15770 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15771 // substitution byte is the more semantic-locating axis on probe-
15772 // as-both values (an author who removes the `^bad^good`
15773 // substitution fragment is likely to also tab-strip the trailing
15774 // separator).
15775 let d = dep_with_fonte(DepSource::Path {
15776 caminho: "../foo^bad^good/".into(),
15777 });
15778 let err = d.validate().unwrap_err();
15779 assert!(
15780 matches!(
15781 err,
15782 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15783 ),
15784 "got {err:?}",
15785 );
15786 }
15787
15788 #[test]
15789 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15790 {
15791 // Diagnostic-shape pin (peer with
15792 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15793 // on the immediate-predecessor arm): the error's Display
15794 // surfaces the offending `:nome`, the offending `:caminho`
15795 // verbatim, the offending byte's hex form, and names the
15796 // shell-history-substitution / RFC-3986-'unwise' / regex-
15797 // negation footgun explicitly so a `feira lint` run can render
15798 // the diagnostic without re-parsing.
15799 let d = dep_with_fonte(DepSource::Path {
15800 caminho: "../foo^bad^good".into(),
15801 });
15802 let rendered = d.validate().unwrap_err().to_string();
15803 assert!(
15804 rendered.contains("caixa-teia"),
15805 "diagnostic must name the offending dep: {rendered}",
15806 );
15807 assert!(
15808 rendered.contains("../foo^bad^good"),
15809 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15810 );
15811 assert!(
15812 rendered.contains("0x5e") || rendered.contains("0x5E"),
15813 "diagnostic must surface the offending byte hex: {rendered:?}",
15814 );
15815 assert!(
15816 rendered.contains("history-substitution") || rendered.contains("history substitution"),
15817 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15818 );
15819 assert!(
15820 rendered.contains("unwise"),
15821 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15822 );
15823 }
15824
15825 #[test]
15826 fn fonte_repo_empty_fires_before_pin_missing() {
15827 // Order pin: empty `:repo` is the more self-locating diagnostic
15828 // (every git source needs a repo; the pin discussion is
15829 // secondary), so it fires before the pin-missing arm even when
15830 // both are violated. Mirrors the
15831 // `nome_empty_takes_precedence_over_versao_invalid` ordering
15832 // discipline on the per-entry layer.
15833 let d = dep_with_fonte(DepSource::Git {
15834 repo: String::new(),
15835 tag: None,
15836 rev: None,
15837 branch: None,
15838 });
15839 let err = d.validate().unwrap_err();
15840 assert!(
15841 matches!(err, DepError::FonteRepoEmpty { .. }),
15842 "got {err:?}"
15843 );
15844 }
15845
15846 #[test]
15847 fn fonte_pin_missing_fires_before_pin_empty() {
15848 // Order pin: a fully-None pin set is structurally distinct from
15849 // a Some(empty) pin — the first surfaces as FontePinMissing
15850 // (no axis chosen), the second as FontePinEmpty (axis chosen
15851 // but value blank). Pin the disjoint relationship so a future
15852 // unification collapses to one variant only as a structural
15853 // decision.
15854 let d = dep_with_fonte(DepSource::Git {
15855 repo: "github:pleme-io/caixa-teia".into(),
15856 tag: None,
15857 rev: None,
15858 branch: None,
15859 });
15860 assert!(matches!(
15861 d.validate().unwrap_err(),
15862 DepError::FontePinMissing { .. }
15863 ));
15864 }
15865
15866 #[test]
15867 fn nome_empty_takes_precedence_over_fonte_invalid() {
15868 // Order pin: a per-entry diagnostic without a non-empty :nome
15869 // can't be self-locating, so :nome "" fires first even when
15870 // :fonte is also malformed. Mirrors
15871 // `nome_empty_takes_precedence_over_versao_invalid` on the
15872 // adjacent axis.
15873 let mut d = dep_with_fonte(DepSource::Git {
15874 repo: String::new(),
15875 tag: None,
15876 rev: None,
15877 branch: None,
15878 });
15879 d.nome = String::new();
15880 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15881 }
15882
15883 #[test]
15884 fn versao_invalid_takes_precedence_over_fonte_invalid() {
15885 // Order pin: the :versao parse-side diagnostic is narrower than
15886 // the :fonte shape diagnostic — a malformed :versao always names
15887 // the parser's reason, which is more actionable than the
15888 // :fonte gate's "the pins are wrong" wording. Pin the ordering
15889 // so a re-ordering surfaces here.
15890 let mut d = dep_with_fonte(DepSource::Git {
15891 repo: String::new(),
15892 tag: None,
15893 rev: None,
15894 branch: None,
15895 });
15896 d.versao = "v0.1".into();
15897 let err = d.validate().unwrap_err();
15898 assert!(
15899 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15900 "got {err:?}"
15901 );
15902 }
15903
15904 #[test]
15905 fn fonte_invalid_diagnostic_carries_offending_nome() {
15906 // The diagnostic-shape pin: every :fonte error variant names
15907 // the offending dep's :nome verbatim, so the author can grep
15908 // caixa.lisp for the `:nome "<n>"` block and fix it in one
15909 // edit. Cover all seven variants so a future variant addition
15910 // forces a parallel diagnostic-shape decision.
15911 for (case, fonte) in [
15912 (
15913 "repo-empty",
15914 DepSource::Git {
15915 repo: String::new(),
15916 tag: Some("v1".into()),
15917 rev: None,
15918 branch: None,
15919 },
15920 ),
15921 (
15922 "repo-shape",
15923 DepSource::Git {
15924 repo: "github:p/x ".into(),
15925 tag: Some("v1".into()),
15926 rev: None,
15927 branch: None,
15928 },
15929 ),
15930 (
15931 "pin-missing",
15932 DepSource::Git {
15933 repo: "github:p/x".into(),
15934 tag: None,
15935 rev: None,
15936 branch: None,
15937 },
15938 ),
15939 (
15940 "pin-ambiguous",
15941 DepSource::Git {
15942 repo: "github:p/x".into(),
15943 tag: Some("v1".into()),
15944 rev: None,
15945 branch: Some("main".into()),
15946 },
15947 ),
15948 (
15949 "pin-empty",
15950 DepSource::Git {
15951 repo: "github:p/x".into(),
15952 tag: Some(String::new()),
15953 rev: None,
15954 branch: None,
15955 },
15956 ),
15957 (
15958 "caminho-empty",
15959 DepSource::Path {
15960 caminho: String::new(),
15961 },
15962 ),
15963 (
15964 "caminho-absolute",
15965 DepSource::Path {
15966 caminho: "/home/me/work/caixa-teia".into(),
15967 },
15968 ),
15969 ] {
15970 let d = dep_with_fonte(fonte);
15971 let msg = d
15972 .validate()
15973 .expect_err(&format!("{case}: expected fonte error"))
15974 .to_string();
15975 assert!(
15976 msg.contains("\"caixa-teia\""),
15977 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15978 );
15979 }
15980 }
15981
15982 // -- :tag / :branch value-shape gate ----------------------------------
15983
15984 #[test]
15985 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15986 // The canonical paste-from-doc footgun on `:tag` — author
15987 // copies `"v0.1.0 "` (trailing space) out of a release-notes
15988 // paragraph. Until this gate landed the empty-pin arm passed
15989 // (the string isn't empty), the resolver issued
15990 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15991 // surfaced at clone time with a quoting-confused git error
15992 // far from the source caixa.lisp. The new gate moves the
15993 // check to caixa-build time and names the offending dep +
15994 // pin + value verbatim.
15995 let d = dep_with_fonte(DepSource::Git {
15996 repo: "github:pleme-io/caixa-teia".into(),
15997 tag: Some("v0.1.0 ".into()),
15998 rev: None,
15999 branch: None,
16000 });
16001 let err = d.validate().unwrap_err();
16002 let DepError::FontePinShape {
16003 nome,
16004 pin,
16005 value,
16006 reason,
16007 } = err
16008 else {
16009 panic!("expected FontePinShape, got other variant");
16010 };
16011 assert_eq!(nome, "caixa-teia");
16012 assert_eq!(pin, ":tag");
16013 assert_eq!(value, "v0.1.0 ");
16014 assert!(
16015 reason.contains("whitespace"),
16016 "reason must surface the whitespace arm, got {reason:?}"
16017 );
16018 }
16019
16020 #[test]
16021 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
16022 // The `.lock` suffix is git's atomic-rename guard for
16023 // in-flight ref updates — a refname ending in `.lock` is
16024 // unwritable on disk. Pinned separately from the whitespace
16025 // arm so a future relaxation that admits one but not the
16026 // other surfaces here.
16027 let d = dep_with_fonte(DepSource::Git {
16028 repo: "github:pleme-io/caixa-teia".into(),
16029 tag: Some("v0.1.0.lock".into()),
16030 rev: None,
16031 branch: None,
16032 });
16033 let err = d.validate().unwrap_err();
16034 let DepError::FontePinShape {
16035 pin, value, reason, ..
16036 } = err
16037 else {
16038 panic!("expected FontePinShape, got other variant");
16039 };
16040 assert_eq!(pin, ":tag");
16041 assert_eq!(value, "v0.1.0.lock");
16042 assert!(
16043 reason.contains(".lock"),
16044 "reason must surface the .lock arm, got {reason:?}"
16045 );
16046 }
16047
16048 #[test]
16049 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
16050 // The canonical "branch name with spaces" footgun (`feature
16051 // foo`, `release branch`) — git's refname parser rejects raw
16052 // whitespace, and the failure surfaces at `git checkout
16053 // 'feature foo'` time with a quoting-confused error far from
16054 // the source caixa.lisp. Pinned on the `:branch` axis so the
16055 // gate-applies-to-both-:tag-and-:branch contract is a build-
16056 // error to relax.
16057 let d = dep_with_fonte(DepSource::Git {
16058 repo: "github:pleme-io/caixa-teia".into(),
16059 tag: None,
16060 rev: None,
16061 branch: Some("feature/foo bar".into()),
16062 });
16063 let err = d.validate().unwrap_err();
16064 let DepError::FontePinShape {
16065 pin, value, reason, ..
16066 } = err
16067 else {
16068 panic!("expected FontePinShape, got other variant");
16069 };
16070 assert_eq!(pin, ":branch");
16071 assert_eq!(value, "feature/foo bar");
16072 assert!(
16073 reason.contains("whitespace"),
16074 "reason must surface the whitespace arm, got {reason:?}"
16075 );
16076 }
16077
16078 #[test]
16079 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
16080 // The `refs/heads/main` shape — the canonical "I copied the
16081 // fully-qualified ref out of `git show-ref` instead of the
16082 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
16083 // at clone time, so this resolves to a literal ref named
16084 // `refs/heads/refs/heads/main` on disk; the silent double-
16085 // prefix is the load-bearing reason to gate at validate.
16086 // The diagnostic must enumerate the leaf the author probably
16087 // meant (`"main"`) so the fix is one edit.
16088 let d = dep_with_fonte(DepSource::Git {
16089 repo: "github:pleme-io/caixa-teia".into(),
16090 tag: None,
16091 rev: None,
16092 branch: Some("refs/heads/main".into()),
16093 });
16094 let err = d.validate().unwrap_err();
16095 let DepError::FontePinShape {
16096 pin, value, reason, ..
16097 } = err
16098 else {
16099 panic!("expected FontePinShape, got other variant");
16100 };
16101 assert_eq!(pin, ":branch");
16102 assert_eq!(value, "refs/heads/main");
16103 assert!(
16104 reason.contains("fully-qualified"),
16105 "reason must surface the qualified-prefix arm, got {reason:?}"
16106 );
16107 assert!(
16108 reason.contains("\"main\""),
16109 "reason must quote the leaf the author probably meant, got {reason:?}"
16110 );
16111 }
16112
16113 #[test]
16114 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
16115 // Sibling arm of the qualified-prefix gate on the `:tag`
16116 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
16117 // footgun). Pinned separately so a future relaxation that
16118 // only catches the `:branch` arm surfaces here.
16119 let d = dep_with_fonte(DepSource::Git {
16120 repo: "github:pleme-io/caixa-teia".into(),
16121 tag: Some("refs/tags/v0.1.0".into()),
16122 rev: None,
16123 branch: None,
16124 });
16125 let err = d.validate().unwrap_err();
16126 let DepError::FontePinShape {
16127 pin, value, reason, ..
16128 } = err
16129 else {
16130 panic!("expected FontePinShape, got other variant");
16131 };
16132 assert_eq!(pin, ":tag");
16133 assert_eq!(value, "refs/tags/v0.1.0");
16134 assert!(
16135 reason.contains("fully-qualified"),
16136 "reason must surface the qualified-prefix arm, got {reason:?}"
16137 );
16138 assert!(
16139 reason.contains("\"v0.1.0\""),
16140 "reason must quote the leaf the author probably meant, got {reason:?}"
16141 );
16142 }
16143
16144 #[test]
16145 fn validate_rejects_git_fonte_with_branch_named_at() {
16146 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
16147 // unsourceable. Pinned so a future relaxation that admits
16148 // any single-character refname surfaces here.
16149 let d = dep_with_fonte(DepSource::Git {
16150 repo: "github:pleme-io/caixa-teia".into(),
16151 tag: None,
16152 rev: None,
16153 branch: Some("@".into()),
16154 });
16155 let err = d.validate().unwrap_err();
16156 let DepError::FontePinShape { pin, value, .. } = err else {
16157 panic!("expected FontePinShape, got other variant");
16158 };
16159 assert_eq!(pin, ":branch");
16160 assert_eq!(value, "@");
16161 }
16162
16163 #[test]
16164 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
16165 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
16166 // a `:tag "../escape"` (path-traversal-shaped slug) silently
16167 // passes parse and surfaces as a refname-parse error or, on
16168 // older git, a literal `../escape` checkout that escapes the
16169 // refs/ directory tree. Pinned separately from the
16170 // qualified-prefix arm so a future relaxation that catches
16171 // one but not the other surfaces here.
16172 let d = dep_with_fonte(DepSource::Git {
16173 repo: "github:pleme-io/caixa-teia".into(),
16174 tag: Some("../escape".into()),
16175 rev: None,
16176 branch: None,
16177 });
16178 let err = d.validate().unwrap_err();
16179 let DepError::FontePinShape { pin, value, .. } = err else {
16180 panic!("expected FontePinShape, got other variant");
16181 };
16182 assert_eq!(pin, ":tag");
16183 assert_eq!(value, "../escape");
16184 }
16185
16186 #[test]
16187 fn validate_accepts_git_fonte_with_hierarchical_branch() {
16188 // The positive-control pin: hierarchical refnames with one or
16189 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
16190 // canonical idiom) round-trip through the gate. Pinned
16191 // separately from the leaf-`"main"` positive control so a
16192 // future tightening that rejects all multi-component refnames
16193 // surfaces here.
16194 let d = dep_with_fonte(DepSource::Git {
16195 repo: "github:pleme-io/caixa-teia".into(),
16196 tag: None,
16197 rev: None,
16198 branch: Some("feature/checkout-rewrite".into()),
16199 });
16200 d.validate().unwrap();
16201 }
16202
16203 #[test]
16204 fn validate_accepts_git_fonte_with_prerelease_tag() {
16205 // The positive-control pin: semver pre-release shape
16206 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
16207 // (only consecutive `..` and trailing `.` are rejected), the
16208 // mid-component hyphen is allowed. Pinned separately from
16209 // the bare-`"v0.1.0"` positive control so a future tightening
16210 // that rejects pre-release tags surfaces here.
16211 let d = dep_with_fonte(DepSource::Git {
16212 repo: "github:pleme-io/caixa-teia".into(),
16213 tag: Some("v0.1.0-alpha.1".into()),
16214 rev: None,
16215 branch: None,
16216 });
16217 d.validate().unwrap();
16218 }
16219
16220 #[test]
16221 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
16222 // The `:rev` axis is routed through `crate::render::is_git_oid`
16223 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
16224 // value with refname-shape punctuation (here, a `:` mid-string
16225 // — would be a refname violation under `is_git_ref_name` too)
16226 // is rejected at the OID-shape gate. The two predicates
16227 // partition the `:fonte` pin axes structurally: an `:rev` value
16228 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
16229 // *still* rejected here because every refname character outside
16230 // `[0-9a-f]` fails the OID gate. Same shape as
16231 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
16232 // on the refname-shaped axes — the diagnostic names the
16233 // offending dep + pin + value verbatim. The flip-from-accept
16234 // case the prior `:tag`/`:branch` gate left as a "future axis"
16235 // (e70d213) — now landed.
16236 let d = dep_with_fonte(DepSource::Git {
16237 repo: "github:pleme-io/caixa-teia".into(),
16238 tag: None,
16239 rev: Some("c0ffee:notarefname".into()),
16240 branch: None,
16241 });
16242 let err = d.validate().unwrap_err();
16243 let DepError::FontePinShape {
16244 nome,
16245 pin,
16246 value,
16247 reason,
16248 } = err
16249 else {
16250 panic!("expected FontePinShape, got other variant");
16251 };
16252 assert_eq!(nome, "caixa-teia");
16253 assert_eq!(pin, ":rev");
16254 assert_eq!(value, "c0ffee:notarefname");
16255 assert!(
16256 !reason.is_empty(),
16257 "FontePinShape `reason` must carry the predicate's wording verbatim"
16258 );
16259 }
16260
16261 #[test]
16262 fn validate_accepts_git_fonte_with_rev_full_sha1() {
16263 // The positive-control pin on the SHA-1 OID width: exactly 40
16264 // lowercase hex characters — the canonical `git rev-parse HEAD`
16265 // emission on a SHA-1-hashed repository (the default on every
16266 // pre-2.42 git and the canonical pleme-io substrate hash).
16267 // Pinned separately from the SHA-256 positive control so a
16268 // future tightening that only admits one width surfaces here.
16269 let d = dep_with_fonte(DepSource::Git {
16270 repo: "github:pleme-io/caixa-teia".into(),
16271 tag: None,
16272 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
16273 branch: None,
16274 });
16275 d.validate().unwrap();
16276 }
16277
16278 #[test]
16279 fn validate_accepts_git_fonte_with_rev_full_sha256() {
16280 // The positive-control pin on the SHA-256 OID width: exactly
16281 // 64 lowercase hex characters — `git`'s
16282 // `extensions.objectFormat = sha256` emission (GA since Git
16283 // 2.42 / Oct 2023). The substrate admits either canonical
16284 // width so an `:rev` authored against a SHA-256-hashed
16285 // upstream round-trips through the gate without per-repo
16286 // configuration. Pinned separately from the SHA-1 positive
16287 // control so a future tightening that drops one width surfaces
16288 // here as a structural decision.
16289 let d = dep_with_fonte(DepSource::Git {
16290 repo: "github:pleme-io/caixa-teia".into(),
16291 tag: None,
16292 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
16293 branch: None,
16294 });
16295 d.validate().unwrap();
16296 }
16297
16298 #[test]
16299 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
16300 // The canonical `git log --short` / `git rev-parse --short HEAD`
16301 // paste-from-release-notes footgun: a 7-char prefix (git's
16302 // default `core.abbrev`) silently passes string emptiness
16303 // checks and resolves to one commit today, but becomes ambiguous
16304 // tomorrow as the repo grows. Until this gate landed the empty-
16305 // pin arm passed (the string isn't empty) and the resolver
16306 // accepted the prefix through git's separate prefix-lookup pass
16307 // — defeating the reproducibility contract `:rev` carries vs.
16308 // `:tag` / `:branch`. The new gate moves the check to caixa-
16309 // build time and names the offending dep + pin + value verbatim.
16310 let d = dep_with_fonte(DepSource::Git {
16311 repo: "github:pleme-io/caixa-teia".into(),
16312 tag: None,
16313 rev: Some("c0ffee0".into()),
16314 branch: None,
16315 });
16316 let err = d.validate().unwrap_err();
16317 let DepError::FontePinShape {
16318 pin, value, reason, ..
16319 } = err
16320 else {
16321 panic!("expected FontePinShape, got other variant");
16322 };
16323 assert_eq!(pin, ":rev");
16324 assert_eq!(value, "c0ffee0");
16325 assert!(
16326 reason.contains("abbreviated") || reason.contains("ambiguous"),
16327 "reason must surface the abbreviation arm, got {reason:?}"
16328 );
16329 }
16330
16331 #[test]
16332 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
16333 // The canonical "I pasted the SHA in uppercase" footgun: `git
16334 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
16335 // bearing `:rev` round-trips inconsistently across the
16336 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
16337 // equality-check pipeline and fails the lacre's content-
16338 // addressing probe with a confusing case-only diff. Pinned
16339 // separately from the non-hex arm so a future relaxation that
16340 // admits one but not the other surfaces here.
16341 let d = dep_with_fonte(DepSource::Git {
16342 repo: "github:pleme-io/caixa-teia".into(),
16343 tag: None,
16344 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
16345 branch: None,
16346 });
16347 let err = d.validate().unwrap_err();
16348 let DepError::FontePinShape {
16349 pin, value, reason, ..
16350 } = err
16351 else {
16352 panic!("expected FontePinShape, got other variant");
16353 };
16354 assert_eq!(pin, ":rev");
16355 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
16356 assert!(
16357 reason.contains("uppercase"),
16358 "reason must surface the uppercase arm, got {reason:?}"
16359 );
16360 }
16361
16362 #[test]
16363 fn validate_rejects_git_fonte_with_rev_refname_value() {
16364 // The cross-axis mis-slot footgun: `:rev "main"` — the author
16365 // conflated `:rev` (hex commit ID, immutable) and `:branch`
16366 // (mutable ref pointing at whatever HEAD is today). Until this
16367 // gate landed the resolver silently dispatched on the value
16368 // shape ("`main` doesn't look like a SHA, fall back to
16369 // refname"), defeating the `:rev` reproducibility contract.
16370 // The new gate rejects every non-hex value on the `:rev` axis,
16371 // so the `:rev`/`:branch` boundary is structurally enforced —
16372 // a refname in the `:rev` slot is a build error, not a
16373 // resolver-time silent reinterpretation.
16374 let d = dep_with_fonte(DepSource::Git {
16375 repo: "github:pleme-io/caixa-teia".into(),
16376 tag: None,
16377 rev: Some("main".into()),
16378 branch: None,
16379 });
16380 let err = d.validate().unwrap_err();
16381 let DepError::FontePinShape {
16382 pin, value, reason, ..
16383 } = err
16384 else {
16385 panic!("expected FontePinShape, got other variant");
16386 };
16387 assert_eq!(pin, ":rev");
16388 assert_eq!(value, "main");
16389 // 4 chars `main` fails the length arm before the character arm,
16390 // so the diagnostic surfaces the abbreviation wording (same
16391 // path the `c0ffee0` 7-char fixture lands on); the structural
16392 // assertion is just that the `:rev "main"` value is rejected.
16393 assert!(
16394 !reason.is_empty(),
16395 "FontePinShape reason must be non-empty for refname-shaped :rev"
16396 );
16397 }
16398
16399 #[test]
16400 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
16401 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
16402 // conflated `:rev` and `:tag`. Pinned separately from the
16403 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
16404 // that catches one but not the other surfaces here. The
16405 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
16406 // assertion is just that the cross-axis mis-slot is a build
16407 // error, regardless of which sub-arm surfaces the diagnostic
16408 // (`is_git_oid` rejects at the first violation; longer
16409 // tag-shape values would hit the non-hex arm instead).
16410 let d = dep_with_fonte(DepSource::Git {
16411 repo: "github:pleme-io/caixa-teia".into(),
16412 tag: None,
16413 rev: Some("v0.1.0".into()),
16414 branch: None,
16415 });
16416 let err = d.validate().unwrap_err();
16417 let DepError::FontePinShape {
16418 pin, value, reason, ..
16419 } = err
16420 else {
16421 panic!("expected FontePinShape, got other variant");
16422 };
16423 assert_eq!(pin, ":rev");
16424 assert_eq!(value, "v0.1.0");
16425 assert!(
16426 !reason.is_empty(),
16427 "FontePinShape reason must be non-empty for tag-shaped :rev"
16428 );
16429 }
16430
16431 #[test]
16432 fn validate_rejects_git_fonte_with_rev_too_long() {
16433 // Boundary case on the upper end: 41 hex chars — one past the
16434 // SHA-1 width, well below the SHA-256 width. Pin so a future
16435 // relaxation that admits "long enough to be a SHA" without
16436 // matching either canonical width surfaces here. The diagnostic
16437 // names the offending length verbatim so the author's grep
16438 // target is unambiguous (either trim one char or paste the
16439 // full SHA-256).
16440 let too_long: String = "0".repeat(41);
16441 let d = dep_with_fonte(DepSource::Git {
16442 repo: "github:pleme-io/caixa-teia".into(),
16443 tag: None,
16444 rev: Some(too_long.clone()),
16445 branch: None,
16446 });
16447 let err = d.validate().unwrap_err();
16448 let DepError::FontePinShape {
16449 pin, value, reason, ..
16450 } = err
16451 else {
16452 panic!("expected FontePinShape, got other variant");
16453 };
16454 assert_eq!(pin, ":rev");
16455 assert_eq!(value, too_long);
16456 assert!(
16457 reason.contains("41"),
16458 "reason must surface the offending length verbatim, got {reason:?}"
16459 );
16460 }
16461
16462 #[test]
16463 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
16464 // The canonical paste-from-doc footgun on `:rev` — author
16465 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
16466 // commit-message paragraph. Until this gate landed the empty-
16467 // pin arm passed (the string isn't empty), the resolver issued
16468 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
16469 // clone time with a quoting-confused git error far from the
16470 // source caixa.lisp. The new gate moves the check to caixa-
16471 // build time. Length is 41 (40 hex + space) so the length arm
16472 // fires first — pinned separately from the pure-length arm to
16473 // ensure the diagnostic surfaces *some* parser wording, not
16474 // silently pass through.
16475 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
16476 let d = dep_with_fonte(DepSource::Git {
16477 repo: "github:pleme-io/caixa-teia".into(),
16478 tag: None,
16479 rev: Some(with_space.clone()),
16480 branch: None,
16481 });
16482 let err = d.validate().unwrap_err();
16483 let DepError::FontePinShape {
16484 pin, value, reason, ..
16485 } = err
16486 else {
16487 panic!("expected FontePinShape, got other variant");
16488 };
16489 assert_eq!(pin, ":rev");
16490 assert_eq!(value, with_space);
16491 assert!(
16492 !reason.is_empty(),
16493 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
16494 );
16495 }
16496
16497 #[test]
16498 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
16499 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
16500 // variant on this axis names the offending dep's `:nome` + the
16501 // `:rev` axis + the offending value verbatim, so the author's
16502 // grep target is the literal `:rev "<value>"` block in
16503 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
16504 // carries_offending_nome_pin_value` test on the refname-shaped
16505 // (`:tag` / `:branch`) axes.
16506 let d = dep_with_fonte(DepSource::Git {
16507 repo: "github:p/x".into(),
16508 tag: None,
16509 rev: Some("not-a-sha".into()),
16510 branch: None,
16511 });
16512 let msg = d
16513 .validate()
16514 .expect_err(":rev: expected FontePinShape")
16515 .to_string();
16516 assert!(
16517 msg.contains("\"caixa-teia\""),
16518 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16519 );
16520 assert!(
16521 msg.contains(":rev"),
16522 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
16523 );
16524 assert!(
16525 msg.contains("not-a-sha"),
16526 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
16527 );
16528 }
16529
16530 #[test]
16531 fn fonte_pin_empty_fires_before_pin_shape() {
16532 // Order pin: a `Some("")` `:tag` is the more self-locating
16533 // diagnostic (the author chose an axis but left it blank;
16534 // grep is unambiguous), so it fires before the shape gate
16535 // even when both arms would match. Pinned so a future
16536 // reordering surfaces here. Mirrors the
16537 // `fonte_repo_empty_fires_before_pin_missing` ordering
16538 // discipline on the peer per-axis arms.
16539 let d = dep_with_fonte(DepSource::Git {
16540 repo: "github:pleme-io/caixa-teia".into(),
16541 tag: Some(String::new()),
16542 rev: None,
16543 branch: None,
16544 });
16545 assert!(matches!(
16546 d.validate().unwrap_err(),
16547 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16548 ));
16549 }
16550
16551 #[test]
16552 fn fonte_pin_shape_fires_after_repo_empty() {
16553 // Order pin: `:repo ""` is the more self-locating axis
16554 // (every git source needs a repo; the per-pin shape gate is
16555 // secondary), so the repo-empty arm fires before the
16556 // per-pin shape arm even when both are violated. Pinned so
16557 // a future reordering surfaces here. Mirrors
16558 // `fonte_repo_empty_fires_before_pin_missing` on the
16559 // adjacent axis pair.
16560 let d = dep_with_fonte(DepSource::Git {
16561 repo: String::new(),
16562 tag: Some("v0.1.0 ".into()),
16563 rev: None,
16564 branch: None,
16565 });
16566 assert!(matches!(
16567 d.validate().unwrap_err(),
16568 DepError::FonteRepoEmpty { .. }
16569 ));
16570 }
16571
16572 #[test]
16573 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16574 // Diagnostic-shape pin across both refname-shaped axes
16575 // (`:tag` + `:branch`): every `FontePinShape` variant names
16576 // the offending dep's `:nome` + the offending pin axis + the
16577 // offending value verbatim, so the author's grep target is
16578 // unambiguous (the literal `:tag "<value>"` / `:branch
16579 // "<value>"` lands in caixa.lisp with quotes). Cover both
16580 // pin axes so a future variant addition forces a parallel
16581 // diagnostic-shape decision.
16582 for (pin_label, fonte) in [
16583 (
16584 ":tag",
16585 DepSource::Git {
16586 repo: "github:p/x".into(),
16587 tag: Some("v0.1.0~1".into()),
16588 rev: None,
16589 branch: None,
16590 },
16591 ),
16592 (
16593 ":branch",
16594 DepSource::Git {
16595 repo: "github:p/x".into(),
16596 tag: None,
16597 rev: None,
16598 branch: Some("feature/foo*".into()),
16599 },
16600 ),
16601 ] {
16602 let d = dep_with_fonte(fonte);
16603 let msg = d
16604 .validate()
16605 .expect_err(&format!("{pin_label}: expected FontePinShape"))
16606 .to_string();
16607 assert!(
16608 msg.contains("\"caixa-teia\""),
16609 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16610 );
16611 assert!(
16612 msg.contains(pin_label),
16613 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16614 );
16615 }
16616 }
16617
16618 #[test]
16619 fn git_source_json_round_trip() {
16620 let src = DepSource::Git {
16621 repo: "github:pleme-io/caixa-teia".into(),
16622 tag: Some("v0.1.0".into()),
16623 rev: None,
16624 branch: None,
16625 };
16626 let s = serde_json::to_string(&src).unwrap();
16627 assert!(s.contains(&format!(
16628 r#""{tipo}":"{git}""#,
16629 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16630 git = crate::render::DEP_SOURCE_TIPO_GIT,
16631 )));
16632 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16633 assert!(s.contains(r#""tag":"v0.1.0""#));
16634 assert!(!s.contains("rev"));
16635 assert!(!s.contains("branch"));
16636 let round: DepSource = serde_json::from_str(&s).unwrap();
16637 assert_eq!(round, src);
16638 }
16639
16640 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16641 //
16642 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16643 // attribute on [`DepSource`] pins three load-bearing byte-sequences
16644 // that flow into every serialized `Dep.fonte` block: the outer
16645 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16646 // the two admitted variant-tag values `"git"` / `"path"` the
16647 // `rename_all = "lowercase"` attribute pins as the discriminator's
16648 // closed-set arms. The three pin tests below round-trip a
16649 // fully-populated variant of each arm through
16650 // [`serde_json::to_value`] and assert each canonical byte-sequence
16651 // appears at its axis — pins a hypothetical future
16652 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16653 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16654 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16655 // at build time rather than at fetch time when the resolver's
16656 // `Dep.fonte` dispatch silently fails to match on the drifted
16657 // discriminator. Same "serialize-and-check" discipline the peer
16658 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16659 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16660 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16661 // family in caixa-core lacking a lifted peer.
16662
16663 #[test]
16664 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16665 // Fail-before-pass-after: a future `tag = "type"` at the derive
16666 // attribute would serialize under `"type":"git"`, and this test
16667 // would trip because `"tipo"` no longer appears at the emitted
16668 // discriminator key. A future `rename_all = "kebab-case"` /
16669 // `"snake_case"` (both no-ops on `Git` since it lacks internal
16670 // word boundaries) is caught by the sibling
16671 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16672 // pin below (Path has no internal boundary either but the pair
16673 // catches any per-arm inconsistency). A future variant rename
16674 // `Git` → `Repository` would emit `"tipo":"repository"` and
16675 // trip this pin.
16676 let src = DepSource::Git {
16677 repo: "github:pleme-io/caixa-teia".into(),
16678 tag: Some("v0.1.0".into()),
16679 rev: None,
16680 branch: None,
16681 };
16682 let json = serde_json::to_value(&src).unwrap();
16683 let obj = json.as_object().expect("Git serializes as a JSON object");
16684 assert_eq!(
16685 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16686 .and_then(serde_json::Value::as_str),
16687 Some(crate::render::DEP_SOURCE_TIPO_GIT),
16688 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16689 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16690 detected in {json}"
16691 );
16692 }
16693
16694 #[test]
16695 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16696 // Fail-before-pass-after: a future variant rename `Path` →
16697 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16698 // this pin. A per-consumer disambiguation as the `defcaixa`
16699 // macro stabilizes ("caminho" → "path" for English-uniformity)
16700 // is scoped to the inner field key, not the discriminator; this
16701 // pin is orthogonal to that and catches only the outer
16702 // discriminator drift.
16703 let src = DepSource::Path {
16704 caminho: "../caixa-teia".into(),
16705 };
16706 let json = serde_json::to_value(&src).unwrap();
16707 let obj = json.as_object().expect("Path serializes as a JSON object");
16708 assert_eq!(
16709 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16710 .and_then(serde_json::Value::as_str),
16711 Some(crate::render::DEP_SOURCE_TIPO_PATH),
16712 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16713 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16714 detected in {json}"
16715 );
16716 }
16717
16718 #[test]
16719 fn dep_source_key_consts_are_pairwise_distinct() {
16720 // Cross-axis collapse detector: a hypothetical future edit that
16721 // accidentally set two of the three consts to the same byte
16722 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16723 // pass every per-arm serialize pin above but silently collapse
16724 // the discriminator's closed-set arms onto one another; this pin
16725 // catches the collapse at build time.
16726 assert_ne!(
16727 crate::render::DEP_SOURCE_KEY_TIPO,
16728 crate::render::DEP_SOURCE_TIPO_GIT,
16729 );
16730 assert_ne!(
16731 crate::render::DEP_SOURCE_KEY_TIPO,
16732 crate::render::DEP_SOURCE_TIPO_PATH,
16733 );
16734 assert_ne!(
16735 crate::render::DEP_SOURCE_TIPO_GIT,
16736 crate::render::DEP_SOURCE_TIPO_PATH,
16737 );
16738 }
16739
16740 #[test]
16741 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16742 // Shape pin against `rename_all` drift: the two variant-tag
16743 // consts must be ASCII-lowercase-only to match the
16744 // `rename_all = "lowercase"` attribute the derive uses; a future
16745 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16746 // would emit `"GIT"` / `"Git"` instead and trip this pin.
16747 for (label, s) in [
16748 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16749 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16750 ] {
16751 assert!(!s.is_empty(), "{label} must not be empty");
16752 assert!(
16753 s.bytes().all(|b| b.is_ascii_lowercase()),
16754 "{label} must be ASCII-lowercase-only (matching \
16755 rename_all = \"lowercase\"), got {s:?}",
16756 );
16757 }
16758 }
16759
16760 // ── per-entry :caracteristicas set-not-multiset gate ────────────
16761 //
16762 // Every Vec-keyed-by-name authoring surface on the typed Caixa
16763 // surface that identifies its entries by a name field now uniformly
16764 // closes the set-not-multiset discipline at build time (cite
16765 // `validate_caracteristicas`'s peer-axis enumeration). The
16766 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16767 // set-shaped (a feature is either enabled or not — there is no
16768 // `feature × 2` semantic), so two entries naming the same feature
16769 // are a redundant declaration the caixa-resolver's lacre pipeline
16770 // would silently dedup at resolve time. The empty-feature arm
16771 // closes the parallel "operationally-meaningless value" axis on
16772 // the same slot. Same linear-walk + `HashSet` + first-collision
16773 // shape every peer set gate uses; same empty-first cascade every
16774 // peer per-entry shape + duplicate gate uses (the empty-feature
16775 // axis is the more-actionable defect since two `""` entries would
16776 // both report `caracteristica: ""` under a duplicate-first
16777 // ordering, with no way to distinguish the offending site).
16778
16779 fn dep_with_features(features: &[&str]) -> Dep {
16780 Dep {
16781 nome: "caixa-teia".into(),
16782 versao: "^0.1".into(),
16783 fonte: None,
16784 opcional: false,
16785 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16786 }
16787 }
16788
16789 #[test]
16790 fn validate_rejects_empty_caracteristica() {
16791 // Fail-before-pass-after pin: every pre-gate codebase accepted
16792 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16793 // imposed no per-entry shape contract), the dep validated, and
16794 // the empty feature would have reached the future caixa-resolver
16795 // lacre pipeline as a no-op feature enable — silently dropping
16796 // the author's intent far from the source `caixa.lisp`. The new
16797 // gate surfaces the structural defect at the typed-validate
16798 // surface with a self-locating diagnostic naming the offending
16799 // dep's `:nome`.
16800 let d = dep_with_features(&[""]);
16801 assert!(
16802 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16803 "expected CaracteristicaEmpty, got {:?}",
16804 d.validate(),
16805 );
16806 }
16807
16808 #[test]
16809 fn validate_rejects_duplicate_caracteristica() {
16810 // Fail-before-pass-after pin on the set-not-multiset arm: the
16811 // feature-toggle slot is set-shaped, so `(:caracteristicas
16812 // ("http" "http"))` is a redundant declaration the lacre
16813 // pipeline dedupes silently at resolve time. The diagnostic
16814 // names the offending dep + the colliding feature verbatim so
16815 // the author can grep their caixa.lisp for `:caracteristicas`
16816 // and fix it in one edit. First-collision determinism is
16817 // pinned separately below.
16818 let d = dep_with_features(&["http", "http"]);
16819 assert!(
16820 matches!(
16821 d.validate().unwrap_err(),
16822 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16823 if nome == "caixa-teia" && caracteristica == "http"
16824 ),
16825 "expected CaracteristicaDuplicate, got {:?}",
16826 d.validate(),
16827 );
16828 }
16829
16830 #[test]
16831 fn validate_accepts_distinct_caracteristicas() {
16832 // The canonical authoring shape — every feature distinct — must
16833 // remain a clean pass (positive control sweep). Covers the
16834 // canonical kebab-case feature names a target caixa typically
16835 // declares.
16836 dep_with_features(&["http", "json", "tls"])
16837 .validate()
16838 .unwrap();
16839 }
16840
16841 #[test]
16842 fn validate_accepts_single_caracteristica() {
16843 // Single-element list is the minimum non-empty shape; passes
16844 // the gate as the identity of the duplicate check (no second
16845 // entry to collide with).
16846 dep_with_features(&["http"]).validate().unwrap();
16847 }
16848
16849 #[test]
16850 fn validate_accepts_empty_caracteristicas_list() {
16851 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16852 // produces `caracteristicas: Vec::new()`; the empty list is
16853 // the gate's empty-set identity and passes vacuously. Pin
16854 // this so a future tightening that requires ≥1 feature
16855 // surfaces here as a test failure rather than a silent
16856 // contract narrowing.
16857 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16858 assert!(dep_with_features(&[]).validate().is_ok());
16859 }
16860
16861 #[test]
16862 fn validate_caracteristica_empty_fires_before_duplicate() {
16863 // Empty-first cascade: an entry with an empty feature *and*
16864 // duplicate entries surfaces the empty diagnostic first. The
16865 // empty-feature axis is the more-actionable defect since
16866 // `caracteristica: ""` is unambiguous; under duplicate-first
16867 // ordering the diagnostic could report the empty string from
16868 // either of two empty entries with no way to distinguish.
16869 // Mirrors the peer empty-before-duplicate ordering
16870 // discipline every per-entry shape + duplicate gate establishes
16871 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16872 // `DuplicateChildCaixa`, `validate_membros`'s
16873 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16874 let d = dep_with_features(&["", "http", "http"]);
16875 assert!(matches!(
16876 d.validate().unwrap_err(),
16877 DepError::CaracteristicaEmpty { .. }
16878 ));
16879 }
16880
16881 #[test]
16882 fn validate_caracteristica_duplicate_first_collision_determinism() {
16883 // Three matching entries: the second occurrence surfaces the
16884 // diagnostic (the second is the first *collision* — the first
16885 // entry is the establishing one, not a duplicate). Mirrors
16886 // every peer first-collision posture
16887 // (`SupervisorError::DuplicateChildCaixa` reports the second
16888 // collision, `AplicacaoError::MembroDuplicate` reports the
16889 // second, `DepError::DuplicateNome` reports the second).
16890 // Pinning this so a future shortcut that flips to last-
16891 // collision (or non-deterministic) surfaces here.
16892 let d = dep_with_features(&["http", "http", "http"]);
16893 assert!(matches!(
16894 d.validate().unwrap_err(),
16895 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16896 ));
16897 }
16898
16899 #[test]
16900 fn validate_per_entry_shape_fires_before_caracteristicas() {
16901 // Per-entry shape precedence: a dep with a malformed `:nome`
16902 // (uppercase) AND duplicate `:caracteristicas` surfaces the
16903 // narrower `NomeInvalid` diagnostic first, not the set-gate
16904 // diagnostic. The `:nome` is the self-locating axis (every
16905 // diagnostic from the caracteristicas gate quotes the
16906 // offending dep's `:nome` to anchor the grep target —
16907 // surfacing the malformed name first keeps that anchor
16908 // valid). Same precedence shape every peer per-entry-shape
16909 // arm establishes against its peer set-gate
16910 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16911 // on the cross-entry `:nome` axis).
16912 let d = Dep {
16913 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16914 versao: "^0.1".into(),
16915 fonte: None,
16916 opcional: false,
16917 caracteristicas: vec!["http".into(), "http".into()],
16918 };
16919 assert!(matches!(
16920 d.validate().unwrap_err(),
16921 DepError::NomeInvalid { .. }
16922 ));
16923 }
16924
16925 // ── per-entry :caracteristicas value-shape gate ──────────────────
16926 //
16927 // Until this gate landed `:caracteristicas` only refused the empty
16928 // string and cross-entry duplicates: a non-empty distinct but
16929 // structurally invalid feature name silently passed validate and the
16930 // failure surfaced at `cargo metadata` time as Cargo's
16931 // `restricted_names::validate_feature_name` parser rejection, far from
16932 // the source `caixa.lisp` with no field naming which `:deps` entry's
16933 // `:caracteristicas` carried the typo. The lifted predicate makes the
16934 // Cargo-feature-name-grammar intersection-floor a substrate-level
16935 // invariant at validate time. Same trajectory as the eight peer
16936 // value-shape predicates each typed surface downstream of a structured
16937 // grammar already follows.
16938
16939 #[test]
16940 fn validate_rejects_caracteristica_with_leading_plus() {
16941 // Fail-before-pass-after pin on the canonical Cargo
16942 // `+<feature>` activation-form-in-feature-name-slot footgun.
16943 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16944 // `+optional-feature` as an enablement of a previously-disabled
16945 // feature; pasting that activation form into `:caracteristicas`
16946 // (which names the feature itself) silently passed pre-gate and
16947 // failed at `cargo metadata` parse time.
16948 let d = dep_with_features(&["+http"]);
16949 let err = d.validate().unwrap_err();
16950 assert!(
16951 matches!(
16952 err,
16953 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16954 if nome == "caixa-teia" && caracteristica == "+http"
16955 ),
16956 "expected CaracteristicaInvalid, got {err:?}"
16957 );
16958 }
16959
16960 #[test]
16961 fn validate_rejects_caracteristica_with_leading_hyphen() {
16962 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16963 // is a legitimate continuation character (kebab-case feature
16964 // names like `runtime-tokio` pass) but Cargo rejects it at the
16965 // start; the structural defect — and its CLI-argument-injection
16966 // adjacency at any downstream Cargo subprocess invocation — is
16967 // closed at validate time, not at `cargo metadata` time.
16968 let d = dep_with_features(&["-json"]);
16969 let err = d.validate().unwrap_err();
16970 assert!(
16971 matches!(
16972 err,
16973 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16974 ),
16975 "expected CaracteristicaInvalid, got {err:?}"
16976 );
16977 }
16978
16979 #[test]
16980 fn validate_rejects_caracteristica_with_leading_dot() {
16981 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16982 // a legitimate continuation character (version-suffix shapes
16983 // like `feat.v2` pass) but the leading-dot form is the
16984 // canonical dotted-version-suffix-as-feature-name confusion.
16985 let d = dep_with_features(&[".feat"]);
16986 let err = d.validate().unwrap_err();
16987 assert!(matches!(
16988 err,
16989 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16990 ));
16991 }
16992
16993 #[test]
16994 fn validate_rejects_caracteristica_with_whitespace() {
16995 // Fail-before-pass-after pin on the embedded-whitespace footgun:
16996 // a feature name with a space inside is structurally a multi-
16997 // token blob (the canonical paste-from-doc footgun, or an
16998 // accidental `"http server"` where the author meant
16999 // `"http-server"`).
17000 let d = dep_with_features(&["http feature"]);
17001 let err = d.validate().unwrap_err();
17002 assert!(matches!(
17003 err,
17004 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
17005 ));
17006 }
17007
17008 #[test]
17009 fn validate_rejects_caracteristica_with_comma() {
17010 // Fail-before-pass-after pin on the embedded-comma footgun:
17011 // the list-separator-belongs-to-the-list-grammar
17012 // miscomprehension where the author writes
17013 // `:caracteristicas ("http,json")` intending two features but
17014 // the `Vec<String>` field consumes the bare token as one entry.
17015 let d = dep_with_features(&["http,json"]);
17016 let err = d.validate().unwrap_err();
17017 assert!(matches!(
17018 err,
17019 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
17020 ));
17021 }
17022
17023 #[test]
17024 fn validate_rejects_caracteristica_with_slash() {
17025 // Fail-before-pass-after pin on the embedded-slash footgun:
17026 // Cargo's `dep/feat` namespaced-dep syntax applies inside
17027 // `[dependencies.<dep>.features]` list entries that already
17028 // name the parent dep (so the syntax says "enable feature
17029 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
17030 // per-dep already (a sibling slot on the `Dep` itself), so the
17031 // segment separator within an entry must be `-`, `_`, `+`,
17032 // or `.`. The diagnostic remediation points at the canonical
17033 // Cargo namespaced-dep discipline.
17034 let d = dep_with_features(&["http/json"]);
17035 let err = d.validate().unwrap_err();
17036 assert!(matches!(
17037 err,
17038 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
17039 ));
17040 }
17041
17042 #[test]
17043 fn validate_rejects_caracteristica_with_non_ascii() {
17044 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
17045 // byte footgun: NFC-vs-NFD normalization across filesystems
17046 // silently rewrites the feature-key, breaking the lacre's
17047 // content-addressing invariant. Pinned at a canonical
17048 // smart-quote-paste shape (`café`) where the raw `é` byte is the
17049 // documented APFS round-trip break.
17050 let d = dep_with_features(&["caf\u{e9}"]);
17051 let err = d.validate().unwrap_err();
17052 assert!(matches!(
17053 err,
17054 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
17055 ));
17056 }
17057
17058 #[test]
17059 fn validate_rejects_caracteristica_with_control_character() {
17060 // Fail-before-pass-after pin on the embedded-control-character
17061 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
17062 // feature name is the canonical paste-from-multiline-doc
17063 // footgun the predicate's reason wording specifically calls out.
17064 let d = dep_with_features(&["http\njson"]);
17065 let err = d.validate().unwrap_err();
17066 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
17067 }
17068
17069 #[test]
17070 fn validate_accepts_canonical_caracteristicas_shapes() {
17071 // Positive control sweep: every canonical Cargo feature name
17072 // shape the pleme-io ecosystem uses must still pass. Mirrors
17073 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
17074 // sweep — drift between either landing site and the predicate's
17075 // accepted set is a build error visible at this pair of tests,
17076 // not a per-renderer "this passed validate but failed at
17077 // cargo metadata time" surprise on the next acceptance.
17078 for s in [
17079 "http",
17080 "json",
17081 "derive",
17082 "serde_json",
17083 "runtime-tokio",
17084 "tokio.full",
17085 "v0.1",
17086 "http+json",
17087 "_internal",
17088 "__private",
17089 "default",
17090 "rt-multi-thread",
17091 "feat.v2",
17092 ] {
17093 let d = dep_with_features(&[s]);
17094 d.validate().unwrap_or_else(|e| {
17095 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
17096 });
17097 }
17098 }
17099
17100 #[test]
17101 fn validate_caracteristica_empty_fires_before_invalid() {
17102 // Cascade precedence pin: an entry list with both an empty
17103 // feature AND an invalid-shape feature surfaces the
17104 // `CaracteristicaEmpty` arm first (the empty value carries no
17105 // self-locating data — `caracteristica: ""` is the diagnostic
17106 // with no way to anchor a grep target — so closing the empty
17107 // axis first preserves the per-entry-shape diagnostic's
17108 // self-locating discipline). Same empty-first cascade every
17109 // peer per-entry shape gate establishes
17110 // (`SupervisorSpec::validate`'s `EmptyChildName` before
17111 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
17112 // before `MembroCaixaInvalid`).
17113 let d = dep_with_features(&["", "+http"]);
17114 assert!(matches!(
17115 d.validate().unwrap_err(),
17116 DepError::CaracteristicaEmpty { .. }
17117 ));
17118 }
17119
17120 #[test]
17121 fn validate_caracteristica_invalid_fires_before_duplicate() {
17122 // Per-entry-shape precedence pin: an entry list with the same
17123 // invalid feature shape declared twice surfaces the
17124 // `CaracteristicaInvalid` diagnostic on the first entry, not
17125 // the `CaracteristicaDuplicate` on the second collision. The
17126 // per-entry shape gate fires before the cross-entry set gate
17127 // — same precedence shape every peer two-arm-plus-set gate
17128 // establishes (`SupervisorSpec::validate`'s
17129 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
17130 // `validate_membros`'s `MembroCaixaInvalid` before
17131 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
17132 // cross-list `DuplicateNome`).
17133 let d = dep_with_features(&["+http", "+http"]);
17134 assert!(matches!(
17135 d.validate().unwrap_err(),
17136 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
17137 ));
17138 }
17139
17140 #[test]
17141 fn validate_rejects_caracteristica_at_65_byte_boundary() {
17142 // Boundary pin on the 64-byte cap — both the boundary-accepting
17143 // case and the boundary-exceeding case in one place, so a
17144 // future cap shift surfaces both arms simultaneously, mirroring
17145 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
17146 // predicate-level pin at the dep-axis landing site.
17147 let max_ok = "a".repeat(64);
17148 dep_with_features(&[&max_ok])
17149 .validate()
17150 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
17151 let too_long = "a".repeat(65);
17152 let d = dep_with_features(&[&too_long]);
17153 assert!(matches!(
17154 d.validate().unwrap_err(),
17155 DepError::CaracteristicaInvalid { .. }
17156 ));
17157 }
17158
17159 // ── self-dep cross-slot gate ─────────────────────────────────────
17160
17161 #[test]
17162 fn validate_no_self_dep_rejects_self_in_deps() {
17163 // A caixa whose `:deps` lists its own `:nome` is a one-node
17164 // cycle in the lacre closure's dep-graph traversal — rejected,
17165 // naming the parent and the offending list tag.
17166 let deps = vec![
17167 Dep::simple("caixa-teia", "^0.1"),
17168 Dep::simple("orquestra", "^0.1"),
17169 ];
17170 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17171 assert!(
17172 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17173 "got {err:?}"
17174 );
17175 }
17176
17177 #[test]
17178 fn validate_no_self_dep_rejects_self_in_deps_dev() {
17179 // Same gate on the `:deps-dev` axis — neither dep list is a
17180 // second-class citizen on the self-edge invariant.
17181 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17182 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17183 assert!(
17184 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17185 "got {err:?}"
17186 );
17187 }
17188
17189 #[test]
17190 fn validate_no_self_dep_deps_fires_before_deps_dev() {
17191 // Walk order pin: a caixa that self-references on both lists
17192 // surfaces the `:deps` arm first — the load-bearing axis the
17193 // lacre closure resolves at every build. Mirrors the canonical
17194 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
17195 let deps = vec![Dep::simple("orquestra", "^0.1")];
17196 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
17197 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
17198 assert!(
17199 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
17200 "got {err:?}"
17201 );
17202 }
17203
17204 #[test]
17205 fn validate_no_self_dep_accepts_distinct_names() {
17206 // Positive control: every dep names a distinct caixa. The
17207 // canonical author surface — peer of
17208 // [`validate_no_self_supervision_accepts_distinct_children`].
17209 let deps = vec![
17210 Dep::simple("caixa-teia", "^0.1"),
17211 Dep::simple("caixa-arch", "^0.1"),
17212 ];
17213 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
17214 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
17215 }
17216
17217 #[test]
17218 fn validate_no_self_dep_empty_lists_pass() {
17219 // A caixa with no declared deps has nothing to self-reference —
17220 // the gate is vacuously satisfied. Peer of
17221 // [`validate_no_self_supervision_empty_children_is_ok`].
17222 validate_no_self_dep(&[], &[], "orquestra").unwrap();
17223 }
17224
17225 #[test]
17226 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
17227 // Diagnostic-shape pin (peer with
17228 // [`validate_no_self_supervision`]'s diagnostic): the error's
17229 // Display surfaces both the offending list tag and the
17230 // parent's `:nome` verbatim, so the author can grep their
17231 // caixa.lisp for the offending block in one edit. Names
17232 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
17233 // surface — every legitimate "I want to use code from this
17234 // caixa" intent routes through one of those three slots.
17235 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17236 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
17237 .unwrap_err()
17238 .to_string();
17239 assert!(
17240 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17241 "diagnostic must name the offending list tag: {rendered}",
17242 );
17243 assert!(
17244 rendered.contains("orquestra"),
17245 "diagnostic must quote the parent caixa name: {rendered}",
17246 );
17247 assert!(
17248 rendered.contains(":bibliotecas"),
17249 "diagnostic must point at the corrective code-surface slot: {rendered}",
17250 );
17251 }
17252
17253 #[test]
17254 fn validate_no_self_dep_accepts_coincidental_substring_match() {
17255 // Identity is exact-string equality, not substring — a dep
17256 // named `"orquestra-helper"` is a distinct caixa even when the
17257 // parent is `"orquestra"`. Pin the exact-match discipline so a
17258 // future relaxation that uses `contains` surfaces here, peer
17259 // with the supervision-tree and Aplicacao-membership gates
17260 // which all use exact-string equality on the typed identity.
17261 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
17262 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17263 }
17264
17265 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
17266
17267 #[test]
17268 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
17269 // Scalar-value pin: the two author-facing kebab-case labels the
17270 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
17271 // the two-list dep-graph slot axis, one arm per typed slot.
17272 // Mirrors the peer scalar-value pin the sibling
17273 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
17274 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
17275 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
17276 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
17277 // (882f498) M3 top-level author-labels, and
17278 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
17279 // Supervisor top-level author-labels carry, so every kind-scoped
17280 // typed-slot-family axis routes through one canonical per-arm
17281 // declaration.
17282 //
17283 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
17284 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
17285 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
17286 // for symmetry) lands as an edit to exactly one const, and
17287 // every consumer that reaches for the label picks it up at
17288 // build time rather than at runtime as a downstream mismatch on
17289 // a `DepError::DuplicateNome { list: … }` diagnostic far from
17290 // the rename's commit.
17291 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
17292 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
17293 }
17294
17295 #[test]
17296 fn dep_author_key_consts_are_pairwise_distinct() {
17297 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
17298 // must not collapse onto one byte-string. A future copy-paste
17299 // slip that renamed both consts to the same value (or a rebrand
17300 // that dropped the `-dev` suffix from one but not the other)
17301 // would leave every `DepError::DuplicateNome { list: … }`
17302 // diagnostic naming an unattributable list — the linter would
17303 // route the author to the wrong caixa.lisp block, or the
17304 // cross-list precedence gate
17305 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
17306 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
17307 // duplicate. Peer of the sibling
17308 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
17309 // other top-level kind-scoped slot-family axes carry
17310 // (implicitly held by their different byte-values today).
17311 assert_ne!(
17312 crate::render::DEP_AUTHOR_KEY_DEPS,
17313 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17314 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
17315 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
17316 self-locates the offending block in the author's caixa.lisp",
17317 );
17318 }
17319
17320 #[test]
17321 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
17322 // Production-through-const pin: the two per-arm list tags
17323 // [`validate_no_self_dep`] threads onto the `list:` field of a
17324 // returned [`DepError::DepIsSelf`] route through the lifted
17325 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
17326 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
17327 // the walker (a rename that reaches one arm but not the const,
17328 // or vice versa) surfaces here at build time rather than at
17329 // runtime as a `feira lint` diagnostic naming the wrong list
17330 // tag. Mirror of the peer
17331 // [`crate::Caixa::declared_servico_slots`] production tagger
17332 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
17333 // onto the two-list dep-graph gate.
17334 let deps = vec![Dep::simple("orquestra", "^0.1")];
17335 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17336 let DepError::DepIsSelf { list, .. } = err else {
17337 panic!("expected DepIsSelf from :deps walk");
17338 };
17339 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
17340
17341 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17342 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17343 let DepError::DepIsSelf { list, .. } = err else {
17344 panic!("expected DepIsSelf from :deps-dev walk");
17345 };
17346 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
17347 }
17348
17349 // ── Dep::nome accessor pins ───────────────────────────────────────
17350 //
17351 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
17352 // projection over the plain-shorthand / explicit-git / explicit-path
17353 // fixture triad the [`Dep`] docstring lists (so the accessor's
17354 // accept-set is exercised across every author-surface `:fonte`
17355 // shape); by-borrow pointer identity so the projection stays
17356 // zero-copy at every consumer site; and validate-composition through
17357 // the [`validate_no_self_dep`] cross-slot gate reading its
17358 // parent-name equality check through the lifted accessor rather than
17359 // the raw field.
17360
17361 #[test]
17362 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
17363 // Plain-shorthand form (`:fonte None`).
17364 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
17365 // Explicit git-source form with a tag pin — same accessor path.
17366 assert_eq!(
17367 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
17368 "caixa-teia",
17369 );
17370 // Explicit path-source form.
17371 assert_eq!(
17372 Dep {
17373 nome: "caixa-teia".to_string(),
17374 versao: "0.1.0".to_string(),
17375 fonte: Some(DepSource::Path {
17376 caminho: "../caixa-teia".to_string(),
17377 }),
17378 opcional: false,
17379 caracteristicas: Vec::new(),
17380 }
17381 .nome(),
17382 "caixa-teia",
17383 );
17384 // The empty-string `:nome` sentinel (which [`Dep::validate`]
17385 // refuses through the [`DepError::NomeEmpty`] arm) still round-
17386 // trips as an empty `&str` through the accessor — the accessor is
17387 // a projection, not a gate; the gate is [`Dep::validate`].
17388 assert_eq!(Dep::simple("", "^0.1").nome(), "");
17389 }
17390
17391 #[test]
17392 fn dep_nome_is_by_borrow_pointer_identity() {
17393 // Zero-copy pin: the accessor must borrow into the field's own
17394 // storage, not clone. If a future rewrite regresses to
17395 // `self.nome.clone().leak()` or an owned-buffer shape, the two
17396 // pointers diverge and this pin fails at build time.
17397 let d = Dep::simple("caixa-teia", "^0.1");
17398 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
17399 }
17400
17401 // ── Dep::versao_requirement accessor pins ─────────────────────────
17402 //
17403 // Three coherence pins on the lifted `Dep::versao_requirement`
17404 // accessor: byte-equal projection over the plain-shorthand /
17405 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
17406 // lists plus the empty-sentinel that round-trips as `""` (the accessor
17407 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
17408 // borrow pointer identity so the projection stays zero-copy at every
17409 // consumer site; and validate-composition through the
17410 // [`crate::render::require_valid_versao_requirement`] cascade reading
17411 // its requirement-shape check through the lifted accessor rather than
17412 // the raw field.
17413 #[test]
17414 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
17415 // Plain-shorthand form (`:fonte None`).
17416 assert_eq!(
17417 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
17418 "^0.1",
17419 );
17420 // Explicit git-source form with a tag pin — same accessor path.
17421 assert_eq!(
17422 Dep::git(
17423 "caixa-teia",
17424 "~0.1.2",
17425 "github:pleme-io/caixa-teia",
17426 "v0.1.0"
17427 )
17428 .versao_requirement(),
17429 "~0.1.2",
17430 );
17431 // Explicit path-source form.
17432 assert_eq!(
17433 Dep {
17434 nome: "caixa-teia".to_string(),
17435 versao: "0.1.0".to_string(),
17436 fonte: Some(DepSource::Path {
17437 caminho: "../caixa-teia".to_string(),
17438 }),
17439 opcional: false,
17440 caracteristicas: Vec::new(),
17441 }
17442 .versao_requirement(),
17443 "0.1.0",
17444 );
17445 // The wildcard requirement (`"*"`) — the shorthand
17446 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
17447 // verbatim through the accessor as `"*"`, same byte-shape the
17448 // author wrote.
17449 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
17450 // The empty-string `:versao` sentinel (which [`Dep::validate`]
17451 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
17452 // trips as an empty `&str` through the accessor — the accessor is
17453 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
17454 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
17455 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
17456 }
17457
17458 #[test]
17459 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
17460 // Zero-copy pin: the accessor must borrow into the field's own
17461 // storage, not clone. If a future rewrite regresses to
17462 // `self.versao.clone().leak()` or an owned-buffer shape, the two
17463 // pointers diverge and this pin fails at build time. Peer of the
17464 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
17465 // discipline extended onto the requirement-carrying axis.
17466 let d = Dep::simple("caixa-teia", "^0.1");
17467 assert!(std::ptr::eq(
17468 d.versao_requirement().as_ptr(),
17469 d.versao.as_ptr(),
17470 ));
17471 }
17472
17473 #[test]
17474 fn dep_validate_reads_requirement_through_accessor() {
17475 // Composition pin: the [`Dep::validate`]
17476 // [`crate::render::require_valid_versao_requirement`] cascade
17477 // consumes the requirement string through the lifted accessor —
17478 // both the requirement-gate input and the
17479 // [`DepError::VersaoInvalid`] error-body carrier route through
17480 // `self.versao_requirement()`. A valid requirement passes
17481 // (positive control); a malformed-but-non-empty requirement fails
17482 // and the diagnostic quotes the offending byte-string verbatim
17483 // (same shape the accessor projects), so a future regression that
17484 // detoured the requirement carrier through a different byte-
17485 // string (say the parsed `VersionReq`'s `Display`, or a
17486 // normalized rewrite) would surface here at build time. The
17487 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
17488 // ahead of the parse arm, pinning the empty-first cascade the
17489 // accessor's `""` sentinel round-trip acknowledges.
17490 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17491 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
17492 assert!(
17493 matches!(
17494 &err,
17495 DepError::VersaoInvalid {
17496 nome,
17497 versao,
17498 ..
17499 } if nome == "caixa-teia" && versao == "v0.1",
17500 ),
17501 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
17502 );
17503 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
17504 assert!(
17505 matches!(
17506 &err,
17507 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
17508 ),
17509 "expected VersaoEmpty from the empty-first arm, got {err:?}",
17510 );
17511 }
17512
17513 // ── Dep::fonte accessor pins ──────────────────────────────────────
17514 //
17515 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
17516 // equal projection over the plain-shorthand (`:fonte None`) /
17517 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
17518 // docstring lists (so the accessor's accept-set is exercised across
17519 // every author-surface `:fonte` shape and both `DepSource` variants);
17520 // pointer identity so the borrowed reference points into the field's
17521 // own `Option<DepSource>` storage (not a cloned side-buffer); and
17522 // validate-composition through the [`Dep::validate`] gate reading
17523 // its per-`:fonte` [`DepSource::validate`] delegation through the
17524 // lifted accessor rather than the raw `if let Some(ref fonte) =
17525 // self.fonte` bracket.
17526
17527 #[test]
17528 fn dep_fonte_returns_declared_source_across_shapes() {
17529 // Plain-shorthand form — `:fonte` omitted, accessor projects
17530 // the `None` partition the resolver-side default-fill treats
17531 // as "resolve through `github:<default-org>/<nome>`".
17532 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
17533 // Explicit git-source form with a tag pin — same accessor path.
17534 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17535 match git.fonte() {
17536 Some(DepSource::Git {
17537 repo,
17538 tag,
17539 rev,
17540 branch,
17541 }) => {
17542 assert_eq!(repo, "github:pleme-io/caixa-teia");
17543 assert_eq!(tag.as_deref(), Some("v0.1.0"));
17544 assert!(rev.is_none());
17545 assert!(branch.is_none());
17546 }
17547 other => panic!("expected explicit git :fonte, got {other:?}"),
17548 }
17549 // Explicit path-source form — the dev-only local-filesystem
17550 // arm the [`Dep`] docstring's third fixture carries.
17551 let path = Dep {
17552 nome: "caixa-teia".to_string(),
17553 versao: "0.1.0".to_string(),
17554 fonte: Some(DepSource::Path {
17555 caminho: "../caixa-teia".to_string(),
17556 }),
17557 opcional: false,
17558 caracteristicas: Vec::new(),
17559 };
17560 match path.fonte() {
17561 Some(DepSource::Path { caminho }) => {
17562 assert_eq!(caminho, "../caixa-teia");
17563 }
17564 other => panic!("expected explicit path :fonte, got {other:?}"),
17565 }
17566 }
17567
17568 #[test]
17569 fn dep_fonte_is_by_borrow_pointer_identity() {
17570 // Zero-copy pin: the accessor must borrow into the field's own
17571 // `Option<DepSource>` storage, not clone into a side buffer. If
17572 // a future rewrite regresses to `self.fonte.clone()` or an
17573 // owned-buffer shape, the two pointers diverge and this pin
17574 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17575 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17576 // identity pins — same by-borrow discipline extended onto the
17577 // outer-`Dep` `Option<&Composite>` composite-reference axis.
17578 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17579 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17580 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17581 assert!(std::ptr::eq(accessed, raw));
17582 }
17583
17584 #[test]
17585 fn dep_validate_reads_fonte_through_accessor() {
17586 // Composition pin: [`Dep::validate`]'s per-`:fonte`
17587 // [`DepSource::validate`] delegation consumes the typed slot
17588 // through the lifted accessor — an author-omitted `:fonte`
17589 // still passes the outer gate (positive control), an explicit
17590 // well-formed git source with exactly one pin passes, and a
17591 // malformed git source (empty `:repo`) surfaces the
17592 // [`DepError::FonteRepoEmpty`] variant quoting the offending
17593 // dep's `:nome` verbatim so a future regression that detoured
17594 // the `:fonte` delegation through a different path (say a
17595 // per-scope override projector) would surface here at build
17596 // time. Peer of the sibling
17597 // `dep_validate_reads_requirement_through_accessor` composition
17598 // pin on the `:versao` axis.
17599 // Positive control 1: no `:fonte` at all.
17600 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17601 // Positive control 2: well-formed git source.
17602 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17603 .validate()
17604 .unwrap();
17605 // Negative control: empty `:repo` — the accessor still returns
17606 // `Some(&DepSource::Git { repo: "", … })` and the delegated
17607 // `DepSource::validate` gate raises the typed carrier.
17608 let bad = Dep {
17609 nome: "caixa-teia".to_string(),
17610 versao: "^0.1".to_string(),
17611 fonte: Some(DepSource::Git {
17612 repo: String::new(),
17613 tag: Some("v0.1.0".to_string()),
17614 rev: None,
17615 branch: None,
17616 }),
17617 opcional: false,
17618 caracteristicas: Vec::new(),
17619 };
17620 let err = bad.validate().unwrap_err();
17621 assert!(
17622 matches!(
17623 &err,
17624 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17625 ),
17626 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17627 );
17628 }
17629
17630 #[test]
17631 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17632 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17633 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17634 // own `:nome` through the lifted accessor rather than the raw
17635 // field. Fails-before-passes-after: with the accessor lifted the
17636 // gate reads its equality check through `dep.nome() ==
17637 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17638 // the diagnostic still names the offending list tag as expected.
17639 let deps = vec![Dep::simple("orquestra", "^0.1")];
17640 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17641 assert!(matches!(
17642 err,
17643 DepError::DepIsSelf {
17644 ref nome,
17645 list,
17646 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17647 ));
17648 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17649 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17650 assert!(matches!(
17651 err,
17652 DepError::DepIsSelf {
17653 ref nome,
17654 list,
17655 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17656 ));
17657 // A non-matching `:nome` passes through the accessor gate.
17658 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17659 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17660 }
17661
17662 // ── Dep::caracteristicas accessor pins ────────────────────────────
17663 //
17664 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17665 // byte-equal projection over the default-empty / single-entry /
17666 // multi-entry fixture triad (so the accessor's accept-set is
17667 // exercised across every author-surface `:caracteristicas` shape,
17668 // matching the peer sibling family's fixture-triad discipline); by-
17669 // borrow pointer identity so the projection stays zero-copy at every
17670 // consumer site; and validate-composition through the
17671 // [`Dep::validate_caracteristicas`] gate reading its per-entry
17672 // linear walk through the lifted accessor rather than the raw
17673 // `for c in &self.caracteristicas` bracket.
17674
17675 #[test]
17676 fn dep_caracteristicas_returns_declared_features_across_shapes() {
17677 // Default-empty form — the [`Dep::simple`] constructor's
17678 // `Vec::new()` fill; the accessor projects the empty slice
17679 // verbatim (no `None` collapse).
17680 assert!(
17681 Dep::simple("caixa-teia", "^0.1")
17682 .caracteristicas()
17683 .is_empty(),
17684 );
17685 // Single-entry form — the canonical Cargo-shaped one-feature
17686 // enable ([`crate::render::is_cargo_feature_name`] accepts the
17687 // `"http"` byte-string as a valid feature name).
17688 let one = Dep {
17689 nome: "caixa-teia".to_string(),
17690 versao: "^0.1".to_string(),
17691 fonte: None,
17692 opcional: false,
17693 caracteristicas: vec!["http".to_string()],
17694 };
17695 assert_eq!(one.caracteristicas(), &["http".to_string()]);
17696 // Multi-entry form — the substrate's set-shaped multi-feature
17697 // enable, exercising the accessor over a length-two slice with
17698 // no duplicate collapse.
17699 let two = Dep {
17700 nome: "caixa-teia".to_string(),
17701 versao: "^0.1".to_string(),
17702 fonte: None,
17703 opcional: false,
17704 caracteristicas: vec!["http".to_string(), "json".to_string()],
17705 };
17706 assert_eq!(
17707 two.caracteristicas(),
17708 &["http".to_string(), "json".to_string()],
17709 );
17710 }
17711
17712 #[test]
17713 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17714 // Zero-copy pin: the accessor must borrow into the field's own
17715 // `Vec<String>` storage, not clone into a side buffer. If a
17716 // future rewrite regresses to `self.caracteristicas.clone()` or
17717 // an owned-buffer shape, the two pointers diverge and this pin
17718 // fails at build time. Peer of the sibling per-`Dep`
17719 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17720 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17721 // borrow discipline extended onto the outer-`Dep` `&[String]`
17722 // slice-projection axis.
17723 let d = Dep {
17724 nome: "caixa-teia".to_string(),
17725 versao: "^0.1".to_string(),
17726 fonte: None,
17727 opcional: false,
17728 caracteristicas: vec!["http".to_string(), "json".to_string()],
17729 };
17730 assert!(std::ptr::eq(
17731 d.caracteristicas().as_ptr(),
17732 d.caracteristicas.as_ptr(),
17733 ));
17734 }
17735
17736 #[test]
17737 fn dep_validate_reads_caracteristicas_through_accessor() {
17738 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17739 // linear walk consumes the feature-toggle list through the
17740 // lifted accessor — a well-formed `:caracteristicas` set passes
17741 // (positive control), an empty-string entry surfaces the
17742 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17743 // `Dep::nome`, and a within-list duplicate surfaces the
17744 // [`DepError::CaracteristicaDuplicate`] variant so a future
17745 // regression that detoured the walk through a different byte-
17746 // string list (say a per-scope override projector) would surface
17747 // here at build time. Peer of the sibling
17748 // `dep_validate_reads_fonte_through_accessor` /
17749 // `dep_validate_reads_requirement_through_accessor` composition
17750 // pins on the `:fonte` / `:versao` axes.
17751 // Positive control: two distinct well-formed feature names pass.
17752 Dep {
17753 nome: "caixa-teia".to_string(),
17754 versao: "^0.1".to_string(),
17755 fonte: None,
17756 opcional: false,
17757 caracteristicas: vec!["http".to_string(), "json".to_string()],
17758 }
17759 .validate()
17760 .unwrap();
17761 // Negative control 1: empty-string feature-name entry — the
17762 // accessor still returns `&[""]` and the walk raises the typed
17763 // empty-first carrier.
17764 let err = Dep {
17765 nome: "caixa-teia".to_string(),
17766 versao: "^0.1".to_string(),
17767 fonte: None,
17768 opcional: false,
17769 caracteristicas: vec![String::new()],
17770 }
17771 .validate()
17772 .unwrap_err();
17773 assert!(
17774 matches!(
17775 &err,
17776 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17777 ),
17778 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17779 );
17780 // Negative control 2: within-list duplicate — the accessor's
17781 // slice view carries both entries, and the walk's dedup arm
17782 // raises the typed duplicate carrier quoting the offending
17783 // feature name verbatim.
17784 let err = Dep {
17785 nome: "caixa-teia".to_string(),
17786 versao: "^0.1".to_string(),
17787 fonte: None,
17788 opcional: false,
17789 caracteristicas: vec!["http".to_string(), "http".to_string()],
17790 }
17791 .validate()
17792 .unwrap_err();
17793 assert!(
17794 matches!(
17795 &err,
17796 DepError::CaracteristicaDuplicate {
17797 nome,
17798 caracteristica,
17799 } if nome == "caixa-teia" && caracteristica == "http",
17800 ),
17801 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17802 );
17803 }
17804
17805 // ── Dep::opcional accessor pins ───────────────────────────────────
17806 //
17807 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17808 // equal projection over the default-`false` / explicit-`true`
17809 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17810 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17811 // exercising the accessor's accept-set over every author-surface
17812 // `:fonte` shape × every author-surface `:opcional` shape; and by-
17813 // `Copy` idempotency so the projection stays value-return (no
17814 // silent detour to a fresh `&bool` borrow that would introduce a
17815 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17816 // shape elides). No composition pin — `:opcional` does not
17817 // participate in [`Dep::validate`] (an opcional dep with any bool
17818 // value is validate-accepted; the missing-source arm is a resolver-
17819 // side runtime dispatch, not a build-time refusal), so the axis
17820 // reduces to the value-shape + `Copy` pin pair the peer
17821 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17822 // outer-`Option<Copy>` accessor pins already carry.
17823
17824 #[test]
17825 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17826 // Default-`false` form via the [`Dep::simple`] constructor —
17827 // the accessor projects the `false` bit the default-fill sets.
17828 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17829 // Default-`false` form via the [`Dep::git`] constructor — same
17830 // default fill; the accessor projects `false` regardless of the
17831 // `:fonte` arm.
17832 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17833 // Explicit-`true` form × plain-shorthand `:fonte` — the
17834 // canonical author-surface "this dep may be missing" shape.
17835 let plain_true = Dep {
17836 nome: "caixa-teia".to_string(),
17837 versao: "^0.1".to_string(),
17838 fonte: None,
17839 opcional: true,
17840 caracteristicas: Vec::new(),
17841 };
17842 assert!(plain_true.opcional());
17843 // Explicit-`true` form × explicit git-source — the accessor
17844 // projects the bit verbatim regardless of the `:fonte` arm.
17845 let git_true = Dep {
17846 nome: "caixa-teia".to_string(),
17847 versao: "^0.1".to_string(),
17848 fonte: Some(DepSource::Git {
17849 repo: "github:pleme-io/caixa-teia".to_string(),
17850 tag: Some("v0.1.0".to_string()),
17851 rev: None,
17852 branch: None,
17853 }),
17854 opcional: true,
17855 caracteristicas: Vec::new(),
17856 };
17857 assert!(git_true.opcional());
17858 // Explicit-`true` form × explicit path-source — the dev-only
17859 // local-filesystem arm the [`Dep`] docstring's third fixture
17860 // carries.
17861 let path_true = Dep {
17862 nome: "caixa-teia".to_string(),
17863 versao: "0.1.0".to_string(),
17864 fonte: Some(DepSource::Path {
17865 caminho: "../caixa-teia".to_string(),
17866 }),
17867 opcional: true,
17868 caracteristicas: Vec::new(),
17869 };
17870 assert!(path_true.opcional());
17871 }
17872
17873 #[test]
17874 fn dep_opcional_projects_bool_by_copy() {
17875 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17876 // (`bool: Copy`) — the accessor does not borrow `&self` past
17877 // the call (no lifetime on the return type), and calling the
17878 // accessor twice on the same [`Dep`] must yield discriminant-
17879 // equal values (idempotent, no side effects on `&self`). Peer
17880 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17881 // `max_restarts_projects_option_by_copy` (eba5211) /
17882 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17883 // outer-`Caixa` altitude — extended here to the outer-`Dep`
17884 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17885 // replaces the pointer-equality claim the sibling per-`Dep`
17886 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17887 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17888 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17889 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17890 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17891 // the same discriminant, so the axis reduces to discriminant
17892 // equality).
17893 //
17894 // Pins against a future silent detour that returned a fresh
17895 // `&bool` reference (which would type-check but silently
17896 // introduce a borrow of `&self` past the call, collapsing the
17897 // load-bearing "no lifetime on the return type" `Copy`
17898 // projection the plain-`Copy`-scalar axis's `bool` shape
17899 // carries) or a stale-read side effect that flipped the outer
17900 // discriminant on successive calls.
17901 for opcional in [false, true] {
17902 let d = Dep {
17903 nome: "caixa-teia".to_string(),
17904 versao: "^0.1".to_string(),
17905 fonte: None,
17906 opcional,
17907 caracteristicas: Vec::new(),
17908 };
17909 let first = d.opcional();
17910 let second = d.opcional();
17911 assert_eq!(
17912 first, second,
17913 "Dep::opcional must be idempotent — two successive calls \
17914 on the same &self must return the same bool",
17915 );
17916 assert_eq!(
17917 first, opcional,
17918 "Dep::opcional must return :opcional verbatim by Copy — \
17919 got {first}, expected {opcional}",
17920 );
17921 assert_eq!(
17922 d.opcional(),
17923 d.opcional,
17924 "Dep::opcional accessor and self.opcional field access \
17925 must byte-equal — a bit-flip drift would silently split \
17926 the paired resolver-side drop-vs-error dispatch from \
17927 the storage-side default-fill the [`Dep::simple`] / \
17928 [`Dep::git`] constructor pair carries",
17929 );
17930 }
17931 }
17932
17933 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17934
17935 #[test]
17936 fn sole_pin_returns_none_for_path_source() {
17937 // A path source carries no git-ref, so `sole_pin()` returns
17938 // `None` structurally — the sibling arm every git-fetching
17939 // consumer partitions off before reaching for a git-ref. Pins
17940 // the Path-arm branch of the accessor against a future silent
17941 // detour that treats a `Self::Path` as an unpinned-git source
17942 // and returns the wrong "no pin" signal (e.g. the empty string,
17943 // or a hard-coded `Some("HEAD")` matching the caixa-crd
17944 // path-arm `git_ref` fill).
17945 let s = DepSource::Path {
17946 caminho: "../local-caixa".to_string(),
17947 };
17948 assert_eq!(s.sole_pin(), None);
17949 }
17950
17951 #[test]
17952 fn sole_pin_returns_none_for_unpinned_git_source() {
17953 // The [`DepSource::default_github`] shorthand shape carries no
17954 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17955 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17956 // materializes when the author omits `:fonte` entirely, then
17957 // hands to `fetch_git` which raises `ResolveError::MissingPin`
17958 // on the `None` arm — the accessor's return matches the arm
17959 // the resolver's diagnostic keys off.
17960 let s = DepSource::default_github("pleme-io", "caixa-teia");
17961 assert_eq!(s.sole_pin(), None);
17962 }
17963
17964 #[test]
17965 fn sole_pin_returns_rev_when_only_rev_is_set() {
17966 let s = DepSource::Git {
17967 repo: "github:o/x".into(),
17968 tag: None,
17969 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17970 branch: None,
17971 };
17972 assert_eq!(
17973 s.sole_pin(),
17974 Some("deadbeefcafebabe1234567890abcdef12345678")
17975 );
17976 }
17977
17978 #[test]
17979 fn sole_pin_returns_tag_when_only_tag_is_set() {
17980 let s = DepSource::Git {
17981 repo: "github:o/x".into(),
17982 tag: Some("v0.1.0".into()),
17983 rev: None,
17984 branch: None,
17985 };
17986 assert_eq!(s.sole_pin(), Some("v0.1.0"));
17987 }
17988
17989 #[test]
17990 fn sole_pin_returns_branch_when_only_branch_is_set() {
17991 let s = DepSource::Git {
17992 repo: "github:o/x".into(),
17993 tag: None,
17994 rev: None,
17995 branch: Some("main".into()),
17996 };
17997 assert_eq!(s.sole_pin(), Some("main"));
17998 }
17999
18000 #[test]
18001 fn sole_pin_precedence_rev_beats_tag_and_branch() {
18002 // Precedence: rev > tag > branch. Validate() rejects
18003 // multiple-pin shapes, but the accessor's precedence is defined
18004 // for pre-validate consumers (the resolver's `MissingPin`
18005 // diagnostic path, the caixa-crd round-trip's default `"main"`
18006 // fallback) and as defense-in-depth if the gate is ever
18007 // bypassed. Pins the same precedence caixa-resolver's
18008 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
18009 // inline.
18010 let s = DepSource::Git {
18011 repo: "github:o/x".into(),
18012 tag: Some("v1".into()),
18013 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
18014 branch: Some("main".into()),
18015 };
18016 assert_eq!(
18017 s.sole_pin(),
18018 Some("deadbeefcafebabe1234567890abcdef12345678")
18019 );
18020 }
18021
18022 #[test]
18023 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
18024 let s = DepSource::Git {
18025 repo: "github:o/x".into(),
18026 tag: Some("v1".into()),
18027 rev: None,
18028 branch: Some("main".into()),
18029 };
18030 assert_eq!(s.sole_pin(), Some("v1"));
18031 }
18032
18033 #[test]
18034 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
18035 // Fail-before-pass-after byte-parity pin: the substrate accessor
18036 // must return byte-identical to the inline
18037 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
18038 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
18039 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
18040 // time if the accessor's precedence silently drifts from the
18041 // consumer-side cascade — the exact drift this lift converges
18042 // to one substrate primitive to close structurally.
18043 //
18044 // Iterates through the 2^3 = 8 combinations of (tag, rev,
18045 // branch) each-either-`None`-or-`Some`, so every arm of the
18046 // precedence cascade lands under the pin. `validate()` refuses
18047 // the 4 multi-pin combinations, but the accessor's return is
18048 // defined on all 8.
18049 let vals = [Some("R".to_string()), None];
18050 for tag in &vals {
18051 for rev in &vals {
18052 for branch in &vals {
18053 let s = DepSource::Git {
18054 repo: "github:o/x".into(),
18055 tag: tag.clone(),
18056 rev: rev.clone(),
18057 branch: branch.clone(),
18058 };
18059 // The exact inline cascade the two pre-lift
18060 // consumer sites hand-rolled, byte-for-byte.
18061 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
18062 assert_eq!(
18063 s.sole_pin(),
18064 expected,
18065 "sole_pin() must byte-equal \
18066 rev.or(tag).or(branch) for \
18067 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
18068 a drift would silently split caixa-resolver's \
18069 fetch_git checkout target from caixa-crd's \
18070 dep_into_ref git_ref fill",
18071 );
18072 }
18073 }
18074 }
18075 }
18076
18077 // Fail-before-pass-after pins on the eleven
18078 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
18079 // constructors folded from the [`DepSource::validate_caminho`]
18080 // wire-up sites. Each pins the generated ctor's output to the
18081 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
18082 // any wrapper-side lowercase / trim / re-order / silent-field-swap
18083 // regression on the two-field `{ nome: nome.to_string(), caminho:
18084 // caminho.to_string() }` construction surfaces here rather than at
18085 // a downstream diagnostic-shape mismatch. Peer of the sibling
18086 // `empty_child_version_ctor_matches_struct_literal_wrap` /
18087 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
18088 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
18089 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
18090 // pins on the peer `SupervisorError` / `AplicacaoError` /
18091 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
18092
18093 #[test]
18094 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
18095 assert_eq!(
18096 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
18097 DepError::FonteCaminhoAbsolute {
18098 nome: "caixa-teia".to_string(),
18099 caminho: "/home/me/work/caixa-teia".to_string(),
18100 },
18101 "generated fonte_caminho_absolute ctor must produce byte-equal \
18102 DepError to the open-coded struct-literal wrap on the same \
18103 (&str, &str) fixture",
18104 );
18105 }
18106
18107 #[test]
18108 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
18109 assert_eq!(
18110 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
18111 DepError::FonteCaminhoTildeExpansion {
18112 nome: "caixa-teia".to_string(),
18113 caminho: "~/work/caixa-teia".to_string(),
18114 },
18115 );
18116 }
18117
18118 #[test]
18119 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
18120 assert_eq!(
18121 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
18122 DepError::FonteCaminhoVarExpansion {
18123 nome: "caixa-teia".to_string(),
18124 caminho: "$HOME/work/caixa-teia".to_string(),
18125 },
18126 );
18127 }
18128
18129 #[test]
18130 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
18131 assert_eq!(
18132 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
18133 DepError::FonteCaminhoLeadingWhitespace {
18134 nome: "caixa-teia".to_string(),
18135 caminho: " ../caixa-teia".to_string(),
18136 },
18137 );
18138 }
18139
18140 #[test]
18141 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
18142 assert_eq!(
18143 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
18144 DepError::FonteCaminhoLeadingHyphen {
18145 nome: "caixa-teia".to_string(),
18146 caminho: "-rf".to_string(),
18147 },
18148 );
18149 }
18150
18151 #[test]
18152 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
18153 assert_eq!(
18154 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
18155 DepError::FonteCaminhoBackslash {
18156 nome: "caixa-teia".to_string(),
18157 caminho: "..\\caixa-teia".to_string(),
18158 },
18159 );
18160 }
18161
18162 #[test]
18163 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
18164 assert_eq!(
18165 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
18166 DepError::FonteCaminhoShellPipe {
18167 nome: "caixa-teia".to_string(),
18168 caminho: "../caixa-teia|evil".to_string(),
18169 },
18170 );
18171 }
18172
18173 #[test]
18174 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
18175 assert_eq!(
18176 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
18177 DepError::FonteCaminhoShellSemicolon {
18178 nome: "caixa-teia".to_string(),
18179 caminho: "../caixa-teia;evil".to_string(),
18180 },
18181 );
18182 }
18183
18184 #[test]
18185 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
18186 assert_eq!(
18187 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
18188 DepError::FonteCaminhoShellBackground {
18189 nome: "caixa-teia".to_string(),
18190 caminho: "../caixa-teia&".to_string(),
18191 },
18192 );
18193 }
18194
18195 #[test]
18196 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
18197 assert_eq!(
18198 DepError::fonte_caminho_shell_command_substitution(
18199 "caixa-teia",
18200 "../caixa-teia`whoami`",
18201 ),
18202 DepError::FonteCaminhoShellCommandSubstitution {
18203 nome: "caixa-teia".to_string(),
18204 caminho: "../caixa-teia`whoami`".to_string(),
18205 },
18206 );
18207 }
18208
18209 #[test]
18210 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
18211 assert_eq!(
18212 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
18213 DepError::FonteCaminhoTrailingSlash {
18214 nome: "caixa-teia".to_string(),
18215 caminho: "../caixa-teia/".to_string(),
18216 },
18217 );
18218 }
18219
18220 #[test]
18221 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
18222 // Cross-axis pin: sweep the two constructor input axes
18223 // (`nome: &str`, `caminho: &str`) through a non-default fixture
18224 // pair against every generated arm in the
18225 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
18226 // / trim / truncate / re-order on the two-field
18227 // `{ nome, caminho }` construction — or a silent field swap
18228 // between the two axes at codegen time — surfaces here rather
18229 // than at a downstream diagnostic-shape mismatch. Peer of the
18230 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
18231 // to_string` cross-axis routing pin on the peer
18232 // `SupervisorError` envelope, extended here onto the
18233 // `DepError` `{ nome: String, caminho: String }` envelope so
18234 // every substrate-primitive ctor family in caixa-core
18235 // guarantees each `&str`-field construction routes the
18236 // caller's `&str` verbatim through `.to_string()`.
18237 let nome = "sibling-teia";
18238 let caminho = "../workspace/sibling";
18239 let cases: [(DepError, DepError); 11] = [
18240 (
18241 DepError::fonte_caminho_absolute(nome, caminho),
18242 DepError::FonteCaminhoAbsolute {
18243 nome: nome.to_string(),
18244 caminho: caminho.to_string(),
18245 },
18246 ),
18247 (
18248 DepError::fonte_caminho_tilde_expansion(nome, caminho),
18249 DepError::FonteCaminhoTildeExpansion {
18250 nome: nome.to_string(),
18251 caminho: caminho.to_string(),
18252 },
18253 ),
18254 (
18255 DepError::fonte_caminho_var_expansion(nome, caminho),
18256 DepError::FonteCaminhoVarExpansion {
18257 nome: nome.to_string(),
18258 caminho: caminho.to_string(),
18259 },
18260 ),
18261 (
18262 DepError::fonte_caminho_leading_whitespace(nome, caminho),
18263 DepError::FonteCaminhoLeadingWhitespace {
18264 nome: nome.to_string(),
18265 caminho: caminho.to_string(),
18266 },
18267 ),
18268 (
18269 DepError::fonte_caminho_leading_hyphen(nome, caminho),
18270 DepError::FonteCaminhoLeadingHyphen {
18271 nome: nome.to_string(),
18272 caminho: caminho.to_string(),
18273 },
18274 ),
18275 (
18276 DepError::fonte_caminho_backslash(nome, caminho),
18277 DepError::FonteCaminhoBackslash {
18278 nome: nome.to_string(),
18279 caminho: caminho.to_string(),
18280 },
18281 ),
18282 (
18283 DepError::fonte_caminho_shell_pipe(nome, caminho),
18284 DepError::FonteCaminhoShellPipe {
18285 nome: nome.to_string(),
18286 caminho: caminho.to_string(),
18287 },
18288 ),
18289 (
18290 DepError::fonte_caminho_shell_semicolon(nome, caminho),
18291 DepError::FonteCaminhoShellSemicolon {
18292 nome: nome.to_string(),
18293 caminho: caminho.to_string(),
18294 },
18295 ),
18296 (
18297 DepError::fonte_caminho_shell_background(nome, caminho),
18298 DepError::FonteCaminhoShellBackground {
18299 nome: nome.to_string(),
18300 caminho: caminho.to_string(),
18301 },
18302 ),
18303 (
18304 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
18305 DepError::FonteCaminhoShellCommandSubstitution {
18306 nome: nome.to_string(),
18307 caminho: caminho.to_string(),
18308 },
18309 ),
18310 (
18311 DepError::fonte_caminho_trailing_slash(nome, caminho),
18312 DepError::FonteCaminhoTrailingSlash {
18313 nome: nome.to_string(),
18314 caminho: caminho.to_string(),
18315 },
18316 ),
18317 ];
18318 for (via_ctor, via_struct_literal) in cases {
18319 assert_eq!(
18320 via_ctor, via_struct_literal,
18321 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
18322 through `.to_string()` in declared field order — a field-swap or \
18323 silent-conversion regression surfaces here rather than at a \
18324 downstream diagnostic-shape mismatch",
18325 );
18326 }
18327 }
18328
18329 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
18330 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
18331 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
18332 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
18333 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
18334
18335 #[test]
18336 fn versao_empty_ctor_matches_struct_literal_wrap() {
18337 assert_eq!(
18338 DepError::versao_empty("caixa-teia"),
18339 DepError::VersaoEmpty {
18340 nome: "caixa-teia".to_string(),
18341 },
18342 );
18343 }
18344
18345 #[test]
18346 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
18347 assert_eq!(
18348 DepError::fonte_repo_empty("caixa-teia"),
18349 DepError::FonteRepoEmpty {
18350 nome: "caixa-teia".to_string(),
18351 },
18352 );
18353 }
18354
18355 #[test]
18356 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
18357 assert_eq!(
18358 DepError::fonte_pin_missing("caixa-teia"),
18359 DepError::FontePinMissing {
18360 nome: "caixa-teia".to_string(),
18361 },
18362 );
18363 }
18364
18365 #[test]
18366 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
18367 assert_eq!(
18368 DepError::fonte_caminho_empty("caixa-teia"),
18369 DepError::FonteCaminhoEmpty {
18370 nome: "caixa-teia".to_string(),
18371 },
18372 );
18373 }
18374
18375 #[test]
18376 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
18377 assert_eq!(
18378 DepError::caracteristica_empty("caixa-teia"),
18379 DepError::CaracteristicaEmpty {
18380 nome: "caixa-teia".to_string(),
18381 },
18382 );
18383 }
18384
18385 #[test]
18386 fn dep_nome_only_ctors_route_nome_through_to_string() {
18387 // Cross-axis routing pin: sweep the single constructor input
18388 // axis (`nome: &str`) through a non-default fixture against
18389 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
18390 // any wrapper-side lowercase / trim / truncate at codegen time
18391 // — or a silent field re-name away from the canonical `nome`
18392 // axis on any one variant — surfaces here rather than at a
18393 // downstream diagnostic-shape mismatch. Peer of the sibling
18394 // `fonte_caminho_ctors_route_nome_and_caminho_through_
18395 // to_string` cross-axis routing pin on the same envelope's
18396 // two-slot family (f85f145) and of the peer
18397 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
18398 // pin on the `SupervisorError` single-slot family (db09650).
18399 let nome = "sibling-teia";
18400 let cases: [(DepError, DepError); 5] = [
18401 (
18402 DepError::versao_empty(nome),
18403 DepError::VersaoEmpty {
18404 nome: nome.to_string(),
18405 },
18406 ),
18407 (
18408 DepError::fonte_repo_empty(nome),
18409 DepError::FonteRepoEmpty {
18410 nome: nome.to_string(),
18411 },
18412 ),
18413 (
18414 DepError::fonte_pin_missing(nome),
18415 DepError::FontePinMissing {
18416 nome: nome.to_string(),
18417 },
18418 ),
18419 (
18420 DepError::fonte_caminho_empty(nome),
18421 DepError::FonteCaminhoEmpty {
18422 nome: nome.to_string(),
18423 },
18424 ),
18425 (
18426 DepError::caracteristica_empty(nome),
18427 DepError::CaracteristicaEmpty {
18428 nome: nome.to_string(),
18429 },
18430 ),
18431 ];
18432 for (via_ctor, via_struct_literal) in cases {
18433 assert_eq!(
18434 via_ctor, via_struct_literal,
18435 "dep_nome_only_ctors!-generated ctor must route `nome` \
18436 through `.to_string()` onto the canonical `nome` field \
18437 — a field-rename or silent-conversion regression surfaces \
18438 here rather than at a downstream diagnostic-shape mismatch",
18439 );
18440 }
18441 }
18442
18443 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
18444 // &'static str }` two-slot envelope on `DepError`, strict
18445 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
18446 // same envelope's `{ nome: String }` one-slot shape and of the
18447 // peer `supervisor_caixa_only_ctors!` (db09650) on the
18448 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
18449
18450 #[test]
18451 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
18452 assert_eq!(
18453 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
18454 DepError::DuplicateNome {
18455 nome: "caixa-teia".to_string(),
18456 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18457 },
18458 "generated duplicate_nome ctor must produce byte-equal \
18459 `DepError::DuplicateNome` to the pre-lift struct-literal \
18460 wrap on the same scalar fixtures",
18461 );
18462 }
18463
18464 #[test]
18465 fn dep_is_self_ctor_matches_struct_literal_wrap() {
18466 assert_eq!(
18467 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18468 DepError::DepIsSelf {
18469 nome: "orquestra".to_string(),
18470 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18471 },
18472 "generated dep_is_self ctor must produce byte-equal \
18473 `DepError::DepIsSelf` to the pre-lift struct-literal \
18474 wrap on the same scalar fixtures",
18475 );
18476 }
18477
18478 #[test]
18479 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
18480 // Cross-axis routing pin: sweep the two constructor input axes
18481 // (`nome: &str`, `list: &'static str`) through non-default
18482 // fixtures against every generated arm in the
18483 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
18484 // lowercase / trim / truncate at codegen time — or a silent
18485 // field re-name away from the canonical `nome` / `list` axes
18486 // on any one variant, or a `list` axis silently rerouted
18487 // through `.to_string()` instead of passed as `&'static str`
18488 // verbatim — surfaces here rather than at a downstream
18489 // diagnostic-shape mismatch. Peer of the sibling
18490 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18491 // (792aa92) on the same envelope's one-slot family, and of the
18492 // peer
18493 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
18494 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
18495 // two-slot `{ caixa: String, reason: String }` shape.
18496 let nome = "sibling-teia";
18497 let cases: [(DepError, DepError); 4] = [
18498 (
18499 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18500 DepError::DuplicateNome {
18501 nome: nome.to_string(),
18502 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18503 },
18504 ),
18505 (
18506 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18507 DepError::DuplicateNome {
18508 nome: nome.to_string(),
18509 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18510 },
18511 ),
18512 (
18513 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18514 DepError::DepIsSelf {
18515 nome: nome.to_string(),
18516 list: crate::render::DEP_AUTHOR_KEY_DEPS,
18517 },
18518 ),
18519 (
18520 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18521 DepError::DepIsSelf {
18522 nome: nome.to_string(),
18523 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18524 },
18525 ),
18526 ];
18527 for (via_ctor, via_struct_literal) in cases {
18528 assert_eq!(
18529 via_ctor, via_struct_literal,
18530 "dep_nome_list_ctors!-generated ctor must route `nome` \
18531 through `.to_string()` onto the canonical `nome` field \
18532 and pass `list` verbatim onto the canonical `&'static str` \
18533 `list` field — a field-rename, silent-conversion, or \
18534 axis-swap regression surfaces here rather than at a \
18535 downstream diagnostic-shape mismatch",
18536 );
18537 }
18538 }
18539
18540 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18541 // value: String, reason: String }` four-slot envelope on
18542 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18543 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18544 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18545 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
18546 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
18547 // envelope. Single-variant lift closing the last open-coded ctor
18548 // site on the `:fonte (:tipo git …)` value-shape trajectory.
18549
18550 #[test]
18551 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18552 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18553 // ctor: sweep both wire-up-shape arms (the refname-pin arm
18554 // routing `":tag"` / `":branch"` value through
18555 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18556 // routing `":rev"` through [`crate::render::is_git_oid`]) and
18557 // assert byte-equal `PartialEq` against the pre-lift
18558 // struct-literal, so any wrapper-side field-rename /
18559 // silent-conversion regression surfaces here rather than at a
18560 // downstream diagnostic-shape mismatch. Peer of the sibling
18561 // per-envelope byte-equal ctor pins
18562 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18563 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18564 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18565 assert_eq!(
18566 DepError::fonte_pin_shape(
18567 "caixa-teia",
18568 ":tag",
18569 "v0.1.0 ",
18570 "trailing whitespace".to_string(),
18571 ),
18572 DepError::FontePinShape {
18573 nome: "caixa-teia".to_string(),
18574 pin: ":tag".to_string(),
18575 value: "v0.1.0 ".to_string(),
18576 reason: "trailing whitespace".to_string(),
18577 },
18578 "fonte_pin_shape ctor must produce byte-equal \
18579 `DepError::FontePinShape` to the pre-lift struct-literal \
18580 wrap on a refname-pin (`:tag` / `:branch`) fixture",
18581 );
18582 assert_eq!(
18583 DepError::fonte_pin_shape(
18584 "caixa-teia",
18585 ":rev",
18586 "DEADBEEF",
18587 "abbreviated OID rejected".to_string(),
18588 ),
18589 DepError::FontePinShape {
18590 nome: "caixa-teia".to_string(),
18591 pin: ":rev".to_string(),
18592 value: "DEADBEEF".to_string(),
18593 reason: "abbreviated OID rejected".to_string(),
18594 },
18595 "fonte_pin_shape ctor must produce byte-equal \
18596 `DepError::FontePinShape` to the pre-lift struct-literal \
18597 wrap on a hex-OID-pin (`:rev`) fixture",
18598 );
18599 }
18600
18601 #[test]
18602 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18603 // Cross-axis routing pin: sweep every one of the four
18604 // constructor input axes (`nome: &str`, `pin: &str`,
18605 // `value: &str`, `reason: String`) through non-default
18606 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18607 // any wrapper-side lowercase / trim / truncate at codegen time
18608 // — or a silent field re-name / axis-swap on any one of the
18609 // four fields, or a `reason` axis silently routed through
18610 // `.to_string()` instead of forwarded owned — surfaces here
18611 // rather than at a downstream diagnostic-shape mismatch. Peer
18612 // of the sibling
18613 // `dep_nome_only_ctors_route_nome_through_to_string` pin
18614 // (792aa92) and
18615 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18616 // pin (6f5e0cd) on the same envelope's one- and two-slot
18617 // families. Distinct-per-axis fixtures rule out any two-axis
18618 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18619 // etc.) that would still pass a same-fixture-per-axis pin.
18620 let nome = "sibling-teia";
18621 let pin = ":branch";
18622 let value = "feature/bar";
18623 let reason = "embedded space".to_string();
18624 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18625 let via_struct_literal = DepError::FontePinShape {
18626 nome: nome.to_string(),
18627 pin: pin.to_string(),
18628 value: value.to_string(),
18629 reason: reason.clone(),
18630 };
18631 assert_eq!(
18632 via_ctor, via_struct_literal,
18633 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18634 through `.to_string()` onto their canonical fields and \
18635 forward `reason` owned onto the canonical `reason` field \
18636 — a field-rename, silent-conversion, or axis-swap \
18637 regression surfaces here rather than at a downstream \
18638 diagnostic-shape mismatch",
18639 );
18640 let DepError::FontePinShape {
18641 nome: n,
18642 pin: p,
18643 value: v,
18644 reason: r,
18645 } = via_ctor
18646 else {
18647 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18648 };
18649 assert_eq!(n, nome);
18650 assert_eq!(p, pin);
18651 assert_eq!(v, value);
18652 assert_eq!(r, reason);
18653 }
18654
18655 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18656 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18657 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18658 // the same envelope's `{ nome: String, caminho: String }` two-slot
18659 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18660 // same envelope's `{ nome: String }` one-slot shape.
18661
18662 #[test]
18663 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18664 assert_eq!(
18665 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18666 DepError::FonteCaminhoControlChar {
18667 nome: "caixa-teia".to_string(),
18668 caminho: "../caixa-teia\x00foo".to_string(),
18669 byte: 0x00,
18670 },
18671 );
18672 }
18673
18674 #[test]
18675 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18676 assert_eq!(
18677 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18678 DepError::FonteCaminhoShellRedirection {
18679 nome: "caixa-teia".to_string(),
18680 caminho: "../caixa-teia>log".to_string(),
18681 byte: b'>',
18682 },
18683 );
18684 }
18685
18686 #[test]
18687 #[allow(
18688 clippy::too_many_lines,
18689 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18690 byte-classification arm on the {nome,caminho,byte} envelope; \
18691 the linear per-variant repetition is exactly what the sweep \
18692 is pinning — a helper macro would hide the shape the fold is \
18693 keying on"
18694 )]
18695 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18696 // Cross-axis routing pin: sweep the three constructor input axes
18697 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18698 // non-default fixture triple against every generated arm in the
18699 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18700 // lowercase / trim / truncate on the two `&str` axes — a silent
18701 // field swap between `nome` and `caminho`, or a silent
18702 // re-classification of the offending byte — surfaces here rather
18703 // than at a downstream diagnostic-shape mismatch. Peer of the
18704 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18705 // to_string` cross-axis routing pin on the same envelope's
18706 // two-slot family (f85f145) and of the sibling
18707 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18708 // same envelope's one-slot family (792aa92), extended here onto
18709 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18710 // envelope so every substrate-primitive ctor family in
18711 // caixa-core's `DepError` envelope guarantees each field routes
18712 // the caller's value verbatim through `.to_string()` (or byte-
18713 // identity for `byte: u8`) in declared field order.
18714 let nome = "sibling-teia";
18715 let caminho = "../workspace/sibling";
18716 let byte = 0x2A_u8;
18717 let cases: [(DepError, DepError); 12] = [
18718 (
18719 DepError::fonte_caminho_control_char(nome, caminho, byte),
18720 DepError::FonteCaminhoControlChar {
18721 nome: nome.to_string(),
18722 caminho: caminho.to_string(),
18723 byte,
18724 },
18725 ),
18726 (
18727 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18728 DepError::FonteCaminhoShellRedirection {
18729 nome: nome.to_string(),
18730 caminho: caminho.to_string(),
18731 byte,
18732 },
18733 ),
18734 (
18735 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18736 DepError::FonteCaminhoShellGlob {
18737 nome: nome.to_string(),
18738 caminho: caminho.to_string(),
18739 byte,
18740 },
18741 ),
18742 (
18743 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18744 DepError::FonteCaminhoShellSubshellGrouping {
18745 nome: nome.to_string(),
18746 caminho: caminho.to_string(),
18747 byte,
18748 },
18749 ),
18750 (
18751 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18752 DepError::FonteCaminhoShellBraceExpansion {
18753 nome: nome.to_string(),
18754 caminho: caminho.to_string(),
18755 byte,
18756 },
18757 ),
18758 (
18759 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18760 DepError::FonteCaminhoShellBracketExpansion {
18761 nome: nome.to_string(),
18762 caminho: caminho.to_string(),
18763 byte,
18764 },
18765 ),
18766 (
18767 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18768 DepError::FonteCaminhoShellQuoteGrouping {
18769 nome: nome.to_string(),
18770 caminho: caminho.to_string(),
18771 byte,
18772 },
18773 ),
18774 (
18775 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18776 DepError::FonteCaminhoShellComment {
18777 nome: nome.to_string(),
18778 caminho: caminho.to_string(),
18779 byte,
18780 },
18781 ),
18782 (
18783 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18784 DepError::FonteCaminhoUrlPercentEncoding {
18785 nome: nome.to_string(),
18786 caminho: caminho.to_string(),
18787 byte,
18788 },
18789 ),
18790 (
18791 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18792 DepError::FonteCaminhoShellVariableExpansion {
18793 nome: nome.to_string(),
18794 caminho: caminho.to_string(),
18795 byte,
18796 },
18797 ),
18798 (
18799 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18800 DepError::FonteCaminhoShellHistoryExpansion {
18801 nome: nome.to_string(),
18802 caminho: caminho.to_string(),
18803 byte,
18804 },
18805 ),
18806 (
18807 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18808 DepError::FonteCaminhoShellHistorySubstitution {
18809 nome: nome.to_string(),
18810 caminho: caminho.to_string(),
18811 byte,
18812 },
18813 ),
18814 ];
18815 for (via_ctor, via_struct_literal) in cases {
18816 assert_eq!(
18817 via_ctor, via_struct_literal,
18818 "fonte_caminho_byte_ctors!-generated ctor must route \
18819 (nome, caminho, byte) through `.to_string()` / byte-\
18820 identity in declared field order — a field-swap or \
18821 silent-conversion regression surfaces here rather than \
18822 at a downstream diagnostic-shape mismatch",
18823 );
18824 }
18825 }
18826
18827 #[test]
18828 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18829 // Fail-before-pass-after byte-parity pin on the lifted
18830 // `impl AsRef<str> for DepList` — asserts the standard-
18831 // library trait impl and the substrate-primitive
18832 // [`super::DepList::as_str`] `pub const fn` accessor resolve
18833 // to the same `&str` per instance across the two-arm closed
18834 // set, so any future silent detour that routes the impl
18835 // through a divergent projection (a per-arm inline
18836 // `match self { DepList::Prod => ":deps", … }` re-inlining
18837 // that opens a compile-time link to the un-lifted arm-literal,
18838 // a swap onto a second projection axis) trips at caixa-core
18839 // test time under `PartialEq` rather than at a downstream
18840 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18841 // every one of the two arms [`super::DepList::ALL`] carries
18842 // so no arm's projection is covered only by the sibling
18843 // `Display` path. Peer of the sibling
18844 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18845 // (1723611) on the top-level dialect-classification closed-
18846 // set typed enum, and the peer
18847 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18848 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18849 // typed enum — the pins together close the substrate
18850 // primitive's `AsRef<str>` projection axis onto the seventh
18851 // (and last unlifted) closed-set typed enum on the caixa
18852 // surface.
18853 for &list in super::DepList::ALL {
18854 assert_eq!(
18855 <super::DepList as AsRef<str>>::as_ref(&list),
18856 list.as_str(),
18857 "AsRef<str> impl on DepList::{list:?} must byte-equal \
18858 DepList::as_str on the same instance — divergence \
18859 signals a silent detour off the substrate-primitive \
18860 accessor"
18861 );
18862 }
18863 }
18864
18865 #[test]
18866 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18867 // Fail-before-pass-after byte-parity pin on the three-path
18868 // convergence discipline the [`super::DepList`] two-list
18869 // dep-graph closed-set typed enum now carries on the `&str`-
18870 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18871 // newly lifted impl), `format!("{v}")` (the pre-existing
18872 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18873 // primitive `pub const fn` accessor both trait impls delegate
18874 // through) must resolve to the same byte-string on every
18875 // instance across the two-arm closed set. Refuses any future
18876 // divergence between the two trait impls (a stray
18877 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18878 // rather than delegating through the shared accessor; a
18879 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18880 // literal cascade) that would silently split the two
18881 // projection paths of the same closed-set typed enum. Mirrors
18882 // the sibling three-path-convergence discipline the peer
18883 // [`crate::CaixaDialeto`] typed enum carries
18884 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18885 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18886 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18887 // d8136db), the peer [`crate::CaixaKind`] triple
18888 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18889 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18890 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18891 // 16d5c7e).
18892 for &list in super::DepList::ALL {
18893 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18894 let via_display: String = format!("{list}");
18895 let via_accessor: &str = list.as_str();
18896 assert_eq!(via_as_ref, via_accessor);
18897 assert_eq!(via_display, via_accessor);
18898 assert_eq!(via_as_ref, via_display.as_str());
18899 }
18900 }
18901
18902 #[test]
18903 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18904 // Fail-before-pass-after byte-parity pin on the newly lifted
18905 // `impl TryFrom<&str> for DepList` — asserts the standard-
18906 // library trait impl and the substrate-primitive
18907 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18908 // to the same two-arm accept-set across every arm the
18909 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18910 // the sibling
18911 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18912 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18913 // and the 12 other substrate-wide trait-idiomatic reverse-
18914 // projection routes-through pins — closes the campaign's
18915 // completeness gap on the two-list dep-graph closed-set enum.
18916 for &list in super::DepList::ALL {
18917 let wire = list.as_str();
18918 assert_eq!(
18919 <super::DepList as TryFrom<&str>>::try_from(wire),
18920 Ok(list),
18921 "TryFrom<&str> impl on DepList must round-trip \
18922 DepList::{list:?}.as_str() = {wire:?} back to \
18923 Ok(DepList::{list:?}) — divergence from \
18924 DepList::from_wire signals a silent detour off the \
18925 substrate-primitive accessor"
18926 );
18927 assert_eq!(
18928 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18929 super::DepList::from_wire(wire),
18930 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18931 DepList::from_wire on the same input"
18932 );
18933 }
18934 }
18935
18936 #[test]
18937 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18938 // Rejection witness on the `impl TryFrom<&str> for DepList` —
18939 // sweeps candidate byte-strings outside the two-arm accept-set
18940 // the sibling [`super::DepList::as_str`] emits (`:deps` /
18941 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18942 // future accidental widening of the trait impl's accept-set (a
18943 // stray case-fold path, a silent inclusion of a rebrand alias
18944 // like `":packages"`, an English rebrand `":dev-deps"` in
18945 // reverse arm-order that would silently swap the two arms) trips
18946 // at caixa-core test time. Peer of the sibling
18947 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18948 // (5b828ed) rejection witness.
18949 let rejected: &[&str] = &[
18950 "",
18951 " ",
18952 "\t",
18953 "\n",
18954 ":deps ",
18955 " :deps",
18956 ":DEPS",
18957 ":Deps",
18958 ":Deps-Dev",
18959 ":deps_dev",
18960 ":deps-development",
18961 ":dev-deps",
18962 ":packages",
18963 ":packages-dev",
18964 "deps",
18965 "deps-dev",
18966 "Prod",
18967 "Dev",
18968 "prod",
18969 "dev",
18970 "\":deps\"",
18971 "\":deps-dev\"",
18972 ":deps\n",
18973 ":deps-dev\n",
18974 ];
18975 for &input in rejected {
18976 assert_eq!(
18977 <super::DepList as TryFrom<&str>>::try_from(input),
18978 Err(()),
18979 "TryFrom<&str> impl on DepList must reject unknown \
18980 byte-string {input:?} — divergence from \
18981 DepList::from_wire on the same input signals a silent \
18982 accept-set widening past the two lifted \
18983 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18984 );
18985 assert_eq!(
18986 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18987 super::DepList::from_wire(input),
18988 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18989 DepList::from_wire on the same input — divergence signals \
18990 the two reverse-projection paths have drifted onto \
18991 different accept-sets"
18992 );
18993 }
18994 }
18995
18996 #[test]
18997 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18998 // Fail-before-pass-after byte-parity pin on the newly lifted
18999 // `impl From<DepList> for &'static str` — asserts the standard-
19000 // library trait impl and the substrate-primitive
19001 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19002 // the same two-arm emit-set across every arm the exhaustive
19003 // [`super::DepList::ALL`] slice enumerates. Materializes the
19004 // `<&'static str as From<DepList>>::from` output in a
19005 // `const`-shape binding to make the `'static` lifetime promise
19006 // a build-time invariant — a future accidental downgrade of
19007 // either arm to a non-`&'static str` (a `String::leak()`-
19008 // produced return, a `Box::leak`-cast) trips at caixa-core
19009 // build time rather than at a downstream `'static`-bound
19010 // consumer. Peer of the sibling
19011 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
19012 // (523157d) and the 13 other substrate-wide forward-projection
19013 // routes-through pins.
19014 const PROD: &str = super::DepList::Prod.as_str();
19015 const DEV: &str = super::DepList::Dev.as_str();
19016 for &list in super::DepList::ALL {
19017 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
19018 let via_method: &'static str = list.as_str();
19019 assert_eq!(
19020 via_trait, via_method,
19021 "From<DepList> for &'static str impl must round-trip \
19022 DepList::{list:?} to the same lifted \
19023 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19024 DepList::as_str returns — divergence signals a silent \
19025 detour off the substrate-primitive accessor"
19026 );
19027 let via_into: &'static str = list.into();
19028 assert_eq!(
19029 via_into, via_method,
19030 "Into<&'static str>::into on DepList::{list:?} must \
19031 byte-equal DepList::as_str on the same input — the \
19032 blanket-derived Into shape must resolve to the same \
19033 as_str dispatch as the explicit From impl"
19034 );
19035 }
19036 assert_eq!(
19037 [PROD, DEV],
19038 [
19039 crate::render::DEP_AUTHOR_KEY_DEPS,
19040 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19041 ],
19042 "const-context DepList::as_str must resolve to the two lifted \
19043 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
19044 of either arm to a non-const or non-static byte-string breaks \
19045 the `&'static str`-lifetime promise the paired \
19046 From<DepList> for &'static str impl carries by construction"
19047 );
19048 }
19049
19050 #[test]
19051 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
19052 // Cross-axis partition pin: the paired trait-idiomatic
19053 // `From<DepList> for &'static str` forward projection and the
19054 // method-named [`super::DepList::as_str`] forward projection
19055 // must resolve identically on every arm, locking the two paths
19056 // together so any future detour trips at caixa-core test time.
19057 // Then a round-trip witness: every arm's forward `From` output
19058 // re-parses through the paired trait-idiomatic reverse
19059 // `TryFrom<&str>` back to the original variant, closing the
19060 // two-way `DepList ↔ &'static str` round-trip on the trait-
19061 // idiomatic axis pair, mirroring the pre-existing method-named
19062 // `as_str` + `from_wire` round-trip. Peer of the sibling
19063 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
19064 // (523157d).
19065 for &list in super::DepList::ALL {
19066 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
19067 let via_method: &'static str = list.as_str();
19068 assert_eq!(
19069 via_trait, via_method,
19070 "From<DepList> for &'static str and DepList::as_str must \
19071 resolve identically on DepList::{list:?} — divergence \
19072 signals the two forward-projection paths have drifted \
19073 onto different emit-sets"
19074 );
19075 }
19076 for &list in super::DepList::ALL {
19077 let emitted: &'static str = list.into();
19078 let re_parsed: Result<super::DepList, ()> =
19079 <super::DepList as TryFrom<&str>>::try_from(emitted);
19080 assert_eq!(
19081 re_parsed,
19082 Ok(list),
19083 "trait-idiomatic axis pair must round-trip \
19084 DepList::{list:?} through `.into::<&'static str>()` and \
19085 back through `TryFrom<&str>` — a break signals the \
19086 forward-emit and reverse-parse axes have drifted onto \
19087 different vocabularies"
19088 );
19089 }
19090 }
19091
19092 #[test]
19093 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
19094 // Fail-before-pass-after byte-parity pin on the newly lifted
19095 // `impl From<&DepList> for &'static str` — asserts the borrowed-
19096 // input standard-library trait impl and the substrate-primitive
19097 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19098 // the same two-arm emit-set across every arm the exhaustive
19099 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
19100 // does not auto-derive the borrowed-input sibling from a paired
19101 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
19102 // U: From<T>` blanket in `core`), so the borrowed-input axis is
19103 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
19104 // shape over [`super::DepList::ALL`] (whose iterator yields
19105 // `&DepList`, not `DepList`) reaches through this impl and no
19106 // other — the paired owned-input [`From<DepList>`] impl requires
19107 // an explicit `.copied()` / dereference before the trait fires.
19108 // Materializes the `<&'static str as From<&DepList>>::from`
19109 // output in a `const`-shape binding to make the `'static`
19110 // lifetime promise a build-time invariant.
19111 const PROD: &str = super::DepList::Prod.as_str();
19112 const DEV: &str = super::DepList::Dev.as_str();
19113 for list in super::DepList::ALL {
19114 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
19115 let via_method: &'static str = list.as_str();
19116 assert_eq!(
19117 via_trait, via_method,
19118 "From<&DepList> for &'static str impl must round-trip \
19119 &DepList::{list:?} to the same lifted \
19120 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19121 DepList::as_str returns — divergence signals a silent \
19122 detour off the substrate-primitive accessor"
19123 );
19124 let via_into: &'static str = list.into();
19125 assert_eq!(
19126 via_into, via_method,
19127 "Into<&'static str>::into on &DepList::{list:?} must \
19128 byte-equal DepList::as_str on the same input — the \
19129 blanket-derived Into shape must resolve to the same \
19130 as_str dispatch as the explicit From impl"
19131 );
19132 }
19133 assert_eq!(
19134 [PROD, DEV],
19135 [
19136 crate::render::DEP_AUTHOR_KEY_DEPS,
19137 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
19138 ],
19139 "const-context DepList::as_str must resolve to the two lifted \
19140 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
19141 From<&DepList> for &'static str impl inherits its `'static` \
19142 lifetime promise from the same accessor the owned-input \
19143 sibling routes through"
19144 );
19145 }
19146
19147 #[test]
19148 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
19149 // Cross-axis partition pin: the paired trait-idiomatic
19150 // owned-input `From<DepList> for &'static str` (523157d
19151 // campaign-shape) and borrowed-input `From<&DepList> for
19152 // &'static str` (this lift) forward projections must resolve
19153 // identically on every arm, locking the two input-shape paths
19154 // together so any future detour trips at caixa-core test time.
19155 // Then a witness that a `.iter().map(Into::into)` pipe over
19156 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
19157 // materializes the two-arm accept-set through the borrowed-
19158 // input axis alone — the exact shape a future M4 admission-
19159 // webhook rejection body composer, a future substrate-wide
19160 // per-arm diagnostic column, or a
19161 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
19162 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
19163 // through — closing the two-way owned/borrowed input-shape
19164 // symmetry on the forward-projection trait-idiomatic axis.
19165 for &list in super::DepList::ALL {
19166 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
19167 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
19168 assert_eq!(
19169 owned, borrowed,
19170 "From<DepList> and From<&DepList> for &'static str must \
19171 resolve identically on DepList::{list:?} — divergence \
19172 signals the owned-input and borrowed-input forward-\
19173 projection paths have drifted onto different emit-sets"
19174 );
19175 }
19176 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
19177 let via_method: Vec<&'static str> =
19178 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19179 assert_eq!(
19180 via_iter, via_method,
19181 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
19182 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
19183 input `From<&DepList> for &'static str` axis is what makes \
19184 the `.iter().map(Into::into)` shape route through the \
19185 substrate-primitive `DepList::as_str` accessor rather than \
19186 through a per-call-site `.copied()` / dereference detour"
19187 );
19188 }
19189
19190 #[test]
19191 fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
19192 // Fail-before-pass-after byte-parity pin on the newly lifted
19193 // `impl From<DepList> for String` — asserts the owned-`String`
19194 // -returning standard-library trait impl and the substrate-
19195 // primitive [`super::DepList::as_str`] `pub const fn` accessor
19196 // resolve to the same two-arm emit-set across every arm the
19197 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19198 // standard library does not carry a blanket
19199 // `impl<T: AsRef<str>> From<T> for String` (nor an
19200 // `impl<T: fmt::Display> From<T> for String`), so the
19201 // owned-`String` forward-projection axis is a distinct trait-
19202 // idiomatic surface that a `let key: String = list.into();`-
19203 // shaped call site reaches through this impl and no other — the
19204 // paired sibling `From<DepList> for &'static str` impl forces
19205 // every owned-`String` call site through an explicit
19206 // `.to_owned()` / `String::from` restatement. Peer of the
19207 // first-mover
19208 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
19209 // (7baa18a), the second-peer
19210 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
19211 // (7851725), the third-peer
19212 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
19213 // (231a18c), and the fourth-peer
19214 // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
19215 // (88942cd) — extends the trait-idiomatic owned-`String`
19216 // forward-projection axis onto the fifth closed-set fieldless
19217 // typed enum on the caixa surface (the two-list dep-graph axis).
19218 for &variant in super::DepList::ALL {
19219 let via_trait: String = <String as From<super::DepList>>::from(variant);
19220 let via_method: &'static str = variant.as_str();
19221 assert_eq!(
19222 via_trait.as_str(),
19223 via_method,
19224 "From<DepList> for String impl must round-trip \
19225 DepList::{variant:?} to the same lifted \
19226 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19227 DepList::as_str returns — divergence signals a silent \
19228 detour off the substrate-primitive accessor"
19229 );
19230 let via_into: String = variant.into();
19231 assert_eq!(
19232 via_into.as_str(),
19233 via_method,
19234 "Into<String>::into on DepList::{variant:?} must \
19235 byte-equal DepList::as_str on the same input — the \
19236 blanket-derived Into shape must resolve to the same \
19237 as_str dispatch as the explicit From impl"
19238 );
19239 }
19240 }
19241
19242 #[test]
19243 fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
19244 // Cross-axis partition pin: the paired trait-idiomatic
19245 // owned-`String` `From<DepList> for String` (this lift) and
19246 // owned-`&'static str` `From<DepList> for &'static str`
19247 // (523157d campaign-shape) forward projections must resolve
19248 // identically on every arm, locking the two return-type-shape
19249 // paths together so any future detour trips at caixa-core test
19250 // time. Also byte-parity witness against the sibling
19251 // [`ToString::to_string`] surface routed through
19252 // [`std::fmt::Display`] — the three owned-heap-string paths
19253 // (`.into::<String>()`, `String::from`, `.to_string()`) must
19254 // resolve identically on every arm so a future consumer that
19255 // picks any of the three lands on the same two-arm lifted
19256 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19257 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
19258 // Then a `.iter().copied().map(String::from)` pipe witness
19259 // over [`super::DepList::ALL`] that materializes the two-arm
19260 // accept-set through the owned-`String` axis alone — the exact
19261 // shape a future M4 admission-webhook rejection body composer
19262 // or a
19263 // `HashMap::<String, DepList>::from_iter(
19264 // DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
19265 // style owned-key per-list lookup reaches through — closing the
19266 // owned-`String` forward-projection axis's iterator-pipe shape.
19267 // Then a direct round-trip witness through the paired
19268 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
19269 // owned-`String`'s [`String::as_str`] borrow that closes the
19270 // two-way `Self → String → Self` round-trip on the trait-
19271 // idiomatic owned-`String` forward + reverse axis pair.
19272 //
19273 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19274 // `From` emit lands on the lowercase Portuguese `as_str`
19275 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19276 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19277 // forcing the round-trip through an intermediate
19278 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19279 // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
19280 // parse resolve through the same lifted
19281 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19282 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19283 // construction (there is no wire/diagnostic axis split on this
19284 // enum), so the owned-`String` forward axis and the reverse
19285 // axis compose directly — matching the peer
19286 // [`crate::supervisor::RestartStrategy`] /
19287 // [`crate::supervisor::RestartPolicy`] /
19288 // [`crate::CaixaDialeto`] owned-`String` axis pairs.
19289 for &list in super::DepList::ALL {
19290 let owned_string: String = <String as From<super::DepList>>::from(list);
19291 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19292 assert_eq!(
19293 owned_string.as_str(),
19294 owned_static,
19295 "From<DepList> for String and From<DepList> for \
19296 &'static str must resolve identically on \
19297 DepList::{list:?} — divergence signals the owned-\
19298 `String` and owned-`&'static str` forward-projection \
19299 return-type-shape paths have drifted onto different \
19300 emit-sets"
19301 );
19302 let via_to_string: String = list.to_string();
19303 assert_eq!(
19304 owned_string, via_to_string,
19305 "From<DepList> for String must byte-equal \
19306 DepList::to_string on DepList::{list:?} — divergence \
19307 signals the trait-idiomatic owned-`String` forward-\
19308 projection axis and the ToString-through-Display axis \
19309 have drifted onto different emit-sets"
19310 );
19311 }
19312 let via_iter: Vec<String> = super::DepList::ALL
19313 .iter()
19314 .copied()
19315 .map(String::from)
19316 .collect();
19317 let via_method: Vec<String> = super::DepList::ALL
19318 .iter()
19319 .map(|l| l.as_str().to_owned())
19320 .collect();
19321 assert_eq!(
19322 via_iter, via_method,
19323 "`.iter().copied().map(String::from)` over DepList::ALL must \
19324 byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
19325 every arm — the owned-`String` `From<DepList> for String` \
19326 axis is what makes the `String::from` composition route \
19327 through the substrate-primitive `DepList::as_str` accessor \
19328 rather than through a per-call-site `.to_owned()` / \
19329 `String::from(list.as_str())` detour"
19330 );
19331 for &variant in super::DepList::ALL {
19332 let emitted: String = variant.into();
19333 let re_parsed: Result<super::DepList, ()> =
19334 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19335 assert_eq!(
19336 re_parsed,
19337 Ok(variant),
19338 "trait-idiomatic owned-`String` forward-projection + \
19339 reverse-projection axis pair must round-trip \
19340 DepList::{variant:?} through `.into::<String>()` and \
19341 back through `TryFrom<&str>` on the owned-`String`'s \
19342 String::as_str borrow — a break signals the owned-\
19343 `String` forward-emit and reverse-parse axes have \
19344 drifted onto different vocabularies (unlike the peer \
19345 CaixaKind axis pair, DepList's forward emit and \
19346 reverse parse share the same lifted \
19347 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
19348 round-trip composes directly)"
19349 );
19350 }
19351 }
19352
19353 #[test]
19354 fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
19355 // Fail-before-pass-after byte-parity pin on the newly lifted
19356 // `impl From<&DepList> for String` — asserts the borrowed-input
19357 // owned-`String`-returning standard-library trait impl and the
19358 // substrate-primitive [`super::DepList::as_str`] `pub const fn`
19359 // accessor resolve to the same two-arm emit-set across every
19360 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
19361 // Rust's standard library does not carry a blanket
19362 // `impl<T: AsRef<str>> From<&T> for String` (nor an
19363 // `impl<T: fmt::Display> From<&T> for String`), so the
19364 // borrowed-input owned-`String` forward-projection axis is a
19365 // distinct trait-idiomatic surface that a
19366 // `let key: String = (&list).into();`-shaped call site reaches
19367 // through this impl and no other — the paired sibling
19368 // `From<DepList> for String` impl forces every borrowed-input
19369 // call site through an explicit `Copy` deref
19370 // (`String::from(*list)`) or an `.as_str().to_owned()` /
19371 // `.to_string()` detour. Peer of the first-mover
19372 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19373 // (579385f) and the second-peer
19374 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19375 // (8465740) — extends the trait-idiomatic borrowed-input owned-
19376 // `String` forward-projection axis off the M2 OTP-shape sibling
19377 // axis pair onto the first non-M2 closed-set fieldless typed
19378 // enum peer (the two-list dep-graph axis).
19379 for &variant in super::DepList::ALL {
19380 let via_trait: String = <String as From<&super::DepList>>::from(&variant);
19381 let via_method: &'static str = variant.as_str();
19382 assert_eq!(
19383 via_trait.as_str(),
19384 via_method,
19385 "From<&DepList> for String impl must round-trip \
19386 &DepList::{variant:?} to the same lifted \
19387 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19388 DepList::as_str returns — divergence signals a silent \
19389 detour off the substrate-primitive accessor"
19390 );
19391 let via_into: String = (&variant).into();
19392 assert_eq!(
19393 via_into.as_str(),
19394 via_method,
19395 "Into<String>::into on &DepList::{variant:?} must \
19396 byte-equal DepList::as_str on the same input — the \
19397 blanket-derived Into shape must resolve to the same \
19398 as_str dispatch as the explicit From impl"
19399 );
19400 }
19401 }
19402
19403 #[test]
19404 fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
19405 // Cross-axis partition pin: the newly lifted trait-idiomatic
19406 // borrowed-input owned-`String` `From<&DepList> for String`
19407 // (this lift), the paired owned-input owned-`String`
19408 // `From<DepList> for String` (32b0ee8), the paired borrowed-
19409 // input owned-`&'static str` `From<&DepList> for &'static str`
19410 // (64aa742), and the paired owned-input owned-`&'static str`
19411 // `From<DepList> for &'static str` (3455cbf) — every corner of
19412 // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
19413 // idiomatic projection family — must resolve identically on
19414 // every arm, locking the four return-shape × input-shape paths
19415 // together so any future detour trips at caixa-core test time.
19416 // Also byte-parity witness against the sibling
19417 // [`ToString::to_string`] surface routed through
19418 // [`std::fmt::Display`] and a direct round-trip witness through
19419 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
19420 // the owned-`String`'s [`String::as_str`] borrow that closes
19421 // the two-way `&Self → String → Self` round-trip on the trait-
19422 // idiomatic borrowed-input owned-`String` forward + reverse
19423 // axis pair. Peer of the first-mover
19424 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19425 // (579385f) and the second-peer
19426 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19427 // (8465740) — closes the whole `{Self, &Self} × {&'static str,
19428 // String}` 2×2 projection corner on the third substrate-wide
19429 // closed-set fieldless typed enum peer (the two-list dep-graph
19430 // axis, first outside the M2 OTP-shape sibling pair).
19431 //
19432 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19433 // `From` emit lands on the lowercase Portuguese `as_str`
19434 // diagnostic vocabulary while the reverse `TryFrom<&str>`
19435 // parses the `PascalCase` `wire_name` author-surface vocabulary,
19436 // forcing the round-trip through an intermediate
19437 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19438 // [`super::DepList::as_str`] emit and
19439 // [`super::DepList::from_wire`] parse resolve through the same
19440 // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19441 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19442 // construction (there is no wire/diagnostic axis split on this
19443 // enum), so the borrowed-input owned-`String` forward axis and
19444 // the reverse axis compose directly — matching the peer
19445 // [`crate::supervisor::RestartStrategy`] /
19446 // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
19447 // `String` axis pairs.
19448 for &list in super::DepList::ALL {
19449 let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
19450 let owned_string: String = <String as From<super::DepList>>::from(list);
19451 let borrowed_static: &'static str =
19452 <&'static str as From<&super::DepList>>::from(&list);
19453 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19454 assert_eq!(
19455 borrowed_string, owned_string,
19456 "From<&DepList> for String and From<DepList> for String \
19457 must resolve identically on DepList::{list:?} — \
19458 divergence signals the borrowed-input and owned-input \
19459 owned-`String` forward-projection input-shape paths \
19460 have drifted onto different emit-sets"
19461 );
19462 assert_eq!(
19463 borrowed_string.as_str(),
19464 borrowed_static,
19465 "From<&DepList> for String and From<&DepList> for \
19466 &'static str must resolve identically on \
19467 DepList::{list:?} — divergence signals the borrowed-\
19468 input `&'static str` and owned-`String` return-shape \
19469 paths have drifted onto different emit-sets"
19470 );
19471 assert_eq!(
19472 borrowed_string.as_str(),
19473 owned_static,
19474 "From<&DepList> for String and From<DepList> for \
19475 &'static str must resolve identically on \
19476 DepList::{list:?} — divergence signals a break in the \
19477 diagonal corner of the {{Self, &Self}} × {{&'static \
19478 str, String}} 2×2 trait-idiomatic projection family"
19479 );
19480 let via_to_string: String = list.to_string();
19481 assert_eq!(
19482 borrowed_string, via_to_string,
19483 "From<&DepList> for String must byte-equal \
19484 DepList::to_string on DepList::{list:?} — divergence \
19485 signals the trait-idiomatic borrowed-input owned-\
19486 `String` forward-projection axis and the ToString-\
19487 through-Display axis have drifted onto different \
19488 emit-sets"
19489 );
19490 }
19491 let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
19492 let via_method: Vec<String> = super::DepList::ALL
19493 .iter()
19494 .map(|l| l.as_str().to_owned())
19495 .collect();
19496 assert_eq!(
19497 via_iter, via_method,
19498 "`.iter().map(String::from)` over DepList::ALL — a call \
19499 site whose iteration axis holds `&DepList` by construction \
19500 — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
19501 on every arm — the borrowed-input owned-`String` \
19502 `From<&DepList> for String` axis is what makes the \
19503 `String::from` composition route through the substrate-\
19504 primitive `DepList::as_str` accessor without a spurious \
19505 `Copy` deref (which would only be reachable through the \
19506 owned-input `From<DepList> for String` axis by first \
19507 calling `.copied()` on the iterator)"
19508 );
19509 for &variant in super::DepList::ALL {
19510 let emitted: String = (&variant).into();
19511 let re_parsed: Result<super::DepList, ()> =
19512 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19513 assert_eq!(
19514 re_parsed,
19515 Ok(variant),
19516 "trait-idiomatic borrowed-input owned-`String` \
19517 forward-projection + reverse-projection axis pair must \
19518 round-trip &DepList::{variant:?} through \
19519 `.into::<String>()` on the borrowed-input surface and \
19520 back through `TryFrom<&str>` on the owned-`String`'s \
19521 String::as_str borrow — a break signals the \
19522 borrowed-input owned-`String` forward-emit and \
19523 reverse-parse axes have drifted onto different \
19524 vocabularies (unlike the peer CaixaKind axis pair, \
19525 DepList's forward emit and reverse parse share the \
19526 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
19527 construction, so the round-trip composes directly)"
19528 );
19529 }
19530 }
19531
19532 #[test]
19533 fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
19534 // Fail-before-pass-after byte-parity pin on the newly lifted
19535 // `impl From<DepList> for std::borrow::Cow<'static, str>` —
19536 // asserts the standard-library trait impl and the substrate-
19537 // primitive [`super::DepList::as_str`] `pub const fn`
19538 // accessor resolve to the same two-arm emit-set across every
19539 // arm the exhaustive [`super::DepList::ALL`] slice
19540 // enumerates. Rust's standard library does not carry a
19541 // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19542 // (nor an `impl<T: fmt::Display> From<T> for
19543 // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19544 // projection axis is a distinct trait-idiomatic surface that
19545 // a `let key: Cow<'static, str> = list.into();`-shaped call
19546 // site reaches through this impl and no other — the paired
19547 // sibling `From<DepList> for &'static str` and
19548 // `From<DepList> for String` impls force every
19549 // `Cow<'static, str>`-parameterized call site through a
19550 // `Cow::Borrowed(list.as_str())` /
19551 // `Cow::Owned(list.to_string())` composition whose type
19552 // bounds have no compile-time link back to the substrate
19553 // primitive.
19554 //
19555 // Also asserts the projection lands on the zero-alloc
19556 // [`std::borrow::Cow::Borrowed`] arm (not the
19557 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19558 // [`super::DepList::as_str`] accessor's `&'static str`
19559 // return lifetime by construction (each match arm resolves
19560 // to one of the two lifted
19561 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19562 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19563 // &str` values) makes the borrowed arm the type-correct
19564 // projection with no runtime allocation. Any future silent
19565 // detour that routes the impl through the owned arm trips
19566 // at caixa-core test time under the
19567 // [`std::borrow::Cow::Borrowed`] discriminator witness
19568 // rather than at a downstream `Cow<'static, str>`-bound
19569 // consumer's silent allocation.
19570 //
19571 // First-mover on the outside-M3 substrate-wide tier of the
19572 // substrate-wide trait-idiomatic
19573 // [`std::borrow::Cow<'static, str>`] forward-projection
19574 // campaign — extends the axis off the paired
19575 // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19576 // the paired M2 OTP-shape
19577 // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19578 // and [`crate::supervisor::RestartPolicy`] (0612398 +
19579 // ee577fd), and the paired M3-mesh-shape
19580 // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19581 // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19582 // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19583 // peers onto the first outside-M3 caixa-core peer (the two-
19584 // list dep-graph axis), opening the outside-M3 caixa-core
19585 // tier of the substrate-wide Cow<'static, str> forward-
19586 // projection campaign's owned-input corner.
19587 for &variant in super::DepList::ALL {
19588 let via_trait: std::borrow::Cow<'static, str> =
19589 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19590 let via_method: &'static str = variant.as_str();
19591 assert_eq!(
19592 via_trait.as_ref(),
19593 via_method,
19594 "From<DepList> for Cow<'static, str> impl must \
19595 round-trip DepList::{variant:?} to the same lifted \
19596 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19597 DepList::as_str returns — divergence signals a \
19598 silent detour off the substrate-primitive accessor"
19599 );
19600 assert!(
19601 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19602 "From<DepList> for Cow<'static, str> impl must land \
19603 on the zero-alloc Cow::Borrowed arm on \
19604 DepList::{variant:?} — a Cow::Owned outcome signals \
19605 the projection has silently allocated where the \
19606 substrate-primitive DepList::as_str `&'static str` \
19607 return makes the borrowed arm the type-correct \
19608 projection"
19609 );
19610 let via_into: std::borrow::Cow<'static, str> = variant.into();
19611 assert_eq!(
19612 via_into.as_ref(),
19613 via_method,
19614 "Into<Cow<'static, str>>::into on DepList::\
19615 {variant:?} must byte-equal DepList::as_str on the \
19616 same input — the blanket-derived Into shape must \
19617 resolve to the same as_str dispatch as the explicit \
19618 From impl"
19619 );
19620 assert!(
19621 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19622 "Into<Cow<'static, str>>::into on DepList::\
19623 {variant:?} must land on the zero-alloc \
19624 Cow::Borrowed arm — the blanket-derived Into shape \
19625 must resolve to the same Cow::Borrowed dispatch as \
19626 the explicit From impl"
19627 );
19628 }
19629 }
19630
19631 #[test]
19632 fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19633 // Cross-axis partition pin: the newly lifted trait-idiomatic
19634 // `From<DepList> for std::borrow::Cow<'static, str>` (this
19635 // lift), the paired owned-input `From<DepList> for
19636 // &'static str` (3455cbf), and the paired owned-input
19637 // `From<DepList> for String` (32b0ee8) forward projections
19638 // must resolve identically on every arm, locking the three
19639 // return-shape paths together by construction so any future
19640 // detour trips at caixa-core test time. Also byte-parity
19641 // witness against the sibling [`ToString::to_string`]
19642 // surface routed through [`std::fmt::Display`] — every
19643 // owned-heap-string path (the `Cow::Owned` promotion of
19644 // this axis's `.into_owned()`, `From<DepList> for String`,
19645 // and `.to_string()`) resolves to the same two-arm lifted
19646 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19647 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19648 // arm.
19649 //
19650 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19651 // witness over [`super::DepList::ALL`] that materializes the
19652 // two-arm accept-set through the
19653 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19654 // shape a future M4 admission-webhook rejection body's
19655 // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19656 // future substrate-wide per-arm diagnostic surface whose
19657 // typing rules out the sibling [`AsRef<str>`] borrowed
19658 // return, or a future per-arm dep-list emitter that binds
19659 // through a [`std::borrow::Cow<'static, str>`] boundary
19660 // reaches through — opening the composable-projection axis
19661 // on the first outside-M3 caixa-core closed-set fieldless
19662 // typed enum peer on the caixa surface. The pipe witness
19663 // also pins the zero-alloc discipline: every element in the
19664 // collected vector satisfies the
19665 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19666 // accidental silent-allocation regression on the pipe's
19667 // iteration axis is a caixa-core-test-time failure.
19668 for &variant in super::DepList::ALL {
19669 let via_cow: std::borrow::Cow<'static, str> =
19670 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19671 let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19672 let via_string: String = <String as From<super::DepList>>::from(variant);
19673 assert_eq!(
19674 via_cow.as_ref(),
19675 via_static,
19676 "From<DepList> for Cow<'static, str> and \
19677 From<DepList> for &'static str must resolve \
19678 identically on DepList::{variant:?} — divergence \
19679 signals the Cow<'static, str> and &'static str \
19680 return-shape paths have drifted onto different \
19681 emit-sets"
19682 );
19683 assert_eq!(
19684 via_cow.as_ref(),
19685 via_string.as_str(),
19686 "From<DepList> for Cow<'static, str> and \
19687 From<DepList> for String must resolve identically \
19688 on DepList::{variant:?} — divergence signals the \
19689 Cow<'static, str> and String return-shape paths \
19690 have drifted onto different emit-sets"
19691 );
19692 let via_to_string: String = variant.to_string();
19693 assert_eq!(
19694 via_cow.as_ref(),
19695 via_to_string.as_str(),
19696 "From<DepList> for Cow<'static, str> must byte-equal \
19697 DepList::to_string on DepList::{variant:?} — \
19698 divergence signals the trait-idiomatic \
19699 Cow<'static, str> forward-projection axis and the \
19700 ToString-through-Display axis have drifted onto \
19701 different emit-sets"
19702 );
19703 }
19704 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19705 .iter()
19706 .copied()
19707 .map(std::borrow::Cow::from)
19708 .collect();
19709 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19710 .iter()
19711 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19712 .collect();
19713 assert_eq!(
19714 via_iter, via_method,
19715 "`.iter().copied().map(Cow::from)` over DepList::ALL \
19716 must byte-equal `.iter().map(|l| \
19717 Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19718 idiomatic `From<DepList> for Cow<'static, str>` axis is \
19719 what makes the `Cow::from` composition route through \
19720 the substrate-primitive `DepList::as_str` accessor with \
19721 the zero-alloc Cow::Borrowed arm by construction, \
19722 rather than a per-call-site `Cow::Owned(list.to_string())` \
19723 allocation"
19724 );
19725 for cow in &via_iter {
19726 assert!(
19727 matches!(cow, std::borrow::Cow::Borrowed(_)),
19728 "every element of the .iter().copied().map(Cow::from) \
19729 pipe over DepList::ALL must land on the zero-alloc \
19730 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19731 signals the pipe's iteration axis has silently \
19732 allocated where the substrate-primitive \
19733 DepList::as_str `&'static str` return makes the \
19734 borrowed arm the type-correct projection"
19735 );
19736 }
19737 }
19738
19739 #[test]
19740 fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19741 // Fail-before-pass-after byte-parity pin on the newly lifted
19742 // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19743 // asserts the borrowed-input standard-library trait impl and
19744 // the substrate-primitive [`super::DepList::as_str`] `pub const
19745 // fn` accessor resolve to the same two-arm emit-set across
19746 // every arm the exhaustive [`super::DepList::ALL`] slice
19747 // enumerates. Rust's standard library does not carry a blanket
19748 // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19749 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19750 // the borrowed-input `Cow<'static, str>` forward-projection
19751 // axis is a distinct trait-idiomatic surface that a
19752 // `let key: Cow<'static, str> = (&list).into();`-shaped call
19753 // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19754 // reaches through this impl and no other — the paired owned-
19755 // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19756 // forces every borrowed-input call site through an explicit
19757 // `Copy` deref (`Cow::from(*list)`) or a
19758 // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19759 // have no compile-time link back to the substrate primitive.
19760 //
19761 // Also asserts the projection lands on the zero-alloc
19762 // [`std::borrow::Cow::Borrowed`] arm (not the
19763 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19764 // [`super::DepList::as_str`] accessor's `&'static str` return
19765 // lifetime by construction (each match arm resolves to one of
19766 // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19767 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19768 // values) makes the borrowed arm the type-correct projection
19769 // with no runtime allocation on the borrowed-input surface
19770 // just as on the paired owned-input surface.
19771 //
19772 // Closes the `{Self, &Self}` input-shape corner on the outside-
19773 // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19774 // on the first outside-M3 caixa-core closed-set fieldless typed
19775 // enum peer on the caixa surface, exactly as afdf0f4 closed it
19776 // on the second M3-mesh-primitive peer
19777 // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19778 // the owning half (eee504d) landed, as 25690ef closed it on
19779 // the first M3-mesh-primitive peer
19780 // ([`crate::aplicacao::WitShape`]) one commit after the owning
19781 // half (8634dec) landed, as d45c409 closed it on the top-level
19782 // [`crate::CaixaKind`] one commit after the owning half
19783 // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19784 // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19785 // [`crate::supervisor::RestartPolicy`] sibling peers one
19786 // commit after (7dd28b3 / 0612398) landed.
19787 for &variant in super::DepList::ALL {
19788 let via_trait: std::borrow::Cow<'static, str> =
19789 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19790 let via_method: &'static str = variant.as_str();
19791 assert_eq!(
19792 via_trait.as_ref(),
19793 via_method,
19794 "From<&DepList> for Cow<'static, str> impl must \
19795 round-trip &DepList::{variant:?} to the same lifted \
19796 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19797 DepList::as_str returns — divergence signals a silent \
19798 detour off the substrate-primitive accessor"
19799 );
19800 assert!(
19801 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19802 "From<&DepList> for Cow<'static, str> impl must land \
19803 on the zero-alloc Cow::Borrowed arm on \
19804 &DepList::{variant:?} — a Cow::Owned outcome signals \
19805 the projection has silently allocated where the \
19806 substrate-primitive DepList::as_str `&'static str` \
19807 return makes the borrowed arm the type-correct \
19808 projection"
19809 );
19810 let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19811 assert_eq!(
19812 via_into.as_ref(),
19813 via_method,
19814 "Into<Cow<'static, str>>::into on &DepList::\
19815 {variant:?} must byte-equal DepList::as_str on the \
19816 same input — the blanket-derived Into shape must \
19817 resolve to the same as_str dispatch as the explicit \
19818 From impl"
19819 );
19820 assert!(
19821 matches!(via_into, std::borrow::Cow::Borrowed(_)),
19822 "Into<Cow<'static, str>>::into on &DepList::\
19823 {variant:?} must land on the zero-alloc \
19824 Cow::Borrowed arm — the blanket-derived Into shape \
19825 must resolve to the same Cow::Borrowed dispatch as \
19826 the explicit From impl"
19827 );
19828 }
19829 }
19830
19831 #[test]
19832 fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19833 // Cross-axis partition pin: the newly lifted trait-idiomatic
19834 // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19835 // str>` (this lift), the paired owned-input `From<DepList> for
19836 // std::borrow::Cow<'static, str>` (6858bac), the paired
19837 // borrowed-input owned-`&'static str` `From<&DepList> for
19838 // &'static str` (3455cbf), and the paired borrowed-input
19839 // owned-`String` `From<&DepList> for String` must resolve
19840 // identically on every arm, locking the four return-shape ×
19841 // input-shape paths together by construction so any future
19842 // detour trips at caixa-core test time. Also byte-parity
19843 // witness against the sibling [`ToString::to_string`] surface
19844 // routed through [`std::fmt::Display`] — every owned-heap-
19845 // string path (this axis's `.into_owned()` promotion, the
19846 // paired [`From<&DepList> for String`], and `.to_string()`)
19847 // resolves to the same two-arm lifted
19848 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19849 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19850 // arm.
19851 //
19852 // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19853 // over [`super::DepList::ALL`] — whose iterator yields
19854 // `&DepList` by construction, so the borrowed-input
19855 // [`Cow<'static, str>`] axis is what routes the pipe through
19856 // the substrate-primitive [`super::DepList::as_str`] accessor
19857 // without a spurious [`Copy`] deref (which would only be
19858 // reachable through the owned-input [`From<DepList> for
19859 // Cow<'static, str>`] axis by first calling `.copied()` on the
19860 // iterator). The pipe witness also pins the zero-alloc
19861 // discipline: every element in the collected vector satisfies
19862 // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19863 // future accidental silent-allocation regression on the pipe's
19864 // iteration axis is a caixa-core-test-time failure. Peer of
19865 // the sibling
19866 // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19867 // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19868 // axis — extends the whole borrowed-input `Cow<'static, str>`
19869 // + paired `{&'static str, String}` cross-axis-parity corner
19870 // onto the first outside-M3 caixa-core closed-set fieldless
19871 // typed enum peer on the caixa surface.
19872 for &variant in super::DepList::ALL {
19873 let borrowed_cow: std::borrow::Cow<'static, str> =
19874 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19875 let owned_cow: std::borrow::Cow<'static, str> =
19876 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19877 let borrowed_static: &'static str =
19878 <&'static str as From<&super::DepList>>::from(&variant);
19879 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19880 assert_eq!(
19881 borrowed_cow, owned_cow,
19882 "From<&DepList> for Cow<'static, str> and \
19883 From<DepList> for Cow<'static, str> must resolve \
19884 identically on DepList::{variant:?} — divergence \
19885 signals the borrowed-input and owned-input \
19886 Cow<'static, str> forward-projection input-shape \
19887 paths have drifted onto different emit-sets"
19888 );
19889 assert_eq!(
19890 borrowed_cow.as_ref(),
19891 borrowed_static,
19892 "From<&DepList> for Cow<'static, str> and \
19893 From<&DepList> for &'static str must resolve \
19894 identically on DepList::{variant:?} — divergence \
19895 signals the borrowed-input Cow<'static, str> and \
19896 &'static str return-shape paths have drifted onto \
19897 different emit-sets"
19898 );
19899 assert_eq!(
19900 borrowed_cow.as_ref(),
19901 borrowed_string.as_str(),
19902 "From<&DepList> for Cow<'static, str> and \
19903 From<&DepList> for String must resolve identically \
19904 on DepList::{variant:?} — divergence signals the \
19905 borrowed-input Cow<'static, str> and owned-`String` \
19906 return-shape paths have drifted onto different \
19907 emit-sets"
19908 );
19909 let via_to_string: String = variant.to_string();
19910 assert_eq!(
19911 borrowed_cow.as_ref(),
19912 via_to_string.as_str(),
19913 "From<&DepList> for Cow<'static, str> must byte-equal \
19914 DepList::to_string on DepList::{variant:?} — \
19915 divergence signals the trait-idiomatic borrowed-input \
19916 Cow<'static, str> forward-projection axis and the \
19917 ToString-through-Display axis have drifted onto \
19918 different emit-sets"
19919 );
19920 }
19921 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19922 .iter()
19923 .map(std::borrow::Cow::from)
19924 .collect();
19925 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19926 .iter()
19927 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19928 .collect();
19929 assert_eq!(
19930 via_iter, via_method,
19931 "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19932 whose iteration axis holds &DepList by construction — \
19933 must byte-equal `.iter().map(|l| \
19934 Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19935 input Cow<'static, str> `From<&DepList> for Cow<'static, \
19936 str>` axis is what makes the `Cow::from` composition \
19937 route through the substrate-primitive `DepList::as_str` \
19938 accessor with the zero-alloc Cow::Borrowed arm by \
19939 construction and without a spurious `Copy` deref (which \
19940 would only be reachable through the owned-input \
19941 `From<DepList> for Cow<'static, str>` axis by first \
19942 calling `.copied()` on the iterator)"
19943 );
19944 for cow in &via_iter {
19945 assert!(
19946 matches!(cow, std::borrow::Cow::Borrowed(_)),
19947 "every element of the .iter().map(Cow::from) pipe \
19948 over DepList::ALL must land on the zero-alloc \
19949 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19950 signals the pipe's iteration axis has silently \
19951 allocated where the substrate-primitive \
19952 DepList::as_str `&'static str` return makes the \
19953 borrowed arm the type-correct projection"
19954 );
19955 }
19956 }
19957
19958 #[test]
19959 fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19960 // Fail-before-pass-after byte-parity pin on the newly lifted
19961 // `impl From<DepList> for Box<str>` — asserts the owned-input
19962 // standard-library trait impl and the substrate-primitive
19963 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19964 // the same two-arm emit-set (the paired
19965 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19966 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19967 // byte-strings) across every arm the exhaustive
19968 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19969 // core-internal tier of the substrate-wide [`Box<str>`] forward-
19970 // projection campaign onto the second caixa-core-internal peer,
19971 // after the render-side path-shape-diagnostic
19972 // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19973 // both corners in one axis) opened the tier. Rust's standard
19974 // library carries `impl From<&str> for Box<str>` and
19975 // `impl From<String> for Box<str>` but no blanket
19976 // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19977 // distinct trait-idiomatic surface that a
19978 // `let key: Box<str> = list.into();`-shaped call site reaches
19979 // through this impl and no other — a paired
19980 // `Box::from(list.as_str())` open-code has no compile-time link
19981 // back to the substrate primitive.
19982 for &variant in super::DepList::ALL {
19983 let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19984 let via_method: &'static str = variant.as_str();
19985 assert_eq!(
19986 via_trait.as_ref(),
19987 via_method,
19988 "From<DepList> for Box<str> impl must round-trip \
19989 DepList::{variant:?} to the same lifted \
19990 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19991 DepList::as_str returns — divergence signals a silent \
19992 detour off the substrate-primitive accessor"
19993 );
19994 let via_into: Box<str> = variant.into();
19995 assert_eq!(
19996 via_into.as_ref(),
19997 via_method,
19998 "Into<Box<str>>::into on DepList::{variant:?} must \
19999 byte-equal DepList::as_str on the same input — the \
20000 blanket-derived Into shape must resolve to the same \
20001 as_str dispatch as the explicit From impl"
20002 );
20003 }
20004 }
20005
20006 #[test]
20007 fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
20008 // Fail-before-pass-after byte-parity pin on the newly lifted
20009 // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
20010 // standard-library trait impl and the substrate-primitive
20011 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
20012 // the same two-arm emit-set (the paired
20013 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20014 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20015 // byte-strings) across every arm the exhaustive
20016 // [`super::DepList::ALL`] slice enumerates. Rust's standard
20017 // library carries `impl From<&str> for Box<str>` and
20018 // `impl From<String> for Box<str>` but no blanket
20019 // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
20020 // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
20021 // input [`Box<str>`] forward-projection axis is a distinct
20022 // trait-idiomatic surface that a
20023 // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
20024 // iterator over `&'static [DepList]` yields `&DepList` by
20025 // construction) or a `let key: Box<str> = (&list).into();`-shaped
20026 // call site reaches through this impl and no other — the paired
20027 // owned-input `From<DepList> for Box<str>` impl alone would force
20028 // every borrowed-input call site through an explicit `Copy` deref
20029 // (`Box::<str>::from(*list)`) or a
20030 // `Box::<str>::from(list.as_str())` open-code whose type bounds
20031 // have no compile-time link back to the substrate primitive.
20032 //
20033 // Closes the `{Self, &Self}` input-shape corner on the second
20034 // caixa-core-internal closed-set fieldless typed enum peer of
20035 // the substrate-wide [`Box<str>`] forward-projection campaign —
20036 // one commit after the paired render-side path-shape-diagnostic
20037 // [`super::super::render::PathShapeViolation`] pair (0d87a72)
20038 // opened the caixa-core-internal tier — matching the trajectory
20039 // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
20040 // in one axis), the caixa-provedor `FerriteRuntime` pair
20041 // (14886a8, both corners in one axis), and the render-side
20042 // `PathShapeViolation` pair (0d87a72, both corners in one axis)
20043 // walked before it.
20044 for &variant in super::DepList::ALL {
20045 let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20046 let via_method: &'static str = variant.as_str();
20047 assert_eq!(
20048 via_trait.as_ref(),
20049 via_method,
20050 "From<&DepList> for Box<str> impl must round-trip \
20051 &DepList::{variant:?} to the same lifted \
20052 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20053 DepList::as_str returns — divergence signals a silent \
20054 detour off the substrate-primitive accessor"
20055 );
20056 let via_into: Box<str> = (&variant).into();
20057 assert_eq!(
20058 via_into.as_ref(),
20059 via_method,
20060 "Into<Box<str>>::into on &DepList::{variant:?} must \
20061 byte-equal DepList::as_str on the same input — the \
20062 blanket-derived Into shape on the borrowed-input \
20063 surface must resolve to the same as_str dispatch as \
20064 the explicit From impl"
20065 );
20066 }
20067
20068 // Pipe witness — the distinguishing shape that forces the
20069 // borrowed-input axis to be independent of the owned-input
20070 // peer. `DepList::ALL.iter()` yields `&DepList` by
20071 // construction, so `.map(Box::<str>::from)` resolves through
20072 // the borrowed-input `From<&DepList> for Box<str>` impl and
20073 // no other — without this axis, the same pipe would force an
20074 // explicit `.copied()` restatement whose type bounds bypass
20075 // the substrate primitive.
20076 let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
20077 let via_accessor: Vec<&'static str> =
20078 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
20079 assert_eq!(
20080 via_pipe.len(),
20081 via_accessor.len(),
20082 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
20083 preserve arity against the paired DepList::as_str \
20084 accessor — a length divergence signals the borrowed-input \
20085 axis has silently rejected an arm"
20086 );
20087 for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
20088 assert_eq!(
20089 pipe_arm.as_ref(),
20090 *accessor_arm,
20091 "DepList::ALL.iter().map(Box::<str>::from) pipe must \
20092 byte-equal the paired \
20093 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
20094 arm — divergence signals the borrowed-input \
20095 `From<&DepList> for Box<str>` axis has silently \
20096 detoured off the substrate-primitive accessor"
20097 );
20098 }
20099 }
20100
20101 #[test]
20102 fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
20103 // Fail-before-pass-after byte-parity pin on the newly lifted
20104 // `impl From<DepList> for std::sync::Arc<str>` — asserts the
20105 // owned-input standard-library trait impl and the substrate-
20106 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20107 // resolve to the same two-arm emit-set (the paired
20108 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20109 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20110 // byte-strings) across every arm the exhaustive
20111 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20112 // core-internal tier of the substrate-wide
20113 // [`std::sync::Arc<str>`] forward-projection campaign onto the
20114 // second caixa-core-internal peer, after the top-level
20115 // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
20116 // opened the tier. Rust's standard library carries
20117 // `impl From<&str> for std::sync::Arc<str>` and
20118 // `impl From<String> for std::sync::Arc<str>` but no blanket
20119 // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
20120 // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
20121 // this axis is a distinct trait-idiomatic surface that a
20122 // `let key: std::sync::Arc<str> = list.into();`-shaped call site
20123 // reaches through this impl and no other — a paired
20124 // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
20125 // compile-time link back to the substrate primitive, and a two-
20126 // step `std::sync::Arc::<str>::from(String::from(list))`
20127 // composition through the owned-`String` axis allocates twice
20128 // (once into the intermediate `String`, once into the
20129 // [`std::sync::Arc<str>`] on the `From<String>` conversion)
20130 // where the single-step trait impl allocates once.
20131 //
20132 // Cross-axis byte-parity witness against the sibling owned-input
20133 // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
20134 // shape axes — locking the five return-shape paths on the owned-
20135 // input surface together by construction so any future detour
20136 // off the substrate-primitive [`super::DepList::as_str`] accessor
20137 // trips at caixa-core test time.
20138 for &variant in super::DepList::ALL {
20139 let via_trait: std::sync::Arc<str> =
20140 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20141 let via_method: &'static str = variant.as_str();
20142 assert_eq!(
20143 via_trait.as_ref(),
20144 via_method,
20145 "From<DepList> for std::sync::Arc<str> impl must round-\
20146 trip DepList::{variant:?} to the same lifted \
20147 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20148 DepList::as_str returns — divergence signals a silent \
20149 detour off the substrate-primitive accessor"
20150 );
20151 let via_into: std::sync::Arc<str> = variant.into();
20152 assert_eq!(
20153 via_into.as_ref(),
20154 via_method,
20155 "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
20156 must byte-equal DepList::as_str on the same input — \
20157 the blanket-derived Into shape must resolve to the same \
20158 as_str dispatch as the explicit From impl"
20159 );
20160 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20161 assert_eq!(
20162 via_trait.as_ref(),
20163 owned_static,
20164 "From<DepList> for std::sync::Arc<str> and \
20165 From<DepList> for &'static str must resolve identically \
20166 on DepList::{variant:?} — divergence signals the owned-\
20167 input std::sync::Arc<str> and &'static str return-shape \
20168 paths have drifted onto different emit-sets"
20169 );
20170 let owned_string: String = <String as From<super::DepList>>::from(variant);
20171 assert_eq!(
20172 via_trait.as_ref(),
20173 owned_string.as_str(),
20174 "From<DepList> for std::sync::Arc<str> and \
20175 From<DepList> for String must resolve identically on \
20176 DepList::{variant:?} — divergence signals the owned-\
20177 input std::sync::Arc<str> and owned-`String` return-shape \
20178 paths have drifted onto different emit-sets"
20179 );
20180 let owned_cow: std::borrow::Cow<'static, str> =
20181 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20182 assert_eq!(
20183 via_trait.as_ref(),
20184 owned_cow.as_ref(),
20185 "From<DepList> for std::sync::Arc<str> and \
20186 From<DepList> for Cow<'static, str> must resolve \
20187 identically on DepList::{variant:?} — divergence signals \
20188 the owned-input std::sync::Arc<str> and \
20189 Cow<'static, str> return-shape paths have drifted onto \
20190 different emit-sets"
20191 );
20192 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20193 assert_eq!(
20194 via_trait.as_ref(),
20195 owned_box.as_ref(),
20196 "From<DepList> for std::sync::Arc<str> and \
20197 From<DepList> for Box<str> must resolve identically on \
20198 DepList::{variant:?} — divergence signals the owned-\
20199 input std::sync::Arc<str> and Box<str> return-shape \
20200 paths have drifted onto different emit-sets"
20201 );
20202 }
20203 }
20204
20205 #[test]
20206 #[allow(
20207 clippy::too_many_lines,
20208 reason = "cross-axis partition pin folds four borrowed-input \
20209 return-shape paths (&'static str, String, Cow<'static, \
20210 str>, Box<str>) plus the paired owned-input Arc<str> \
20211 witness and the .iter().map(std::sync::Arc::<str>::from) \
20212 pipe witness into one exhaustive round-trip over \
20213 DepList::ALL — the accepted line-count cost of keying \
20214 the whole borrowed-input Arc<str> corner to the \
20215 substrate-primitive as_str accessor at the same test-site"
20216 )]
20217 fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
20218 // Fail-before-pass-after byte-parity pin on the newly lifted
20219 // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
20220 // borrowed-input standard-library trait impl and the substrate-
20221 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20222 // resolve to the same two-arm emit-set across every arm the
20223 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20224 // standard library does not carry a blanket
20225 // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
20226 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20227 // the borrowed-input `std::sync::Arc<str>` forward-projection
20228 // axis is a distinct trait-idiomatic surface that a
20229 // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
20230 // site or a
20231 // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
20232 // pipe reaches through this impl and no other — the paired
20233 // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
20234 // forces every borrowed-input call site through a spurious
20235 // `Copy` deref
20236 // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
20237 // `.copied()` restatement whose type bounds have no compile-time
20238 // link back to the substrate primitive.
20239 //
20240 // Closes the `{Self, &Self}` input-shape corner on the second
20241 // caixa-core-internal closed-set fieldless typed enum peer of
20242 // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
20243 // forward-projection campaign — one commit after the paired
20244 // top-level [`crate::CaixaKind`] pair (c17be64) opened the
20245 // caixa-core-internal tier — matching the
20246 // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
20247 // Box<str>}` 2×4 forward-projection matrix the peer projection
20248 // surfaces already close on this same enum.
20249 //
20250 // Cross-axis partition pin against the paired owned-input
20251 // [`From<DepList> for std::sync::Arc<str>`] and the sibling
20252 // borrowed-input `{&'static str, String, Cow<'static, str>,
20253 // Box<str>}` return-shape axes — locking the five return-shape
20254 // × input-shape paths on the borrowed-input surface together by
20255 // construction so any future detour off the substrate-primitive
20256 // accessor trips at caixa-core test time. Then a
20257 // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
20258 // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
20259 // construction, so the borrowed-input
20260 // [`std::sync::Arc<str>`] axis is what routes the pipe through
20261 // the substrate-primitive [`super::DepList::as_str`] accessor
20262 // without a spurious [`Copy`] deref (which would only be
20263 // reachable through the owned-input
20264 // [`From<DepList> for std::sync::Arc<str>`] axis by first
20265 // calling `.copied()` on the iterator).
20266 for &variant in super::DepList::ALL {
20267 let via_trait: std::sync::Arc<str> =
20268 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20269 let via_method: &'static str = variant.as_str();
20270 assert_eq!(
20271 via_trait.as_ref(),
20272 via_method,
20273 "From<&DepList> for std::sync::Arc<str> impl must round-\
20274 trip &DepList::{variant:?} to the same lifted \
20275 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20276 DepList::as_str returns — divergence signals a silent \
20277 detour off the substrate-primitive accessor"
20278 );
20279 let via_into: std::sync::Arc<str> = (&variant).into();
20280 assert_eq!(
20281 via_into.as_ref(),
20282 via_method,
20283 "Into<std::sync::Arc<str>>::into on &DepList::\
20284 {variant:?} must byte-equal DepList::as_str on the \
20285 same input — the blanket-derived Into shape on the \
20286 borrowed-input surface must resolve to the same as_str \
20287 dispatch as the explicit From impl"
20288 );
20289 let owned_arc: std::sync::Arc<str> =
20290 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20291 assert_eq!(
20292 via_trait, owned_arc,
20293 "From<&DepList> for std::sync::Arc<str> and \
20294 From<DepList> for std::sync::Arc<str> must resolve \
20295 identically on DepList::{variant:?} — divergence \
20296 signals the borrowed-input and owned-input \
20297 std::sync::Arc<str> forward-projection input-shape \
20298 paths have drifted onto different emit-sets"
20299 );
20300 let borrowed_static: &'static str =
20301 <&'static str as From<&super::DepList>>::from(&variant);
20302 assert_eq!(
20303 via_trait.as_ref(),
20304 borrowed_static,
20305 "From<&DepList> for std::sync::Arc<str> and \
20306 From<&DepList> for &'static str must resolve \
20307 identically on DepList::{variant:?} — divergence \
20308 signals the borrowed-input std::sync::Arc<str> and \
20309 &'static str return-shape paths have drifted onto \
20310 different emit-sets"
20311 );
20312 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20313 assert_eq!(
20314 via_trait.as_ref(),
20315 borrowed_string.as_str(),
20316 "From<&DepList> for std::sync::Arc<str> and \
20317 From<&DepList> for String must resolve identically on \
20318 DepList::{variant:?} — divergence signals the \
20319 borrowed-input std::sync::Arc<str> and owned-`String` \
20320 return-shape paths have drifted onto different emit-\
20321 sets"
20322 );
20323 let borrowed_cow: std::borrow::Cow<'static, str> =
20324 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20325 assert_eq!(
20326 via_trait.as_ref(),
20327 borrowed_cow.as_ref(),
20328 "From<&DepList> for std::sync::Arc<str> and \
20329 From<&DepList> for Cow<'static, str> must resolve \
20330 identically on DepList::{variant:?} — divergence \
20331 signals the borrowed-input std::sync::Arc<str> and \
20332 Cow<'static, str> return-shape paths have drifted onto \
20333 different emit-sets"
20334 );
20335 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20336 assert_eq!(
20337 via_trait.as_ref(),
20338 borrowed_box.as_ref(),
20339 "From<&DepList> for std::sync::Arc<str> and \
20340 From<&DepList> for Box<str> must resolve identically \
20341 on DepList::{variant:?} — divergence signals the \
20342 borrowed-input std::sync::Arc<str> and Box<str> \
20343 return-shape paths have drifted onto different emit-sets"
20344 );
20345 }
20346 let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
20347 .iter()
20348 .map(std::sync::Arc::<str>::from)
20349 .collect();
20350 let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
20351 .iter()
20352 .map(|l| std::sync::Arc::<str>::from(l.as_str()))
20353 .collect();
20354 assert_eq!(
20355 via_iter, via_method,
20356 "`.iter().map(std::sync::Arc::<str>::from)` over \
20357 DepList::ALL — a call site whose iteration axis holds \
20358 `&DepList` by construction — must byte-equal \
20359 `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
20360 on every arm — the borrowed-input std::sync::Arc<str> \
20361 `From<&DepList> for std::sync::Arc<str>` axis is what \
20362 makes the `std::sync::Arc::<str>::from` composition route \
20363 through the substrate-primitive `DepList::as_str` \
20364 accessor without a spurious `Copy` deref (which would \
20365 only be reachable through the owned-input \
20366 `From<DepList> for std::sync::Arc<str>` axis by first \
20367 calling `.copied()` on the iterator)"
20368 );
20369 }
20370
20371 #[test]
20372 fn dep_list_from_into_rc_str_routes_through_as_str_accessor() {
20373 // Fail-before-pass-after byte-parity pin on the newly lifted
20374 // `impl From<DepList> for std::rc::Rc<str>` — asserts the
20375 // owned-input standard-library trait impl and the substrate-
20376 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20377 // resolve to the same two-arm emit-set (the paired
20378 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20379 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20380 // byte-strings) across every arm the exhaustive
20381 // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20382 // core-internal tier of the substrate-wide
20383 // [`std::rc::Rc<str>`] forward-projection campaign onto the
20384 // third caixa-core-internal peer, after the top-level
20385 // [`crate::CaixaKind`] (e04aff0), the second-peer
20386 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and the render-
20387 // side [`crate::render::PathShapeViolation`] (31fc43e) pairs
20388 // opened the tier. Rust's standard library carries
20389 // `impl From<&str> for std::rc::Rc<str>` and
20390 // `impl From<String> for std::rc::Rc<str>` but no blanket
20391 // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and the
20392 // [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait
20393 // tables are disjoint, so this axis is a distinct trait-
20394 // idiomatic surface that a
20395 // `let key: std::rc::Rc<str> = list.into();`-shaped call site
20396 // reaches through this impl and no other — a paired
20397 // `std::rc::Rc::<str>::from(list.as_str())` open-code has no
20398 // compile-time link back to the substrate primitive, and a
20399 // two-step `std::rc::Rc::<str>::from(String::from(list))`
20400 // composition through the owned-`String` axis allocates twice
20401 // (once into the intermediate `String`, once into the
20402 // [`std::rc::Rc<str>`] on the `From<String>` conversion) where
20403 // the single-step trait impl allocates once.
20404 //
20405 // Cross-axis byte-parity witness against the sibling owned-
20406 // input `{&'static str, String, Cow<'static, str>, Box<str>,
20407 // std::sync::Arc<str>}` return-shape axes — locking the six
20408 // return-shape paths on the owned-input surface together by
20409 // construction so any future detour off the substrate-
20410 // primitive [`super::DepList::as_str`] accessor trips at
20411 // caixa-core test time.
20412 for &variant in super::DepList::ALL {
20413 let via_trait: std::rc::Rc<str> =
20414 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20415 let via_method: &'static str = variant.as_str();
20416 assert_eq!(
20417 via_trait.as_ref(),
20418 via_method,
20419 "From<DepList> for std::rc::Rc<str> impl must round-\
20420 trip DepList::{variant:?} to the same lifted \
20421 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20422 DepList::as_str returns — divergence signals a silent \
20423 detour off the substrate-primitive accessor"
20424 );
20425 let via_into: std::rc::Rc<str> = variant.into();
20426 assert_eq!(
20427 via_into.as_ref(),
20428 via_method,
20429 "Into<std::rc::Rc<str>>::into on DepList::{variant:?} \
20430 must byte-equal DepList::as_str on the same input — \
20431 the blanket-derived Into shape must resolve to the \
20432 same as_str dispatch as the explicit From impl"
20433 );
20434 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20435 assert_eq!(
20436 via_trait.as_ref(),
20437 owned_static,
20438 "From<DepList> for std::rc::Rc<str> and \
20439 From<DepList> for &'static str must resolve identically \
20440 on DepList::{variant:?} — divergence signals the owned-\
20441 input std::rc::Rc<str> and &'static str return-shape \
20442 paths have drifted onto different emit-sets"
20443 );
20444 let owned_string: String = <String as From<super::DepList>>::from(variant);
20445 assert_eq!(
20446 via_trait.as_ref(),
20447 owned_string.as_str(),
20448 "From<DepList> for std::rc::Rc<str> and \
20449 From<DepList> for String must resolve identically on \
20450 DepList::{variant:?} — divergence signals the owned-\
20451 input std::rc::Rc<str> and owned-`String` return-shape \
20452 paths have drifted onto different emit-sets"
20453 );
20454 let owned_cow: std::borrow::Cow<'static, str> =
20455 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20456 assert_eq!(
20457 via_trait.as_ref(),
20458 owned_cow.as_ref(),
20459 "From<DepList> for std::rc::Rc<str> and \
20460 From<DepList> for Cow<'static, str> must resolve \
20461 identically on DepList::{variant:?} — divergence signals \
20462 the owned-input std::rc::Rc<str> and Cow<'static, str> \
20463 return-shape paths have drifted onto different emit-sets"
20464 );
20465 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20466 assert_eq!(
20467 via_trait.as_ref(),
20468 owned_box.as_ref(),
20469 "From<DepList> for std::rc::Rc<str> and \
20470 From<DepList> for Box<str> must resolve identically on \
20471 DepList::{variant:?} — divergence signals the owned-\
20472 input std::rc::Rc<str> and Box<str> return-shape paths \
20473 have drifted onto different emit-sets"
20474 );
20475 let owned_arc: std::sync::Arc<str> =
20476 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20477 assert_eq!(
20478 via_trait.as_ref(),
20479 owned_arc.as_ref(),
20480 "From<DepList> for std::rc::Rc<str> and \
20481 From<DepList> for std::sync::Arc<str> must resolve \
20482 identically on DepList::{variant:?} — divergence signals \
20483 the owned-input std::rc::Rc<str> and std::sync::Arc<str> \
20484 return-shape paths have drifted onto different emit-sets \
20485 (the two disjoint reference-counted trait tables have \
20486 desynchronized on the caixa-core two-list dep-graph axis)"
20487 );
20488 }
20489 }
20490
20491 #[test]
20492 #[allow(
20493 clippy::too_many_lines,
20494 reason = "cross-axis partition pin folds five borrowed-input \
20495 return-shape paths (&'static str, String, Cow<'static, \
20496 str>, Box<str>, std::sync::Arc<str>) plus the paired \
20497 owned-input Rc<str> witness and the \
20498 .iter().map(std::rc::Rc::<str>::from) pipe witness into \
20499 one exhaustive round-trip over DepList::ALL — the \
20500 accepted line-count cost of keying the whole borrowed-\
20501 input Rc<str> corner to the substrate-primitive as_str \
20502 accessor at the same test-site"
20503 )]
20504 fn dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
20505 // Fail-before-pass-after byte-parity pin on the newly lifted
20506 // `impl From<&DepList> for std::rc::Rc<str>` — asserts the
20507 // borrowed-input standard-library trait impl and the substrate-
20508 // primitive [`super::DepList::as_str`] `pub const fn` accessor
20509 // resolve to the same two-arm emit-set across every arm the
20510 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20511 // standard library does not carry a blanket
20512 // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
20513 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20514 // the borrowed-input `std::rc::Rc<str>` forward-projection axis
20515 // is a distinct trait-idiomatic surface that a
20516 // `let key: std::rc::Rc<str> = (&list).into();`-shaped call
20517 // site or a
20518 // `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
20519 // pipe reaches through this impl and no other — the paired
20520 // owned-input `From<DepList> for std::rc::Rc<str>` impl alone
20521 // would force every borrowed-input call site through a spurious
20522 // `Copy` deref
20523 // (`std::rc::Rc::<str>::from((*list).as_str())`) or a
20524 // `.copied()` restatement whose type bounds have no compile-
20525 // time link back to the substrate primitive.
20526 //
20527 // Closes the `{Self, &Self}` input-shape corner on the third
20528 // caixa-core-internal closed-set fieldless typed enum peer of
20529 // the substrate-wide trait-idiomatic [`std::rc::Rc<str>`]
20530 // forward-projection campaign, matching the trajectory the
20531 // paired [`crate::CaixaKind`] (e04aff0),
20532 // [`crate::dialeto::CaixaDialeto`] (c5595e5), and
20533 // [`crate::render::PathShapeViolation`] (31fc43e) pairs walked
20534 // before it on the same tier of the same axis.
20535 //
20536 // Cross-axis partition pin against the paired owned-input
20537 // [`From<DepList> for std::rc::Rc<str>`] and the sibling
20538 // borrowed-input `{&'static str, String, Cow<'static, str>,
20539 // Box<str>, std::sync::Arc<str>}` return-shape axes — locking
20540 // the six return-shape × input-shape paths on the borrowed-
20541 // input surface together by construction so any future detour
20542 // off the substrate-primitive accessor trips at caixa-core
20543 // test time. Then a `.iter().map(std::rc::Rc::<str>::from)`
20544 // pipe witness over [`super::DepList::ALL`] — whose iterator
20545 // yields `&DepList` by construction, so the borrowed-input
20546 // [`std::rc::Rc<str>`] axis is what routes the pipe through
20547 // the substrate-primitive [`super::DepList::as_str`] accessor
20548 // without a spurious [`Copy`] deref (which would only be
20549 // reachable through the owned-input
20550 // [`From<DepList> for std::rc::Rc<str>`] axis by first calling
20551 // `.copied()` on the iterator).
20552 for &variant in super::DepList::ALL {
20553 let via_trait: std::rc::Rc<str> =
20554 <std::rc::Rc<str> as From<&super::DepList>>::from(&variant);
20555 let via_method: &'static str = variant.as_str();
20556 assert_eq!(
20557 via_trait.as_ref(),
20558 via_method,
20559 "From<&DepList> for std::rc::Rc<str> impl must round-\
20560 trip &DepList::{variant:?} to the same lifted \
20561 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20562 DepList::as_str returns — divergence signals a silent \
20563 detour off the substrate-primitive accessor"
20564 );
20565 let via_into: std::rc::Rc<str> = (&variant).into();
20566 assert_eq!(
20567 via_into.as_ref(),
20568 via_method,
20569 "Into<std::rc::Rc<str>>::into on &DepList::\
20570 {variant:?} must byte-equal DepList::as_str on the \
20571 same input — the blanket-derived Into shape on the \
20572 borrowed-input surface must resolve to the same \
20573 as_str dispatch as the explicit From impl"
20574 );
20575 let owned_rc: std::rc::Rc<str> =
20576 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20577 assert_eq!(
20578 via_trait, owned_rc,
20579 "From<&DepList> for std::rc::Rc<str> and \
20580 From<DepList> for std::rc::Rc<str> must resolve \
20581 identically on DepList::{variant:?} — divergence \
20582 signals the borrowed-input and owned-input \
20583 std::rc::Rc<str> forward-projection input-shape \
20584 paths have drifted onto different emit-sets"
20585 );
20586 let borrowed_static: &'static str =
20587 <&'static str as From<&super::DepList>>::from(&variant);
20588 assert_eq!(
20589 via_trait.as_ref(),
20590 borrowed_static,
20591 "From<&DepList> for std::rc::Rc<str> and \
20592 From<&DepList> for &'static str must resolve \
20593 identically on DepList::{variant:?} — divergence \
20594 signals the borrowed-input std::rc::Rc<str> and \
20595 &'static str return-shape paths have drifted onto \
20596 different emit-sets"
20597 );
20598 let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20599 assert_eq!(
20600 via_trait.as_ref(),
20601 borrowed_string.as_str(),
20602 "From<&DepList> for std::rc::Rc<str> and \
20603 From<&DepList> for String must resolve identically on \
20604 DepList::{variant:?} — divergence signals the \
20605 borrowed-input std::rc::Rc<str> and owned-`String` \
20606 return-shape paths have drifted onto different emit-\
20607 sets"
20608 );
20609 let borrowed_cow: std::borrow::Cow<'static, str> =
20610 <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20611 assert_eq!(
20612 via_trait.as_ref(),
20613 borrowed_cow.as_ref(),
20614 "From<&DepList> for std::rc::Rc<str> and \
20615 From<&DepList> for Cow<'static, str> must resolve \
20616 identically on DepList::{variant:?} — divergence \
20617 signals the borrowed-input std::rc::Rc<str> and \
20618 Cow<'static, str> return-shape paths have drifted onto \
20619 different emit-sets"
20620 );
20621 let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20622 assert_eq!(
20623 via_trait.as_ref(),
20624 borrowed_box.as_ref(),
20625 "From<&DepList> for std::rc::Rc<str> and \
20626 From<&DepList> for Box<str> must resolve identically \
20627 on DepList::{variant:?} — divergence signals the \
20628 borrowed-input std::rc::Rc<str> and Box<str> \
20629 return-shape paths have drifted onto different emit-sets"
20630 );
20631 let borrowed_arc: std::sync::Arc<str> =
20632 <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20633 assert_eq!(
20634 via_trait.as_ref(),
20635 borrowed_arc.as_ref(),
20636 "From<&DepList> for std::rc::Rc<str> and \
20637 From<&DepList> for std::sync::Arc<str> must resolve \
20638 identically on DepList::{variant:?} — divergence \
20639 signals the borrowed-input std::rc::Rc<str> and \
20640 std::sync::Arc<str> return-shape paths have drifted \
20641 onto different emit-sets (the two disjoint reference-\
20642 counted trait tables have desynchronized on the \
20643 caixa-core two-list dep-graph axis)"
20644 );
20645 }
20646 let via_iter: Vec<std::rc::Rc<str>> = super::DepList::ALL
20647 .iter()
20648 .map(std::rc::Rc::<str>::from)
20649 .collect();
20650 let via_method: Vec<std::rc::Rc<str>> = super::DepList::ALL
20651 .iter()
20652 .map(|l| std::rc::Rc::<str>::from(l.as_str()))
20653 .collect();
20654 assert_eq!(
20655 via_iter, via_method,
20656 "`.iter().map(std::rc::Rc::<str>::from)` over \
20657 DepList::ALL — a call site whose iteration axis holds \
20658 `&DepList` by construction — must byte-equal \
20659 `.iter().map(|l| std::rc::Rc::<str>::from(l.as_str()))` \
20660 on every arm — the borrowed-input std::rc::Rc<str> \
20661 `From<&DepList> for std::rc::Rc<str>` axis is what makes \
20662 the `std::rc::Rc::<str>::from` composition route through \
20663 the substrate-primitive `DepList::as_str` accessor \
20664 without a spurious `Copy` deref (which would only be \
20665 reachable through the owned-input \
20666 `From<DepList> for std::rc::Rc<str>` axis by first \
20667 calling `.copied()` on the iterator)"
20668 );
20669 }
20670
20671 #[test]
20672 fn dep_list_author_keys_covers_every_arm() {
20673 // Load-bearing pin on the substrate-canonical
20674 // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
20675 // on the `:`-prefixed kebab-case tatara-lisp author-surface
20676 // key axis: every variant of the sibling
20677 // [`super::DepList::ALL`] exhaustive-iteration surface must
20678 // project through [`super::DepList::as_str`] onto an entry the
20679 // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
20680 // roster's length must byte-equal `super::DepList::ALL.len()`
20681 // so a silent skew between the [`super::DepList::as_str`]
20682 // match's arm-set and the roster's arm-set trips here at
20683 // caixa-core test time rather than at a downstream M4
20684 // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
20685 // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
20686 // a `feira dep --list …` "did you mean" hint drift / a
20687 // downstream [`super::DepError`] widening's typed `list:
20688 // DepList` carry that fans on the enum through a stale
20689 // accepted-set. A future arm addition (a `:build-dep` or
20690 // `:tool-dep` third list once the substrate grows Cargo-style
20691 // split-graphs — both trajectory items the sibling
20692 // [`super::DepList::from_wire`] doc block already names)
20693 // extends [`super::DepList::ALL`] as a single edit and this
20694 // pin sweeps the new arm by iteration; the paired
20695 // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
20696 // or this assertion trips. Every entry is further pinned to
20697 // open with the ASCII `:` byte (the tatara-lisp author-surface
20698 // keyword marker) so a silent collapse of the author-key axis
20699 // with any hypothetical peer un-prefixed wire-form axis (an
20700 // entry byte-identical to a sibling `deps` / `deps-dev`
20701 // bare-kebab byte-string that would let an author-key-axis
20702 // consumer accept the un-prefixed vocabulary) trips here
20703 // rather than at a downstream consumer's
20704 // vocabulary-collision miss.
20705 //
20706 // Peer of the sibling
20707 // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
20708 // (bd708bd) /
20709 // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
20710 // (427fe75) /
20711 // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
20712 // (3033f45) /
20713 // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
20714 // (ce9412b) /
20715 // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
20716 // (3e5b194) /
20717 // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
20718 // (9d9f585) /
20719 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20720 // (b553ec9) /
20721 // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
20722 // (1898d77) /
20723 // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
20724 // (cc42c0e) pins — the same closed-set exhaustive-roster
20725 // coverage discipline extended here onto the two-list dep-graph
20726 // closed-set typed enum, the ninth substrate-side closed-set
20727 // typed enum on the roster axis and the last unlifted
20728 // `&'static str`-carrying closed-set typed enum on the top-
20729 // level manifest surface to converge onto the discipline.
20730 //
20731 // Fail-before-pass-after locally verified by mutating one arm
20732 // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
20733 // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
20734 // `":deps-dev"` to `":deps_dev"`) — the length pin still
20735 // passes but the `contains` check fires on the mutated arm;
20736 // and by shortening the roster to one entry — the length pin
20737 // fires first.
20738 assert_eq!(
20739 super::DepList::AUTHOR_KEYS.len(),
20740 super::DepList::ALL.len(),
20741 "DepList::AUTHOR_KEYS.len() must byte-equal \
20742 DepList::ALL.len() — a mismatch means the roster and \
20743 the enum's arm-set have drifted; downstream consumers \
20744 that fan through both will silently disagree on the \
20745 accepted arm-set"
20746 );
20747 for &variant in super::DepList::ALL {
20748 let key = variant.as_str();
20749 assert!(
20750 super::DepList::AUTHOR_KEYS.contains(&key),
20751 "DepList::{variant:?}.as_str() = {key:?} must be a \
20752 member of DepList::AUTHOR_KEYS — the emitter and the \
20753 roster have drifted out of lockstep"
20754 );
20755 }
20756 for tag in super::DepList::AUTHOR_KEYS {
20757 let first = tag.chars().next().unwrap_or_else(|| {
20758 panic!(
20759 "DepList::AUTHOR_KEYS entry {tag:?} must be a \
20760 non-empty `:`-prefixed kebab-case tatara-lisp \
20761 author-surface key byte-string"
20762 )
20763 });
20764 assert_eq!(
20765 first, ':',
20766 "DepList::AUTHOR_KEYS entry {tag:?} must open with \
20767 the ASCII `:` byte (tatara-lisp author-surface \
20768 keyword marker) — an un-prefixed entry would \
20769 collide the roster with any hypothetical peer bare-\
20770 kebab wire-form axis a downstream consumer might \
20771 disambiguate against"
20772 );
20773 }
20774 // Pin the exact two-arm roster in declaration order so a
20775 // future arm-swap on either the roster or the paired
20776 // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
20777 // arm-key mapping that leaves both the length pin and the
20778 // membership pin passing on their own) trips at caixa-core
20779 // test time under `assert_eq!`. Order matches variant
20780 // declaration order verbatim (`Prod` → `Dev`) so the roster
20781 // is the canonical ordering every listing / rendering
20782 // consumer defers to. Same declaration-order pin the sibling
20783 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20784 // (b553ec9) closes on the M3 `:politicas :rate-limit`
20785 // canonical-suffix axis.
20786 assert_eq!(
20787 super::DepList::AUTHOR_KEYS,
20788 &[
20789 crate::render::DEP_AUTHOR_KEY_DEPS,
20790 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
20791 ],
20792 "DepList::AUTHOR_KEYS must enumerate every arm's \
20793 author-surface key exactly once, in variant declaration \
20794 order (Prod → Dev)"
20795 );
20796 }
20797
20798 #[test]
20799 fn dep_list_from_str_routes_through_try_from_str_impl() {
20800 // Fail-before-pass-after byte-parity pin on the newly lifted
20801 // `impl std::str::FromStr for DepList` — asserts the standard-
20802 // library `.parse()` parse-axis entry point and the paired
20803 // [`super::DepList::try_from`] `TryFrom<&str>` impl (which in
20804 // turn routes through the substrate-primitive
20805 // [`super::DepList::from_wire`] `Option<Self>` accessor)
20806 // resolve to the same two-arm accept-set across every arm the
20807 // exhaustive [`super::DepList::ALL`] slice enumerates. First-
20808 // mover on the substrate-wide `FromStr` parse-axis campaign —
20809 // the peer method-named `from_wire` accessor and the paired
20810 // `TryFrom<&str>` trait impl fix the two-arm accept set; this
20811 // pin locks the `FromStr::from_str` trait entry point onto the
20812 // same set so any future divergence (a stray per-arm `match s`
20813 // re-inlining that opens a compile-time link to an un-lifted
20814 // arm-literal, a swap onto a hand-rolled parser that widens
20815 // the accept-set past the two wire-format consts) trips at
20816 // caixa-core test time.
20817 use std::str::FromStr;
20818 for &list in super::DepList::ALL {
20819 let wire = list.as_str();
20820 assert_eq!(
20821 <super::DepList as FromStr>::from_str(wire),
20822 Ok(list),
20823 "FromStr impl on DepList must round-trip \
20824 DepList::{list:?}.as_str() = {wire:?} back to \
20825 Ok(DepList::{list:?}) — divergence from \
20826 DepList::try_from signals a silent detour off the \
20827 paired reverse-projection trait impl"
20828 );
20829 assert_eq!(
20830 <super::DepList as FromStr>::from_str(wire).ok(),
20831 super::DepList::from_wire(wire),
20832 "FromStr ok()-projection on {wire:?} must byte-equal \
20833 DepList::from_wire on the same input — divergence \
20834 signals the two reverse-projection trait paths have \
20835 drifted off the substrate-primitive accessor"
20836 );
20837 // `.parse::<DepList>()` short-form witness — the stdlib
20838 // consumer surface that reaches the enum through the
20839 // `T: FromStr` bound, not through `TryFrom<&str>`.
20840 let via_parse: Result<super::DepList, ()> = wire.parse();
20841 assert_eq!(
20842 via_parse,
20843 Ok(list),
20844 "`{wire:?}`.parse::<DepList>() must resolve to \
20845 Ok(DepList::{list:?}) — divergence signals the \
20846 stdlib `.parse()` short-form has drifted from the \
20847 lifted `FromStr::from_str` impl"
20848 );
20849 }
20850 }
20851
20852 #[test]
20853 fn dep_list_from_str_rejects_unknown_byte_strings() {
20854 // Rejection witness on the `impl FromStr for DepList` —
20855 // sweeps candidate byte-strings outside the two-arm accept-set
20856 // the sibling [`super::DepList::as_str`] emits (`:deps` /
20857 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
20858 // future accidental widening of the trait impl's accept-set (a
20859 // stray case-fold path, a silent inclusion of a rebrand alias
20860 // like `":packages"`, an English rebrand `":dev-deps"` in
20861 // reverse arm-order that would silently swap the two arms) trips
20862 // at caixa-core test time. Peer of the sibling
20863 // `dep_list_try_from_str_rejects_unknown_byte_strings` rejection
20864 // witness — the two pins together bracket both reverse-projection
20865 // trait impls against the same rejected set.
20866 use std::str::FromStr;
20867 let rejected: &[&str] = &[
20868 "",
20869 " ",
20870 "\t",
20871 "\n",
20872 ":deps ",
20873 " :deps",
20874 ":DEPS",
20875 ":Deps",
20876 ":Deps-Dev",
20877 ":deps_dev",
20878 ":deps-development",
20879 ":dev-deps",
20880 ":packages",
20881 ":packages-dev",
20882 "deps",
20883 "deps-dev",
20884 "Prod",
20885 "Dev",
20886 "prod",
20887 "dev",
20888 "\":deps\"",
20889 "\":deps-dev\"",
20890 ":deps\n",
20891 ":deps-dev\n",
20892 ];
20893 for &input in rejected {
20894 assert_eq!(
20895 <super::DepList as FromStr>::from_str(input),
20896 Err(()),
20897 "FromStr impl on DepList must reject unknown \
20898 byte-string {input:?} — divergence from \
20899 DepList::from_wire on the same input signals a silent \
20900 accept-set widening past the two lifted \
20901 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
20902 );
20903 assert_eq!(
20904 <super::DepList as FromStr>::from_str(input).ok(),
20905 super::DepList::from_wire(input),
20906 "FromStr ok()-projection on {input:?} must byte-equal \
20907 DepList::from_wire on the same input — divergence \
20908 signals the FromStr trait path has drifted off the \
20909 substrate-primitive accessor"
20910 );
20911 let via_parse: Result<super::DepList, ()> = input.parse();
20912 assert_eq!(
20913 via_parse,
20914 Err(()),
20915 "`{input:?}`.parse::<DepList>() must reject the \
20916 unknown byte-string — divergence signals the stdlib \
20917 `.parse()` short-form has drifted from the lifted \
20918 `FromStr::from_str` impl"
20919 );
20920 }
20921 }
20922
20923 #[test]
20924 #[allow(
20925 clippy::too_many_lines,
20926 reason = "cross-axis partition pin folds the substrate-primitive \
20927 as_str accessor's `.as_bytes()` byte-tail plus the \
20928 paired str-view (AsRef<str>, Display, as_str) and \
20929 reverse-projection ({&'static str, String, \
20930 Cow<'static, str>, Box<str>, std::sync::Arc<str>, \
20931 std::rc::Rc<str>}) return-shape axes' `.as_bytes()` \
20932 byte-tails plus a <T: AsRef<[u8]>>-bound-consumer \
20933 witness plus a blake3::Hasher::update-shape byte-\
20934 input surface witness into one exhaustive round-trip \
20935 over DepList::ALL — the accepted line-count cost of \
20936 opening the byte-view axis keyed to the substrate-\
20937 primitive as_str accessor at the same test-site"
20938 )]
20939 #[allow(
20940 clippy::needless_borrows_for_generic_args,
20941 reason = "the borrowed-input surface (&variant) is exercised \
20942 deliberately: the `<T: AsRef<[u8]>>`-bound consumer \
20943 and the `blake3::Hasher::update`-shape byte-input \
20944 surface both accept either owned or borrowed input \
20945 through the standard-library blanket \
20946 `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`, \
20947 and this pin round-trips both input shapes to lock \
20948 the borrowed-input path load-bearing against a \
20949 future silent regression"
20950 )]
20951 fn dep_list_as_ref_bytes_routes_through_as_str_accessor() {
20952 // `<T: AsRef<[u8]>>`-bound-consumer witness helper: a generic
20953 // byte-input function accepts a [`super::DepList`] directly
20954 // through the trait bound, without the caller open-coding the
20955 // two-hop `list.as_str().as_bytes()` composition. Lifted to
20956 // the top of the function per `clippy::items_after_statements`.
20957 fn generic_bytes_sink<T: AsRef<[u8]>>(t: T) -> Vec<u8> {
20958 t.as_ref().to_vec()
20959 }
20960 // `blake3::Hasher::update`-shape byte-input surface mock:
20961 // mirrors `blake3::Hasher::update` / `ring::digest::Context::
20962 // update` / `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound
20963 // `update` signature so a per-caixa BLAKE3 content-address
20964 // closure that composes `hasher.update(list)` on the
20965 // [`crate::Lacre`] closure builder reaches the substrate-
20966 // primitive `as_str` accessor through the [`super::DepList`]
20967 // `AsRef<[u8]>` axis and no other. Lifted to the top of the
20968 // function per `clippy::items_after_statements`.
20969 struct MockHasher(Vec<u8>);
20970 impl MockHasher {
20971 fn new() -> Self {
20972 Self(Vec::new())
20973 }
20974 fn update(&mut self, bytes: impl AsRef<[u8]>) -> &mut Self {
20975 self.0.extend_from_slice(bytes.as_ref());
20976 self
20977 }
20978 fn finalize(self) -> Vec<u8> {
20979 self.0
20980 }
20981 }
20982
20983 // Fail-before-pass-after byte-parity pin on the newly lifted
20984 // `impl AsRef<[u8]> for DepList` — asserts the trait-idiomatic
20985 // byte-view standard-library impl and the substrate-primitive
20986 // [`super::DepList::as_str`] `pub const fn` accessor's
20987 // `.as_bytes()` byte-tail resolve to the same two-arm
20988 // `:`-prefixed kebab-case byte-string emit-set across every
20989 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
20990 // Extends the substrate-wide trait-idiomatic byte-view axis
20991 // onto the third closed-set fieldless typed enum on the
20992 // caixa-core-internal tier — matching the trajectory the
20993 // sibling [`super::CaixaKind`] first-mover [`AsRef<[u8]>`]
20994 // impl (69d8d86) and [`super::CaixaDialeto`] second-mover
20995 // impl (8151347) walked before it.
20996 for &variant in super::DepList::ALL {
20997 let via_trait: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
20998 let via_method_bytes: &[u8] = variant.as_str().as_bytes();
20999 assert_eq!(
21000 via_trait, via_method_bytes,
21001 "AsRef<[u8]> for DepList impl must byte-equal \
21002 DepList::as_str().as_bytes() on DepList::\
21003 {variant:?} — divergence signals a silent detour off \
21004 the substrate-primitive accessor"
21005 );
21006 // Cross-axis witness against the paired str-view axes'
21007 // `.as_bytes()` byte-tails: [`AsRef<str>`] /
21008 // [`std::fmt::Display`] / [`super::DepList::as_str`] all
21009 // resolve to the same lifted `render::DEP_AUTHOR_KEY_*`
21010 // const roster, and the byte-view axis must byte-equal
21011 // each of their `.as_bytes()` byte-tails by construction
21012 // — locking the str-view and byte-view axes together at
21013 // the substrate-primitive accessor.
21014 let str_view_ref: &str = <super::DepList as AsRef<str>>::as_ref(&variant);
21015 assert_eq!(
21016 via_trait,
21017 str_view_ref.as_bytes(),
21018 "AsRef<[u8]> for DepList and AsRef<str> for DepList \
21019 must resolve to byte-equal byte-tails on DepList::\
21020 {variant:?} — divergence signals the byte-view and \
21021 str-view axes have drifted off the same substrate-\
21022 primitive as_str accessor"
21023 );
21024 let display_bytes = variant.to_string();
21025 assert_eq!(
21026 via_trait,
21027 display_bytes.as_bytes(),
21028 "AsRef<[u8]> for DepList and \
21029 <DepList as std::fmt::Display>::to_string must \
21030 resolve to byte-equal byte-tails on DepList::\
21031 {variant:?} — divergence signals the byte-view axis \
21032 and the Display formatter axis have drifted off the \
21033 same substrate-primitive as_str accessor"
21034 );
21035 // Cross-axis witness against the paired reverse-
21036 // projection axes' `.as_bytes()` byte-tails: every one of
21037 // `{&'static str, String, Cow<'static, str>, Box<str>,
21038 // std::sync::Arc<str>, std::rc::Rc<str>}` allocates (or
21039 // borrows) the same `:`-prefixed kebab byte-string the
21040 // substrate-primitive accessor emits, so the byte-view
21041 // axis must byte-equal each of their `.as_bytes()` byte-
21042 // tails by construction.
21043 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
21044 assert_eq!(
21045 via_trait,
21046 owned_static.as_bytes(),
21047 "AsRef<[u8]> for DepList and From<DepList> for \
21048 &'static str must resolve to byte-equal byte-tails on \
21049 DepList::{variant:?}"
21050 );
21051 let owned_string: String = <String as From<super::DepList>>::from(variant);
21052 assert_eq!(
21053 via_trait,
21054 owned_string.as_bytes(),
21055 "AsRef<[u8]> for DepList and From<DepList> for \
21056 String must resolve to byte-equal byte-tails on \
21057 DepList::{variant:?}"
21058 );
21059 let owned_cow: std::borrow::Cow<'static, str> =
21060 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
21061 assert_eq!(
21062 via_trait,
21063 owned_cow.as_bytes(),
21064 "AsRef<[u8]> for DepList and From<DepList> for \
21065 Cow<'static, str> must resolve to byte-equal byte-\
21066 tails on DepList::{variant:?}"
21067 );
21068 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
21069 assert_eq!(
21070 via_trait,
21071 owned_box.as_bytes(),
21072 "AsRef<[u8]> for DepList and From<DepList> for \
21073 Box<str> must resolve to byte-equal byte-tails on \
21074 DepList::{variant:?}"
21075 );
21076 let owned_arc: std::sync::Arc<str> =
21077 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
21078 assert_eq!(
21079 via_trait,
21080 owned_arc.as_bytes(),
21081 "AsRef<[u8]> for DepList and From<DepList> for \
21082 std::sync::Arc<str> must resolve to byte-equal byte-\
21083 tails on DepList::{variant:?}"
21084 );
21085 let owned_rc_str: std::rc::Rc<str> =
21086 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
21087 assert_eq!(
21088 via_trait,
21089 owned_rc_str.as_bytes(),
21090 "AsRef<[u8]> for DepList and From<DepList> for \
21091 std::rc::Rc<str> must resolve to byte-equal byte-\
21092 tails on DepList::{variant:?}"
21093 );
21094 }
21095 // `<T: AsRef<[u8]>>`-bound-consumer witness: the generic byte-
21096 // input function `generic_bytes_sink` (lifted above per
21097 // `clippy::items_after_statements`) accepts a [`super::DepList`]
21098 // directly through the trait bound, without the caller open-
21099 // coding the two-hop `list.as_str().as_bytes()` composition.
21100 // This is the shape that reaches the caixa-lacre BLAKE3
21101 // content-address closure's
21102 // `blake3::Hasher::update(impl AsRef<[u8]>)` byte-input surface
21103 // through this impl and no other. Exercised on both owned and
21104 // borrowed input surfaces via the standard-library blanket
21105 // `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`.
21106 for &variant in super::DepList::ALL {
21107 let via_generic = generic_bytes_sink(variant);
21108 let via_borrowed_generic = generic_bytes_sink(&variant);
21109 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21110 assert_eq!(
21111 via_generic, via_method_bytes,
21112 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21113 DepList::{variant:?} must yield the same byte-tail \
21114 DepList::as_str().as_bytes() returns — divergence \
21115 signals the byte-view axis fails to bridge a generic \
21116 byte-input trait bound to the substrate-primitive \
21117 accessor"
21118 );
21119 assert_eq!(
21120 via_borrowed_generic, via_method_bytes,
21121 "generic `<T: AsRef<[u8]>>`-bound consumer on \
21122 &DepList::{variant:?} must yield the same byte-tail \
21123 DepList::as_str().as_bytes() returns — the borrowed-\
21124 input surface must resolve to the same as_str dispatch"
21125 );
21126 }
21127 // `blake3::Hasher::update`-shape byte-input surface witness
21128 // on the caixa-lacre compounding target: the `MockHasher`
21129 // (lifted above per `clippy::items_after_statements`) mirrors
21130 // `blake3::Hasher::update` / `ring::digest::Context::update` /
21131 // `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound update
21132 // signature and accepts a [`super::DepList`] directly, routing
21133 // its byte-tail through the substrate-primitive `as_str`
21134 // accessor — the shape a future per-caixa BLAKE3 content-
21135 // address closure composes to fold a dep-list discriminator
21136 // byte-tag into the [`crate::Lacre`] closure body so a
21137 // downstream `Lacre` consumer can partition the runtime-
21138 // closure `:deps` from the dev-only-closure `:deps-dev` at
21139 // content-address time.
21140 for &variant in super::DepList::ALL {
21141 let mut owned_hasher = MockHasher::new();
21142 owned_hasher.update(variant);
21143 let owned_folded = owned_hasher.finalize();
21144 assert_eq!(
21145 owned_folded,
21146 variant.as_str().as_bytes(),
21147 "`hasher.update(list)`-shape composition on DepList::\
21148 {variant:?} must fold the same byte-tail DepList::\
21149 as_str().as_bytes() returns — the shape a future \
21150 per-caixa BLAKE3 content-address closure composes to \
21151 fold a dep-list discriminator byte-tag into the Lacre \
21152 closure body"
21153 );
21154 let mut borrowed_hasher = MockHasher::new();
21155 borrowed_hasher.update(&variant);
21156 let borrowed_folded = borrowed_hasher.finalize();
21157 assert_eq!(
21158 borrowed_folded,
21159 variant.as_str().as_bytes(),
21160 "`hasher.update(&list)`-shape composition on \
21161 &DepList::{variant:?} must fold the same byte-tail \
21162 DepList::as_str().as_bytes() returns — the borrowed-\
21163 input surface must resolve to the same as_str dispatch"
21164 );
21165 }
21166 }
21167
21168 #[test]
21169 #[expect(
21170 clippy::too_many_lines,
21171 reason = "the byte-owned reverse-projection axis is extended \
21172 onto DepList here as the third peer on the substrate-\
21173 wide byte-owned Vec<u8>-output projection family \
21174 (after the sibling first-mover CaixaKind, b245fd6, \
21175 and second-mover CaixaDialeto, 4cceaf5), so the pin \
21176 binds the new impl against every paired byte-view \
21177 and str-view axis on the same enum plus a generic \
21178 <T: Into<Vec<u8>>>-bound consumer witness and a \
21179 std::io::Write::write_all-shape owned-byte-sink \
21180 surface witness on both owned and borrowed input \
21181 shapes to lock the whole family against a future \
21182 silent regression"
21183 )]
21184 fn dep_list_from_into_owned_vec_bytes_routes_through_as_str_accessor() {
21185 // `<T: Into<Vec<u8>>>`-bound-consumer witness helper: a generic
21186 // owned-byte-input function accepts a [`super::DepList`]
21187 // directly through the trait bound, without the caller open-
21188 // coding the three-hop `list.as_str().as_bytes().to_vec()`
21189 // composition. Lifted to the top of the function per
21190 // `clippy::items_after_statements`.
21191 fn generic_owned_bytes_sink<T: Into<Vec<u8>>>(t: T) -> Vec<u8> {
21192 t.into()
21193 }
21194 // `std::io::Write::write_all`-shape owned-byte-sink surface
21195 // mock: mirrors `std::io::Write::write_all` /
21196 // `bytes::BytesMut::extend_from_slice` / any per-arm audit-log
21197 // byte-sink that consumes a `Vec<u8>` payload via
21198 // `Into<Vec<u8>>`, so a future per-caixa per-`:deps`/`:deps-dev`
21199 // audit-log emit reaches the substrate-primitive `as_str`
21200 // accessor through the byte-owned reverse-projection axis and
21201 // no other. Lifted to the top of the function per
21202 // `clippy::items_after_statements`.
21203 struct MockOwnedByteSink(Vec<u8>);
21204 impl MockOwnedByteSink {
21205 fn new() -> Self {
21206 Self(Vec::new())
21207 }
21208 fn write_all(&mut self, bytes: impl Into<Vec<u8>>) -> &mut Self {
21209 self.0.extend_from_slice(&bytes.into());
21210 self
21211 }
21212 fn finalize(self) -> Vec<u8> {
21213 self.0
21214 }
21215 }
21216
21217 // Fail-before-pass-after byte-parity pin on the newly lifted
21218 // `impl From<DepList> for Vec<u8>` and
21219 // `impl From<&DepList> for Vec<u8>` — asserts the trait-
21220 // idiomatic byte-owned reverse-projection standard-library
21221 // impls and the substrate-primitive
21222 // [`super::DepList::as_str`] `pub const fn` accessor's
21223 // `.as_bytes().to_vec()` byte-tail resolve to the same two-arm
21224 // `:`-prefixed kebab-case byte-string emit-set across every
21225 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
21226 // Extends the substrate-wide trait-idiomatic byte-owned
21227 // reverse-projection axis onto the third closed-set fieldless
21228 // typed enum on the caixa-core-internal tier — matching the
21229 // trajectory the sibling first-mover [`super::CaixaKind`]
21230 // `From<{Self, &Self}> for Vec<u8>` impls (b245fd6) and the
21231 // second-mover [`crate::dialeto::CaixaDialeto`] impls (4cceaf5)
21232 // walked before it on the caixa-core tier of the byte-owned
21233 // axis.
21234 for &variant in super::DepList::ALL {
21235 let via_owned_from: Vec<u8> = <Vec<u8> as From<super::DepList>>::from(variant);
21236 let via_borrowed_from: Vec<u8> = <Vec<u8> as From<&super::DepList>>::from(&variant);
21237 let via_method_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
21238 assert_eq!(
21239 via_owned_from, via_method_bytes,
21240 "From<DepList> for Vec<u8> impl must byte-equal \
21241 DepList::as_str().as_bytes().to_vec() on DepList::\
21242 {variant:?} — divergence signals a silent detour off \
21243 the substrate-primitive accessor"
21244 );
21245 assert_eq!(
21246 via_borrowed_from, via_method_bytes,
21247 "From<&DepList> for Vec<u8> impl must byte-equal \
21248 DepList::as_str().as_bytes().to_vec() on DepList::\
21249 {variant:?} — divergence signals a silent detour off \
21250 the substrate-primitive accessor"
21251 );
21252 assert_eq!(
21253 via_owned_from, via_borrowed_from,
21254 "From<DepList> for Vec<u8> and From<&DepList> for \
21255 Vec<u8> must byte-equal each other on DepList::\
21256 {variant:?} — divergence signals the owned-input and \
21257 borrowed-input paths have drifted off the same \
21258 substrate-primitive as_str accessor"
21259 );
21260 // Cross-axis witness against the paired [`AsRef<[u8]>`]
21261 // borrowed byte-view axis: the byte-owned reverse-
21262 // projection axis must byte-equal the paired borrowed
21263 // byte-view axis by construction — locking the byte-view
21264 // and byte-owned axes together at the substrate-primitive
21265 // accessor.
21266 let borrowed_bytes: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21267 assert_eq!(
21268 via_owned_from,
21269 borrowed_bytes.to_vec(),
21270 "From<DepList> for Vec<u8> and AsRef<[u8]> for DepList \
21271 must resolve to byte-equal byte-tails on DepList::\
21272 {variant:?} — divergence signals the byte-owned and \
21273 byte-view axes have drifted off the same substrate-\
21274 primitive as_str accessor"
21275 );
21276 // Cross-axis witness against the str-owned reverse-
21277 // projection family's `.into_bytes()` / `.as_bytes().to_vec()`
21278 // byte-tails: every one of `{String, Cow<'static, str>,
21279 // Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
21280 // allocates (or borrows) the same `:`-prefixed kebab byte-
21281 // string the substrate-primitive accessor emits, so the
21282 // byte-owned axis must byte-equal each of their owned
21283 // byte-tails by construction.
21284 let owned_string: String = <String as From<super::DepList>>::from(variant);
21285 assert_eq!(
21286 via_owned_from,
21287 owned_string.into_bytes(),
21288 "From<DepList> for Vec<u8> and \
21289 String::from(list).into_bytes() must resolve to byte-\
21290 equal byte-tails on DepList::{variant:?}"
21291 );
21292 let owned_cow: std::borrow::Cow<'static, str> =
21293 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
21294 assert_eq!(
21295 via_owned_from,
21296 owned_cow.as_bytes().to_vec(),
21297 "From<DepList> for Vec<u8> and From<DepList> for \
21298 Cow<'static, str> must resolve to byte-equal byte-\
21299 tails on DepList::{variant:?}"
21300 );
21301 let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
21302 assert_eq!(
21303 via_owned_from,
21304 owned_box.as_bytes().to_vec(),
21305 "From<DepList> for Vec<u8> and From<DepList> for \
21306 Box<str> must resolve to byte-equal byte-tails on \
21307 DepList::{variant:?}"
21308 );
21309 let owned_arc: std::sync::Arc<str> =
21310 <std::sync::Arc<str> as From<super::DepList>>::from(variant);
21311 assert_eq!(
21312 via_owned_from,
21313 owned_arc.as_bytes().to_vec(),
21314 "From<DepList> for Vec<u8> and From<DepList> for \
21315 std::sync::Arc<str> must resolve to byte-equal byte-\
21316 tails on DepList::{variant:?}"
21317 );
21318 let owned_rc_str: std::rc::Rc<str> =
21319 <std::rc::Rc<str> as From<super::DepList>>::from(variant);
21320 assert_eq!(
21321 via_owned_from,
21322 owned_rc_str.as_bytes().to_vec(),
21323 "From<DepList> for Vec<u8> and From<DepList> for \
21324 std::rc::Rc<str> must resolve to byte-equal byte-\
21325 tails on DepList::{variant:?}"
21326 );
21327 }
21328 // `<T: Into<Vec<u8>>>`-bound-consumer witness on both owned
21329 // and borrowed input shapes: the generic owned-byte-input
21330 // function `generic_owned_bytes_sink` (lifted above per
21331 // `clippy::items_after_statements`) accepts a
21332 // [`super::DepList`] and a `&DepList` directly through the
21333 // trait bound, without the caller open-coding the three-hop
21334 // `list.as_str().as_bytes().to_vec()` composition.
21335 for &variant in super::DepList::ALL {
21336 let via_generic_owned = generic_owned_bytes_sink(variant);
21337 // Bind the borrowed-input path through an explicit
21338 // `&DepList` local so the generic-consumer witness routes
21339 // through `From<&DepList> for Vec<u8>` (T binds to
21340 // `&DepList`) rather than clippy-collapsing the borrow
21341 // onto the owned-input `From<DepList> for Vec<u8>` peer.
21342 let variant_ref: &super::DepList = &variant;
21343 let via_generic_borrowed = generic_owned_bytes_sink(variant_ref);
21344 let via_method_bytes = variant.as_str().as_bytes().to_vec();
21345 assert_eq!(
21346 via_generic_owned, via_method_bytes,
21347 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21348 DepList::{variant:?} must yield the same byte-tail \
21349 DepList::as_str().as_bytes().to_vec() returns — \
21350 divergence signals the byte-owned axis fails to \
21351 bridge a generic owned-byte-input trait bound to the \
21352 substrate-primitive accessor"
21353 );
21354 assert_eq!(
21355 via_generic_borrowed, via_method_bytes,
21356 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
21357 &DepList::{variant:?} must yield the same byte-tail \
21358 DepList::as_str().as_bytes().to_vec() returns — the \
21359 borrowed-input surface must resolve to the same \
21360 as_str dispatch"
21361 );
21362 }
21363 // `std::io::Write::write_all`-shape owned-byte-sink surface
21364 // witness: the `MockOwnedByteSink` (lifted above per
21365 // `clippy::items_after_statements`) mirrors
21366 // `std::io::Write::write_all` /
21367 // `bytes::BytesMut::extend_from_slice`'s `impl Into<Vec<u8>>`-
21368 // bound owned-byte input signature and accepts a
21369 // [`super::DepList`] directly on both owned and borrowed input
21370 // shapes, routing its byte-tail through the substrate-
21371 // primitive `as_str` accessor — the shape a future per-caixa
21372 // per-`:deps`/`:deps-dev` audit-log emit composes to fold a
21373 // dep-list discriminator byte-tag into a downstream owned-
21374 // byte-sink surface so a partition of the runtime-closure
21375 // `:deps` from the dev-only-closure `:deps-dev` reaches the
21376 // sink through this axis and no other.
21377 for &variant in super::DepList::ALL {
21378 let mut owned_sink = MockOwnedByteSink::new();
21379 owned_sink.write_all(variant);
21380 let owned_folded = owned_sink.finalize();
21381 assert_eq!(
21382 owned_folded,
21383 variant.as_str().as_bytes(),
21384 "`sink.write_all(list)`-shape composition on DepList::\
21385 {variant:?} must fold the same byte-tail DepList::\
21386 as_str().as_bytes() returns"
21387 );
21388 let mut borrowed_sink = MockOwnedByteSink::new();
21389 // Same explicit `&DepList` binding as the generic-consumer
21390 // witness above: routes the owned-byte-sink surface
21391 // through `From<&DepList> for Vec<u8>` (T binds to
21392 // `&DepList`) rather than clippy-collapsing the borrow
21393 // onto the owned-input peer.
21394 let variant_ref: &super::DepList = &variant;
21395 borrowed_sink.write_all(variant_ref);
21396 let borrowed_folded = borrowed_sink.finalize();
21397 assert_eq!(
21398 borrowed_folded,
21399 variant.as_str().as_bytes(),
21400 "`sink.write_all(&list)`-shape composition on \
21401 &DepList::{variant:?} must fold the same byte-tail \
21402 DepList::as_str().as_bytes() returns — the borrowed-\
21403 input surface must resolve to the same as_str dispatch"
21404 );
21405 }
21406 }
21407
21408 #[test]
21409 fn dep_list_try_from_bytes_routes_through_from_wire_accessor() {
21410 // Fail-before-pass-after byte-parity pin on the newly lifted
21411 // `impl TryFrom<&[u8]> for DepList` — asserts the trait-
21412 // idiomatic byte-view reverse-projection standard-library impl
21413 // and the substrate-primitive [`super::DepList::from_wire`]
21414 // `Option<Self>` accessor resolve to the same two-arm
21415 // `:`-prefixed kebab-case wire accept-set across every arm the
21416 // exhaustive [`super::DepList::ALL`] slice enumerates. Extends
21417 // the substrate-wide trait-idiomatic byte-view reverse-
21418 // projection axis onto the third caixa-core-internal closed-set
21419 // fieldless typed enum peer — mirror of the paired
21420 // [`TryFrom<&str> for DepList`] str-view reverse-projection
21421 // axis on the same enum, and the byte-view companion of the
21422 // pre-existing byte-owned reverse-projection family
21423 // ([`AsRef<[u8]>`], [`From<DepList> for Vec<u8>`],
21424 // [`From<&DepList> for Vec<u8>`]) on this same enum. Peer of
21425 // the sibling
21426 // [`crate::kind::tests::caixa_kind_try_from_bytes_routes_through_from_wire_accessor`]
21427 // (18d1940) on the first-mover [`crate::CaixaKind`] closed-set
21428 // typed-enum peer and the sibling
21429 // [`crate::dialeto::tests::caixa_dialeto_try_from_bytes_routes_through_from_wire_accessor`]
21430 // (d102cb8) on the second-mover [`crate::CaixaDialeto`] peer —
21431 // tracks the "route through `from_wire` via `std::str::from_utf8`"
21432 // discipline the first-mover established.
21433 //
21434 // Rust's standard library carries no blanket
21435 // `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so
21436 // a two-hop composition through [`std::str::from_utf8`] + the
21437 // paired [`TryFrom<&str>`] axis is reachable through the pre-
21438 // existing str-view reverse-projection axis alone. But that
21439 // two-hop shape has no compile-time link back to the byte-view
21440 // reverse-projection axis, forces every downstream
21441 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer to open-code
21442 // the composition at every call site, and admits a silent split
21443 // whenever a future call site takes a sibling byte-projection
21444 // axis whose parse arm-set carries no compile-time byte-view
21445 // surface. This impl closes the byte-view reverse-projection
21446 // axis at the substrate-primitive
21447 // [`super::DepList::from_wire`] accessor so every future
21448 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer reaches the
21449 // same two-arm `:`-prefixed kebab-case wire accept-set through
21450 // one trait dispatch.
21451 for &variant in super::DepList::ALL {
21452 let wire_bytes: &[u8] = variant.as_str().as_bytes();
21453 assert_eq!(
21454 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes),
21455 Ok(variant),
21456 "TryFrom<&[u8]> impl on DepList must round-trip \
21457 DepList::{variant:?}.as_str().as_bytes() back to \
21458 Ok(DepList::{variant:?}) — divergence from \
21459 DepList::from_wire signals a silent detour off the \
21460 substrate-primitive accessor"
21461 );
21462 assert_eq!(
21463 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes).ok(),
21464 super::DepList::from_wire(variant.as_str()),
21465 "TryFrom<&[u8]> ok()-projection on \
21466 DepList::{variant:?}.as_str().as_bytes() must \
21467 byte-equal DepList::from_wire on the paired &str input"
21468 );
21469 // Cross-axis witness: the byte-view reverse-projection axis
21470 // must agree with the paired str-view reverse-projection
21471 // axis ([`TryFrom<&str>`]) on every accepted arm — the two
21472 // reverse paths share one `:`-prefixed kebab accept-set
21473 // through the substrate-primitive `from_wire` accessor.
21474 let via_str: Result<super::DepList, ()> =
21475 <super::DepList as TryFrom<&str>>::try_from(variant.as_str());
21476 let via_bytes: Result<super::DepList, ()> =
21477 <super::DepList as TryFrom<&[u8]>>::try_from(wire_bytes);
21478 assert_eq!(
21479 via_bytes, via_str,
21480 "TryFrom<&[u8]> and TryFrom<&str> reverse-projection \
21481 axes on DepList must agree on DepList::{variant:?} — \
21482 divergence signals the byte-view and str-view reverse \
21483 paths have drifted off the same substrate-primitive \
21484 from_wire accessor"
21485 );
21486 // Cross-axis witness against the paired [`AsRef<[u8]>`]
21487 // borrowed byte-view axis: feeding the same byte-tail the
21488 // forward byte-view axis emits back through the reverse
21489 // byte-view axis must round-trip to the originating arm —
21490 // locks the forward and reverse byte-view axes together at
21491 // the substrate-primitive accessor.
21492 let borrowed_bytes: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
21493 assert_eq!(
21494 <super::DepList as TryFrom<&[u8]>>::try_from(borrowed_bytes),
21495 Ok(variant),
21496 "TryFrom<&[u8]> fed the AsRef<[u8]>-projected byte-tail \
21497 of DepList::{variant:?} must round-trip to \
21498 Ok(DepList::{variant:?}) — divergence signals the \
21499 forward and reverse byte-view axes have drifted off \
21500 the same substrate-primitive as_str/from_wire accessor \
21501 pair"
21502 );
21503 }
21504 }
21505
21506 #[test]
21507 fn dep_list_try_from_bytes_rejects_unknown_and_non_utf8_bytes() {
21508 // Rejection witness on the `impl TryFrom<&[u8]> for DepList` —
21509 // sweeps two rejection paths the byte-view reverse-projection
21510 // axis collapses onto the single unit-error `Err(())` return:
21511 // the invalid-UTF-8 rejection path ([`std::str::from_utf8`]
21512 // returns `Err` before [`super::DepList::from_wire`] runs) and
21513 // the valid-UTF-8-but-unknown-wire rejection path
21514 // ([`super::DepList::from_wire`] returns `None` on a byte-
21515 // string outside the two-arm `:`-prefixed kebab-case accept-
21516 // set). Both must reject, so a future accidental widening of
21517 // the trait impl's accept-set (a case-fold path, a silent
21518 // acceptance of a `":packages"` rebrand alias, a
21519 // `#[serde(rename_all = "…")]` attribute drift that widens the
21520 // parse arm-set silently, a stray fallback that maps invalid
21521 // UTF-8 onto a default arm rather than the trait-idiomatic
21522 // `Err(())`) trips at caixa-core test time. Peer of the sibling
21523 // [`crate::kind::tests::caixa_kind_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
21524 // (18d1940) on the first-mover [`crate::CaixaKind`] peer and
21525 // the sibling
21526 // [`crate::dialeto::tests::caixa_dialeto_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
21527 // (d102cb8) on the second-mover [`crate::CaixaDialeto`] peer.
21528 //
21529 // Non-UTF-8 candidates:
21530 // - a lone 0xFF byte (never valid as a UTF-8 leading byte)
21531 // - a lone 0x80 continuation byte with no leading byte
21532 // - a truncated multi-byte sequence (0xC3 without its continuation)
21533 // - a UTF-16 BOM-style byte pair the UTF-8 validator rejects
21534 // - a UTF-16 surrogate half rejected by UTF-8
21535 let non_utf8_rejected: &[&[u8]] = &[
21536 &[0xFF],
21537 &[0x80],
21538 &[0xC3],
21539 &[0xFF, 0xFE],
21540 &[0xED, 0xA0, 0x80],
21541 ];
21542 for &input in non_utf8_rejected {
21543 assert_eq!(
21544 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21545 Err(()),
21546 "TryFrom<&[u8]> impl on DepList must reject the non-\
21547 UTF-8 byte-sequence {input:?} with Err(()) — silent \
21548 acceptance signals the UTF-8 validation path collapsed \
21549 onto a default arm rather than the trait-idiomatic \
21550 unit-error"
21551 );
21552 }
21553 // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
21554 // string, whitespace-only forms, case-folded variants of
21555 // accepted arms, the un-`:`-prefixed bare-kebab
21556 // ("deps"/"deps-dev") the sibling
21557 // [`super::DepList::from_wire`] doc block flags as a
21558 // `:`-prefix-discipline hazard, plausible rebrand aliases the
21559 // sibling `dep_list_try_from_str_rejects_unknown_byte_strings`
21560 // rejection witness (5b828ed) already pins on the str-view
21561 // reverse axis, and whitespace-padded/quoted forms.
21562 let unknown_wire_rejected: &[&[u8]] = &[
21563 b"",
21564 b" ",
21565 b"\t",
21566 b"\n",
21567 b":deps ",
21568 b" :deps",
21569 b":DEPS",
21570 b":Deps",
21571 b":Deps-Dev",
21572 b":deps_dev",
21573 b":deps-development",
21574 b":dev-deps",
21575 b":packages",
21576 b":packages-dev",
21577 b"deps",
21578 b"deps-dev",
21579 b"Prod",
21580 b"Dev",
21581 b"prod",
21582 b"dev",
21583 b"\":deps\"",
21584 b"\":deps-dev\"",
21585 b":deps\n",
21586 b":deps-dev\n",
21587 ];
21588 for &input in unknown_wire_rejected {
21589 assert_eq!(
21590 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21591 Err(()),
21592 "TryFrom<&[u8]> impl on DepList must reject the valid-\
21593 UTF-8-but-unknown-wire byte-string {input:?} with \
21594 Err(()) — silent acceptance signals an accept-set \
21595 widening off the paired DepList::from_wire resolver"
21596 );
21597 // Cross-axis witness: on a byte-string that is valid UTF-8,
21598 // the byte-view reverse-projection axis must agree with the
21599 // paired str-view reverse-projection axis
21600 // ([`TryFrom<&str>`]) — both route through the same
21601 // [`super::DepList::from_wire`] resolver, so the two
21602 // rejection paths align by construction.
21603 if let Ok(s) = std::str::from_utf8(input) {
21604 assert_eq!(
21605 <super::DepList as TryFrom<&[u8]>>::try_from(input),
21606 <super::DepList as TryFrom<&str>>::try_from(s),
21607 "TryFrom<&[u8]> and TryFrom<&str> reverse-\
21608 projection axes on DepList must agree on the \
21609 valid-UTF-8 input {input:?} — divergence signals \
21610 the two reverse paths have drifted off the same \
21611 substrate-primitive from_wire accessor"
21612 );
21613 }
21614 }
21615 }
21616}
21617
21618#[cfg(test)]
21619mod dep_source_is_variant_tests {
21620 use super::*;
21621
21622 fn all_variants() -> Vec<(DepSource, &'static str)> {
21623 vec![
21624 (
21625 DepSource::Git {
21626 repo: "github:pleme-io/caixa-teia".into(),
21627 tag: Some("v0.1.0".into()),
21628 rev: None,
21629 branch: None,
21630 },
21631 "Git",
21632 ),
21633 (
21634 DepSource::Path {
21635 caminho: "../caixa-teia".into(),
21636 },
21637 "Path",
21638 ),
21639 ]
21640 }
21641
21642 fn predicate_row(s: &DepSource) -> [bool; 2] {
21643 [s.is_git(), s.is_path()]
21644 }
21645
21646 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
21647 // derive-generated per-arm predicate partition — for every variant
21648 // in `all_variants()`, the observed 2-slot predicate row must equal
21649 // a one-hot row with the `true` at exactly the same index as the
21650 // variant's declaration order. Expected rows are generated live
21651 // from the enumeration rather than transcribed by hand, so a
21652 // copy-paste flip that reroutes one arm through the wrong predicate
21653 // lane trips at the identity-diagonal assertion the way every peer
21654 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
21655 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
21656 // / [`crate::upgrade::UpgradeInstruction`] /
21657 // [`crate::aplicacao::PlacementStrategy`] /
21658 // [`crate::aplicacao::RateLimitUnit`] /
21659 // [`crate::aplicacao::WitTarget`] /
21660 // [`crate::render::PathShapeViolation`] partition pin already does.
21661 #[test]
21662 fn dep_source_is_variant_predicates_partition_the_arm_set() {
21663 let variants = all_variants();
21664 for (idx, (variant, name)) in variants.iter().enumerate() {
21665 let observed = predicate_row(variant);
21666 let mut expected = [false; 2];
21667 expected[idx] = true;
21668 assert_eq!(
21669 observed, expected,
21670 "DepSource::{name} at declaration-order slot {idx} must \
21671 satisfy exactly one is_* predicate (its own); observed \
21672 row must equal the one-hot expected row — a drift \
21673 would silently reroute one `:fonte`-arm consumer \
21674 through the wrong predicate lane"
21675 );
21676 }
21677 }
21678
21679 // Byte-parity pin on the two field-agnostic `matches!` shapes the
21680 // per-arm arm-discriminator predicates replace at any future
21681 // consumer site (a `:fonte`-shape-only lint rule that flags path
21682 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
21683 // a future admission-webhook that rejects `:fonte` shapes outside
21684 // the `is_git()` accept-set, a caixa-lacre indexing pass that
21685 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
21686 // Refuses a future accidental split between the derived predicate
21687 // and its `matches!` shape — a hand-rolled shadow impl that
21688 // overrides one path, an accidental rebrand that leaves one
21689 // consumer on the raw `matches!` form — on the two load-bearing
21690 // `:fonte`-arm-discriminator axes every downstream substrate
21691 // consumer of the dep-source axis keys off.
21692 #[test]
21693 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
21694 for (variant, name) in all_variants() {
21695 let via_matches_git = matches!(variant, DepSource::Git { .. });
21696 let via_predicate_git = variant.is_git();
21697 assert_eq!(
21698 via_predicate_git, via_matches_git,
21699 "DepSource::{name}.is_git() must byte-equal \
21700 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
21701 future converged consumer site would silently \
21702 disagree with its pre-lift shape"
21703 );
21704 let via_matches_path = matches!(variant, DepSource::Path { .. });
21705 let via_predicate_path = variant.is_path();
21706 assert_eq!(
21707 via_predicate_path, via_matches_path,
21708 "DepSource::{name}.is_path() must byte-equal \
21709 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
21710 future converged consumer site would silently \
21711 disagree with its pre-lift shape"
21712 );
21713 }
21714 }
21715
21716 // Cross-pin against every constructor path that materializes a
21717 // [`DepSource`] shape today (the [`DepSource::default_github`]
21718 // resolver-side fallback that materializes an unpinned
21719 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
21720 // surface constructor that materializes a pinned `:tag`-carrying
21721 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
21722 // fixture family builds inline). Every constructor's return must
21723 // satisfy the arm-discriminator predicate the constructor's
21724 // variant name matches — a future constructor addition (an
21725 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
21726 // enclosing docstring already names as a trajectory item) surfaces
21727 // as a build-time failure that names the offending drift when its
21728 // return arm doesn't route through the paired predicate.
21729 #[test]
21730 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
21731 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
21732 assert!(
21733 via_default_github.is_git(),
21734 "DepSource::default_github must materialize a Git-arm shape — \
21735 a future constructor that routed through a non-Git arm \
21736 (a registry-fetch pin, a `DepSource::Feira` promotion) \
21737 would silently split the resolver's unpinned-shorthand \
21738 materializer from the sole_pin() precedence cascade"
21739 );
21740 assert!(
21741 !via_default_github.is_path(),
21742 "DepSource::default_github must NOT materialize a Path-arm \
21743 shape — the paired negation pin"
21744 );
21745
21746 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
21747 .fonte
21748 .expect("Dep::git materializes a Some(fonte)");
21749 assert!(
21750 via_dep_git.is_git(),
21751 "Dep::git's `:fonte` materialization must land on the Git \
21752 arm — the author-surface pinned-git constructor's return \
21753 must route through the paired predicate"
21754 );
21755 assert!(!via_dep_git.is_path(), "paired negation pin");
21756
21757 let via_path = DepSource::Path {
21758 caminho: "../caixa-teia".into(),
21759 };
21760 assert!(
21761 via_path.is_path(),
21762 "the dev-mode Path-arm materialization must satisfy is_path()"
21763 );
21764 assert!(!via_path.is_git(), "paired negation pin");
21765 }
21766
21767 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
21768 // String, reason: String }` three-slot envelope on `DepError`,
21769 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
21770 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
21771 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
21772 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
21773 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
21774 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
21775
21776 #[test]
21777 fn versao_invalid_ctor_matches_struct_literal_wrap() {
21778 assert_eq!(
21779 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
21780 DepError::VersaoInvalid {
21781 nome: "caixa-teia".to_string(),
21782 versao: "^0..1".to_string(),
21783 reason: "invalid comparator".to_string(),
21784 },
21785 "versao_invalid ctor must produce byte-equal \
21786 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
21787 );
21788 }
21789
21790 #[test]
21791 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
21792 assert_eq!(
21793 DepError::fonte_repo_shape(
21794 "caixa-teia",
21795 "-upload-pack=evil",
21796 "leading dash rejected".to_string(),
21797 ),
21798 DepError::FonteRepoShape {
21799 nome: "caixa-teia".to_string(),
21800 repo: "-upload-pack=evil".to_string(),
21801 reason: "leading dash rejected".to_string(),
21802 },
21803 "fonte_repo_shape ctor must produce byte-equal \
21804 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
21805 );
21806 }
21807
21808 #[test]
21809 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
21810 assert_eq!(
21811 DepError::caracteristica_invalid(
21812 "caixa-teia",
21813 "bad feature!",
21814 "embedded space rejected".to_string(),
21815 ),
21816 DepError::CaracteristicaInvalid {
21817 nome: "caixa-teia".to_string(),
21818 caracteristica: "bad feature!".to_string(),
21819 reason: "embedded space rejected".to_string(),
21820 },
21821 "caracteristica_invalid ctor must produce byte-equal \
21822 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
21823 );
21824 }
21825
21826 #[test]
21827 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
21828 // Cross-axis routing pin: sweep the three constructor input axes
21829 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
21830 // distinct-per-axis fixtures against every generated arm in the
21831 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
21832 // lowercase / trim / truncate on the two `&str` axes — a silent
21833 // field swap between `nome`, the middle `<axis>` field, and
21834 // `reason`, or a `reason` axis silently rerouted through
21835 // `.to_string()` instead of forwarded owned — surfaces here rather
21836 // than at a downstream diagnostic-shape mismatch. Peer of the
21837 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
21838 // through_to_string` (0e35793) cross-axis routing pin on the same
21839 // envelope's `{ nome, caminho, byte }` three-slot family and of
21840 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
21841 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
21842 // — extended here onto the `{ nome, <axis>: String, reason:
21843 // String }` three-slot envelope so every substrate-primitive ctor
21844 // family in caixa-core's `DepError` envelope guarantees each field
21845 // routes the caller's value verbatim through `.to_string()` (or
21846 // owned-forward for `reason: String`) in declared field order.
21847 // Distinct-per-axis fixtures rule out any two-axis swap
21848 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
21849 // same-fixture-per-axis pin.
21850 let nome = "sibling-teia";
21851 let axis = "distinct-axis-value";
21852 let reason = "distinct rejection sentence".to_string();
21853 assert_eq!(
21854 DepError::versao_invalid(nome, axis, reason.clone()),
21855 DepError::VersaoInvalid {
21856 nome: nome.to_string(),
21857 versao: axis.to_string(),
21858 reason: reason.clone(),
21859 },
21860 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
21861 `reason` → `reason` in declared field order",
21862 );
21863 assert_eq!(
21864 DepError::fonte_repo_shape(nome, axis, reason.clone()),
21865 DepError::FonteRepoShape {
21866 nome: nome.to_string(),
21867 repo: axis.to_string(),
21868 reason: reason.clone(),
21869 },
21870 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
21871 `reason` → `reason` in declared field order",
21872 );
21873 assert_eq!(
21874 DepError::caracteristica_invalid(nome, axis, reason.clone()),
21875 DepError::CaracteristicaInvalid {
21876 nome: nome.to_string(),
21877 caracteristica: axis.to_string(),
21878 reason: reason.clone(),
21879 },
21880 "caracteristica_invalid must route `nome` → `nome`, \
21881 `axis` → `caracteristica`, `reason` → `reason` in declared \
21882 field order",
21883 );
21884 }
21885
21886 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
21887 // two-slot envelope on `DepError`, missing rung between
21888 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
21889 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
21890 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
21891 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
21892 // two-slot `{ nome, list: &'static str }` envelope (same slot
21893 // count, `&'static str` axis instead of owned `String` axis).
21894
21895 #[test]
21896 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
21897 assert_eq!(
21898 DepError::fonte_pin_empty("caixa-teia", ":tag"),
21899 DepError::FontePinEmpty {
21900 nome: "caixa-teia".to_string(),
21901 pin: ":tag".to_string(),
21902 },
21903 "fonte_pin_empty ctor must produce byte-equal \
21904 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
21905 on the same `(&str, &str)` fixture",
21906 );
21907 }
21908
21909 #[test]
21910 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
21911 assert_eq!(
21912 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
21913 DepError::FontePinAmbiguous {
21914 nome: "caixa-teia".to_string(),
21915 pins: ":tag, :rev".to_string(),
21916 },
21917 "fonte_pin_ambiguous ctor must produce byte-equal \
21918 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
21919 wrap on the same `(&str, &str)` fixture",
21920 );
21921 }
21922
21923 #[test]
21924 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
21925 assert_eq!(
21926 DepError::caracteristica_duplicate("caixa-teia", "http"),
21927 DepError::CaracteristicaDuplicate {
21928 nome: "caixa-teia".to_string(),
21929 caracteristica: "http".to_string(),
21930 },
21931 "caracteristica_duplicate ctor must produce byte-equal \
21932 `DepError::CaracteristicaDuplicate` to the pre-lift \
21933 struct-literal wrap on the same `(&str, &str)` fixture",
21934 );
21935 }
21936
21937 #[test]
21938 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
21939 // Owned-`String` routing pin: thread the real
21940 // `set.join(", ")` `String` carrier through the ctor's
21941 // `&str`-parameter Deref coercion, so the ambiguity-arm
21942 // wire-up site's actual `&set.join(", ")` shape stays
21943 // byte-equal to a direct `":tag, :rev"` literal. A future
21944 // parameter-shape change silently dropping the Deref
21945 // coercion route (e.g., a switch to `impl Into<String>`)
21946 // surfaces here rather than at the wire-up's compile
21947 // error far from the ctor definition.
21948 let set: Vec<&'static str> = vec![":tag", ":rev"];
21949 let joined: String = set.join(", ");
21950 assert_eq!(
21951 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
21952 DepError::FontePinAmbiguous {
21953 nome: "caixa-teia".to_string(),
21954 pins: ":tag, :rev".to_string(),
21955 },
21956 "fonte_pin_ambiguous ctor must accept an owned-`String` \
21957 `&set.join(\", \")` carrier via Deref coercion — the exact \
21958 shape the ambiguity-arm wire-up site passes into it",
21959 );
21960 }
21961
21962 #[test]
21963 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
21964 // Cross-axis routing pin: sweep the two constructor input axes
21965 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
21966 // fixtures against every generated arm in the
21967 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
21968 // trim / truncate at codegen time — a silent field swap between
21969 // `nome` and the middle `<axis>` field, or a `<axis>` axis
21970 // silently rerouted through the wrong field on any one variant
21971 // — surfaces here rather than at a downstream diagnostic-shape
21972 // mismatch. Peer of the sibling
21973 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
21974 // (6f5e0cd) pin on the same envelope's peer two-slot family
21975 // (`{ nome, list: &'static str }`) and of the sibling
21976 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
21977 // (5621f8a) pin on the same envelope's three-slot `{ nome,
21978 // <axis>: String, reason: String }` family — extended here onto
21979 // the `{ nome, <axis>: String }` two-slot envelope so the last
21980 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
21981 // ladder guarantees each field routes the caller's value
21982 // verbatim through `.to_string()` in declared field order.
21983 // Distinct-per-axis fixtures rule out any two-axis swap
21984 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
21985 // per-axis pin.
21986 let nome = "sibling-teia";
21987 let axis = "distinct-axis-value";
21988 assert_eq!(
21989 DepError::fonte_pin_empty(nome, axis),
21990 DepError::FontePinEmpty {
21991 nome: nome.to_string(),
21992 pin: axis.to_string(),
21993 },
21994 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
21995 in declared field order",
21996 );
21997 assert_eq!(
21998 DepError::fonte_pin_ambiguous(nome, axis),
21999 DepError::FontePinAmbiguous {
22000 nome: nome.to_string(),
22001 pins: axis.to_string(),
22002 },
22003 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
22004 in declared field order",
22005 );
22006 assert_eq!(
22007 DepError::caracteristica_duplicate(nome, axis),
22008 DepError::CaracteristicaDuplicate {
22009 nome: nome.to_string(),
22010 caracteristica: axis.to_string(),
22011 },
22012 "caracteristica_duplicate must route `nome` → `nome`, \
22013 `axis` → `caracteristica` in declared field order",
22014 );
22015 }
22016
22017 #[test]
22018 fn nome_invalid_ctor_matches_struct_literal_wrap() {
22019 // Equivalence pin: the ctor produces byte-equal
22020 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
22021 // literal that cloned the offending `:deps :nome` verbatim and
22022 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
22023 // owned `reason` payload at the caller site inside
22024 // [`Dep::validate`]. Guards any future field-addition /
22025 // reordering / accessor-return tweak on the variant. Sibling of
22026 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
22027 // (below) and the sibling three-slot
22028 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
22029 // pin on the same envelope's three-slot `{ nome, <axis>: String,
22030 // reason: String }` family.
22031 let nome = "Caixa-Teia";
22032 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
22033 let via_ctor = DepError::nome_invalid(nome, reason.clone());
22034 let via_literal = DepError::NomeInvalid {
22035 nome: nome.to_string(),
22036 reason,
22037 };
22038 assert_eq!(
22039 via_ctor, via_literal,
22040 "nome_invalid(nome, reason) must byte-equal the open-coded \
22041 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
22042 );
22043 assert_eq!(
22044 via_ctor.to_string(),
22045 via_literal.to_string(),
22046 "Display byte-string must byte-equal the open-coded struct-literal"
22047 );
22048 }
22049
22050 #[test]
22051 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
22052 // Boundary-sweep pin on the ctor's two-slot projection: sweep
22053 // the two ctor input axes (`nome: &str`, `reason: String`)
22054 // through distinct-per-axis fixtures against a representative
22055 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
22056 // wrapper-side silent lowercase / trim / truncate at codegen
22057 // time — a silent field swap between `nome` and `reason`, an
22058 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
22059 // divergence on the `reason` axis — surfaces at caixa-core
22060 // build time rather than at a downstream diagnostic consumer
22061 // that reads `err.nome` / `err.reason` back and gets a different
22062 // value than the one it stored. Peer of the sibling
22063 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
22064 // (7f7c950) pin on the same envelope's peer two-slot family
22065 // (`{ nome, <axis>: String }`) — extended here onto the
22066 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
22067 // variant carries. Distinct-per-axis fixtures rule out any
22068 // two-axis swap (`nome` ↔ `reason`) that would still pass a
22069 // same-fixture-per-axis pin. The sweep list carries a mixed
22070 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
22071 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
22072 // over-63-byte) so a future silent per-input normalization
22073 // surfaces on the arm that diverges.
22074 for nome in [
22075 "Caixa-Teia",
22076 "caixa_teia",
22077 "caixa.teia",
22078 "-caixa-teia",
22079 "caixa-teia-",
22080 "caixa/teia",
22081 &"a".repeat(64),
22082 ] {
22083 let reason = crate::render::is_dns_1123_label(nome)
22084 .expect_err("fixture must be a DNS-1123-refused label");
22085 let via_ctor = DepError::nome_invalid(nome, reason.clone());
22086 let DepError::NomeInvalid {
22087 nome: stored_nome,
22088 reason: stored_reason,
22089 } = via_ctor
22090 else {
22091 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
22092 };
22093 assert_eq!(
22094 stored_nome, nome,
22095 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
22096 );
22097 assert_eq!(
22098 stored_reason, reason,
22099 "reason slot must forward the owned `String` verbatim for {nome:?}"
22100 );
22101 }
22102 }
22103
22104 #[test]
22105 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
22106 // End-to-end pin: the sole in-crate wire-up site
22107 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
22108 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
22109 // the ctor's output on the same DNS-1123-refused `:deps :nome`
22110 // fixture, with identical `Display` rendering. A future silent
22111 // de-lift of the wire-up back to the open-coded struct-literal
22112 // trips this test at caixa-core build time rather than at a
22113 // downstream diagnostic consumer far from the wire-up commit.
22114 // Sibling of the peer
22115 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
22116 // pin on the same wire-up — extended here from a `matches!`
22117 // shape check to a byte-identity + Display parity route through
22118 // the ctor.
22119 let d = Dep::simple("Caixa_Teia", "^0.1");
22120 let observed = d.validate().unwrap_err();
22121 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
22122 .expect_err("fixture must be DNS-1123-refused");
22123 let expected = DepError::nome_invalid("Caixa_Teia", reason);
22124 assert_eq!(
22125 observed, expected,
22126 "Dep::validate's DNS-1123 refusal arm must byte-equal \
22127 nome_invalid(nome, reason)"
22128 );
22129 assert_eq!(
22130 observed.to_string(),
22131 expected.to_string(),
22132 "Display byte-string parity"
22133 );
22134 }
22135}