fix(contracts): set zod jitless before any schema is built so the production csp sees no eval (F-7, 13-08)

zod probed Function("") on its first object schema, which the production CSP
(no unsafe-eval) reported on every boot. Schema code now imports z from
src/contracts/zod.ts, enforced by a dependency-cruiser rule, and the CSP smoke
drops its init-script workaround.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
donghyeon-ka
2026-09-27 12:58:57 +09:00
co-authored by Claude Opus 5.5
parent 606c191941
commit 9dc95ca066
16 changed files with 74 additions and 32 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "../../contracts/zod.ts";
import { projectValidationIssues } from "../../contracts/validation-issues.ts";
const metaSchema = z
+1 -1
View File
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "./zod.ts";
import {
CONTRACT_SET_ALGORITHM,
+1 -1
View File
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "./zod.ts";
import { contractSetSchema } from "./contract-set.ts";
+15
View File
@@ -0,0 +1,15 @@
import { z } from "zod";
/**
* F-7 (13-08). zod probes `new Function("")` when it builds its first object
* schema, to decide whether it may compile parsers. The production CSP has no
* 'unsafe-eval', so the browser reports that probe on every boot even though
* zod catches the refusal. `jitless` skips the probe; it only helps if it runs
* before any schema is built, and a bundler may evaluate a shared chunk before
* the entry module body. So every module that builds a schema imports `z`
* from here: the dependency, not import order in main.tsx, puts this first.
*/
z.config({ jitless: true });
export { z };
export type { ZodIssue, ZodType } from "zod";
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "../../../contracts/zod.ts";
import type {
CommandEffectDescriptor,
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "../../../contracts/zod.ts";
import type { RuntimeValidator } from "../../../contracts/external-contract-runtime.ts";
import { runtimeSchemaCodecFromValidator } from "../../../contracts/schema-registry.ts";
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "../../../contracts/zod.ts";
export const referenceResourceFormSchema = z
.object({
+1 -1
View File
@@ -8,7 +8,7 @@ import {
type FormEvent,
} from "react";
import { flushSync } from "react-dom";
import type { ZodType, ZodIssue } from "zod";
import type { ZodIssue, ZodType } from "../../contracts/zod.ts";
import type { AppFailure } from "../../contracts/errors.ts";
import {
useLocale,
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "../../contracts/zod.ts";
export const PLATFORM_ROUTE_CODECS = {
// D-16: a route without input ignores unknown keys (`?utm_source=`, OAuth