Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ Edit `scripts/post_generate_fixes.py` and add a new function. The script:
- **Activation Keys** (discriminated by identifier type):
- `PropertyIdActivationKey`/`PropertyTagActivationKey`

**Note on Pricing Types:**

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:
- Fixed-rate pricing: `is_fixed=Literal[True]` (CPC, CPCV, CPM Fixed, vCPM Fixed, Flat Rate)
- Auction-based pricing: `is_fixed=Literal[False]` (CPM Auction, vCPM Auction)

**Guidelines for Choosing What to Alias:**

✅ **DO create aliases for:**
Expand Down Expand Up @@ -198,6 +204,54 @@ toolname = "package.__main__:main"
```
This enables `uvx toolname` and `pip install toolname` to work correctly.

## Development Environment & Tools

**Using uv for Package Management**

This project uses `uv` for fast, reliable Python package management. ALWAYS use `uv` commands rather than bare `python` or `pip`:

```bash
# Install dependencies (including dev dependencies)
uv sync --extra dev

# Run scripts with the virtual environment
uv run pytest # Run tests
uv run python scripts/sync_schemas.py # Sync schemas
uv run python scripts/generate_types.py # Generate types

# Activate the virtual environment (if needed for multiple commands)
source .venv/bin/activate
# OR use .venv/bin/python directly
.venv/bin/python scripts/generate_types.py
```

**Schema Update Workflow**

When pulling in updated schemas from upstream:

1. **Sync schemas**: `python3 scripts/sync_schemas.py` (no venv needed, uses stdlib)
- Downloads latest schemas from AdCP GitHub
- Uses content hashing to only update changed schemas
- Updates `schemas/cache/.hashes.json` for tracking

2. **Generate types**: `uv run python scripts/generate_types.py` (requires dev dependencies)
- Requires `datamodel-code-generator` from dev dependencies
- Regenerates all Pydantic models from schemas
- Runs post-generation fixes automatically
- Consolidates exports into `generated.py`

3. **Verify changes**: `uv run pytest`
- All 258+ tests should pass
- Verifies backward compatibility

4. **Review for semantic aliases**: Check if new discriminated unions need aliases
- Look for numbered types (Type1, Type2) in generated files
- Add semantic aliases to `src/adcp/types/aliases.py` if needed
- Update exports in `src/adcp/__init__.py`
- Add tests in `tests/test_type_aliases.py`

**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.

## Python-Specific Patterns

**Optional Dependencies with TYPE_CHECKING**
Expand Down
16 changes: 8 additions & 8 deletions schemas/cache/.hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/media-buy/sync-creatives-response.json": "c06c1296e4ddea110b8dee1b0e40289fea32f52c56ebf123512319008dfcc615",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/media-buy/update-media-buy-request.json": "e907faefc302a58870554f8a1ac84de5529e4806c4da04879f153cade2372747",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/media-buy/update-media-buy-response.json": "b4214297b1f975c8c7f2f18149ffa41e599237d8619b82796a9d7a36bb3c4593",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpc-option.json": "da12700396dc58a3703767a565d5a4d34e49735b11a62700c5f526d035e34f96",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpcv-option.json": "89c7792ff3f269eb5539260deb50e547ca93ce2bf942e6798a77b6a2244aaf49",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-auction-option.json": "c49080b6f07441933b825334929cfd961d4d0865b257072d0c06dcfb59775d72",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-fixed-option.json": "d73c4177ae7455b5214338c8ecb50ea21ba35004cb95d82bf340d6c3d863ab7b",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpp-option.json": "f2e69bd56476841f858546e8ffb0be192e8c654bb6a0a614f1a65f83d2bbf38a",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpv-option.json": "e69547037ecd1d0ec2788b1d9daa17bc934bd682a07c9cebe7a23b2874048663",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpc-option.json": "8db2f8f68bff3e9f5c8c8a0843e307e7b40533883d14bab210c78ff73dd2de63",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpcv-option.json": "df1a5e0101397d0a5fe72f3bbb591794a6c1936d7a21db6ccc4986e13d822bc5",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-auction-option.json": "55af0a07ab1e8ad56963d3fdba3b7ca302a764022e849929748752bb9090850c",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpm-fixed-option.json": "f1906ad4266ba8d4486ea17396be2bf71cbb7ef1eb059b975e39c405161f3469",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpp-option.json": "ecaa85d2d9119146a458940b87cfa2d056a43538c03469bf6a6b45c9588bbd16",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/cpv-option.json": "c4a6f5f7c8e4d513cb133e185f12c93f10942a32516de1b4ce7e50520dc1baf6",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/flat-rate-option.json": "133ebe6814dacb72989d79da945437321baabdf85a3e5b14c2a3b695ee471bee",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-auction-option.json": "a69127626afec1168fd85cde9605618980531874aae221115fd6d918684e3d1e",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-fixed-option.json": "94925835a296eb43e4cea75f10b674902489e5393db538ccb1b1b623877dfaef",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-auction-option.json": "67aa8d6695991dc65f9abc9a126e82a031a5fabc7a611f8d29699c2fd5e38c82",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/pricing-options/vcpm-fixed-option.json": "b560ed8eb0196a793d6d1304a4dea62dc3a1fd06b1fb676b95aa93b68618fce9",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/signals/activate-signal-request.json": "6d60816d28aa28d188b9180c909e089954eca6b3dc734bd315d639ff345a9679",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/signals/activate-signal-response.json": "90e3b5875040b3ba3d7d0f2a1279cf9c7ab5015d0dfa2fd0849cf38f734bd5b3",
"https://raw.githubusercontent.com/adcontextprotocol/adcp/main/static/schemas/v1/signals/get-signals-request.json": "38f802f555aa3df77ebbb0e48f2bd93ae15571a2bbb3982bd2ee7e73a19451d5",
Expand Down
8 changes: 7 additions & 1 deletion schemas/cache/1.0.0/cpc-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": true,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand All @@ -39,7 +44,8 @@
"pricing_option_id",
"pricing_model",
"rate",
"currency"
"currency",
"is_fixed"
],
"title": "CPC Pricing Option",
"type": "object"
Expand Down
8 changes: 7 additions & 1 deletion schemas/cache/1.0.0/cpcv-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": true,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand All @@ -39,7 +44,8 @@
"pricing_option_id",
"pricing_model",
"rate",
"currency"
"currency",
"is_fixed"
],
"title": "CPCV Pricing Option",
"type": "object"
Expand Down
8 changes: 7 additions & 1 deletion schemas/cache/1.0.0/cpm-auction-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": false,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand Down Expand Up @@ -68,7 +73,8 @@
"pricing_option_id",
"pricing_model",
"price_guidance",
"currency"
"currency",
"is_fixed"
],
"title": "CPM Auction Pricing Option",
"type": "object"
Expand Down
8 changes: 7 additions & 1 deletion schemas/cache/1.0.0/cpm-fixed-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": true,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand All @@ -39,7 +44,8 @@
"pricing_option_id",
"pricing_model",
"rate",
"currency"
"currency",
"is_fixed"
],
"title": "CPM Fixed Rate Pricing Option",
"type": "object"
Expand Down
6 changes: 6 additions & 0 deletions schemas/cache/1.0.0/cpp-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": true,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand Down Expand Up @@ -60,6 +65,7 @@
"pricing_model",
"rate",
"currency",
"is_fixed",
"parameters"
],
"title": "CPP Pricing Option",
Expand Down
6 changes: 6 additions & 0 deletions schemas/cache/1.0.0/cpv-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": true,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand Down Expand Up @@ -75,6 +80,7 @@
"pricing_model",
"rate",
"currency",
"is_fixed",
"parameters"
],
"title": "CPV Pricing Option",
Expand Down
8 changes: 7 additions & 1 deletion schemas/cache/1.0.0/vcpm-auction-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": false,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand Down Expand Up @@ -68,7 +73,8 @@
"pricing_option_id",
"pricing_model",
"currency",
"price_guidance"
"price_guidance",
"is_fixed"
],
"title": "vCPM Auction Pricing Option",
"type": "object"
Expand Down
8 changes: 7 additions & 1 deletion schemas/cache/1.0.0/vcpm-fixed-option.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"is_fixed": {
"const": true,
"description": "Whether this is a fixed rate (true) or auction-based (false)",
"type": "boolean"
},
"min_spend_per_package": {
"description": "Minimum spend requirement per package using this pricing option, in the specified currency",
"minimum": 0,
Expand All @@ -39,7 +44,8 @@
"pricing_option_id",
"pricing_model",
"rate",
"currency"
"currency",
"is_fixed"
],
"title": "vCPM Fixed Rate Pricing Option",
"type": "object"
Expand Down
Loading