Skip to content

Commit d61ca33

Browse files
bokelleyclaude
andauthored
feat: integrate AdCP schema improvements (PR #222 + #223) (#73)
* feat: resolve schema collisions with AssetContentType, FormatCategory, and unified Package Implements changes from upstream AdCP PR #222 and PR #223: **New Types (PR #222)** - AssetContentType: Consolidated enum for asset content types (13 values) - FormatCategory: Semantic enum for format categories (7 values) **Unified Package (PR #223)** - create_media_buy and update_media_buy now return full Package objects - Removed CreatedPackageReference (deprecated) - Better API consistency and developer experience **Breaking Changes** - Removed CreatedPackageReference: use Package directly - Removed AffectedPackage: removed from upstream schemas **Backward Compatibility** - AssetType maintained as deprecated alias to AssetContentType Test results: 283/295 passing (12 failures for removed CreatedPackageReference - expected) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * test: remove obsolete CreatedPackageReference tests Removed 5 test functions that tested CreatedPackageReference since this type was removed in AdCP PR #223. The PR unified Package responses so that both create_media_buy and update_media_buy now return full Package objects instead of minimal references. Removed tests: - test_package_type_aliases_imports - test_package_type_aliases_point_to_correct_modules - test_package_type_aliases_have_correct_fields - test_package_type_aliases_in_exports - test_package_aliases_can_instantiate All 290 tests now pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: consolidate schema analysis into changelog, remove temp docs Removed temporary documentation files (SCHEMA_COLLISION_PROPOSAL.md, UPSTREAM_SCHEMA_RECOMMENDATIONS.md) that were used during analysis. Enhanced CHANGELOG_ENTRY.md to include: - Detailed description of upstream schema improvements (PR #222 + #223) - Complete list of new types with all enum values - Expanded migration guide with more examples - Upstream recommendations identified during integration The key findings (orphaned asset-type.json, enum organization suggestions, discriminator standardization opportunities) are now captured in the changelog for future reference. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: remove orphaned asset-type.json and update schemas Upstream PR #222 removed the orphaned asset-type.json schema file. Our local cache had stale copies that were no longer referenced upstream. Changes: - Removed stale asset-type.json from schemas/cache/1.0.0/ - Removed asset_type.py generated file (no longer has upstream schema) - Removed orphaned type exports: AssetTypeSchema, ContentLength, Dimensions, Duration, FileSize, Quality, Requirements - Added deprecation alias: AssetType = AssetContentType - Synced 6 updated schemas (deployment, destination, activate-signal, get-signals) The sync discovered asset-type.json was 404 upstream - it was removed in PR #222 as part of the enum consolidation work. Tests: 288/290 passing (2 failures in signals tests due to schema API changes from destinations → deployments in upstream) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: update changelog to reflect upstream already removed asset-type.json The orphaned asset-type.json was already removed by the AdCP team in PR #222. Updated changelog to acknowledge this was properly handled upstream. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: automatically remove orphaned schemas during sync Added automatic cleanup of schema files that no longer exist upstream. This prevents stale cached schemas from causing issues when upstream removes or renames schema files. Changes: - Scan for JSON files in cache that aren't in the upstream schema list - Remove orphaned files and their empty parent directories - Report removed count in sync summary - Updated script documentation to explain new feature Example output: Cleaning up orphaned schemas: ✗ asset-type.json (removed - no longer in upstream) ✗ core/asset-type.json (removed - no longer in upstream) This would have automatically caught the stale asset-type.json files that were orphaned after PR #222. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: update signals API tests for destinations → deployments change Upstream schema updates changed the signals API from using 'destinations' to 'deployments'. Updated test fixtures to match new API structure. Changes: - GetSignalsRequest.deliver_to.destinations → deployments - ActivateSignalRequest.destinations → deployments Tests now passing: 290/290 (100%) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: remove temporary changelog entry file Release Please will automatically generate changelog from commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: resolve linter errors in stable.py and __init__.py - Fix import sorting per ruff I001 rules - Fix line length by moving comment above import - Remove orphaned 'Requirements' from __all__ (type was removed with asset-type.json) All linter checks now passing. 🤖 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 f9432a3 commit d61ca33

23 files changed

+120
-542
lines changed

schemas/cache/1.0.0/asset-type.json

Lines changed: 0 additions & 168 deletions
This file was deleted.

schemas/cache/1.0.0/core/asset-type.json

Lines changed: 0 additions & 91 deletions
This file was deleted.

scripts/sync_schemas.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
not just those listed in index.json. This ensures we get all schemas including
77
asset types (vast-asset.json, daast-asset.json) with discriminators from PR #189.
88
9+
Features:
10+
- Content-based change detection (only updates files when content changes)
11+
- Automatic cleanup of orphaned schemas (files removed upstream)
12+
- Preserves directory structure from upstream
13+
- Symlink to latest version for convenience
14+
915
Usage:
1016
python scripts/sync_schemas.py # Normal sync (uses content hashing)
1117
python scripts/sync_schemas.py --force # Force re-download all schemas
@@ -207,6 +213,7 @@ def main():
207213
print("Downloading schemas:")
208214
updated_count = 0
209215
cached_count = 0
216+
removed_count = 0
210217

211218
for url in schema_urls:
212219
was_updated, new_hash = download_schema_file(url, version, hash_cache, force=args.force)
@@ -219,6 +226,37 @@ def main():
219226
if new_hash:
220227
updated_hashes[url] = new_hash
221228

229+
# Clean up orphaned schemas (files that exist locally but not upstream)
230+
version_dir = CACHE_DIR / version
231+
if version_dir.exists():
232+
# Get list of expected filenames from URLs
233+
expected_files = {url.split("/")[-1] for url in schema_urls}
234+
# Also allow the hash cache file
235+
expected_files.add(".hashes.json")
236+
237+
# Find orphaned JSON files
238+
orphaned_files = []
239+
for json_file in version_dir.rglob("*.json"):
240+
if json_file.name not in expected_files and json_file.name != ".hashes.json":
241+
orphaned_files.append(json_file)
242+
243+
# Remove orphaned files
244+
if orphaned_files:
245+
print("\nCleaning up orphaned schemas:")
246+
for orphan in orphaned_files:
247+
rel_path = orphan.relative_to(version_dir)
248+
print(f" ✗ {rel_path} (removed - no longer in upstream)")
249+
orphan.unlink()
250+
removed_count += 1
251+
252+
# Remove empty directories
253+
parent = orphan.parent
254+
try:
255+
if parent != version_dir and not any(parent.iterdir()):
256+
parent.rmdir()
257+
except OSError:
258+
pass
259+
222260
# Save updated hash cache
223261
if updated_hashes:
224262
save_hash_cache(updated_hashes)
@@ -237,6 +275,8 @@ def main():
237275
print(f" Location: {version_dir}")
238276
print(f" Updated: {updated_count}")
239277
print(f" Cached: {cached_count}")
278+
if removed_count > 0:
279+
print(f" Removed: {removed_count} (orphaned)")
240280

241281
except Exception as e:
242282
print(f"\n✗ Error syncing schemas: {e}", file=sys.stderr)

src/adcp/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108
# Audience & Targeting
109109
ActivateSignalRequest,
110110
ActivateSignalResponse,
111+
# Type enums from PR #222
112+
AssetContentType,
111113
# Core domain types
112114
BrandManifest,
113115
# Creative Operations
@@ -131,6 +133,7 @@
131133
Error,
132134
FlatRatePricingOption,
133135
Format,
136+
FormatCategory,
134137
FormatId,
135138
GetMediaBuyDeliveryRequest,
136139
GetMediaBuyDeliveryResponse,
@@ -218,6 +221,9 @@
218221
"Error",
219222
"Format",
220223
"FormatId",
224+
# New type enums from PR #222
225+
"AssetContentType",
226+
"FormatCategory",
221227
"Product",
222228
"Property",
223229
# Core domain types (from stable API)

0 commit comments

Comments
 (0)