Repository navigation
feat(web_core): bind and validate code catalog entries through their documents - #47
Draft
louis-bompart wants to merge 1 commit into
Draft
louis-bompart wants to merge 1 commit into
louis-bompart wants to merge 1 commit into
Conversation
…documents The core now reads the schema of an entry defined in code from its catalog's own toJson() document, as Catalog.fromJson loads it, so a code catalog behaves as the catalog it publishes. NodeResolver, the Lit A2uiController, PayloadValidator, function argument checks, the child reference map and the function invoker all go through the new componentSchemaOf and functionSchemaOf. Validation runs the document's schema first, then the entry's own Zod schema (safeParseEntry), so refinements only code expresses still run and functions still receive their arguments as their own schema parses them. Entries loaded from JSON, and entries whose schema is plain JSON Schema, are read as before. The Zod-to-JSON conversions now write a described child reference (ComponentIdSchema.describe(...), optionally) as a $ref to ComponentId or ChildList, so the reloaded entry still sees the child. As a result, callMcpTool rejects a server argument, as its published catalog closes args. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 4 tasks
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.
Description
With a loaded catalog now behaving like its code catalog, this PR makes the core use the JSON for catalogs defined in code too: it reads every entry's schema from the catalog's own
toJson()document, the wayCatalog.fromJsonloads it. A code catalog then behaves exactly like the document it publishes.entry_schema.ts(internal):componentSchemaOf(catalog, entry)andfunctionSchemaOf(catalog, fn)return the schema derived from the catalog's document, reloaded once per catalog. An entry loaded from JSON, or whoseschemais a JSON Schema object, is returned as is.NodeResolver, the LitA2uiController,PayloadValidator, the function argument checks ofDataContext, the child reference map and the catalog's function invoker read entries this way.safeParseEntryvalidates with the document's schema first, then with the entry's own schema, so a.refine()still applies. A function receives its arguments as its own schema parses them.Catalog.toJson()writes a child reference whose description was replaced, such asComponentIdSchema.describe('The child.'), as a$reftoComponentIdorChildList, so the reloaded catalog still recognizes the child.callMcpToolcall with aserverargument now fails validation, as the published catalog closesargs.A payload that the document rejects is now rejected even where the Zod schema alone accepted or stripped it. The changelog marks this as breaking.
Validation
yarn buildintypescript/core/web_core, thennode --test "dist/**/*.test.js": 1316 tests, 0 failing.node tests/conformance/conformance_test.mjs: every vector passes.yarn lintintypescript/core/web_core: 0 errors.yarn buildandyarn testintypescript/catalogs/mcp,typescript/catalogs/vegachart,typescript/renderers/markdown-it,typescript/renderers/lit,typescript/renderers/reactandtypescript/agents/a2ui_agent: all pass.yarn buildintypescript/renderers/angular,tools/composer,tools/editorandtools/inspector. The Angular tests were not run: the local Java is too old for the Closure Compiler step.Regroups #20.
Part of a2ui-project#2160.
🤖 Generated with Claude Code