Schema representation divergence between canonical $ref pointers and inlined "REF:" description tags
- 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:
- Canonical JSON Schema
$refpointers. - Inlined schema definitions that embed a synthetic
REF:prefix inside the schema'sdescriptionfield.
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:
{
"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:
{
"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$refnodes, and wraps the object inallOf: [{ "$ref": "ComponentCommon" }, ...]. - When given Structure A (a catalog loaded from a real
catalog.jsonfile), the schema is already wrapped inallOf. The processor looks forschema['properties']at the top level, findsnull, 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_jsonnormalizes 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),loadCatalogFromSchemamaintainsCOMMON_TYPE_SCHEMASand maps$refnodes to concrete Zod types. - In Dart (
a2ui_core/lib/src/core/catalog.dart),Catalog.fromJsonhistorically expanded only local#/pointers, leavingcommon_types.jsonreferences untouched, which made properties fromComponentCommonandCheckableinaccessible to developer tooling.
Proposed resolution
- Establish canonical external representation: All schemas serialized on disk, in capabilities envelopes, or sent over the wire must use canonical JSON Schema
$refpointers. TheREF:description tag should never be emitted on the wire. - Make capabilities generation structure-agnostic: The capabilities generator must detect whether a component is already enveloped with
ComponentCommon. If already enveloped, it must preserve existingallOfbranches rather than re-wrapping or discarding nested properties. - Harmonize
Catalog.fromJsonacross languages: When ingesting a catalog, each SDK core library should resolve standard common types using a local embedded copy ofcommon_types.jsonrather 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: EnsureCatalog.fromJsonexposes resolvedpropertiesandrequiredPropertiesonComponentApiby traversingallOfand integrating common types (ComponentCommon,Checkable).lib/src/processing/processor.dart: Update_generateInlineCatalogto inspectallOfbefore adding an envelope:- If
ComponentCommonalready exists inallOf, retain the structure and do not double-wrap. - Extract properties from child
allOfnodes if top-levelpropertiesis missing. - In
_processRefs, handle both inlinedREF:tags and canonical$refnodes.
- If
lib/src/core/common_schemas.dart: Document thatREF:tags in descriptions are internal and must be converted to$refupon export.
TypeScript Web Core (typescript/web_core)
src/catalog/schema_loader.ts: EnsurecollectComponentSubSchemascleanly extracts properties and required fields regardless of whether the input catalog usesallOfor flat properties.src/catalog/schema_generator.ts: EnsuretransformRefDescriptionNodestripsREF:descriptions unconditionally before exporting public schemas or capabilities.
Python Core (python/a2ui_core)
src/a2ui/core/catalog/catalog.py: Verify_normalize_external_schema_refsandfrom_jsoncorrectly 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
- 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
- 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
- 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"Source: a2ui-project/a2ui