Commit 574ec90
fix: remove stale generated files and improve type generation (#58)
* fix: remove stale generated files and improve type generation infrastructure
This commit addresses the downstream report that pricing options were missing
the is_fixed discriminator field. Investigation revealed the discriminator
already exists in the individual pricing option schema files generated by
datamodel-code-generator.
The root causes were:
1. Stale files (pricing_option.py, brand_manifest_ref.py, index.py, start_timing.py)
persisting from previous generations
2. No mechanism to clean output directory before regeneration
3. Timestamp-only changes creating noisy commits
Changes:
- Remove stale generated files that no longer correspond to current schemas
- Add clean slate generation: delete entire output directory before regenerating
types to prevent stale artifacts from old schema versions
- Add timestamp change detection: restore files where only the generation
timestamp changed to avoid noisy commits
- Update CLAUDE.md with patterns for preventing stale files and noisy commits
All pricing options now correctly have the is_fixed discriminator:
- Fixed-rate: CpmFixedRatePricingOption, VcpmFixedRatePricingOption, etc.
(is_fixed: Annotated[Literal[True], ...])
- Auction: CpmAuctionPricingOption, VcpmAuctionPricingOption
(is_fixed: Annotated[Literal[False], ...])
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: remove imports of deleted stale files and update post-generation fixes
CI was failing because generated.py was importing the stale files we deleted:
- brand_manifest_ref.py
- index.py
- pricing_option.py
- start_timing.py
Changes:
- Remove imports of stale files from src/adcp/types/generated.py
- Remove exports of stale symbols from __all__
- Update fix_brand_manifest_references() to:
- Fix import statement (brand_manifest_ref → brand_manifest)
- Fix class references (BrandManifest → BrandManifest1)
- Update fix_enum_defaults() to check brand_manifest.py instead of deleted brand_manifest_ref.py
Fixes test failures in CI for all Python versions and schema validation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: add stable public API layer to shield users from generated type changes
Problem:
- Users importing from generated_poc directly (e.g., BrandManifest1, BrandManifest2)
creates brittle code that breaks when schemas evolve
- Generated type names with numbered suffixes expose internal implementation details
- No stable API contract prevents breaking changes in minor versions
Solution:
- Created src/adcp/types/stable.py with clean aliases (BrandManifest → BrandManifest1)
- Updated adcp.types to re-export from stable API instead of generated internals
- Added deprecation warning to generated_poc/__init__.py for direct imports
- Documented stable API patterns in CLAUDE.md
Benefits:
- Users see clean names (BrandManifest not BrandManifest1)
- Schema evolution handled via alias updates, not user code changes
- Breaking changes properly versioned per semver
- Deprecation warnings guide users to correct imports
Migration:
✅ from adcp.types import BrandManifest # Clean, stable
❌ from adcp.types.generated_poc.brand_manifest import BrandManifest1 # Breaks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: expose BrandManifestReference union type in stable API
Add BrandManifestReference as a union type (BrandManifest | AnyUrl) to
properly represent the oneOf schema from brand-manifest-ref.json. This
allows users to pass either an inline BrandManifest object or a URL
string pointing to a hosted manifest.
Changes:
- Add BrandManifestReference = BrandManifest1 | AnyUrl in stable.py
- Export BrandManifestReference from adcp.types
- Restore deprecation warning to generated_poc/__init__.py
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: integrate upstream BrandManifest schema consolidation
Synced schemas and regenerated types after upstream fixed brand-manifest.json
to be a single clean type instead of incorrectly using anyOf with different
required fields.
Changes:
- Updated schemas from upstream (brand-manifest, list-creatives-response, promoted-offerings)
- BrandManifest is now single clean type with name (required) and url (optional)
- Removed obsolete post-generation fix for BrandManifest references
- Made consolidate_exports.py aliases conditional to avoid referencing non-existent types
- Updated stable API to reflect clean BrandManifest type
All 258 tests pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: sort imports to satisfy ruff linter
Ruff detected unsorted imports in __init__.py and stable.py. The imports
are now sorted alphabetically which is the expected format.
Changes:
- Sort imports in src/adcp/types/__init__.py
- Sort imports in src/adcp/types/stable.py
All tests pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: export core domain types and pricing options from main package
Improve downstream ergonomics by exporting commonly-used types directly
from the main `adcp` package, eliminating the need to import from
`adcp.types.stable` for typical workflows.
Added exports:
- Core domain types: BrandManifest, Creative, CreativeManifest, MediaBuy, Package
- Status enums: CreativeStatus, MediaBuyStatus, PackageStatus, PricingModel
- All 9 pricing options: CpcPricingOption, CpmFixedRatePricingOption, etc.
This enables "import from adcp and go" for 90% of user workflows:
```python
from adcp import (
BrandManifest,
MediaBuy,
Package,
CpmFixedRatePricingOption,
MediaBuyStatus,
)
# Create media buy
brand = BrandManifest(name="ACME")
pricing = CpmFixedRatePricingOption(...)
```
All 258 tests pass. Addresses code-reviewer feedback for 5-star ergonomics.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: update README with ergonomic type import improvements
Updated Type Safety section to show that commonly-used types are now
exported from the main adcp package, including:
- Core domain types (BrandManifest, Creative, MediaBuy, Package, etc.)
- Status enums (CreativeStatus, MediaBuyStatus, PackageStatus, PricingModel)
- All 9 pricing options with discriminators
- Request/Response types for all operations
Added examples showing type-safe pricing options and status enum usage.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: add API documentation strategy recommendation
Created comprehensive plan for auto-generating API reference documentation
using pdoc3. Key benefits:
- Zero config - works with existing docstrings and type hints
- GitHub Pages ready - single command generates static HTML
- Pydantic aware - extracts Field descriptions from JSON Schema
- Searchable - adds search across all types and methods
- Fast - regenerates in ~1 second
Includes:
- Implementation plan with GitHub Actions workflow
- Cost/benefit analysis
- Example output structure
- Quick start guide for contributors
Recommended over Sphinx (overkill) and MkDocs (narrative-focused).
Setup time ~30min, near-zero maintenance overhead.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: rename generated.py to _generated.py to signal internal API
Consolidate all generated types into a private module that's clearly
internal. This gives SDK internals convenient access while signaling
to users they should use the stable public API instead.
Changes:
- Rename src/adcp/types/generated.py → _generated.py
- Update all imports throughout codebase
- Add clear warning in _generated.py header
- Update consolidate_exports.py to generate _generated.py
- Update stable.py to import from _generated
All 274 tests pass (2 pre-existing failures unrelated to this change).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: update imports and add linter config for _generated.py
- Fix remaining imports in tests and CLI to use _generated
- Add ruff noqa comments to skip E501 and I001 in generated file
- Update consolidate script to format __all__ with proper line breaks
- Update CI workflow to use _generated import
All 274 tests pass (2 pre-existing failures unrelated to this change).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: update CI workflow to use _generated.py path
The CI workflow was still checking the old generated.py path. Update it
to use the new _generated.py path for syntax validation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: address code review issues and update documentation
Critical fixes:
- Fix test_public_api.py: Remove non-existent SimpleADCPClient, fix Format field expectations
- Update documentation: Replace generated.py → _generated.py in CLAUDE.md and README.md
- Update pyproject.toml: Fix black/ruff exclude patterns for _generated.py
All 276 tests now passing!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: update schema drift check to use _generated.py path
The CI workflow schema drift check was still referencing the old
generated.py path. Update to _generated.py.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* chore: regenerate types to sync with CI
Regenerate types to match what CI generates. Only timestamp changed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: improve schema drift check to ignore timestamp-only changes
The CI drift check was failing because it regenerates types during
validation, which updates the timestamp, then complains about the change.
This fix ignores timestamp-only changes (expected during CI regeneration)
while still catching real schema drift.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: move testing patterns to docs/ and create testing guide
Moves testing examples from tests/examples/ (confusing location) to docs/
where users can find them.
Changes:
- Create docs/testing-guide.md with comprehensive testing best practices
- Move RECOMMENDED_TESTING_PATTERNS.py → docs/examples/testing_patterns.py
- Remove tests/examples/ directory
Benefits:
- Clear documentation for SDK users and contributors
- Executable examples demonstrating best practices
- No confusion about whether examples are actual tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* chore: remove temporary testing documentation files
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e3e5066 commit 574ec90
File tree
138 files changed
+2338
-1322
lines changed- .github/workflows
- docs
- examples
- examples
- schemas/cache
- 1.0.0
- scripts
- src/adcp
- testing
- types
- generated_poc
- utils
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
138 files changed
+2338
-1322
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
| 146 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
20 | 46 | | |
21 | 47 | | |
22 | 48 | | |
| |||
27 | 53 | | |
28 | 54 | | |
29 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
30 | 64 | | |
31 | 65 | | |
32 | 66 | | |
| |||
35 | 69 | | |
36 | 70 | | |
37 | 71 | | |
38 | | - | |
| 72 | + | |
39 | 73 | | |
40 | 74 | | |
41 | 75 | | |
| |||
48 | 82 | | |
49 | 83 | | |
50 | 84 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | 85 | | |
55 | | - | |
| 86 | + | |
56 | 87 | | |
57 | | - | |
| 88 | + | |
58 | 89 | | |
59 | 90 | | |
60 | 91 | | |
61 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
62 | 103 | | |
63 | 104 | | |
64 | 105 | | |
| |||
79 | 120 | | |
80 | 121 | | |
81 | 122 | | |
82 | | - | |
| 123 | + | |
83 | 124 | | |
84 | 125 | | |
85 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
214 | 220 | | |
215 | 221 | | |
216 | 222 | | |
| |||
220 | 226 | | |
221 | 227 | | |
222 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
223 | 242 | | |
224 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
225 | 250 | | |
226 | 251 | | |
227 | 252 | | |
| |||
252 | 277 | | |
253 | 278 | | |
254 | 279 | | |
255 | | - | |
| 280 | + | |
256 | 281 | | |
257 | 282 | | |
258 | 283 | | |
| |||
0 commit comments