diff --git a/.dependency-cruiser.json b/.dependency-cruiser.json index 133c1641..9aa7ada8 100644 --- a/.dependency-cruiser.json +++ b/.dependency-cruiser.json @@ -58,14 +58,14 @@ }, { "name": "zod-is-reached-through-contracts-zod", - "comment": "F-7 (13-08). src/contracts/zod.ts sets zod jitless before any schema is built, so the production CSP never sees zod's Function probe. Schema code imports z from there.", + "comment": "F-7 (13-08). src/contracts/zod.ts sets zod jitless before any schema is built, so the production CSP never sees zod's Function probe. Schema code imports z from there. A subpath (zod/v4, zod/mini) is the same zod and counts too (0929/P-07-06).", "severity": "error", "from": { "path": "^src", "pathNot": "^src/contracts/zod\\.ts$" }, "to": { - "path": "^zod$" + "path": "^zod(/|$)" } }, { diff --git a/docs/architecture/layers.md b/docs/architecture/layers.md index 973e6e6a..4c30f033 100644 --- a/docs/architecture/layers.md +++ b/docs/architecture/layers.md @@ -42,7 +42,7 @@ Each row is one `forbidden` rule in `.dependency-cruiser.json`, by its `name`. | `presentation-does-not-know-adapters` | `src/presentation`, except `adapters/query` | adapters, bootstrap, TanStack | | `page-templates-own-layout-only` | `src/presentation/templates` | application, adapters, bootstrap, the presentation query adapter, TanStack. Templates take data and actions as props | | `icon-vendor-is-facade-only` | all of `src`, except the lucide vendor facade | `lucide-react` | -| `zod-is-reached-through-contracts-zod` | all of `src`, except `src/contracts/zod.ts` | `zod` | +| `zod-is-reached-through-contracts-zod` | all of `src`, except `src/contracts/zod.ts` | `zod` and its subpaths (`zod/v4`) | | `design-system-is-reached-through-its-index` | code outside the design system and its named facades | design-system files other than its `index.ts` | | `adapters-do-not-know-presentation` | `src/adapters` | presentation, bootstrap | | `feature-domain-is-framework-neutral` | `src/features//domain` | application, presentation, adapters, bootstrap, any feature's application, adapters and presentation, React, TanStack | diff --git a/scripts/check-architecture.ts b/scripts/check-architecture.ts index 2413162c..1a232292 100644 --- a/scripts/check-architecture.ts +++ b/scripts/check-architecture.ts @@ -931,6 +931,15 @@ async function runGraphFixtureChecks(): Promise { target === "zod", ), }, + { + name: "zod subpath import outside src/contracts/zod.ts is rejected", + passed: blockingViolations(importBoundaryGraph).some( + ({ rule, source, target }) => + rule === "zod-is-reached-through-contracts-zod" && + source === "src/presentation/pages/subpath-zod.ts" && + target === "zod/v4", + ), + }, { name: "zod through src/contracts/zod.ts is accepted", passed: !blockingViolations(importBoundaryGraph).some(({ source }) => diff --git a/tests/fixtures/architecture/dependency-graph/import-boundaries/presentation/pages/subpath-zod.ts b/tests/fixtures/architecture/dependency-graph/import-boundaries/presentation/pages/subpath-zod.ts new file mode 100644 index 00000000..3c1d4cde --- /dev/null +++ b/tests/fixtures/architecture/dependency-graph/import-boundaries/presentation/pages/subpath-zod.ts @@ -0,0 +1,5 @@ +// 0929/P-07-06: a zod subpath is the same zod, so it is reached through +// src/contracts/zod.ts too. +import { z } from "zod/v4"; + +export const subpathSchema = z.string();