Skip to content

fix(python/core,agent): treat custom checks/accessibility params as props - #4529

Open
jacobsimionato wants to merge 1 commit into
macros/1-runtime-bug-fixesfrom
macros/2-checks-a11y-params
Open

jacobsimionato wants to merge 1 commit into
macros/1-runtime-bug-fixesfrom
macros/2-checks-a11y-params

Conversation

@jacobsimionato

@jacobsimionato jacobsimionato commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Stack: 6/11 (overview) · previous: #4528 · next: #4562

Reviewer guide: A2UI Python macros: reviewer guide explains how the whole stack fits together.

Problem

In v1.0, every component can carry envelope fields: @checks (validation rules), @accessibility (screen-reader labels), @metadata, and @catalogId. They come from two shared schema mixins: ComponentCommon (id, accessibility, metadata, catalogId) and Checkable (checks). Components and macros (Python functions that expand into A2UI components server-side) may also declare their own parameter with the bare name, meaning the name without the @ prefix, such as checks or accessibility. The Python SDK confused the two: a declared accessibility, or a required checks, was taken for the envelope field and dropped or moved. So a macro such as FormCard(label: str, checks: Sequence[CheckRule]) (CheckRule is one {condition, message} validation rule) could not be called correctly from A2UI Express or Direct JSON (the SDK's LLM output formats). metadata and catalogId go through the same classification, so the fix covers all four names.

After this PR, this Express call compiles, expands, and passes strict validation, with the rule landing as @checks on the macro's inner TextField:

f1 = FormCard("Email", ?required($/ok, "Required"))

Summary

  1. a2ui-core uses one rule to decide whether a bare envelope-named property is the standard field or the component's own prop (table below). required lists are followed through allOf and local $refs.
  2. CatalogSchemaHelper in the agent SDK drops its own copy of this rule and calls the core functions, so inference formats and PayloadValidator agree.
  3. The Express compiler writes ?check(...) results into a component's own checks property when that property is a CheckRule array.
  4. MacroExpander binds a v1.0 @checks array to an optional checks: Sequence[CheckRule] macro parameter when bare checks is omitted, and does not also copy it onto the expanded root.
Bare property Required? id in the same properties block? Result
Any of the four Yes Either Custom prop
accessibility, metadata, catalogId No Yes, with the standard shape Standard field
accessibility, metadata, catalogId No No Custom prop
checks No Either Standard if Checkable or a CheckRule array, else custom

@-prefixed keys stay standard when their shape matches. Neither mixin marks these keys as required, which is why "required" means custom.

Breaking changes: None for the standard catalogs. Python SDK users with custom catalogs see different results where a schema marks one of these four names as required, or declares a bare accessibility, metadata, or catalogId without an inlined id: those are now custom props. Both CHANGELOG.md files note this.

New and changed API

  1. is_component_checkable and get_custom_envelope_properties (already public in a2ui.core.catalog) now follow the table above.
  2. New Express errors: a ?check(...) on a component whose own checks does not take CheckRule items raises ExpressValidationError ("Component 'X' declares a 'checks' property that does not take CheckRule checks, so it cannot take ?check(...)."). Giving checks both ways raises ExpressDuplicatePropertyError for checks.

Where to review

Category Files Diff (+/-)
Production 5 +212 / -98
Tests 3 +523 / -0
Docs and changelogs 3 +11 / -1
Total 11 +746 / -99

Start here:

  1. python/a2ui_core/src/a2ui/core/catalog/catalog.py: _is_standard_mixin_property_schema and _collect_conjunctive_required. Verify that v0.9 and v1.0 standard components are still checkable.
  2. python/a2ui_agent/src/a2ui/utils/_schema_helper.py: verify nothing relied on the removed local checks (including the catalogId description match).
  3. python/a2ui_agent/src/a2ui/inference_formats/express/compiler.py: verify which key gets compiled checks (checks or @checks) and when a custom checks keeps its positional slot.
  4. python/a2ui_agent/src/a2ui/transformers/macros/expander.py: verify @checks is bound only for an optional, exactly Sequence[CheckRule] parameter.
Implementation details
  1. _declared_property_blocks and _schema_references_checkable now yield or pass (properties, required) pairs and use immutable frozenset visited sets, so a $def visited in one anyOf/oneOf branch is still followed in a sibling branch.
  2. Catalog._flatten_validation_components gathers required from all pieces and passes is_required to the mixin check.
  3. CatalogSchemaHelper.has_custom_check_rules(name) (internal) reports a custom bare checks property whose items are CheckRule. Express uses it to decide whether a custom checks keeps its positional slot (it does not when ?check(...) fills it) and which key receives compiled checks.
  4. processor._is_standard_check_rule_sequence_type accepts exactly Sequence[CheckRule] (optionally | None, through Annotated and type aliases). Unions with other types stay custom, matching schema synthesis.
  5. The expander tracks the binding with a checks_consumed_by_param flag, and the macros README.md documents this exception.
Verification

Measured at the stack tip (all 11 commits applied):

  1. Full Python suite passes (6027 passed).
  2. mypy is clean (283 source files).
  3. 56 conformance goldens are valid.
  4. Prettier and pyink are clean on every commit, and every commit has a DCO sign-off.

This PR adds test_custom_accessibility_and_required_checks_without_inline_id and test_get_custom_envelope_properties_scopes_visited_defs_per_branch (python/a2ui_core/tests/test_catalog.py), test_inline_id_and_required_checks_parity_with_core (python/a2ui_agent/tests/test_catalog_schema_helper.py), and test_v10_macros_declaring_checks_and_accessibility_work_in_express_and_direct_json (python/a2ui_agent/tests/test_macros.py).

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

Copy link
Copy Markdown
Contributor

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 resolves an issue where declared accessibility and required or optional checks macro parameters collided with v1.0 envelope mixins. It updates the schema helper and catalog validation logic to treat bare accessibility properties without an inlined id and required bare checks properties as custom component properties rather than standard mixins. Additionally, the macro expander has been updated to handle cases where checks are consumed by macro parameters, and comprehensive end-to-end tests have been added. There are no review comments, so no further feedback is provided.

@jacobsimionato jacobsimionato changed the title fix(python/core,agent): distinguish custom checks/accessibility params from mixins fix(python/core,agent): preserve custom checks and accessibility params Dec 2, 2026
@jacobsimionato
jacobsimionato removed this pull request from stack #4536 December 2, 2026 23:18
@jacobsimionato
jacobsimionato removed this pull request from stack #4552 December 3, 2026 12:03
@jacobsimionato
jacobsimionato force-pushed the macros/2-checks-a11y-params branch from 1038deb to 6dd00f1 Compare December 3, 2026 12:04
@jacobsimionato
jacobsimionato marked this pull request as ready for review December 3, 2026 12:04
@jacobsimionato
jacobsimionato removed this pull request from stack #4563 December 3, 2026 12:06
@jacobsimionato jacobsimionato changed the title fix(python/core,agent): preserve custom checks and accessibility params fix(python/core,agent): treat custom checks/accessibility params as props Dec 3, 2026
…s from mixins

Signed-off-by: Jacob Simionato <jsimionato@google.com>
@jacobsimionato
jacobsimionato force-pushed the macros/2-checks-a11y-params branch from 6dd00f1 to 6da8db3 Compare December 3, 2026 12:24

This branch has not been deployed

No deployments
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.

1 participant