Skip to content

proposal(10): Zod#12

Open
christian-byrne wants to merge 1 commit intoComfy-Org:mainfrom
christian-byrne:proposal/zod
Open

proposal(10): Zod#12
christian-byrne wants to merge 1 commit intoComfy-Org:mainfrom
christian-byrne:proposal/zod

Conversation

@christian-byrne
Copy link

Proposal #10: Zod — Runtime Schema Validation

Summary

Adds a migration proposal and PoC schema definitions for Zod v3 runtime schema validation at all system boundaries: IPC channel inputs, JSON data loaded from disk, external API responses, and source module contracts.

What's Included

File Purpose
.github/proposals/proposal-zod.md Full proposal with problem analysis, alternatives comparison, implementation plan, and risk assessment
schemas/installation.ts Zod schema for the installation record (derived from 5 source modules + installations.js)
schemas/settings.ts Zod schema for the settings object (derived from settings.js defaults + ipc.js sections)
schemas/ipc.ts Zod schemas for 9 high-risk IPC channel inputs
schemas/github.ts Zod schemas for GitHub API responses + CDN manifests
schemas/validate-example.ts Standalone PoC that validates existing installations.json and settings.json against the schemas

Key Decisions

  • Zod v3 over v4 — v4's CJS bundle is ~288 KB vs v3's ~68 KB (this codebase uses require())
  • Zod over Valibot/TypeBox — z.infer<> type inference is the killer feature for eliminating type/runtime drift; bundle size is irrelevant in an Electron app (~120 MB baseline)
  • .passthrough() on all schemas — allows forward compatibility and source-specific extensions
  • safeParse() rollout strategy — log validation failures first, don't crash; switch to strict parse() later

Dependencies

No Application Code Modified

This PR only adds new files (proposal doc + schema definitions). No existing code is changed.

Add migration proposal for Zod v3 runtime schema validation covering:
- IPC channel inputs (renderer→main)
- JSON data loaded from disk (installations.json, settings.json)
- External API responses (GitHub releases, CDN manifests)
- Source module contracts (buildInstallation return shapes)

Includes PoC schema definitions in schemas/ directory with a standalone
validation example. No existing application code is modified.

Depends on: Proposal Comfy-Org#2 (TypeScript) for z.infer<> type inference.

Amp-Thread-ID: https://ampcode.com/threads/T-019c7926-be08-704f-b583-1c5167315271
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