Fix visible validation depending on consumer zod version#299
Merged
Conversation
…children prompt rule catalog.validate() behavior changed under consumers' zod resolution: z.any() object keys are optional on zod 4.3 but nonoptional on zod 4.4+, so a spec omitting an element's visible field validates on 4.3 and fails on 4.4. The core test suite (zod 4.3.6) asserts the optional behavior, so optional is the intent; pin it explicitly with .optional() so all zod 4.x agree. children stays required (long-standing, zod-version-independent contract; relaxing it would change InferSpec types for consumers). Instead the default prompt rules now state explicitly that every element must include a children array, with [] for leaves, which benchmarking shows models otherwise omit on roughly a third of first attempts. - core: InferSpecObject honors SchemaType.optional at the type level (additive; no schema used optional before) - all framework schemas: visible marked ...s.optional() - framework prompt defaultRules: REQUIRED FIELDS rule for children - core: regression tests locking visible-optional and children-required
Contributor
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.
catalog.validate() behavior changed under consumers' zod resolution: z.any() object keys are optional on zod 4.3 but nonoptional on zod 4.4+, so a spec omitting an element's visible field validates on 4.3 and fails on 4.4. The core test suite (zod 4.3.6) asserts the optional behavior, so optional is the intent; pin it explicitly with .optional() so all zod 4.x agree.
children stays required (long-standing, zod-version-independent contract; relaxing it would change InferSpec types for consumers). Instead the default prompt rules now state explicitly that every element must include a children array, with [] for leaves, which benchmarking shows models otherwise omit on roughly a third of first attempts.