Repository navigation
feat(python): add CatalogSchemaInspector, macro placement hints, and RendererState.commit - #4471
Conversation
Signed-off-by: Greg Spencer <gspencer@google.com>
nan-yu
left a comment
There was a problem hiding this comment.
Thanks, Greg! This gives extension packages a clean way to inspect catalogs and transform macros without reaching into _shared. The schema_helper move is byte-identical with working shims, the expander refactor keeps the old behavior, and the transactional commit rolls back correctly across batches, delete/re-create and defaultless surfaces. The full a2ui_agent suite, the codegen tests and mypy all pass locally.
A few things I found, inline:
seed_surface_catalogsloses the sidecar surface catalog across turns, so macros on those surfaces stop expanding on turn 2.Icon.nameis classified as a plain enum, which hides that it can be bound.- v0.8 catalogs are accepted but give wrong metadata.
- Only the inspector class is marked experimental, not the types it returns.
🤖 Agent-generated
🧹 Docs Site Preview RemovedThe preview for PR #4471 has been cleaned up because the pull request is closed. |
|
@gspencergoog Heads-up as we start implementing
Happy to coordinate as both stacks move forward. 🤖 Agent-generated |
…dererState.commit, drop on_collision, static core __all__)
…rerState.commit from #4471
@jacobsimionato Sounds good, let's converge on Current state on my side:
Sound good? |
… and restore synthesizer kernel extensions Signed-off-by: Greg Spencer <gspencer@google.com>
nan-yu
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround! I re-checked the earlier comments against 7a5312c. The Icon.name classification, v0.8 rejection, experimental marking and v1.0-only placement hints are all fixed. The new MacroExpander.surface_catalogs covers most of the multi-turn sidecar case, with one rollback gap left (inline).
The PR title and description also still describe on_collision, seed_surface_catalogs and commit_or_validate_messages, which no longer exist. Could they be refreshed to match the CHANGELOG?
🤖 Agent-generated
This sounds good! I'm also trying to see if I can simplify the design a bit for the MessageTransformer stuff e.g. I don't love the concept of binding. Hopefully that will only make the interactions simpler also. |
jacobsimionato
left a comment
There was a problem hiding this comment.
LGTM! All Round 3 feedback is cleanly addressed, the merge with main is clean, and splitting the transformer pipeline into #4543 keeps this PR focused. Before squash-merging, please update the PR title and description so they reflect the final API (a2ui.utils.experimental, RendererState.commit/surface_catalogs, and dropping on_collision and the standalone commit helpers).
🤖 Agent-generated
…ages Move internal schema helper and catalog check modules down into a2ui.utils (with shims kept in a2ui.inference_formats._shared) to keep internal imports acyclic, publish CatalogSchemaInspector and PropertyInfo for typed read-only schema inspection, add allowed_parents and allowed_children kwargs to @macro, and publish MacroSpec, get_macro_spec, build_inference_catalogs, and lower_messages. Signed-off-by: Greg Spencer <gspencer@google.com>
Signed-off-by: Greg Spencer <gspencer@google.com>
Signed-off-by: Greg Spencer <gspencer@google.com>
…cros, and hints
…public extension guide Signed-off-by: Greg Spencer <gspencer@google.com>
…dererState.commit, drop on_collision, static core __all__)
…taging Stage surface_catalogs updates on a local copy inside transform_to_transport so mid-batch failures leave instance state unchanged, and add a transaction() context manager so callers can roll back MacroExpander surface tracking when RendererState.commit rejects a lowered batch.
…degen param Signed-off-by: Greg Spencer <gspencer@google.com>
2dfff42 to
bc5a623
Compare
Summary
Add typed catalog-schema inspection (
a2ui.utils.experimental),@macroplacement hints (allowed_parents,allowed_children), read-onlyMacroExpander.surface_catalogstracking, and atomicRendererState.commit/surface_catalogshelpers toa2ui-agent-sdk. External extension packages can inspect catalog schemas, expand@macrocomponents across turns, and commit multi-turn payloads without importing privatea2ui.inference_formats._sharedmodules.Reviewer Focus
python/a2ui_agent/src/a2ui/utils/catalog_inspector.pyandpython/a2ui_agent/src/a2ui/utils/experimental.py: Read-only schema classification (PropertyKind,PropertyValueType,is_integer, typedenum_values,child_id_key,is_checkable). Marked@experimentaland exported froma2ui.utils.experimentalbecause it will be superseded byCatalogModelina2ui-core.python/a2ui_agent/src/a2ui/transformers/macros/macro.pyandexpander.py:allowed_parents/allowed_childrenmetadata on@macro, read-onlyMacroExpander.surface_catalogstracking across turns, and refactored macro expansion helpers.python/a2ui_agent/src/a2ui/utils/renderer_state.py: AtomicRendererState.commit()andsurface_catalogssnapshot, plus widened_PayloadStatestr | Nonecatalog ID typing.Changes
CatalogSchemaInspector,PropertyInfo,PropertyKind,PropertyValueType, andresolve_default_catalog_idinpython/a2ui_agent/src/a2ui/utils/catalog_inspector.pyand exported them froma2ui.utils.experimental.a2ui.inference_formats._sharedintoa2ui.utils._schema_helperanda2ui.utils._catalogs, keeping compatibility shims at the old paths.allowed_parentsandallowed_childrenparameters to@macroinpython/a2ui_agent/src/a2ui/transformers/macros/macro.py, emittingallowedParentsandallowedChildrenschema metadata and rejecting bare strings.MacroExpander.surface_catalogstracking and split_expand_component_listinto smaller helpers inpython/a2ui_agent/src/a2ui/transformers/macros/expander.py.RendererState.commit()andsurface_catalogsinpython/a2ui_agent/src/a2ui/utils/renderer_state.pyand widened_PayloadStatecatalog IDs tostr | None.python/a2ui_agent/src/a2ui/utils/_experimental.pyso@experimentalpreservesinspect.iscoroutinefunctionfor async callables.__all__topython/a2ui_core/src/a2ui/core/schema/__init__.pyand its generator in.agents/skills/a2ui-generate-pydantic-models/scripts/codegen_pydantic.py.a2ui.experimentaltoFORBIDDEN_PREFIXESinpython/a2ui_agent/tests/test_framework_agnostic.py.python/a2ui_agent/tests/utils/test_catalog_inspector.py,python/a2ui_agent/tests/test_macro_lowering.py, andpython/a2ui_agent/tests/utils/test_experimental.py, and updatedpython/a2ui_agent/CHANGELOG.md.Impact & Risks
a2ui.utils.experimental,RendererState, and@macroadditions are backwards compatible with existing defaults (allowed_parents=(),allowed_children=()).CatalogSchemaInspectoremits an@experimentalUserWarningon construction unlessA2UI_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=1is set.a2ui.core.schema.__all__is additive and preservesa2ui-corebackwards compatibility.Testing
uv run pytest python/a2ui_agent/tests/test_macro_lowering.py python/a2ui_agent/tests/utils/test_experimental.py python/a2ui_agent/tests/test_framework_agnostic.py python/a2ui_agent/tests/utils/test_catalog_inspector.py python/a2ui_core/tests/test_codegen_pydantic.pyuv run mypy python/a2ui_agent/src python/a2ui_core/src/a2ui/core/schema/__init__.pyuv run pyink --check python/a2ui_agent python/a2ui_core/src/a2ui/core/schema/__init__.py