Context
The dependency update on origin/dev moved zod to ^4.4.3, removed the direct zod-to-json-schema dependency from package.json, and moved js-yaml to 5.2.0. The AI MCP validation and tool-listing path still carries Zod 3-era assumptions.
Live latest-open sweep: checked the latest 20 open issues immediately before filing; no equivalent Zod v4 / AI MCP schema compatibility ticket found. A2A in-flight sweep: checked the latest 30 all-state messages immediately before filing; no overlapping [lane-claim] / [lane-intent] found.
The Problem
V-B-A found two concrete failures on the updated origin/dev dependency set:
zod-to-json-schema emits {} for Zod v4 schemas. Direct probe:
zodToJsonSchema(z.object({a:z.string()}), {target:'openApi3',$refStrategy:'none'}) -> {}
z.toJSONSchema(z.object({a:z.string()})) -> object schema with properties, required, and additionalProperties:false
z.toJSONSchema(z.array(z.unknown())) -> array schema with items:{}
js-yaml@5.2.0 no longer provides a default ESM export. Direct probe:
import * as yaml from 'js-yaml' works and exposes yaml.load
import yaml from 'js-yaml' throws SyntaxError: The requested module 'js-yaml' does not provide an export named 'default'
The existing targeted unit suite currently fails before its assertions with that js-yaml import error.
The Architectural Reality
The affected runtime surface is the AI MCP tool-shape compiler:
ai/mcp/ToolService.mjs imports yaml as a default and imports zodToJsonSchema from zod-to-json-schema to publish inputSchema / outputSchema for tools/list.
ai/mcp/validation/openApiValidator.mjs builds the Zod schemas consumed by ToolService.
ai/services.mjs also imports yaml as a default for OpenAPI-backed service validation.
- Several AI services and unit tests import
js-yaml as a default and must be compatible with js-yaml@5 ESM exports.
test/playwright/unit/ai/mcp/validation/OpenApiValidatorCompliance.spec.mjs imports zod-to-json-schema directly and encodes Zod 3-era converter behavior.
The Fix
- Replace direct runtime use of
zod-to-json-schema in ai/ with Zod v4's built-in JSON Schema emitter (z.toJSONSchema(...) or equivalent local helper).
- Preserve the OpenAPI/MCP schema semantics currently required by clients: object strictness for inputs, passthrough/open output objects where intended, array
items:{} for unknown arrays, and no hollow {} schemas in tools/list.
- Replace default
js-yaml imports in ai/ and targeted AI unit tests with namespace imports that work under js-yaml@5.
- Update targeted tests away from
zod-to-json-schema expectations and toward Zod v4's built-in emitter.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
MCP tools/list inputSchema / outputSchema |
ai/mcp/ToolService.mjs + server OpenAPI YAML |
Emit real JSON Schema from Zod v4 schemas; never {} for ordinary objects/arrays |
Fail tests before publishing hollow schemas |
Existing MCP/OpenAPI validation tests |
Direct Zod v4 probe + targeted unit suite |
| AI OpenAPI YAML loading |
ai/** modules importing js-yaml |
Use namespace import with yaml.load under js-yaml@5 |
Import-time failure blocks startup/tests |
Existing source imports |
Direct import yaml failure probe |
Decision Record impact
none
Acceptance Criteria
Out of Scope
- No broad package update or audit fix; dependency versions are already updated on
origin/dev.
- No changes outside the AI Zod/OpenAPI/YAML compatibility path unless a targeted test proves they are required.
- No redesign of the OpenAPI-to-Zod bridge beyond the minimum needed for Zod v4 compatibility.
Avoided Traps
- Do not keep using
zod-to-json-schema just because it remains hoisted transitively; it is no longer a direct dependency and emits hollow schemas for Zod v4.
- Do not file or patch from package-name assumptions alone; this ticket is grounded in runtime probes against the updated dependency set.
Related
- Dependency update landed on
origin/dev before this ticket.
Origin Session ID: b36a73d4-b659-4cd0-8c21-3c497b99857c
Handoff Retrieval Hint: "Zod v4 breaks AI MCP schema emission js-yaml default import zod-to-json-schema emits empty object"
Context
The dependency update on
origin/devmovedzodto^4.4.3, removed the directzod-to-json-schemadependency frompackage.json, and movedjs-yamlto5.2.0. The AI MCP validation and tool-listing path still carries Zod 3-era assumptions.Live latest-open sweep: checked the latest 20 open issues immediately before filing; no equivalent Zod v4 / AI MCP schema compatibility ticket found. A2A in-flight sweep: checked the latest 30 all-state messages immediately before filing; no overlapping
[lane-claim]/[lane-intent]found.The Problem
V-B-A found two concrete failures on the updated
origin/devdependency set:zod-to-json-schemaemits{}for Zod v4 schemas. Direct probe:zodToJsonSchema(z.object({a:z.string()}), {target:'openApi3',$refStrategy:'none'})->{}z.toJSONSchema(z.object({a:z.string()}))-> object schema withproperties,required, andadditionalProperties:falsez.toJSONSchema(z.array(z.unknown()))-> array schema withitems:{}js-yaml@5.2.0no longer provides a default ESM export. Direct probe:import * as yaml from 'js-yaml'works and exposesyaml.loadimport yaml from 'js-yaml'throwsSyntaxError: The requested module 'js-yaml' does not provide an export named 'default'The existing targeted unit suite currently fails before its assertions with that
js-yamlimport error.The Architectural Reality
The affected runtime surface is the AI MCP tool-shape compiler:
ai/mcp/ToolService.mjsimportsyamlas a default and importszodToJsonSchemafromzod-to-json-schemato publishinputSchema/outputSchemafortools/list.ai/mcp/validation/openApiValidator.mjsbuilds the Zod schemas consumed by ToolService.ai/services.mjsalso importsyamlas a default for OpenAPI-backed service validation.js-yamlas a default and must be compatible withjs-yaml@5ESM exports.test/playwright/unit/ai/mcp/validation/OpenApiValidatorCompliance.spec.mjsimportszod-to-json-schemadirectly and encodes Zod 3-era converter behavior.The Fix
zod-to-json-schemainai/with Zod v4's built-in JSON Schema emitter (z.toJSONSchema(...)or equivalent local helper).items:{}for unknown arrays, and no hollow{}schemas intools/list.js-yamlimports inai/and targeted AI unit tests with namespace imports that work underjs-yaml@5.zod-to-json-schemaexpectations and toward Zod v4's built-in emitter.Contract Ledger Matrix
tools/listinputSchema/outputSchemaai/mcp/ToolService.mjs+ server OpenAPI YAML{}for ordinary objects/arraysai/**modules importingjs-yamlyaml.loadunderjs-yaml@5import yamlfailure probeDecision Record impact
none
Acceptance Criteria
ai/runtime imports ofjs-yamlare compatible withjs-yaml@5.2.0ESM exports.ai/mcp/ToolService.mjsno longer depends onzod-to-json-schemafor runtime schema emission.zod@4.4.3.ai/finds no remaining runtimezod-to-json-schemaimport.Out of Scope
origin/dev.Avoided Traps
zod-to-json-schemajust because it remains hoisted transitively; it is no longer a direct dependency and emits hollow schemas for Zod v4.Related
origin/devbefore this ticket.Origin Session ID: b36a73d4-b659-4cd0-8c21-3c497b99857c
Handoff Retrieval Hint: "Zod v4 breaks AI MCP schema emission js-yaml default import zod-to-json-schema emits empty object"