Repository navigation
refactor(web_core_v1_0): pass schema adapters explicitly - #10
Closed
louis-bompart wants to merge 3 commits into
Closed
louis-bompart wants to merge 3 commits into
louis-bompart wants to merge 3 commits into
Conversation
The hand-written `@index` schema is not a Zod schema, so the Zod adapter
cannot reflect its keys and `validateFunctionArgs` stopped rejecting
unknown arguments such as `{offset: 1, foo: 2}`.
Functions can now declare `argumentKeys`. Argument validation uses them
before asking a schema adapter, and `@index` declares `offset`.
`createFunctionImplementation` carries the field through.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Importing @a2ui/schema-zod used to register its adapter in a global slot that core read from 16 call sites. The package declared "sideEffects": false, so a bundler could drop that import, and the result depended on import order. Core now holds no adapter of its own: - `CatalogOptions.schemaAdapter` gives each catalog the adapter its schemas were written for. Serializing, validating against, linking and resolving a catalog's components use it, through `requireSchemaAdapter`, which names the catalog and the missing operation when it fails. - `MessageProcessorOptions.schemaAdapter` supplies the protocol schema, and defaults to the adapter the catalogs share. - `Catalog.fromJson` takes the adapter in its options. schema-zod adds `parseZodCatalog` as the shorthand. - `linkCatalogs` rejects catalogs with different adapters. - An empty catalog's reference map needs no adapter. - The global registry, and the integrity-checker helpers that only forwarded to it, are removed. schema-zod no longer registers anything on import, and the basic catalog passes `zodCatalogSchemaAdapter` explicitly. Core's tests no longer import Zod or schema-zod, which also removes the build cycle where core's tests needed schema-zod and schema-zod needed core. Tests that check behavior with Zod schemas move to schema-zod/src/integration and the timing suite to schema-zod/tests. Where Zod was incidental, core's tests use a small hand-written schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Core's ESLint config rejects imports of zod, zod-to-json-schema, json-schema-to-zod and @a2ui/schema-zod, so core stays schema-library neutral. - A schema-zod test bundles a consumer with esbuild, which trusts "sideEffects": false, runs the bundle, and checks it renders. The consumer wires the Zod adapter only through values it uses, so the test shows that explicit wiring survives tree shaking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
Collaborator
Author
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
Importing
@a2ui/schema-zodused to register its adapter in a global slot, which core read from 16 call sites. The package declares"sideEffects": false, so a bundler could drop that import. The result also depended on import order. This PR removes the global slot: each adapter is now passed explicitly.CatalogOptions.schemaAdaptergives each catalog the adapter for its schemas. Every schema operation on a catalog goes throughrequireSchemaAdapter. When the adapter is missing, the error names the catalog and the operation.MessageProcessorOptions.schemaAdaptersupplies the protocol schema. When it isn't set, the processor uses the adapter its catalogs share.Catalog.fromJson(json, {schemaAdapter, protocolVersion?, catalogId?})now requires an adapter.schema-zodaddsparseZodCatalog(json)as a shorthand. The deprecatedCatalog.fromSchemais removed.linkCatalogsrejects catalogs that use different adapters.registerCatalogSchemaAdapter,getCatalogSchemaAdapter,installZodCatalogSchemaAdapter, and the integrity-checker functions that only forwarded to the registry.zodCatalogSchemaAdapterexplicitly.Commits
fix(web_core_v1_0): reject unknown @index arguments again. refactor(web_core_v1_0): remove Zod runtime dependency #9 replaced the@indexschema with a hand-written one. The Zod adapter can't read that schema's keys, so{offset: 1, foo: 2}was accepted. Functions can now declareargumentKeys, and@indexdeclaresoffset. This commit doesn't depend on the other two, so it could also go into refactor(web_core_v1_0): remove Zod runtime dependency #9.refactor(web_core_v1_0): pass schema adapters explicitly. This is the change described above. Core's tests no longer import Zod or@a2ui/schema-zod, which removes the build cycle: before, core's tests neededschema-zodbuilt, andschema-zodneeded core built.schema-zod/src/integration/. They import core only through@a2ui/web_core_v1_0.schema-zod/tests/timing.test(schema-zod): guard the schema adapter boundary.zod,zod-to-json-schema,json-schema-to-zodand@a2ui/schema-zod."sideEffects": false, then runs the bundle and checks that it renders.Reviewing commit by commit is easiest. In commit 2, the files under
schema-zod/src/integration/differ from their originals only in imports,new ZodCatalog(...)in place ofnew Catalog(...), andparseZodCatalog(...)in place ofCatalog.fromJson(...).Validation
Each commit was built from clean, then linted, format-checked and tested on its own. Lint has no errors; the existing warnings are unchanged.
@a2ui/web_core_v1_0@a2ui/schema-zodyarn test:timing)@a2ui/catalog-basicThe totals are 573 before and 586 after: 12 new tests in core and the bundling test. Core now builds and tests with
schema-zodnot built at all.Not in this PR
extractRefFields. ReadingschemaMetadata.childRefsfirst would allow catalogs written with other schema libraries.package.jsonstill has atest:conformancescript, but refactor(web_core): isolate v1.0 core package #5 removed the wireit configuration it runs.🤖 Generated with Claude Code