Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

Adds semantic aliases for all remaining user-facing discriminated union types, ensuring downstream users never need to import from generated_poc or use numbered types.

Changes

New Semantic Aliases (10 types)

PublisherProperties variants (selection_type discriminator):

  • PublisherPropertiesAllPublisherProperties (selection_type='all')
  • PublisherPropertiesByIdPublisherProperties4 (selection_type='by_id')
  • PublisherPropertiesByTagPublisherProperties5 (selection_type='by_tag')
  • Also exports: PropertyId, PropertyTag (constraint types)

Deployment variants (type discriminator):

  • PlatformDeploymentDeployment1 (type='platform')
  • AgentDeploymentDeployment2 (type='agent')

Destination variants (type discriminator):

  • PlatformDestinationDestination1 (type='platform')
  • AgentDestinationDestination2 (type='agent')

Documentation

Added comprehensive prevention strategy in CLAUDE.md:

  • Complete coverage status (30 user-facing types aliased, 15 internal types correctly skipped)
  • 5-strategy approach to prevent numbered type usage
  • Manual audit workflow for type regeneration
  • Decision criteria for when to alias vs skip

Testing

  • Added 13 new tests covering imports, type checking, and instantiation
  • All 31 tests in test_type_aliases.py passing
  • Validates aliases are exported from all paths (main package, types module, aliases module)

Impact

Before (users had to do this):

from adcp.types.generated_poc.product import PublisherProperties5, PropertyTag
from adcp.types.generated_poc.deployment import Deployment1

After (clean, semantic API):

from adcp import PublisherPropertiesByTag, PropertyTag, PlatformDeployment

Coverage Status

100% of user-facing discriminated unions now have semantic aliases (30 types)
15 internal helper types correctly left unaliased (Input2, Packages1, etc.)

Breaking Changes

None - only adds new exports, doesn't change existing API.

Checklist

  • Added semantic aliases for all user-facing discriminated unions
  • Exported from aliases.py, types/__init__.py, and main __init__.py
  • Added comprehensive tests (13 new tests)
  • Updated documentation with prevention strategy
  • All tests passing (31/31 in test_type_aliases.py)
  • No breaking changes to existing API

Related Issues

Resolves the need for users to import from generated_poc when working with publisher properties and signal deployments/destinations.

bokelley and others added 4 commits November 18, 2025 16:48
Add user-friendly type aliases for the PublisherProperties discriminated
union variants to improve developer experience and avoid direct imports
from generated_poc.

Changes:
- Add PublisherPropertiesAll (selection_type='all')
- Add PublisherPropertiesById (selection_type='by_id')
- Add PublisherPropertiesByTag (selection_type='by_tag')
- Export PropertyId and PropertyTag types for use with the variants
- Update all export paths (aliases.py, types/__init__.py, __init__.py)
- Add comprehensive tests covering imports, type checking, and instantiation

These aliases follow the established pattern for other discriminated unions
(PreviewRender, VastAsset, etc.) and provide clear, semantic names that
match the spec's discriminator values.

Example usage:
```python
from adcp import PublisherPropertiesByTag, PropertyTag

props = PublisherPropertiesByTag(
    publisher_domain="example.com",
    selection_type="by_tag",
    property_tags=[PropertyTag("premium"), PropertyTag("video")]
)
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ed unions

Complete the semantic aliasing coverage by adding aliases for signal
deployment and destination types used in GetSignalsResponse.

Changes:
- Add PlatformDeployment (Deployment1, type='platform')
- Add AgentDeployment (Deployment2, type='agent')
- Add PlatformDestination (Destination1, type='platform')
- Add AgentDestination (Destination2, type='agent')
- Update all export paths (aliases.py, __init__.py)
- Add 7 comprehensive tests covering imports, type checking, and instantiation

These aliases complete coverage of all user-facing discriminated unions
in the AdCP SDK. Users no longer need to import numbered types or reach
into generated_poc for any common operations.

Example usage:
```python
from adcp import PlatformDeployment, AgentDestination

deployment = PlatformDeployment(
    type="platform",
    platform="the-trade-desk",
    is_live=True
)

destination = AgentDestination(
    type="agent",
    agent_url="https://agent.example.com"
)
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add detailed documentation on:
- Complete coverage of all 30 user-facing discriminated union aliases
- List of 15 internal types that don't need aliases
- Five-strategy approach to prevent numbered type usage:
  1. Complete aliasing coverage checklist
  2. Automated detection script (check_missing_aliases.py)
  3. CI enforcement in workflows
  4. Import linting with pre-commit hooks
  5. Type regeneration workflow documentation

This ensures downstream users never need to import from generated_poc
or use numbered types, maintaining a clean and stable public API.

The documentation includes:
- Updated list of all current semantic aliases
- Guidelines for when to alias vs skip
- Bash commands for auditing numbered types
- Python script templates for automation
- CI/CD integration examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley changed the title Complete semantic alias coverage for discriminated unions feat: complete semantic alias coverage for discriminated unions Nov 19, 2025
@bokelley bokelley merged commit ab49c98 into main Nov 19, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants