Repository navigation
Conversation
gsmith85
added a commit
that referenced
this pull request
Oct 1, 2026
Implement Task 4 (PR 1d) of the ucp-schema codegen pipeline: - Wire Commands::GenerateTypes in src/bin/ucp-schema.rs with --profile, --capability, --extension, --schema-dir (alias --schema-local-base), --schema-remote-base, --output, and --pretty. - Implement CliExitCode for CodegenError and generalize write_json_output to <T: serde::Serialize + ?Sized>. - Add CLI integration tests in tests/generate_types_test.rs covering stdout pretty/compact output, file output, repeatable/comma-delimited flags, and error exit codes. Stacked PR Roadmap: - PR 1a (#81): Identifier qualification, UCP keyword stripping, $ref rewriting - PR 1b (#82): Directional schema slicing and $ref alignment - PR 1c (#83): Capability/extension reachability, composition, and generate_types() library API - PR 1d (this PR): CLI generate-types subcommand - PR 2: Self-contained .well-known/ucp --profile scoping - PR 3: Inline conditional variant hoisting and ordered anyOf union lowering - PR 4: OpenAPI 3.1 REST binding assembly (generate-openapi)
gsmith85
added a commit
that referenced
this pull request
Oct 1, 2026
Implement Task 4 (PR 1d) of the ucp-schema codegen pipeline: - Wire Commands::GenerateTypes in src/bin/ucp-schema.rs with --profile, --capability, --extension, --schema-dir (alias --schema-local-base), --schema-remote-base, --output, and --pretty. - Implement CliExitCode for CodegenError and generalize write_json_output to <T: serde::Serialize + ?Sized>. - Add CLI integration tests in tests/generate_types_test.rs covering stdout pretty/compact output, file output, repeatable/comma-delimited flags, and error exit codes. Stacked PR Roadmap: - PR 1a (#81): Identifier qualification, UCP keyword stripping, $ref rewriting - PR 1b (#82): Directional schema slicing and $ref alignment - PR 1c (#83): Capability/extension reachability, composition, and generate_types() library API - PR 1d (this PR): CLI generate-types subcommand - PR 2: Self-contained .well-known/ucp --profile scoping - PR 3: Inline conditional variant hoisting and ordered anyOf union lowering - PR 4: OpenAPI 3.1 REST binding assembly (generate-openapi)
gsmith85
added a commit
that referenced
this pull request
Oct 1, 2026
Implement Task 4 (PR 1d) of the ucp-schema codegen pipeline: - Wire Commands::GenerateTypes in src/bin/ucp-schema.rs with --profile, --capability, --extension, --schema-dir (alias --schema-local-base), --schema-remote-base, --output, and --pretty. - Implement CliExitCode for CodegenError and generalize write_json_output to <T: serde::Serialize + ?Sized>. - Add CLI integration tests in tests/generate_types_test.rs covering stdout pretty/compact output, file output, repeatable/comma-delimited flags, and error exit codes. Stacked PR Roadmap: - PR 1a (#81): Identifier qualification, UCP keyword stripping, $ref rewriting - PR 1b (#82): Directional schema slicing and $ref alignment - PR 1c (#83): Capability/extension reachability, composition, and generate_types() library API - PR 1d (this PR): CLI generate-types subcommand - PR 2: Self-contained .well-known/ucp --profile scoping - PR 3: Inline conditional variant hoisting and ordered anyOf union lowering - PR 4: OpenAPI 3.1 REST binding assembly (generate-openapi)
gsmith85
force-pushed
the
feat/codegen-slicing
branch
from
October 1, 2026 23:45
b6fcada to
88c578b
Compare
gsmith85
added a commit
that referenced
this pull request
Oct 1, 2026
Implement Task 4 (PR 1d) of the ucp-schema codegen pipeline: - Wire Commands::GenerateTypes in src/bin/ucp-schema.rs with --profile, --capability, --extension, --schema-dir (alias --schema-local-base), --schema-remote-base, --output, and --pretty. - Implement CliExitCode for CodegenError and generalize write_json_output to <T: serde::Serialize + ?Sized>. - Add CLI integration tests in tests/generate_types_test.rs covering stdout pretty/compact output, file output, repeatable/comma-delimited flags, and error exit codes. Stacked PR Roadmap: - PR 1a (#81): Identifier qualification, UCP keyword stripping, $ref rewriting - PR 1b (#82): Directional schema slicing and $ref alignment - PR 1c (#83): Capability/extension reachability, composition, and generate_types() library API - PR 1d (this PR): CLI generate-types subcommand - PR 2: Self-contained .well-known/ucp --profile scoping - PR 3: Inline conditional variant hoisting and ordered anyOf union lowering - PR 4: OpenAPI 3.1 REST binding assembly (generate-openapi)
gsmith85
added a commit
that referenced
this pull request
Oct 2, 2026
Implement Task 4 (PR 1d) of the ucp-schema codegen pipeline: - Wire Commands::GenerateTypes in src/bin/ucp-schema.rs with --profile, --capability, --extension, --schema-dir (alias --schema-local-base), --schema-remote-base, --output, and --pretty. - Implement CliExitCode for CodegenError and generalize write_json_output to <T: serde::Serialize + ?Sized>. - Add CLI integration tests in tests/generate_types_test.rs covering stdout pretty/compact output, file output, repeatable/comma-delimited flags, and error exit codes. Stacked PR Roadmap: - PR 1a (#81): Identifier qualification, UCP keyword stripping, $ref rewriting - PR 1b (#82): Directional schema slicing and $ref alignment - PR 1c (#83): Capability/extension reachability, composition, and generate_types() library API - PR 1d (this PR): CLI generate-types subcommand - PR 2: Self-contained .well-known/ucp --profile scoping - PR 3: Inline conditional variant hoisting and ordered anyOf union lowering - PR 4: OpenAPI 3.1 REST binding assembly (generate-openapi)
gsmith85
added a commit
that referenced
this pull request
Oct 2, 2026
Implement Task 4 (PR 1d) of the ucp-schema codegen pipeline: - Wire Commands::GenerateTypes in src/bin/ucp-schema.rs with --profile, --capability, --extension, --schema-dir (alias --schema-local-base), --schema-remote-base, --output, and --pretty. - Implement CliExitCode for CodegenError and generalize write_json_output to <T: serde::Serialize + ?Sized>. - Add CLI integration tests in tests/generate_types_test.rs covering stdout pretty/compact output, file output, repeatable/comma-delimited flags, and error exit codes. Stacked PR Roadmap: - PR 1a (#81): Identifier qualification, UCP keyword stripping, $ref rewriting - PR 1b (#82): Directional schema slicing and $ref alignment - PR 1c (#83): Capability/extension reachability, composition, and generate_types() library API - PR 1d (this PR): CLI generate-types subcommand - PR 2: Self-contained .well-known/ucp --profile scoping - PR 3: Inline conditional variant hoisting and ordered anyOf union lowering - PR 4: OpenAPI 3.1 REST binding assembly (generate-openapi)
gsmith85
force-pushed
the
feat/codegen-slicing
branch
from
October 2, 2026 16:37
88c578b to
4ed1ea1
Compare
This was referenced Oct 2, 2026
gsmith85
force-pushed
the
feat/codegen-slicing
branch
from
October 7, 2026 06:00
4ed1ea1 to
7b74335
Compare
gsmith85
force-pushed
the
feat/codegen-slicing
branch
from
October 7, 2026 22:04
7b74335 to
9380b3c
Compare
Extend `src/codegen/normalizer.rs` with the directional slicing and reference alignment passes needed to compile UCP-annotated schemas into standard JSON Schema `$defs` entries:
- `normalize_def_schema`: strip UCP keywords, rewrite `$ref` targets to `#/$defs/<PascalName>`, and normalize `additionalProperties: true` onto open object definitions
- `has_directional_annotations` and `schema_supports_complete`: detect `ucp_request`/`ucp_response` annotations and `"complete"` lifecycle operations via `loader::for_each_schema_object`
- `slice_directional_schemas`: resolve `CreateRequest`, `UpdateRequest`, optional `CompleteRequest`, and `Response` ("read") slices via `resolver::resolve`, omitting empty request slices for response-only nested value types
- `align_directional_refs`: rewrite `#/$defs/<Target>` inside directional request slices to `#/$defs/<Target><Suffix>` when present in `known_defs` (falling back to `<Target>UpdateRequest` for `CompleteRequest` slices)
This PR is **Part 2 (PR 1b)** of a stacked series introducing a unified two-layer codegen pipeline to `ucp-schema` so downstream SDKs (`python-sdk`, `js-sdk`, `java-sdk`) can delete their bespoke schema preprocessors and generate idiomatic models directly from UCP schemas:
- **PR 1a (`feat/codegen-normalizer`, #81)**: Naming qualification, UCP keyword stripping, and `$ref` rewriting utilities (`src/codegen/normalizer.rs`).
- **PR 1b (this PR)**: Base definition normalization, directional request/response slicing (`CreateRequest` / `UpdateRequest` / `CompleteRequest` / `Response`), and directional `$ref` alignment.
- **PR 1c**: Capability/extension reachability, extension composition, and the `generate_types()` library API (`src/codegen/mod.rs`).
- **PR 1d**: `ucp-schema generate-types` CLI subcommand (`--schema-dir`, `--capability`, `--extension`, `--output`, `--pretty`).
- **Phase 2 (PR 2)**: `--profile` discovery, remote schema fetching via `ucp.capabilities[].schema` URLs, and self-describing `x-ucp-metadata`.
- **Phase 3 (PRs 3a-3d)**: Polymorphic union reification (open-union `anyOf` with `<Union>Base` fallback) and `ucp-schema generate-openapi` (Layer 2 REST path projection).
gsmith85
force-pushed
the
feat/codegen-slicing
branch
from
October 8, 2026 00:32
9380b3c to
e626830
Compare
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
Implements Task 2 (PR 1b) of the two-layer
ucp-schemacode-generation pipeline: directional schema slicing and reference alignment passes insrc/codegen/normalizer.rs, stacked on #81.Changes
normalize_def_schema: strip UCP keywords, rewrite$reftargets to#/$defs/<PascalName>, synchronize canonical top-leveltitles, and normalizeadditionalProperties: trueonto open object definitions.has_directional_annotationsandschema_supports_complete: detectucp_request/ucp_responseannotations and"complete"lifecycle operations vialoader::for_each_schema_object(skipping instance data insideconst/enum/default/examples).slice_directional_schemas: resolveCreateRequest,UpdateRequest, optionalCompleteRequest, andResponse("read") slices viaresolver::resolve, omitting empty request slices for response-only nested value types.align_directional_refs: rewrite#/$defs/<Target>inside directional request slices to#/$defs/<Target><Suffix>when present inknown_defs(falling back to<Target>UpdateRequestforCompleteRequestslices).Stacked PR Series Roadmap
$refrewriting (src/codegen/normalizer.rs)$refalignment (src/codegen/normalizer.rs)generate_types()library API (src/codegen/{mod,reachability,hoist,compose}.rs)generate-typessubcommand (src/bin/ucp-schema.rs,tests/generate_types_test.rs).well-known/ucp--profilescoping (src/codegen/profile.rs)src/codegen/normalizer.rs,src/codegen/reify.rs)<Union>Base) (src/codegen/reify.rs)src/codegen/reify.rs)generate_models.sh,postprocess_models.py,src/ucp_sdk/models/)generate_models.sh,scripts/generate-zod-from-types.mjs,src/spec_generated.ts)ucp-schema generate-openapi,src/openapi/mod.rs)Test Plan
cargo fmt --checkcargo test --all-targetscargo clippy --all-targets -- -D warnings