Skip to content

Conversation

@jacobsimionato
Copy link
Collaborator

@jacobsimionato jacobsimionato commented Jan 20, 2026

This PR introduces a dedicated ChildId type to the common_types.json schema and updates the standard catalog and documentation to use it. It also completely removes the redundant id type definition, replacing all references with ChildId.

Rationale

In A2UI v0.9, validating referential integrity (ensuring that a component's child or trigger property points to a valid ID in the same surface) currently relies on heuristics. A validator has to "guess" which fields represent IDs based on naming conventions (e.g., checking if a property is named child, children, content, or trigger).

This approach is brittle, especially for Custom Catalogs, where a developer might introduce a new component (e.g., SplitView) with properties like leftPane and rightPane. A generic validator would not know these are structural links that need to be checked.

The Fix

We introduce a semantic marker type in common_types.json:

"ChildId": {
  "type": "string",
  "description": "The unique identifier for a component, used for both definitions and references within the same surface."
}

We then update the standard catalog, the definition of ChildList, and ComponentCommon to explicitly $ref this type. This ensures that every id property and every property that refers to an id is explicitly typed.

Validator Logic (Hypothetical)

With this change, a validator can be implemented deterministically without hardcoded property names. It simply inspects the resolved schema for each property:

# Pseudocode for a robust validator
def validate_component(component, schema):
    for prop, value in component.items():
        prop_schema = resolve_schema(prop, schema)
        
        # Check if this property is structurally defined as an ID Reference
        if prop_schema[''] == 'common_types.json#//ChildId':
            if value not in known_surface_ids:
                raise ValidationError(f"Dangling reference: Component '{value}' not found.")

This ensures that any component in any catalog (standard or custom) that uses these types will automatically benefit from referential integrity checks.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a ComponentIdRef type to explicitly mark component ID references within the A2UI JSON schema. This is a valuable change that improves the schema's clarity and simplifies server-side validation by making it easier to identify and check structural links in the UI tree. The changes are applied consistently across the common types and the standard component catalog, and the documentation is updated to reflect this new requirement. Overall, this is a solid improvement for the protocol's robustness. I have one minor suggestion to further enhance validation.

Comment on lines 11 to 14
"ComponentIdRef": {
"type": "string",
"description": "A reference to the unique ID of another component within the same surface."
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve schema validation, consider adding "minLength": 1 to this definition. This would prevent empty strings from being considered valid component ID references, which is likely the intended behavior. For consistency, the same constraint could be applied to the main id definition as well.

    "ComponentIdRef": {
      "type": "string",
      "description": "A reference to the unique ID of another component within the same surface.",
      "minLength": 1
    },

"description": "A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",
"properties": {
"componentId": {
"$ref": "#/$defs/id"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this PR remove the id type, since it's no longer used? Theid was meant to serve a similar purpose, with perhaps a too-generic name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes! Ummm sorry I was vibecoding too freely and missed that there was an ID type already defined right above my new one.


To ensure that automated validators can verify the integrity of your UI tree (checking that parents reference existing children), custom catalogs MUST adhere to the following strict typing rules:

1. **Single Child References:** Any property that holds the ID of another component MUST use the `ComponentIdRef` type defined in `common_types.json`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be more specific to name it childIdRef?

Copy link
Collaborator Author

@jacobsimionato jacobsimionato Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just ComponentId?

I like the idea of including "Ref" in the name, to imply that it's a validated reference. But I think it's even neater if we can share the same type between declarations and references, in which case a generic name makes more sense.

I think when we write a validator, we can have special cased logic so that it knows that the root id parameter of each Component is a declaration (seeing as this is part of the core A2UI specification), but any other parameters with type ComponentId must be references.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. Thanks!

@jacobsimionato jacobsimionato changed the title Simplify server-side validation of A2UI messages by adding ComponentIdRef to explicitly mark component references Simplify server-side validation of A2UI messages by adding ChildId to explicitly mark component references Jan 21, 2026
@gspencergoog gspencergoog merged commit 8259520 into google:main Jan 21, 2026
5 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in A2UI Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants