Skip to content

feat: support capability extensions in codegen and cart-to-checkout conversion - #81

Closed
damaz91 wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
damaz91:feat/capability-extensions-codegen
Closed

feat: support capability extensions in codegen and cart-to-checkout conversion#81
damaz91 wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
damaz91:feat/capability-extensions-codegen

Conversation

@damaz91

@damaz91 damaz91 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds native capability extension support directly into the Python SDK codegen pipeline:

  1. Request Variant Projection: Updates preprocess_schemas.py so that request variants (*_create_request.json, *_update_request.json, *_complete_request.json) are generated across all capability extensions in $defs (such as cart.json, fulfillment.json, discount.json, buyer_consent.json).
  2. Generated Extension Models: Generates typed Pydantic models for capability extensions across shopping operations:
    • cart_create_request.Checkout: adds cart_id and relaxes line_items to optional.
    • fulfillment_create_request.Checkout / fulfillment_update_request.Checkout: adds fulfillment.
    • discount_create_request.Checkout / discount_create_request.Cart / discount_update_request.*: adds discounts.
    • buyer_consent_create_request.Checkout / buyer_consent_update_request.Checkout: adds buyer.
  3. Cart Conversion Validator: Injects @model_validator(mode="after") (_enforce_cart_conversion) into cart_create_request.Checkout in postprocess_models.py to enforce that either cart_id or line_items is provided.
  4. Postprocess AfterValidator Fix: Strips trailing whitespace and commas before inserting AfterValidator(...) into multiline Annotated aliases to prevent syntax errors during formatting.

Category (Required)

  • Core Protocol: Changes to the base communication layer, global context, or breaking refactors. (Requires Technical Council approval)
  • Governance/Contributing: Updates to GOVERNANCE.md, CONTRIBUTING.md, or CODEOWNERS. (Requires Governance Council approval)
  • Capability: New schemas (Discovery, Cart, etc.) or extensions. (Requires Maintainer approval)
  • Documentation: Updates to README, or documentations regarding schema or capabilities. (Requires Maintainer approval)
  • Infrastructure: CI/CD, Linters, or build scripts. (Requires DevOps Maintainer approval)
  • Maintenance: Version bumps, lockfile updates, or minor bug fixes. (Requires DevOps Maintainer approval)
  • SDK: Language-specific SDK updates and releases. (Requires DevOps Maintainer approval)
  • Samples / Conformance: Maintaining samples and the conformance suite. (Requires Maintainer approval)
  • UCP Schema: Changes to the ucp-schema tool (resolver, linter, validator). (Requires Maintainer approval)
  • Community Health (.github): Updates to templates, workflows, or org-level configs. (Requires DevOps Maintainer approval)

Related Issues

N/A

Checklist

  • I have followed the Contributing Guide (including Conventional Commits title requirements and ! for breaking changes).
  • I have updated the documentation (if applicable).
  • My changes pass all local linting and formatting checks.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • (For Core/Capability) I have included/updated the relevant JSON schemas.
  • I have regenerated Python Pydantic models by running generate_models.sh under python_sdk.

ryanmco and others added 2 commits August 19, 2026 14:27
…onversion

- Generate request variants across all capability extension $defs in preprocess_schemas.py
- Inject _enforce_cart_conversion validator in postprocess_models.py to allow cart_id or line_items in cart checkout creation
- Fix trailing comma issue when injecting AfterValidator into multiline Annotated aliases
- Add CapabilityExtensionSemanticTest to test_codegen_pipeline.py
- Regenerate models against UCP version 2026-04-08
@damaz91 damaz91 closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants