feat(swift): add A2UICore error types, JSONValue path extensions, and message models#1999
Open
pinieb wants to merge 19 commits into
Open
feat(swift): add A2UICore error types, JSONValue path extensions, and message models#1999pinieb wants to merge 19 commits into
pinieb wants to merge 19 commits into
Conversation
…ma dependency Replaces the custom JSONSchema target with a multi-target Swift package structure that uses the swift-json-schema fork (v0.13.1) as an external dependency. This is the foundation for porting the A2UI v0.9.1 protocol implementation from prototype to production quality. Changes: - Remove custom JSONSchema target (JSONValue.swift + tests) - Add swift-json-schema dependency (from: "0.13.1") to Package.swift - Bump swift-tools-version to 6.1 and add macOS 13 to platforms - Define 4 production targets: A2UIJSON, A2UICore, A2UISwiftUI, A2UISampleClient - Define 3 test targets with placeholder tests - Create stub source files for each target - Update AGENTS.md to document new target architecture - Update .gitignore for Swift Package Manager artifacts Verification: - `swift package resolve` resolves swift-json-schema at 0.13.1 - `swift build` compiles all 7 targets - `swift test --enable-swift-testing` passes (3 placeholder tests)
…chema Implements all 14 A2UI v0.9.1 common type JSON Schema definitions using the swift-json-schema fork. Schemas are defined as a raw JSON document matching the specification's common_types.json exactly, and registered into Context via the remoteSchema parameter for $ref resolution. Changes: - Define complete common types document in A2UICommonSchema (all 14 defs: ComponentId, AccessibilityAttributes, ComponentCommon, ChildList, DataBinding, DynamicValue, DynamicString, DynamicNumber, DynamicBoolean, DynamicStringList, FunctionCall, CheckRule, Checkable, Action) - Add A2UISchemaRegistry helper to create a Context pre-populated with A2UI schemas - Add 31 tests covering URI helpers, document structure, schema registry, validation of all schema types (positive and negative cases), and cross-reference resolution (including recursive Action → FunctionCall → DynamicValue chains) - Remove placeholder A2UIJSONTests (superseded by comprehensive tests) Design notes: - Raw JSON string approach used instead of JSONValue dictionary literals to avoid Swift type-checker issues with deeply nested expressions - FunctionCall's catalog.json oneOf reference omitted; catalog-level validation handled at runtime by ComponentCatalog - Context.remoteSchemaStorage is internal in the fork, so schemas are registered via the Context(remoteSchema:) initializer Verification: - swift build passes (all targets) - swift test passes (34 tests in 3 suites, 0.017s)
… message models Ports the foundational A2UICore types from the prototype: error types, JSONValue path-based subscripting, and all server/client message models. Changes: - Add 4 error types: ClientServerError, GenericError, ValidationFailedError, LocalFunctionError (now Sendable) - Add JSONValue+Path extensions with type-safe accessors and JSON Pointer get/set subscripting, adapted for the fork's OrderedDictionary-based JSONValue (including .integer case handling) - Add Resolved protocol and ResolvedAction model with identity-based equality - Add 6 message types: EnvelopeMessage, CreateSurfaceMessage, DeleteSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, ClientToServerMessage (with v0.9/v0.9.1 version validation) - Add OrderedJSON and JSONSchema product dependencies to A2UICore target - Add 50 tests covering type accessors, path operations, message decoding/encoding round-trips, and error cases - Remove placeholder A2UICore.swift stub and placeholder test Verification: - swift build passes (all targets) - swift test passes (84 tests in 5 suites)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Pete Biencourt <piebie@google.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements core A2UI models, messages, error types, and schema definitions in Swift, along with path-based JSON utility extensions and comprehensive unit tests. The feedback highlights a potential runtime crash in JSONValue+Path.swift when converting large Double values to Int without bounds checking, and notes that parsePath is not fully RFC 6901 (JSON Pointer) compliant. Additionally, it is recommended to avoid using try? inside ClientServerError's decoding initializer to prevent swallowing decoding errors.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Pete Biencourt <piebie@google.com>
jacobsimionato
left a comment
Collaborator
There was a problem hiding this comment.
Feedback on Swift Core implementation inconsistencies compared to the blueprint and web_core reference implementation.
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
Ports the foundational A2UICore types from the prototype: error types,
JSONValue path-based subscripting, and all server/client message models.
Changes
ValidationFailedError, LocalFunctionError (now Sendable)
Pointer get/set subscripting, adapted for the fork's
OrderedDictionary-based JSONValue (including .integer case handling)
equality
DeleteSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage,
ClientToServerMessage (with v0.9/v0.9.1 version validation)
decoding/encoding round-trips, and error cases
Verification