Closed
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00bd65ae79
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
3f8c27f to
216013b
Compare
Contributor
Author
|
closing for #14232 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Note to reviewer: 80% of the diff is generated pydantic types
This PR adds Python/Pydantic code generation for the app-server protocol in
codex-rs/app-server-protocol, using the existing JSON Schema export layer rather than introducing new Rust derive macros. The goal is to make the Rust protocol types the single source of truth while generating Python bindings that stay aligned with the existing TypeScript and JSON schema artifacts.The implementation is intentionally scoped to code generation only. It does not include PyPI packaging or release automation.
What Changed
The protocol exporter now generates Python bindings alongside the existing TypeScript and JSON outputs. A new
codex app-server generate-pythonCLI subcommand was added, and schema fixture regeneration now vendors Python output underschema/python/.The generated Python package preserves the existing protocol split:
codex_app_server_protocol.modelscodex_app_server_protocol.v2.modelsTo improve readability of the generated Python, the exporter now enables title-based naming in
datamodel-code-generator. On top of that, Python-only schema title rewrites are applied for request/notification envelope wrappers so they generate stable names likeItemStartedServerNotificationinstead of collision-driven suffixes such asItemStartedNotification1.The generated base model is also patched to use
populate_by_name=True, which keeps aliased fields such as_metaworking correctly in Pydantic.Design Notes
This PR deliberately keeps Python concerns in the export layer rather than pushing them into Rust protocol derives. That avoids coupling the Rust model definitions to Python packaging or Pydantic-specific behavior and keeps
ts-rsfocused on TypeScript.A generic schema-to-Pydantic generator is still being used under the hood, so this approach is best viewed as a pragmatic codegen path rather than a formal compatibility proof. The exporter now does additional shaping of the Python input schema to preserve version boundaries and improve generated names, which gets us much closer to a usable generated API without introducing a separate custom emitter.
Validation
cargo test -p codex-app-server-protocoljust fix -p codex-app-server-protocoljust fmt