Generate Python SDK types from repository app-server schemas (#44032)

## Why

Keep Python protocol models aligned with the checked-in app-server schemas and preserve reviewed generated artifacts when staging SDK releases.

## What changed

- Generate SDK types from the schema directory configured in `pyproject.toml`, with a `--schema-dir` override, instead of invoking the pinned runtime binary.
- Refresh Python artifacts through `just write-app-server-schema` for standard repository exports. Skip SDK updates for scratch and experimental exports.
- Regenerate protocol models and notification dispatch, deriving the known payload union from the registry so `Notification.payload` covers every registered event.
- Explicitly allowlist convenience API parameters so new protocol fields do not silently expand method signatures. Preserve existing approval path wrappers.
- Stage SDK releases using checked-in generated files without regenerating them.

## Testing

Add coverage for schema selection, refresh gating and failure handling, release artifact preservation, notification payload typing, and approval path compatibility. Update the generation drift test to use repository schemas.

GitOrigin-RevId: fab350b07cf170258b91fbafa8da384aeb2e3bd7
This commit is contained in:
Ahmed Ibrahim
2026-09-09 03:27:31 +00:00
committed by copyberry
parent fe52d795c9
commit 45134c0463
11 changed files with 2437 additions and 602 deletions
@@ -29,7 +29,8 @@ def main() -> None:
args = parser.parse_args()
workspace_root = Path(__file__).resolve().parents[2]
schema_root = args.schema_root or workspace_root / "app-server-protocol" / "schema"
repository_schema_root = workspace_root / "app-server-protocol" / "schema"
schema_root = args.schema_root or repository_schema_root
env = os.environ.copy()
env["CODEX_APP_SERVER_SCHEMA_ROOT"] = str(schema_root)
@@ -54,6 +55,31 @@ def main() -> None:
check=True,
)
# Scratch exports and experimental-only bundles do not update checked-in SDK code.
if (
not args.experimental
and schema_root.resolve() == repository_schema_root.resolve()
):
sdk_root = workspace_root.parent / "sdk" / "python"
subprocess.run(
[
"uv",
"run",
"--project",
str(sdk_root),
"--frozen",
"--only-group",
"test",
"python",
str(sdk_root / "scripts" / "update_sdk_artifacts.py"),
"generate-types",
"--schema-dir",
str(schema_root / "json"),
],
cwd=workspace_root,
check=True,
)
if __name__ == "__main__":
main()