Skip to content

Commit e47ff66

Browse files
bokelleyclaude
andauthored
feat: Add is_fixed discriminator to pricing types (#56)
* feat: Add is_fixed discriminator to pricing types Synced updated AdCP schemas from upstream that add the is_fixed discriminator field to pricing option types. This discriminator distinguishes between fixed-rate and auction-based pricing options. Changes: - Synced 8 updated pricing schema files from upstream - Regenerated all Python types from schemas - Added is_fixed discriminator to pricing option types: - CpcPricingOption (is_fixed=True) - CpcvPricingOption (is_fixed=True) - CpmFixedRatePricingOption (is_fixed=True) - CpmAuctionPricingOption (is_fixed=False) - CppPricingOption (is_fixed varies) - CpvPricingOption (is_fixed varies) - VcpmFixedRatePricingOption (is_fixed=True) - VcpmAuctionPricingOption (is_fixed=False) - FlatRatePricingOption (is_fixed=True) The pricing types already have semantic names, so no new type aliases were needed. All 258 tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: Add development workflow and uv usage to CLAUDE.md Added comprehensive documentation for: - Using uv for package management (uv sync, uv run) - Schema update workflow (sync → generate → test → review) - When to use venv vs system python for different scripts - Pricing type discriminators (is_fixed field) This captures learnings from the pricing discriminator update to help future development work go more smoothly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a277ad2 commit e47ff66

File tree

109 files changed

+1775
-2127
lines changed

Some content is hidden

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

109 files changed

+1775
-2127
lines changed

CLAUDE.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ Edit `scripts/post_generate_fixes.py` and add a new function. The script:
148148
- **Activation Keys** (discriminated by identifier type):
149149
- `PropertyIdActivationKey`/`PropertyTagActivationKey`
150150

151+
**Note on Pricing Types:**
152+
153+
Pricing option types (`CpcPricingOption`, `CpmAuctionPricingOption`, `CpmFixedRatePricingOption`, etc.) already have clear semantic names from the schema generator, so they don't need aliases. These types now include an `is_fixed` discriminator:
154+
- Fixed-rate pricing: `is_fixed=Literal[True]` (CPC, CPCV, CPM Fixed, vCPM Fixed, Flat Rate)
155+
- Auction-based pricing: `is_fixed=Literal[False]` (CPM Auction, vCPM Auction)
156+
151157
**Guidelines for Choosing What to Alias:**
152158

153159
**DO create aliases for:**
@@ -198,6 +204,54 @@ toolname = "package.__main__:main"
198204
```
199205
This enables `uvx toolname` and `pip install toolname` to work correctly.
200206

207+
## Development Environment & Tools
208+
209+
**Using uv for Package Management**
210+
211+
This project uses `uv` for fast, reliable Python package management. ALWAYS use `uv` commands rather than bare `python` or `pip`:
212+
213+
```bash
214+
# Install dependencies (including dev dependencies)
215+
uv sync --extra dev
216+
217+
# Run scripts with the virtual environment
218+
uv run pytest # Run tests
219+
uv run python scripts/sync_schemas.py # Sync schemas
220+
uv run python scripts/generate_types.py # Generate types
221+
222+
# Activate the virtual environment (if needed for multiple commands)
223+
source .venv/bin/activate
224+
# OR use .venv/bin/python directly
225+
.venv/bin/python scripts/generate_types.py
226+
```
227+
228+
**Schema Update Workflow**
229+
230+
When pulling in updated schemas from upstream:
231+
232+
1. **Sync schemas**: `python3 scripts/sync_schemas.py` (no venv needed, uses stdlib)
233+
- Downloads latest schemas from AdCP GitHub
234+
- Uses content hashing to only update changed schemas
235+
- Updates `schemas/cache/.hashes.json` for tracking
236+
237+
2. **Generate types**: `uv run python scripts/generate_types.py` (requires dev dependencies)
238+
- Requires `datamodel-code-generator` from dev dependencies
239+
- Regenerates all Pydantic models from schemas
240+
- Runs post-generation fixes automatically
241+
- Consolidates exports into `generated.py`
242+
243+
3. **Verify changes**: `uv run pytest`
244+
- All 258+ tests should pass
245+
- Verifies backward compatibility
246+
247+
4. **Review for semantic aliases**: Check if new discriminated unions need aliases
248+
- Look for numbered types (Type1, Type2) in generated files
249+
- Add semantic aliases to `src/adcp/types/aliases.py` if needed
250+
- Update exports in `src/adcp/__init__.py`
251+
- Add tests in `tests/test_type_aliases.py`
252+
253+
**Important**: The sync_schemas.py script uses only Python stdlib (urllib, json, pathlib) and doesn't require the virtual environment. The generate_types.py script requires dev dependencies and must use `uv run` or the venv python.
254+
201255
## Python-Specific Patterns
202256

203257
**Optional Dependencies with TYPE_CHECKING**

schemas/cache/.hashes.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@
9090
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/media-buy/sync-creatives-response.json": "c06c1296e4ddea110b8dee1b0e40289fea32f52c56ebf123512319008dfcc615",
9191
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/media-buy/update-media-buy-request.json": "e907faefc302a58870554f8a1ac84de5529e4806c4da04879f153cade2372747",
9292
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/media-buy/update-media-buy-response.json": "b4214297b1f975c8c7f2f18149ffa41e599237d8619b82796a9d7a36bb3c4593",
93-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpc-option.json": "da12700396dc58a3703767a565d5a4d34e49735b11a62700c5f526d035e34f96",
94-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpcv-option.json": "89c7792ff3f269eb5539260deb50e547ca93ce2bf942e6798a77b6a2244aaf49",
95-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-auction-option.json": "c49080b6f07441933b825334929cfd961d4d0865b257072d0c06dcfb59775d72",
96-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-fixed-option.json": "d73c4177ae7455b5214338c8ecb50ea21ba35004cb95d82bf340d6c3d863ab7b",
97-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpp-option.json": "f2e69bd56476841f858546e8ffb0be192e8c654bb6a0a614f1a65f83d2bbf38a",
98-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpv-option.json": "e69547037ecd1d0ec2788b1d9daa17bc934bd682a07c9cebe7a23b2874048663",
93+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpc-option.json": "8db2f8f68bff3e9f5c8c8a0843e307e7b40533883d14bab210c78ff73dd2de63",
94+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpcv-option.json": "df1a5e0101397d0a5fe72f3bbb591794a6c1936d7a21db6ccc4986e13d822bc5",
95+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-auction-option.json": "55af0a07ab1e8ad56963d3fdba3b7ca302a764022e849929748752bb9090850c",
96+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-fixed-option.json": "f1906ad4266ba8d4486ea17396be2bf71cbb7ef1eb059b975e39c405161f3469",
97+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpp-option.json": "ecaa85d2d9119146a458940b87cfa2d056a43538c03469bf6a6b45c9588bbd16",
98+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpv-option.json": "c4a6f5f7c8e4d513cb133e185f12c93f10942a32516de1b4ce7e50520dc1baf6",
9999
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/flat-rate-option.json": "133ebe6814dacb72989d79da945437321baabdf85a3e5b14c2a3b695ee471bee",
100-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-auction-option.json": "a69127626afec1168fd85cde9605618980531874aae221115fd6d918684e3d1e",
101-
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-fixed-option.json": "94925835a296eb43e4cea75f10b674902489e5393db538ccb1b1b623877dfaef",
100+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-auction-option.json": "67aa8d6695991dc65f9abc9a126e82a031a5fabc7a611f8d29699c2fd5e38c82",
101+
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-fixed-option.json": "b560ed8eb0196a793d6d1304a4dea62dc3a1fd06b1fb676b95aa93b68618fce9",
102102
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/signals/activate-signal-request.json": "6d60816d28aa28d188b9180c909e089954eca6b3dc734bd315d639ff345a9679",
103103
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/signals/activate-signal-response.json": "90e3b5875040b3ba3d7d0f2a1279cf9c7ab5015d0dfa2fd0849cf38f734bd5b3",
104104
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/signals/get-signals-request.json": "38f802f555aa3df77ebbb0e48f2bd93ae15571a2bbb3982bd2ee7e73a19451d5",

schemas/cache/1.0.0/cpc-option.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": true,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -39,7 +44,8 @@
3944
"pricing_option_id",
4045
"pricing_model",
4146
"rate",
42-
"currency"
47+
"currency",
48+
"is_fixed"
4349
],
4450
"title": "CPC Pricing Option",
4551
"type": "object"

schemas/cache/1.0.0/cpcv-option.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": true,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -39,7 +44,8 @@
3944
"pricing_option_id",
4045
"pricing_model",
4146
"rate",
42-
"currency"
47+
"currency",
48+
"is_fixed"
4349
],
4450
"title": "CPCV Pricing Option",
4551
"type": "object"

schemas/cache/1.0.0/cpm-auction-option.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": false,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -68,7 +73,8 @@
6873
"pricing_option_id",
6974
"pricing_model",
7075
"price_guidance",
71-
"currency"
76+
"currency",
77+
"is_fixed"
7278
],
7379
"title": "CPM Auction Pricing Option",
7480
"type": "object"

schemas/cache/1.0.0/cpm-fixed-option.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": true,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -39,7 +44,8 @@
3944
"pricing_option_id",
4045
"pricing_model",
4146
"rate",
42-
"currency"
47+
"currency",
48+
"is_fixed"
4349
],
4450
"title": "CPM Fixed Rate Pricing Option",
4551
"type": "object"

schemas/cache/1.0.0/cpp-option.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": true,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -60,6 +65,7 @@
6065
"pricing_model",
6166
"rate",
6267
"currency",
68+
"is_fixed",
6369
"parameters"
6470
],
6571
"title": "CPP Pricing Option",

schemas/cache/1.0.0/cpv-option.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": true,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -75,6 +80,7 @@
7580
"pricing_model",
7681
"rate",
7782
"currency",
83+
"is_fixed",
7884
"parameters"
7985
],
8086
"title": "CPV Pricing Option",

schemas/cache/1.0.0/vcpm-auction-option.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": false,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -68,7 +73,8 @@
6873
"pricing_option_id",
6974
"pricing_model",
7075
"currency",
71-
"price_guidance"
76+
"price_guidance",
77+
"is_fixed"
7278
],
7379
"title": "vCPM Auction Pricing Option",
7480
"type": "object"

schemas/cache/1.0.0/vcpm-fixed-option.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"pattern": "^[A-Z]{3}$",
1616
"type": "string"
1717
},
18+
"is_fixed": {
19+
"const": true,
20+
"description": "Whether this is a fixed rate (true) or auction-based (false)",
21+
"type": "boolean"
22+
},
1823
"min_spend_per_package": {
1924
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
2025
"minimum": 0,
@@ -39,7 +44,8 @@
3944
"pricing_option_id",
4045
"pricing_model",
4146
"rate",
42-
"currency"
47+
"currency",
48+
"is_fixed"
4349
],
4450
"title": "vCPM Fixed Rate Pricing Option",
4551
"type": "object"

0 commit comments

Comments
 (0)