chore: migrate circuit-json schemas to Zod v4#661
Conversation
|
Hi @seveibar — this CI-green migration is the prerequisite for the Zod v4 work tracked in tscircuit/core#2810. Once merged, the release workflow will publish circuit-json@0.0.455; Footprinter #726 and Props #752 are ready to validate against it. Could you review when you have a moment? |
|
@seveibar this one is the head of the Zod v4 chain, and it's the only piece that can land right now — all checks pass here ( The dependency order matters, so flagging it explicitly:
The reason is concrete: the published declare const point: z.ZodObject<{
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
...
}, "strip", z.ZodTypeAny, { ... }, { ... }>;
So there's nothing I can fix in the downstream PRs until this one is released. If you'd rather I close #752/#726 and reopen them after a circuit-json release, happy to do that — just let me know which you prefer. |
332a83b to
2b31a1a
Compare
|
Rebased onto current Re-verified on the rebased head:
Worth restating why this one is the bottleneck rather than just one of several open PRs: the published Merging and releasing this unblocks that chain in one step; nothing downstream needs code changes, just a re-run. Happy to rebase again if more lands first. |
|
Adding the measurement that I think makes this PR worth prioritizing — it isn't just a dependency bump. tscircuit/tscircuit#4077 reports circuit-JSON generation OOMing past ~4.4 GB RSS on a mid-size board, and its heap-snapshot retainer analysis names the cause precisely: Zod v3 eagerly binds I measured the schema set this package exports, walking every object reachable from all 259 exported schemas and counting bound-method closures.
−89.5%, and that's just the static schema set — the multiplier in #4077 comes from those closures being retained per parsed element during generation. I re-ran at depth caps 25 and 45 to rule out the traversal limit hiding something: Stable, so the gap is real and not a traversal artifact. Separately, I profiled where allocation actually goes during generation in Why this PR specifically: it's the head of the chain. This PR is self-contained and green on its own. Happy to rebase whenever. |
|
Re-confirming today that this PR is the single blocker for two others, with fresh evidence. The currently published
Blocked on this PR: tscircuit/props#752 and tscircuit/footprinter#726. Neither can go green until this merges and publishes. Both are otherwise ready. To restate the case from my earlier comment, since it's the part that makes this more than a version bump — measured across all 259 exported schemas:
−89.5%. That's the This PR is self-contained, |
Summary
Release coordination
Zod v3 and v4 schema instances cannot be composed. When this PR merges, the repository release workflow will publish circuit-json@0.0.455. Dependent PRs require that exact patch range, then release in this order: circuit-json, footprinter #726, @tscircuit/props #752, then tscircuit/core.
Consumers that inspect raw Zod errors must use the Zod v4 error APIs. Zod v4 also rejects non-finite numbers and unsafe integers where Zod v3 accepted them.
Verification
Related to tscircuit/core#2810