Skip to content

Initialize a2ui_core SDK with schema definitions and basic UI catalog components#1575

Merged
nan-yu merged 2 commits into
a2ui-project:mainfrom
nan-yu:re-arch-2
Jun 9, 2026
Merged

Initialize a2ui_core SDK with schema definitions and basic UI catalog components#1575
nan-yu merged 2 commits into
a2ui-project:mainfrom
nan-yu:re-arch-2

Conversation

@nan-yu

@nan-yu nan-yu commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. For larger changes, raising an issue first helps reduce redundant work.

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@gspencergoog

Copy link
Copy Markdown
Collaborator

/gemini summary

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the summary. You can try again by commenting /gemini summary.

@nan-yu

nan-yu commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

/gemini summary

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the summary. You can try again by commenting /gemini summary.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall, this approach seems fantastic and we should adopt it in our other libraries.

Remind me again why we couldn't use something like https://pypi.org/project/json-schema-to-pydantic/ ? It'd be amazing if we didn't need to maintain so much special cased logic here. But also, we don't change the schema very often, so it's not a huge deal.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I ran into the following issues with json-schema-to-pydantic:

  • Rejection of Cross-File / Multi-Document References ($ref): json-schema-to-pydantic strictly enforces intra-document references (#/). Even when converting remote URLs to local relative file paths (common_types.json#/..., catalog.json#/...), it immediately throws ReferenceError: Only local references (#/...) are supported. It lacks a multi-document resolver capable of linking our separated, modular specifications.
  • Custom Catalog DSL Incompatibility: Our component catalog (basic/catalog.json) groups specifications inside custom top-level container keys ("components": { ... }) rather than standard JSON Schema "properties". Generic parsers do not recognize this DSL layout, treating the catalog as an empty schema object.
  • Discriminated Union Optimization (O(1) Routing): We require O(1) routing via Pydantic's Annotated[Union[...], Field(..., discriminator="component")] for high-frequency UI payload parsing. Off-the-shelf tools fail to synthesize optimized discriminated unions across heterogeneous component schemas, generating slow sequential try-except evaluators.
  • Symmetrical Inheritance & Singularization: We need components to cleanly inherit from CatalogComponentCommon without duplicating inherited base fields (id, weight), and resolve inline JSON object definitions into clean semantic helper classes (e.g., OptionItem instead of generic Option or DynamicModel wrappers).

I also updated the doc to include that.

return "\n".join(output)


def generate_basic_catalog_components(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Future idea: It could be nice to generalize this to generate_catalog_components at some point, so we can point it at any catalog file that adheres to our structure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I created an issue to track the idea: #1592.

@nan-yu nan-yu merged commit 3c4ece4 into a2ui-project:main Jun 9, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in A2UI Jun 9, 2026
@nan-yu nan-yu deleted the re-arch-2 branch June 9, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants