Skip to content

feat: migrate workspace to Zod 4 (DD-120)#408

Merged
jithinraj merged 1 commit intomainfrom
feat/zod4-schema
Feb 22, 2026
Merged

feat: migrate workspace to Zod 4 (DD-120)#408
jithinraj merged 1 commit intomainfrom
feat/zod4-schema

Conversation

@jithinraj
Copy link
Member

Summary

  • Migrate all 9 Zod-consuming packages from Zod 3.25.x to Zod 4.3.6 (DD-120)
  • Enforce single Zod major across workspace via pnpm.overrides
  • Breaking for downstream TS consumers: .d.ts types change (Zod 3/4 types are not assignment-compatible)

Key migration patterns

  • z.record(ValueSchema) -> z.record(z.string(), ValueSchema) (single-arg form removed in Zod 4)
  • .default({}) -> .prefault({}) for input-type defaults (Zod 4 .default() requires output-type values)
  • ZodError.errors -> ZodError.issues (.errors alias removed)
  • issue.path type: PropertyKey[] in Zod 4 (includes symbol); cast to (string | number)[] at 2 call sites

Changed files

  • 9 package.json files: zod bumped to ^4.3.6
  • Root package.json: Added pnpm.overrides.zod: "^4.3.6"
  • packages/schema/src/json.ts: 2x z.record() 2-arg form
  • packages/schema/src/interaction.ts: 1x z.record() 2-arg form
  • packages/control/src/validators.ts: 2x z.record() 2-arg form
  • packages/mcp-server/src/schemas/bundle.ts: 1x z.record() 2-arg form
  • packages/mcp-server/src/infra/policy.ts: 3x .default({}) -> .prefault({})
  • packages/protocol/src/issue.ts: Zod issue path type cast
  • packages/cli/src/lib/conformance/validators.ts: Zod issue path type cast
  • packages/schema/__tests__/dispute.test.ts: 9x .error.errors -> .error.issues
  • packages/schema/__tests__/interaction.test.ts: 10x .error.errors -> .error.issues

Test plan

  • All 4138+ tests pass
  • Build: 76/76 targets pass
  • Lint, typecheck, format: clean
  • guard.sh + check-planning-leak.sh: clean
  • No Zod 3 imports remain anywhere in workspace
  • .superRefine() verified NOT deprecated in Zod 4 (no churn needed)

Migrate all 9 packages from Zod 3.22.x to Zod 4.3.6. This is a
breaking change for downstream TypeScript consumers who compile
against exported @peac/schema types (z.infer<> types are not
assignment-compatible across Zod majors).

Schema changes:
- z.record() single-arg form removed in Zod 4: add explicit
  z.string() key schema in 5 locations (schema, control, mcp-server)
- .default({}) on object schemas requires output-type-compatible
  values in Zod 4: use .prefault({}) for input-type defaults (policy.ts)
- ZodError.errors alias removed: use .issues in test assertions
- issue.path typed as PropertyKey[] (was (string | number)[]): add
  casts at 2 call sites (protocol/issue.ts, cli/validators.ts)

No behavioral changes to schema validation, receipt issuance, or
verification. All 4138 tests pass across 167 test files.

Workspace enforcement:
- pnpm.overrides forces zod@^4.3.6 across all workspace packages
- Prevents mixed Zod 3/4 which causes runtime TypeError
@jithinraj jithinraj merged commit 0280df2 into main Feb 22, 2026
8 checks passed
@jithinraj jithinraj deleted the feat/zod4-schema branch February 24, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant