feat(types): disambiguated aliases for colliding type names (#911 Step 2)#941
Merged
Conversation
Implements #911 (Step 2). Step 1 (#919) made cross-module generated-type name collisions loud via a build guard; this adds disambiguated, adopter-facing aliases for the high-traffic colliding names #911 calls out so adopters can import each per-module variant unambiguously from adcp.types. Convention: <Context><BaseName>, where <Context> is derived from the defining module/verb (e.g. SyncAccountsAccount, DeliveryCreative, CapabilitiesMediaBuy), matching existing precedent in aliases.py (SyncCreativeResult, MediaBuyDeliveryStatus, SyncAudiencesAudience). Covers 33 aliases across Creative, Account, Authentication, MediaBuy, GovernanceAgent, CreditLimit, Setup, Sort, Signal, and Unit. Each alias imports its variant directly from the source module, so it resolves to the correct class regardless of consolidate sort order. These aliases do not remove the underlying generated_poc collisions, so the Step 1 guard and scripts/collision_allowlist.json are intentionally unchanged. No generated_poc or _generated.py edits. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Clean additive change. Right shape: aliases import each variant directly from its source module, so the binding survives consolidate sort-order shifts and the renumber churn that _generated.py is prone to.
Things I checked
- Purely additive. None of the 33 names exist at HEAD — the diff only inserts into import blocks, both
__all__blocks, and the snapshot. No public export removed, renamed, or repointed.feat(types):is the correct semver signal; no!warranted. - Alias mapping is faithful. All 24
generated_pocsource modules exist and every aliased base class (Account,Creative,Authentication,MediaBuy,Setup,CreditLimit,GovernanceAgent,Sort,Signal,Unit) is defined in the module the alias names. The shape claims that justify the disambiguation are true at source:core/notification_config.pymakescredentialsoptional whilecore/push_notification_configrequires it;get_creative_delivery_response.Creativeis the lean totals view (totals/variant_count) vslist_creatives_response.Creative's rich record (status/assets/assignments).ad-tech-protocol-expert: sound. - No shadowing. The four
*Unitaliases are distinct enums and don't touch the pre-existingUnit = DimensionUnitbinding at__init__.py:838— correctly called out in thealiases.pycomment.code-reviewer: clean. - Import layering intact. Only
aliases.pyand__init__.pygainedgenerated_pocimports — both on thetest_import_layering.pyallowlist. No other module touched. Nogenerated_poc/,_generated.py, orconsolidate_exports.pyedits, so the Step 1 guard andcollision_allowlist.jsonstay green as designed. - Stability contract.
tests/test_collision_aliases.pypins each alias to its__module__byis-identity, so a future regen that repointed a binding fails loudly instead of silently swapping the wire shape. Aliases target named classes at stable module paths, not numbered anonymous variants — the renumber footgun doesn't apply here.
Follow-ups (non-blocking — file as issues)
- Scope is 33 of ~210 collisions by design — this advances #911 Step 2, doesn't close it. The skipped cases (
Brandno longer colliding,DimensionUnitalready unambiguous, the{sandbox}complianceAccountstub) are documented and reasonable.
Minor nits (non-blocking)
- Pre-existing snapshot duplicates.
tests/fixtures/public_api_snapshot.jsoncarries duplicateWholesaleFeedEvent/WholesaleFeedWebhookentries adjacent to the newWholesaleFeedSignalinsertion. They're on HEAD, stem from_generated.py, and aren't introduced here — worth a separate cleanup, not this PR's problem.
LGTM. Follow-ups noted below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Advances #911 (Step 2). Step 1 (#919, merged) made cross-module generated-type name collisions loud via a build guard; this PR provides disambiguated, adopter-facing aliases for the high-traffic colliding names #911 calls out, so adopters can import each per-module variant unambiguously from
adcp.typesinstead of getting whichever module wins the consolidate sort order.This does not implement the full set of ~210 collisions — it covers the high-traffic, adopter-facing names named in the issue, so it advances Step 2 rather than closing #911.
Naming convention (the API decision)
<Context><BaseName>, where<Context>is derived from the defining module/verb. This matches existing precedent inaliases.py(SyncCreativeResult,MediaBuyDeliveryStatus,SyncAudiencesAudience).33 aliases added, each pointing at the correct per-module class:
CreativeDeliveryCreative,ListCreativesCreative,SyncCreativesCreative,BuildCreativeCreative,CapabilitiesCreativeAccountCoreAccount,SyncAccountsAccount,SyncGovernanceAccount,CapabilitiesAccountAuthenticationPushNotificationAuthentication,NotificationAuthentication,ReportingWebhookAuthentication,GovernanceAuthentication,CreateMediaBuyAuthenticationMediaBuyCoreMediaBuy,GetMediaBuysMediaBuy,CapabilitiesMediaBuyGovernanceAgentCoreGovernanceAgent,SyncGovernanceGovernanceAgentCreditLimitCoreCreditLimit,SyncAccountsCreditLimitSetupCoreSetup,SyncAccountsSetup,SyncEventSourcesSetupSortListCreativesSort,TasksListSort,ListTasksSortSignalGetSignalsSignal,WholesaleFeedSignalUnitDurationUnit,OverlayUnit,RealEstateUnit,VehicleUnitEach alias imports its variant directly from the source module, so it resolves to the correct class regardless of consolidate sort order — verified by
is-identity /__module__checks in the tests.Notes / scope decisions
Brand(in the issue's table) is no longer a collision on currentmain— only one module defines it, so it already imports unambiguously and is not in the allowlist. Skipped.Unit: the issue table referencedenums.dimension_unit, but that class is actually namedDimensionUnit(already unambiguous). The realUnitcollision is acrosscore.duration / overlay / real_estate_item / vehicle_item; aliased those by the dimension they measure.Account: thecompliance.comply_test_controller_requestvariant is a trivial{sandbox}test stub; intentionally not aliased.notification_config.Authenticationmakescredentialsoptional whilepush_notification_configrequires it;list_creatives_response.Creativeis the rich record vs the lean delivery-totals winner).Interaction with Step 1
Aliasing in
aliases.pydoes not remove the underlyinggenerated_poccollisions, so per the Step 1 design thecollision_allowlist.json+ guard stay unchanged. The guard andtests/test_collision_guard.pyremain green. Nogenerated_poc/,_generated.py,consolidate_exports.py, orKNOWN_COLLISIONSedits.Tests / verification
tests/test_collision_aliases.py: each alias resolves to the class defined in its named module (is/__module__), is importable fromadcp.types+ in__all__, alias set is internally consistent, distinct variants are distinct classes, plus shape-marker assertions.tests/fixtures/public_api_snapshot.jsonregenerated (purely additive, only theadcp.typessection).test_collision_aliases,test_collision_guard,test_import_layering,test_public_api,test_type_aliases;make lint,make typecheck,make typecheck-all,make validate-generated; fullmake test(5727 passed).No
ADCP_VERSIONbump, no schema re-download.🤖 Generated with Claude Code