Skip to content

Commit 64f1f6a

Browse files
committed
feat(models): update Python SDK schemas for UCP release 2026-08-25
- Update schema preprocessing pipeline for v2026-08-25 response definitions - Regenerate Pydantic models from UCP release/2026-08-25 JSON schemas - Restructure models into common, shopping, and transport verticals - Add Location Search/Lookup, Loyalty, Request Constraints, Permalinks, and Actions models - Move shared primitives and payment extensions to common namespace - Bump package version to 0.5.0 in pyproject.toml and update README.md
1 parent 51bf73c commit 64f1f6a

212 files changed

Lines changed: 5053 additions & 765 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codespellignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ mor
22
tok
33
fpan
44
dpan
5+
requestor

.github/workflows/conventional-commits.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: semantic-pull-request
36-
uses: amannn/action-semantic-pull-request@v6
36+
# zizmor: ignore[unpinned-uses]
37+
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
3738
env:
3839
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3940
with:

.github/workflows/governance.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name: PR Governance
33

44
on:
5+
# zizmor: ignore[dangerous-triggers]
56
pull_request_target:
67
types: [
78
opened,
@@ -13,23 +14,21 @@ on:
1314
assigned,
1415
unassigned
1516
]
16-
workflow_run:
17-
workflows: ["PR Review Listener"]
18-
types: [completed]
17+
pull_request_review:
18+
types: [submitted, dismissed]
1919

2020
jobs:
2121
governance:
2222
name: Reviews
23+
# skip for draft PRs
24+
if: github.event.pull_request.draft == false
2325
permissions:
2426
statuses: write
2527
contents: read
2628
pull-requests: read
2729
# Use the reusable workflow defined in the central governance repository
2830
# zizmor: ignore[ref-confusion]
29-
uses: Universal-Commerce-Protocol/.github/.github/workflows/reusable-governance.yml@main
30-
with:
31-
pr-number: ${{ github.event.pull_request.number }}
32-
commit-sha: ${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha }}
31+
uses: Universal-Commerce-Protocol/.github/.github/workflows/reusable-governance.yml@dc6fd211c5e46503fb56983146d8004ef2e514fb # main
3332
secrets:
3433
# Required: An org-level Read token to read team memberships
3534
ORG_READ_TOKEN: ${{ secrets.ORG_READ_TOKEN }}

.github/workflows/linter.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@ on:
2020
pull_request:
2121
branches: [main]
2222

23+
permissions:
24+
contents: read
25+
2326
jobs:
2427
pre-commit:
2528
runs-on: ubuntu-latest
2629
steps:
27-
- uses: actions/checkout@v5
28-
- uses: actions/setup-python@v6
30+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
31+
with:
32+
persist-credentials: false
33+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
2934
with:
3035
python-version: '3.x'
31-
- uses: pre-commit/action@v3.0.1
36+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
3237
env:
3338
# workaround for pre-commit/action not being updated to node24
3439
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

.github/workflows/pr-review-listener.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on:
33
pull_request_review:
44
types: [submitted, dismissed]
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
signal:
811
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@ jobs:
1818
contents: read
1919
steps:
2020
- name: Checkout code
21-
uses: actions/checkout@v5
21+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
22+
with:
23+
persist-credentials: false
2224

2325
# Installs uv (and manages Python automatically)
2426
- name: Install uv
25-
uses: astral-sh/setup-uv@v8.2.0
27+
# zizmor: ignore[cache-poisoning]
28+
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
2629
with:
2730
enable-cache: true
2831

29-
# 'uv build' automatically creates the sdist and wheel inz 'dist/'
32+
# 'uv build' automatically creates the sdist and wheel in 'dist/'
3033
- name: Build package
3134
run: uv build
3235

3336
- name: Publish to PyPI
34-
uses: pypa/gh-action-pypi-publish@release/v1
37+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128480b75e93ec # release/v1

.github/workflows/tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
steps:
3535
- name: Checkout repository
3636
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
37+
with:
38+
persist-credentials: false
3739
- name: Set up Python
3840
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
3941
with:
@@ -49,14 +51,16 @@ jobs:
4951
steps:
5052
- name: Checkout repository
5153
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
54+
with:
55+
persist-credentials: false
5256
- name: Install uv
5357
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
5458
with:
5559
enable-cache: true
5660
- name: Regenerate models from the pinned spec version
57-
# SDK 0.4.x targets UCP 2026-04-08 (see the README compatibility
61+
# SDK 0.5.x targets UCP 2026-08-25 (see the README compatibility
5862
# table). Bump this pin together with the SDK version line.
59-
run: ./generate_models.sh 2026-04-08
63+
run: ./generate_models.sh 2026-08-25
6064
- name: Normalize file endings (as pre-commit's end-of-file-fixer does)
6165
run: |
6266
python3 - <<'PY'
@@ -72,7 +76,7 @@ jobs:
7276
run: |
7377
git add -A -- src/ucp_sdk/models/schemas
7478
if ! git diff --cached --quiet -- src/ucp_sdk/models/schemas; then
75-
echo "::error::Committed models differ from regeneration against the pinned UCP spec. Either the generation pipeline is broken, or the models were edited without regenerating. Run ./generate_models.sh 2026-04-08 and commit the result."
79+
echo "::error::Committed models differ from regeneration against the pinned UCP spec. Either the generation pipeline is broken, or the models were edited without regenerating. Run ./generate_models.sh 2026-08-25 and commit the result."
7680
git --no-pager diff --cached --stat -- src/ucp_sdk/models/schemas
7781
git --no-pager diff --cached -- src/ucp_sdk/models/schemas
7882
exit 1

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ node_modules/
33
__pycache__/
44
.venv/
55
*.py[cod]
6+
ucp/
7+
uv.lock

README.md

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@ This repository contains the Python SDK for the
3535
models for UCP schemas, making it easy to build UCP-compliant applications in
3636
Python.
3737

38-
### UCP Version Compatibility
39-
40-
Each version of the Python SDK is generated against a specific version of the
41-
UCP schema:
42-
43-
| SDK Version | UCP Schema Version |
44-
| ----------------- | ------------------ |
45-
| **`0.4.x`** | **`2026-04-08`** |
46-
| `0.3.x` | `2026-01-23` |
47-
| `0.2.x` / `0.1.x` | `2026-01-11` |
48-
4938
## Installation
5039

5140
To use this SDK in your own project, install it from PyPI:
@@ -71,20 +60,22 @@ from ucp_sdk.models.schemas.shopping.checkout import Checkout
7160
checkout = Checkout.model_validate(checkout_data)
7261

7362
# Access typed fields
74-
print(checkout.status) # "incomplete" | "ready_for_complete" | ...
75-
print(checkout.currency) # ISO 4217 currency code
63+
print(checkout.status) # "incomplete" | "ready_for_complete" | ...
64+
print(checkout.currency) # ISO 4217 currency code
7665
for item in checkout.line_items:
7766
print(f"{item.item.title}: {item.quantity}")
7867
```
7968

8069
### Available model packages
8170

82-
| Package | Description |
83-
| --------------------------------------- | --------------------------------------------------- |
84-
| `ucp_sdk.models.schemas.shopping` | Checkout, cart, catalog, order, payment models |
85-
| `ucp_sdk.models.schemas.shopping.types` | Line items, totals, buyer, fulfillment, signals |
86-
| `ucp_sdk.models.schemas.transports` | REST, MCP, and embedded protocol bindings |
87-
| `ucp_sdk.models.schemas` | Service definitions, capabilities, payment handlers |
71+
| Package | Description |
72+
| --------------------------------------- | ----------------------------------------------------------------- |
73+
| `ucp_sdk.models.schemas.common` | Location search/lookup, identity linking, loyalty, payment terms |
74+
| `ucp_sdk.models.schemas.common.types` | Shared primitives (amounts, prices, totals, postal address, etc.) |
75+
| `ucp_sdk.models.schemas.shopping` | Checkout, cart, catalog, order, buyer consent, permalink models |
76+
| `ucp_sdk.models.schemas.shopping.types` | Line items, adjustments, fulfillments, destinations, attribution |
77+
| `ucp_sdk.models.schemas.transports` | REST, MCP, and embedded protocol bindings |
78+
| `ucp_sdk.models.schemas` | Service definitions, capabilities, profile, payment handlers |
8879

8980
### Validation
9081

@@ -133,21 +124,13 @@ uv sync
133124
```
134125

135126
Where `<version>` is the version of the UCP specification to use (for example,
136-
"2026-04-08").
127+
"2026-08-25").
137128

138129
If no version is specified, the `main` branch of the
139130
[UCP repo](https://github.com/Universal-Commerce-Protocol/ucp) will be used.
140131

141132
The generated code is automatically formatted using `ruff`.
142133

143-
### Running Tests
144-
145-
Run the schema preprocessing test suite with:
146-
147-
```bash
148-
uv run python -m unittest discover -s tests -p "test_*.py"
149-
```
150-
151134
## Contributing
152135

153136
We welcome community contributions. See our

generate_models.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ if ! command -v git &> /dev/null; then
2727
exit 1
2828
fi
2929

30-
# Check if uv is installed before cloning or modifying generated files
31-
if ! command -v uv &> /dev/null; then
32-
echo "Error: uv not found."
33-
echo "Please install uv: curl -LsSf https://astral.sh/uv/install.sh | sh"
34-
exit 1
35-
fi
36-
3730
# UCP Version to use (if provided, use release/$1 branch; otherwise, use main)
3831
if [ -z "$1" ]; then
3932
BRANCH="main"
@@ -46,6 +39,7 @@ fi
4639
# Ensure ucp directory is clean before cloning
4740
rm -rf ucp
4841
git clone -b "$BRANCH" --depth 1 https://github.com/Universal-Commerce-Protocol/ucp ucp
42+
rm -rf ucp/.git
4943

5044
# Output directory
5145
OUTPUT_DIR="src/ucp_sdk/models/schemas"
@@ -101,9 +95,19 @@ uv run \
10195
echo "Post-processing generated models (constraints the generator ignores)..."
10296
uv run python postprocess_models.py || exit 1
10397

98+
# Normalize file endings (as pre-commit's end-of-file-fixer does)
99+
python3 - <<'PY'
100+
from pathlib import Path
101+
102+
for path in Path("src/ucp_sdk/models/schemas").rglob("*.py"):
103+
text = path.read_text(encoding="utf-8")
104+
fixed = text.rstrip("\n") + "\n" if text.strip() else ""
105+
if fixed != text:
106+
path.write_text(fixed, encoding="utf-8")
107+
PY
108+
104109
echo "Formatting generated models..."
105110
uv run ruff format
106111
uv run ruff check --fix "$OUTPUT_DIR"
107112

108-
109113
echo "Done. Models generated in $OUTPUT_DIR"

0 commit comments

Comments
 (0)