feat: migrate workspace to Zod 4 (DD-120)#408
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pnpm.overrides.d.tstypes 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(.errorsalias removed)issue.pathtype:PropertyKey[]in Zod 4 (includessymbol); cast to(string | number)[]at 2 call sitesChanged files
package.jsonfiles:zodbumped to^4.3.6package.json: Addedpnpm.overrides.zod: "^4.3.6"packages/schema/src/json.ts: 2xz.record()2-arg formpackages/schema/src/interaction.ts: 1xz.record()2-arg formpackages/control/src/validators.ts: 2xz.record()2-arg formpackages/mcp-server/src/schemas/bundle.ts: 1xz.record()2-arg formpackages/mcp-server/src/infra/policy.ts: 3x.default({})->.prefault({})packages/protocol/src/issue.ts: Zod issue path type castpackages/cli/src/lib/conformance/validators.ts: Zod issue path type castpackages/schema/__tests__/dispute.test.ts: 9x.error.errors->.error.issuespackages/schema/__tests__/interaction.test.ts: 10x.error.errors->.error.issuesTest plan
.superRefine()verified NOT deprecated in Zod 4 (no churn needed)