#2901·a2ui

Schema representation divergence between canonical $ref pointers and inlined "REF:" description tags

Author: jacobsimionatoCreated Sep 30, 2026Updated Sep 30, 2026
Labelstype: bugP2component: specificationstatus: first-line-handled
  • I have searched the existing issues to make sure this bug has not already been reported.

Describe the bug

In A2UI, UI component catalogs define the components and functions that an agent can send to a client. Components share common structures defined by the protocol specification, such as:

  • Component lifecycle envelopes (ComponentCommon, containing accessibility attributes)
  • Client-side validation rules (Checkable, containing checks)
  • Interaction handlers (Action)
  • Dynamic bindings and function calls (DynamicString, DataBinding)

Across our multi-language implementations (Dart, TypeScript, Python), there is an architectural inconsistency in how these shared definitions are represented in component schemas. Two different, conflicting formats are in active use:

  1. Canonical JSON Schema $ref pointers.
  2. Inlined schema definitions that embed a synthetic REF: prefix inside the schema's description field.

This divergence causes runtime bugs, dropped properties during client capabilities negotiation, and forces tooling (such as CLI code generators and inspectors) to implement dual-mode parsers.


The two schema structures

Structure A: Canonical $ref pointers (published catalogs)

In published catalog schema documents (such as catalogs/basic/catalog.json), components follow standard JSON Schema. Shared types are referenced by URI, and common envelopes are composed via allOf:

json
{
  "Heading": {
    "type": "object",
    "allOf": [
      {
        "$ref": "https://a2ui.org/specification/v0_9/common_types.json#/$defs/ComponentCommon"
      },
      {
        "type": "object",
        "properties": {
          "component": { "const": "Heading" },
          "text": {
            "$ref": "https://a2ui.org/specification/v0_9/common_types.json#/$defs/DynamicString",
            "description": "Heading text"
          }
        },
        "required": ["component", "text"]
      }
    ]
  }
}

Structure B: Inlined schemas with REF: description tags (in-memory builders)

In client SDKs where schemas are defined in code (such as TypeScript Zod definitions or Dart CommonSchemas), schemas are inlined directly to allow local in-memory validation without network requests. Because in-memory schema validators do not natively preserve cross-document $ref identity, the reference target was encoded into the description string:

json
{
  "Heading": {
    "type": "object",
    "properties": {
      "text": {
        "anyOf": [
          { "type": "string" },
          {
            "type": "object",
            "properties": { "path": { "type": "string" } },
            "required": ["path"],
            "description": "REF:common_types.json#/$defs/DataBinding|A JSON Pointer path in the data model."
          }
        ],
        "description": "REF:common_types.json#/$defs/DynamicString|Heading text"
      }
    },
    "required": ["text"]
  }
}

Problems caused by this divergence

1. Dropped properties during client capabilities generation

When a client advertises its inline catalogs in a2uiClientCapabilities, the message processor converts component schemas to JSON:

  • The processor expects Structure B (bare objects without an envelope). It runs a regex search for description.startsWith('REF:'), converts them to $ref nodes, and wraps the object in allOf: [{ "$ref": "ComponentCommon" }, ...].
  • When given Structure A (a catalog loaded from a real catalog.json file), the schema is already wrapped in allOf. The processor looks for schema['properties'] at the top level, finds null, and generates an empty component shell. All actual properties (text, variant, etc.) are dropped.

2. Leaking implementation details into user-facing text

The string prefix REF:<path>| is an internal parser hint. If an SDK or documentation generator does not explicitly strip this prefix with regular expressions, internal schema paths leak into docstrings, editor tooltips, and model prompts.

3. Asymmetric catalog ingestion across SDKs

  • In Python (a2ui_core/catalog/catalog.py), Catalog.from_json normalizes external references against built-in Pydantic schema tables and inlines definitions so the document is self-contained.
  • In TypeScript (web_core/src/catalog/schema_loader.ts), loadCatalogFromSchema maintains COMMON_TYPE_SCHEMAS and maps $ref nodes to concrete Zod types.
  • In Dart (a2ui_core/lib/src/core/catalog.dart), Catalog.fromJson historically expanded only local #/ pointers, leaving common_types.json references untouched, which made properties from ComponentCommon and Checkable inaccessible to developer tooling.

Proposed resolution

  1. Establish canonical external representation: All schemas serialized on disk, in capabilities envelopes, or sent over the wire must use canonical JSON Schema $ref pointers. The REF: description tag should never be emitted on the wire.
  2. Make capabilities generation structure-agnostic: The capabilities generator must detect whether a component is already enveloped with ComponentCommon. If already enveloped, it must preserve existing allOf branches rather than re-wrapping or discarding nested properties.
  3. Harmonize Catalog.fromJson across languages: When ingesting a catalog, each SDK core library should resolve standard common types using a local embedded copy of common_types.json rather than requiring external tools to maintain custom reference tables.

Implementation guidance and conformance test specifications

Files requiring updates

Dart Core (dart/a2ui_core)

  • lib/src/core/catalog.dart: Ensure Catalog.fromJson exposes resolved properties and requiredProperties on ComponentApi by traversing allOf and integrating common types (ComponentCommon, Checkable).
  • lib/src/processing/processor.dart: Update _generateInlineCatalog to inspect allOf before adding an envelope:
    • If ComponentCommon already exists in allOf, retain the structure and do not double-wrap.
    • Extract properties from child allOf nodes if top-level properties is missing.
    • In _processRefs, handle both inlined REF: tags and canonical $ref nodes.
  • lib/src/core/common_schemas.dart: Document that REF: tags in descriptions are internal and must be converted to $ref upon export.

TypeScript Web Core (typescript/web_core)

  • src/catalog/schema_loader.ts: Ensure collectComponentSubSchemas cleanly extracts properties and required fields regardless of whether the input catalog uses allOf or flat properties.
  • src/catalog/schema_generator.ts: Ensure transformRefDescriptionNode strips REF: descriptions unconditionally before exporting public schemas or capabilities.

Python Core (python/a2ui_core)

  • src/a2ui/core/catalog/catalog.py: Verify _normalize_external_schema_refs and from_json correctly handle both full specification URLs (https://a2ui.org/.../common_types.json) and relative references (common_types.json).

Proposed conformance tests

1. Capabilities generation with enveloped catalogs

Target: conformance/core/message_processor_v0_9.yaml

yaml
- name: test_v09_get_capabilities_enveloped_catalog_no_double_wrapping
  description: Verifies that an already-enveloped catalog retains all inner properties and does not get double-wrapped in allOf.
  action: get_renderer_capabilities
  catalogs:
    - catalogId: "https://a2ui.org/catalogs/v09/published"
      components:
        Text:
          type: object
          allOf:
            - $ref: "https://a2ui.org/specification/v0_9/common_types.json#/$defs/ComponentCommon"
            - properties:
                component: {const: "Text"}
                text:
                  $ref: "https://a2ui.org/specification/v0_9/common_types.json#/$defs/DynamicString"
                  description: "Text content"
              required:
                - "component"
                - "text"
  args:
    includeInlineCatalogs: true
    version: "v0.9"
  expect:
    v0.9:
      supportedCatalogIds:
        - "https://a2ui.org/catalogs/v09/published"
      inlineCatalogs:
        - catalogId: "https://a2ui.org/catalogs/v09/published"
          components:
            Text:
              allOf:
                - $ref: "common_types.json#/$defs/ComponentCommon"
                - properties:
                    component: {const: "Text"}
                    text:
                      $ref: "common_types.json#/$defs/DynamicString"
                      description: "Text content"
                  required:
                    - "component"
                    - "text"

2. Core catalog ingestion with common types

Target: conformance/core/catalog.yaml

yaml
- name: test_v09_catalog_ingestion_with_inherited_common_types
  description: Verifies that allOf references to ComponentCommon and Checkable contribute accessibility and checks properties to the component API.
  action: from_json
  catalog:
    catalogId: "test-inherited"
    components:
      TextInput:
        type: object
        allOf:
          - $ref: "https://a2ui.org/specification/v0_9/common_types.json#/$defs/ComponentCommon"
          - $ref: "https://a2ui.org/specification/v0_9/common_types.json#/$defs/Checkable"
          - properties:
              component: {const: "TextInput"}
              value: {type: string}
            required: ["component", "value"]
  expect:
    catalogId: "test-inherited"
    components:
      TextInput:
        properties:
          component: {const: "TextInput"}
          value: {type: string}
          accessibility:
            $ref: "https://a2ui.org/specification/v0_9/common_types.json#/$defs/AccessibilityAttributes"
            description: "Accessibility properties"
          checks:
            type: array
            items:
              $ref: "https://a2ui.org/specification/v0_9/common_types.json#/$defs/CheckRule"
        requiredProperties:
          - "component"
          - "value"

3. CLI code generator parity across schema representations

Target: conformance/cli/codegen.yaml

yaml
- name: test_codegen_ref_description_tag_parity
  description: Tests that a catalog using inlined REF: description tags generates typesafe models identical to canonical $ref catalogs.
  catalog_schema:
    catalogId: "tag_catalog"
    components:
      ActionCard:
        properties:
          title:
            type: string
            description: "REF:common_types.json#/$defs/DynamicString|Title of the card"
          on_press:
            type: object
            description: "REF:common_types.json#/$defs/Action|Handler when pressed"
          child:
            type: string
            description: "REF:common_types.json#/$defs/ComponentId|Child component"
        required: ["title"]
  args: ["codegen", "-c", "${CATALOG_PATH}", "-o", "${OUT_DIR}"]
  expect:
    exit_code: 0
    files:
      tag_catalog.py:
        content_contains:
          - "class ActionCard(ComponentBuilderNode):"
          - "title: DynamicString"
          - "on_press: Optional[Action] = None"
          - "child: Optional[Child] = None"
          - 'r"""Title of the card"""'
        content_not_contains:
          - "REF:"
          - "common_types.json"