Repository navigation
fix(swift/core): emit v1.0 inline catalogs without the ComponentCommon envelope - #3382
karolkulesza wants to merge 16 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the 'MessageProcessor' in both Python and Swift to correctly handle v1.0 inline catalogs. Specifically, v1.0 inline catalogs now omit the 'ComponentCommon' envelope (leaving components as plain schemas), format the 'protocolVersion' as a bare semantic version (e.g., '1.0' instead of 'v1.0'), and exclude system functions starting with '@'. Corresponding conformance and unit tests have been added. Feedback on the Python implementation suggests verifying that dynamically retrieved attributes are not callable before processing them to prevent potential runtime crashes.
…n envelope
v1.0 composes ComponentCommon in the message envelope, and a2ui_protocol.md
says catalog components must not wrap it again. Swift's getRendererCapabilities
wrapped every inline component in allOf [ComponentCommon, ...] for every
version, and listed the @index system function in every v1.0 inline catalog.
- Swift: v1.0 inline components are plain {type, properties, required}
schemas; @-prefixed functions are not declared. v0.9 output and
componentEnvelopeRef are unchanged.
- Python: v1.0 inline catalogs get catalogId and the bare protocolVersion,
as in web_core, also when the catalog document did not declare them.
- conformance: add test_v10_get_renderer_capabilities_inline_catalogs.
Refs a2ui-project#3061
….0 inline catalogs _generate_inline_catalog reads catalog_id and protocol_version with getattr on a duck-typed catalog; ignore them when they are methods instead of values, as system_functions.py already does for index.
88956e5 to
f3e5bcc
Compare
|
Rebased onto main to resolve the |
…catalog-envelope # Conflicts: # swift/core/Sources/A2UICore/Processing/MessageProcessor.swift
|
Merged
The new capabilities test and the conformance case now use the |
…escription in v1.0 inline components
…olVersion in v1.0 inline catalogs
Description
Swift leg of #3061. It does not remove
componentEnvelopeRef; that is left to the decisionin the issue.
v1.0 composes
ComponentCommonin the message envelope (agent_to_renderer.json), andspecification/v1_0/docs/a2ui_protocol.mdsays catalog components "MUST NOT be redundantlywrapped with
ComponentCommonviaallOf". web_core and Python only apply the envelope belowv1.0. Swift's
MessageProcessor.getRendererCapabilitiesapplied it for every version, and alsolisted the
@indexsystem function underfunctionsin every v1.0 inline catalog, althoughthe
@namespace is reserved for system functions.Changes:
MessageProcessor.generateInlineCatalog): for v1.0 each component is{type: object, properties, required}, with thecomponentconst as before, plus theschema's
descriptionand the component'sallowedParents,allowedChildrenandmetadatawhen set (
JSONSchema.Schemadrops those keywords, so they come fromAnyComponentAPI), asweb_core, Python and Dart emit them. v0.9 keeps the
allOfenvelope and still honourscomponentEnvelopeRef, whose doc comments now say it onlyapplies before v1.0. v1.0 inline catalogs no longer declare
@-prefixed functions, andfunctionsis left out when no function remains.MessageProcessor.get_renderer_capabilities): a v1.0 inline catalog gets itscatalogIdand the bareprotocolVersion(1.0), as web_core'sgenerateInlineCatalogdoes. Before, Python left
protocolVersionout when the catalog document did not declare it,and
catalog_definition.jsonreads a missingprotocolVersionas0.9. A blankprotocolVersioncounts as undeclared, a leadingvis stripped, and theto_json()document is copied rather than changed in place.
test_v10_get_renderer_capabilities_inline_catalogsinmessage_processor_v1_0.yaml, the first v1.0 capabilities case withincludeInlineCatalogs: true.Before this change the new case failed in Swift (envelope and
@index) and in Python (noprotocolVersion); web_core and Dart pass it as they are.Tests:
getRendererCapabilitiesWrapsComponentEnvelopeOnlyBeforeV10(one call for v0.9.1 and v1.0 with a custom
componentEnvelopeRef),getRendererCapabilitiesKeepsV10ComponentDefinitionFields, and a check that@indexis leftout next to user functions. Full
swift testpasses;swift-format lint --strictis clean.test_catalog_json.pyforvprefix stripping, an undeclared or blankprotocolVersion, thecatalog_idoverride, and no in-place change to theto_json()document. Full
python/a2ui_corepytest, mypy and pyink pass.node tests/conformance/conformance_test.mjspasses.message_processor_conformance_test.dartpasses.Known limit: Swift has no catalog
toJSON, so it still rebuilds each inline component from itsschema, in both versions, as before.
Refs #3061
Pre-launch Checklist
One time:
For this PR: