Conversation
…esolver Extract component tree resolution, schema property classification, check validation, action binding, and dynamic value evaluation from SurfaceViewModel into a dedicated NodeResolver class. - Introduce NodeResolver under swift/core/Sources/A2UICore/Resolution/ - Update SurfaceViewModel to compose NodeResolver and publish rootNode - Add unit tests for NodeResolver in NodeResolverTests Fixes a2ui-project#2090
…ct#2487) - Encapsulate SurfaceComponentsModel in NodeResolver alongside DataModel. - Add convenience initializer accepting SurfaceViewModel directly. - Expose parameterless resolveTree() -> Node? on the public API surface. - Restrict recursion machinery and schema evaluation helpers to private. - Remove SurfaceViewModel.resolveNode(...). - Support initial components seeding in SurfaceComponentsModel. - Update NodeResolverTests to test exclusively through the public API surface.
- Add v1.0 JSON schemas and validation support (Draft 2020-12 common_types and catalog_definition) - Modernize wire models: rename client/server types to AgentToRendererMessage and RendererToAgentMessage (with RendererAction and RendererError, eliminating legacy typealiases) - Add RPC message models: CallRendererFunctionMessage, RendererFunctionResponseMessage, CallAgentFunctionMessage, AgentFunctionResponseMessage - Add AllowedCallers, ValidationResult, ValidationSeverity, and UnicodeIdentifierValidator - Extend ComponentAPI with allowedParents/allowedChildren and FunctionAPI with allowedCallers/requiresUserActivation - Implement State Engine v1.0 behaviors: explicit null deletion in DataModel, @index in DataContext, template child instance IDs, path resolution for empty relative pointers, and GraphTopologyValidator composition constraints - Implement bidirectional RPCHandler on MessageProcessor with outboundListener integration - Update Basic Catalog v1.0: add IndexFunction, modernize validation functions to return ValidationResult, and support v1.0 components - Add comprehensive unit and v1.0 conformance test suites with embedded test YAMLs
- Replace static validErrorCodes set and manual decoder validation in ValidationFailedError with a string-backed Code enum (VALIDATION_FAILED, UNALLOWED_PARENT, UNALLOWED_CHILD) - Leverage synthesized Codable for ValidationFailedError - Update RendererError discriminator to check ValidationFailedError.Code(rawValue:) - Update MessageErrorMapper to map detail codes directly to Code enum - Add unit tests verifying all Code cases and rejecting invalid error codes
- Add A2UIProtocolVersion string-backed enum (.v09, .v091, .v10) with loose prefix parsing and synthesized Codable support - Update AgentToRendererMessage and RendererToAgentMessage to decode and encode version using A2UIProtocolVersion - Extend ValidationConfig and MessageProcessor.CapabilitiesOptions with typed protocolVersion properties and initializers - Add isV10 and a2uiProtocolVersion helper properties to CatalogProtocol - Update A2UIValidator, NodeResolver, and BasicCatalog to use A2UIProtocolVersion - Add comprehensive decoding and validation unit tests for supported and unsupported version strings
…se prefix parsing - Remove loose initializer from A2UIProtocolVersion and rely on standard synthesized raw-value Codable - Enforce strict raw value matching (v0.9, v0.9.1, v1.0) in A2UIValidator, ValidationConfig, MessageProcessor, and CatalogProtocol - Update unit tests to verify un-prefixed versions (0.9, 1.0) are strictly rejected as invalid protocol versions
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the A2UI Swift core to support protocol version 1.0, renaming server/client terminology to agent/renderer, refactoring tree resolution into a dedicated NodeResolver, and introducing bidirectional RPC capabilities, composition constraints, and the @index system function. The review feedback highlights a critical concurrency issue in RPCHandler where an unstructured task could cause a data race on pendingCalls, unsafe Double to Int conversions in DataContext and IndexFunction that could lead to crashes or incorrect parsing, and strict version checks in SurfaceViewModel that limit forward compatibility.
…pealiases - Fix NumericFunction in BasicFunctions.v10Functions to return validationResult - Eliminate force unwrapping in NodeResolver and test suites - Introduce FunctionErrorPayload.Code string-backed enum for standard error codes - Enforce schema invariants for GenericError and FunctionResponse - Add A2UIValidator checks for v1.0 RPC actions and reject unrecognized actions - Wrap lines in GraphTopologyValidator to comply with 100-character line limit - Restore deprecated typealiases with renamed hint for ServerToClientMessage, ClientToServerMessage, ClientAction, and ClientServerError
…rward compatibility - Isolate RPCHandler timeout Task to @mainactor to eliminate data race - Use Int(exactly:) for safe Double-to-Int conversion in DataContext and IndexFunction - Support Double offset parsing in IndexFunction with fallback - Implement forward-compatible isAtLeastV10 check on CatalogProtocol
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
This pull request implements A2UI Protocol v1.0 support in the Swift codebase (
swift/core,swift/swiftui, andswift/sample) while maintaining backward compatibility with v0.9 and v0.9.1 catalogs and payloads. It also modernizes wire models and error types to use typed enums and updated naming conventions.Protocol models & versioning
A2UIProtocolVersionenum (v0.9,v0.9.1,v1.0) with standard raw-valueCodabledecoding and encoding.AgentToRendererMessage,RendererToAgentMessage,RendererAction, andRendererErrorwithout legacy type aliases.ValidationFailedErrorto use a string-backedCodeenum (VALIDATION_FAILED,UNALLOWED_PARENT,UNALLOWED_CHILD) with compiler-synthesizedCodable.Remote procedure calls (RPC)
CallRendererFunctionMessage,RendererFunctionResponseMessage,CallAgentFunctionMessage, andAgentFunctionResponseMessage.RPCHandlertoMessageProcessorfor bidirectional function execution and correlation with timeout and error handling.Catalogs & validation
common_types.jsonandcatalog_definition.jsoninA2UICommonSchema.swift.AllowedCallers,ValidationResult,ValidationSeverity, andUnicodeIdentifierValidator.ComponentAPIwithallowedParentsandallowedChildren, andFunctionAPIwithallowedCallersandrequiresUserActivation.GraphTopologyValidatorto enforce component composition rules.State engine updates
DataModel.@indexevaluation inDataContextfor templates.path: "") and template child instance IDs (<child>_<parent>_<index>).Basic catalog v1.0
IndexFunctionfor accessing iteration index in templates.EmailFunction,NumericFunction,RequiredFunction,RegexFunction,LengthFunction) to returnValidationResult.v10Catalogandv10Componentswith Draft 2020-12 schema compatibility.Testing & conformance
V10ConformanceTestswith embedded test YAML data inEmbeddedV10YAML.swift, ensuring test suites run self-contained within the repository without requiring unmerged upstream files on disk.RPCHandler,A2UIProtocolVersion,CatalogV10,StateEngineV10, andIndexFunction.Verification
From repository root:
swift build: builds cleanly without errors.swift testinswift/core: 225 core tests and 17 conformance tests pass.swift testinswift/swiftui: 58 SwiftUI integration tests pass.swift-format lint -r swift/: 0 warnings, 0 errors.