Repository navigation
feat(release): add api_surface.py and a2ui-release-notes Generator/Critic skill - #4524
gspencergoog wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new automated pipeline and tooling for generating A2UI release notes, including a detailed workflow guide, a static public API surface differ script supporting TypeScript and Python, and a comprehensive test suite. The review feedback is highly constructive, pointing out critical areas for improvement in the API surface differ script. Specifically, the reviewer identified a potential negative slicing bug in relative Python import resolution, suggested printing captured yarn build errors to improve debuggability, recommended filtering out test files from the approximate public files list on build failures, and advised expanding test directory exclusions to cover singular 'test/' paths. Addressing these issues will significantly enhance the robustness and maintainability of the release notes automation tool.
ditman
left a comment
There was a problem hiding this comment.
🤖 Left inline comments on SKILL.md, the two workflows, and api_surface.py (including reproducer tests for the parser and security bugs).
Before investing more in fixing individual edge cases in the 2,245-line regex/AST differ in api_surface.py, it's worth considering off-the-shelf options for extracting APIs without adding flow complexity:
- Python:
griffe(uvx griffe check <pkg> -a <since> -b <until>) reads both git refs natively viaload_git—no extra before/after checkout needed—and handles__all__,@property/setters,@overload,Enum,async,posonly, and breaking-change classification out of the box with zero repo deps. - TypeScript:
api_surface.pyalready builds/extracts before-and-after.d.tsdirectories (npm tarball or worktreeyarn build), andtypescriptis already in the Yarn workspace—so swapping the ~700-line regexparse_dts_treefor a small Node script using the TS Compiler API (ts.createProgram+checker.getExportsOfModule) or@microsoft/api-extractordrops into the exact same before/after flow with zero regex fragility.
|
|
||
| # Generating A2UI release notes | ||
|
|
||
| This skill prepares release pull requests for any of the 19 published packages |
There was a problem hiding this comment.
No need to mention that there are "19" published packages... "for the packages registered in ./github/release_packages.json" should be enough
| 2. Run a Generator pass to produce risk-ordered bullets and a SemVer bump | ||
| recommendation. | ||
| 3. Run the deterministic gate (`release_notes.py check-notes`) for Gates 1 and 3. | ||
| 4. Run a fresh-context Critic pass to audit semantic Gates 2, 4, and 5. |
|
|
||
| Store intermediate JSON artifacts in a temporary directory outside the | ||
| repository (for example via `mktemp -d`) so scratch files are never committed to | ||
| the release branch. |
There was a problem hiding this comment.
If this adds complexity/brittleness, we can just .gitignore a known location within the repo.
|
|
||
| ```bash | ||
| git checkout -b release/<scope>-<date> "${REMOTE}/main" | ||
| WORK_DIR=$(mktemp -d) |
There was a problem hiding this comment.
Are these commands being run verbatim, or is this just an example for the model? Just to know how deeply these commands need to be reviewed (now and later)
| | Python (`python`) | `a2ui-core` -> `a2ui-agent-sdk` -> `a2ui-a2a` -> `a2ui-adk`, `a2ui-agent-experimental` | | ||
| | Dart (`pub`) | `dart-a2ui_core` -> `dart-a2ui_agent`, `dart-a2ui_flutter`, `a2ui_cli` | | ||
| | TypeScript (`npm`) | `web_core` -> `sandbox`, `markdown-it`, `agent`, `catalog-vegachart` -> `catalog-mcp`, `lit`, `react`, `angular` | | ||
| | Swift (`swiftpm`) | `swift` | |
There was a problem hiding this comment.
It'd be much better to have a deterministic tool that generates these lists, rather than maintaining this list here. (Actually don't we already have an implementation of this? we reviewed it in python)
| TS_FUNC_RE = re.compile( | ||
| r"^(?:export\s+)?(?:default\s+)?(?:declare\s+)?(?:async\s+)?function\s+" | ||
| r"(?P<name>[A-Za-z_$][\w$]*)\s*(?P<generics><[^>]*>)?\s*\(" | ||
| ) | ||
| TS_TYPE_RE = re.compile( | ||
| r"^(?:export\s+)?(?:declare\s+)?type\s+(?P<name>[A-Za-z_$][\w$]*)" | ||
| r"(?:\s*<[^>]*>)?\s*=\s*(?P<rhs>.+)$", | ||
| re.DOTALL, | ||
| ) |
There was a problem hiding this comment.
🤖 Bug (hits live @a2ui/web_core): TS_FUNC_RE, TS_TYPE_RE, and TS_MEMBER_METHOD_RE match generic parameter lists with <[^>]*>, which fails on nested generics (<C extends CatalogInterface<string>>). Running parse_dts_tree on @a2ui/web_core silently drops real public exports like linkCatalogs and AgentFunctionHandler. (Related: TS_BLOCK_RE at L113 stops at { inside <T extends { id: string }>.)
Reproducer test (currently fails—linkCatalogs is missing):
def test_ts_nested_generics_parsed(self):
dts = "export declare function linkCatalogs<C extends CatalogInterface<string>>(c: C): C;\n"
self.assertIn("linkCatalogs", apis.parse_dts_content(dts, "src/index.d.ts"))| decs = _decorator_names(stmt) | ||
| full_name = f"{cls_name}.{stmt.name}" | ||
| if "property" in decs: | ||
| ret = _py_ann(stmt.returns) | ||
| sig = f"property {full_name}: {ret}" if ret else f"property {full_name}" | ||
| return SymbolInfo( | ||
| name=full_name, | ||
| kind="property", | ||
| signature=sig, | ||
| file=rel_path, | ||
| value_type=ret, |
There was a problem hiding this comment.
🤖 Bug (hits live a2ui-core): _py_class_member_from_func only checks "property" in decs, so @foo.setter (decs == {"setter"}) is parsed as kind="method" and overwrites the @property entry in _record_py_export. On live a2ui-core, ComponentModel.properties is misclassified as a method (def ComponentModel.properties(new_props: ...) -> None).
Reproducer test (currently fails with kind == "method"):
def test_py_property_with_setter_stays_property(self):
src = "class C:\n @property\n def x(self) -> int: return 1\n @x.setter\n def x(self, v: int) -> None: pass\n"
mod = apis._parse_py_module(src, "python/a2ui_core/src/p.py", "python/a2ui_core")
surface = {}
apis._record_py_export(surface, set(), {mod.module_name: mod}, mod, "C", "")
self.assertEqual(surface["C.x"].kind, "property")| def _extract_py_class_members( | ||
| class_node: ast.ClassDef, rel_path: str | ||
| ) -> list[SymbolInfo]: | ||
| members: list[SymbolInfo] = [] | ||
| for stmt in class_node.body: | ||
| member: SymbolInfo | None = None | ||
| if isinstance(stmt, (ast.FunctionDef, ast.AsyncFunctionDef)): | ||
| member = _py_class_member_from_func(class_node.name, stmt, rel_path) | ||
| elif isinstance(stmt, ast.AnnAssign): | ||
| member = _py_class_member_from_ann(class_node.name, stmt, rel_path) | ||
| if member is not None: |
There was a problem hiding this comment.
🤖 Bug (hits live a2ui-core): _extract_py_class_members ignores ast.Assign, so Enum members and unannotated class constants are completely invisible. On live a2ui-core, both RpcErrorCode and A2uiProtocolVersion extract 0 members, so removing or renaming enum values produces an empty diff.
Reproducer test (currently fails—removing ERR yields removed: []):
def test_py_enum_member_removal_detected(self):
before = apis._parse_py_module("import enum\nclass S(str, enum.Enum):\n OK = 'ok'\n ERR = 'err'\n", "p/src/s.py", "p")
after = apis._parse_py_module("import enum\nclass S(str, enum.Enum):\n OK = 'ok'\n", "p/src/s.py", "p")
s_before, s_after = {}, {}
apis._record_py_export(s_before, set(), {before.module_name: before}, before, "S", "")
apis._record_py_export(s_after, set(), {after.module_name: after}, after, "S", "")
self.assertIn("S.ERR", s_before)
self.assertNotIn("S.ERR", s_after)| def _classify_callable_change( | ||
| before: SymbolInfo, after: SymbolInfo, *, check_param_names: bool | ||
| ) -> bool | str: | ||
| if before.params is None or after.params is None: | ||
| return "unknown" | ||
| old_pos, old_kw, old_var, old_kwarg = _split_param_kinds(before.params) | ||
| new_pos, new_kw, new_var, new_kwarg = _split_param_kinds(after.params) | ||
| verdict = _compare_positional_params( | ||
| old_pos, new_pos, old_var, new_var, check_names=check_param_names | ||
| ) | ||
| verdict = _combine_breaking( |
There was a problem hiding this comment.
🤖 Bug: _classify_callable_change / _compare_single_param miss two Python breaking changes:
SymbolInfodoesn't trackis_async, sodef fetch(url: str) -> str→async def fetch(url: str) -> stris classified asbreaking: False._compare_single_param(L478) never checksold.kind == "positional" and new.kind == "posonly", sodef connect(host: str)→def connect(host: str, /)(breaks keyword callers) is also classified asbreaking: False.
Reproducer test (both currently return breaking: False):
def test_py_async_and_posonly_are_breaking(self):
b1 = apis._parse_py_module("def fetch(url: str) -> str: ...\n", "p/src/m.py", "p").defs["fetch"]
a1 = apis._parse_py_module("async def fetch(url: str) -> str: ...\n", "p/src/m.py", "p").defs["fetch"]
self.assertIs(apis._classify_callable_change(b1, a1, check_param_names=True), True)
b2 = apis._parse_py_module("def connect(host: str) -> None: ...\n", "p/src/m.py", "p").defs["connect"]
a2 = apis._parse_py_module("def connect(host: str, /) -> None: ...\n", "p/src/m.py", "p").defs["connect"]
self.assertIs(apis._classify_callable_change(b2, a2, check_param_names=True), True)| def _apply_ts_export_list( | ||
| stmt: str, | ||
| locals_by_name: dict[str, list[SymbolInfo]], | ||
| exported: dict[str, SymbolInfo], | ||
| ) -> None: | ||
| match = TS_EXPORT_LIST_RE.match(stmt) | ||
| if not match: | ||
| return | ||
| for raw_item in match.group("items").split(","): | ||
| item = _normalize_ws(raw_item).removeprefix("type ").strip() | ||
| if not item: |
There was a problem hiding this comment.
🤖 Bug: _apply_ts_export_list only looks up re-exported names in the current file's locals_by_name (ignoring from './foo.js'), while parse_dts_tree parses every .d.ts file in dist/ regardless of entrypoints. As a result, export { Foo as PublicFoo } from './foo.js' never emits PublicFoo, and removing a re-export from index.d.ts while foo.d.ts remains in dist/ reports removed: [].
(Also in this area: _merge_ts_symbol at L1463 drops the set half of a get/set pair and is order-dependent for 3+ overloads; _parse_ts_method at L1314 ignores the ? optional marker on interface methods.)
Reproducer test (currently fails—'PublicFoo' is not emitted):
def test_ts_barrel_reexport_alias_emitted(self):
surface = apis.parse_dts_tree({
"dist/foo.d.ts": "export declare class Foo { run(): void; }\n",
"dist/index.d.ts": "export { Foo as PublicFoo } from './foo.js';\n",
})
self.assertIn("PublicFoo", surface)
Summary
Adds
.github/scripts/api_surface.py, advisory PR workflows (.github/workflows/api_surface.ymland.github/workflows/api_surface_comment.yml), and the.agents/skills/a2ui-release-notes/SKILL.mdskill for generating and auditingCHANGELOG.mdentries across all 18 packages in.github/release_packages.json(#4215). Combines static public API diffs (TypeScript.d.tsbundles via npm tarball or worktree build, Python AST__all__, and degraded Dart/Swift file scanning) withrelease_notes.py check-notesandwrite-sectionvalidation.Reviewer Focus
.github/scripts/api_surface.py: check public API extraction and diffing for npm (tarball fetch with host/size validation and isolated worktree build fallback), Python AST, and Dart/Swift degraded modes, plus PR merge-base mode..github/workflows/api_surface.ymland.github/workflows/api_surface_comment.yml: check untrustedpull_request_targetartifact separation (read-only PR job uploads JSON/Markdown artifact; privileged workflow posts/updates sticky PR comment)..agents/skills/a2ui-release-notes/SKILL.md: verify Generator/Critic release-note drafting workflow, 18-package coverage including@a2ui/sandbox, and ecosystem release dependency order.Changes
.github/scripts/api_surface.py(Python stdlib only) with per-package--since..--untilAPI surface diffing and--prmerge-base detection..github/scripts/tests/test_api_surface.pycovering TypeScript.d.tsextraction, npm tarball/worktree fallback, Python AST diffs, Dart/Swift degraded modes, and PR CLI rendering..github/workflows/api_surface.ymland.github/workflows/api_surface_comment.ymlto compute advisory API-surface diffs on pull requests and update a sticky summary comment safely across forks..agents/skills/a2ui-release-notes/SKILL.mdguiding agents throughrelease_notes.py context,api_surface.py, deterministiccheck-notesvalidation, andwrite-sectionacross all 18 packages.Testing
GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 python3 -m unittest discover -s .github/scripts/tests-> 224 tests passed (including 20test_api_surface.pytests).uvx pyink==25.12.0 --check .github/scripts/api_surface.py .github/scripts/tests/test_api_surface.py-> passed.prettier --checkon.github/workflows/api_surface.yml,.github/workflows/api_surface_comment.yml, and.agents/skills/a2ui-release-notes/SKILL.md-> passed.python3 scripts/fix_licenses.py --check-> passed.lint_skill.py .agents/skills/a2ui-release-notes-> 0 errors, 0 warnings.uvx zizmor .github/workflows/api_surface.yml .github/workflows/api_surface_comment.yml-> 0 findings.cognitive_complexity.py .github/scripts/api_surface.py-> max complexity 15 (0 functions over 15).