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
378 changes: 332 additions & 46 deletions CHANGELOG.md

Large diffs are not rendered by default.

170 changes: 168 additions & 2 deletions MIGRATION_v9_to_v10.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ pip install adcp

`pip install adcp` selects SDK 10, which targets AdCP 3.3. To stay on SDK 9
(AdCP 3.2), pin `adcp>=9,<10`. Read
[the SDK 10 migration guide](MIGRATION_v9_to_v10.md) before upgrading.
[the SDK 10 migration guide](MIGRATION_v9_to_v10.md) before upgrading; the
10.0.0 entry in [CHANGELOG.md](CHANGELOG.md) lists every change since 9.6.2.

## Quick Start: Test Helpers

Expand Down Expand Up @@ -430,6 +431,7 @@ the SDK's supported versions in the error details.
- **[Migrating from SDK 6 to 7](https://github.com/adcontextprotocol/adcp-client-python/blob/main/MIGRATION_v6_to_v7.md)** - Breaking API, security, concurrency, and webhook changes
- **[Migrating from SDK 7 to 8](https://github.com/adcontextprotocol/adcp-client-python/blob/main/MIGRATION_v7_to_v8.md)** - Secure webhook defaults and telemetry changes
- **[Migrating from SDK 8 to 9](MIGRATION_v8_to_v9.md)** - Strict validation, HTTP security and reporting caller ownership
- **[Migrating from SDK 9 to 10](MIGRATION_v9_to_v10.md)** - AdCP 3.3.0: every breaking change with its adopter action, type-level changes and the two `TaskStatus` enums
- **[Migrating from AdCP 3.1 to 3.2](MIGRATION_ADCP_3.1_TO_3.2.md)** - Compact lifecycle adoption and old/new compatibility matrix
- **[Durable legacy purchase continuations](docs/legacy-purchase-continuations.md)** - Safe products-only compatibility redemption and crash recovery
- **[Media-buy lifecycle coordinator](docs/media-buy-lifecycle-coordinator.md)** - Negotiated catalog-to-purchase workflow across AdCP 3.0, 3.1, and 3.2; remaining buyer parity is tracked in [#1154](https://github.com/adcontextprotocol/adcp-client-python/issues/1154)
Expand Down
4 changes: 4 additions & 0 deletions scripts/run_pyright_type_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
"reportAttributeAccessIssue: pyright does not resolve DurationUnit through "
"the lazy adcp.types facade"
),
"protocol_task_status_narrowing.py": (
"reportIncompatibleVariableOverride: pyright treats narrowing the mutable "
"status field to an enum-member Literal as incompatible; mypy admits it"
),
"reporting_buyer_submission_intents.py": (
"reportArgumentType: ADCPClient against the ReportingReceiptSubmissionClient protocol"
),
Expand Down
3 changes: 3 additions & 0 deletions src/adcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ def _resolve_version() -> str:
"Format",
"FormatOptionReference",
"GeneratedTaskStatus",
"ProtocolTaskStatus",
"GetAccountFinancialsRequest",
"GetAccountFinancialsResponse",
"GetBrandIdentityRequest",
Expand Down Expand Up @@ -1729,6 +1730,7 @@ def get_adcp_version() -> str:
"generated",
"aliases",
"GeneratedTaskStatus",
"ProtocolTaskStatus",
# Semantic type aliases (for better API ergonomics)
"AccountReferenceById",
"AccountReferenceByNaturalKey",
Expand Down Expand Up @@ -2391,6 +2393,7 @@ def get_adcp_version() -> str:
PropertyIdActivationKey,
PropertyTagActivationKey,
Proposal,
ProtocolTaskStatus,
ProvidePerformanceFeedbackRequest,
ProvidePerformanceFeedbackResponse,
PublishedPostAsset,
Expand Down
2 changes: 2 additions & 0 deletions src/adcp/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ class name, or a numbered variant has no semantic alias — import it by its
"GetCreativeFeaturesSuccessResponse",
# Internal/special exports
"GeneratedTaskStatus",
"ProtocolTaskStatus",
# Backward compatibility aliases (deprecated)
"Action",
"Capability",
Expand Down Expand Up @@ -1875,6 +1876,7 @@ def __dir__() -> list[str]:
Protocol,
ProtocolEnvelope,
ProtocolResponse,
ProtocolTaskStatus,
Provenance,
ProvenanceDeclaredBy,
ProvidePerformanceFeedbackByBuyerRefRequest,
Expand Down
6 changes: 6 additions & 0 deletions src/adcp/types/_eager.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@
Offer as TmpOffer,
)
from adcp.types._generated import TaskStatus as GeneratedTaskStatus

# Stable, unambiguous name for the wire task-status enum (enums/task-status.json).
# ``adcp.TaskStatus`` is the client-side ``TaskResult.status`` enum, a different
# type with different members; see MIGRATION_v9_to_v10.md#two-taskstatus-enums.
ProtocolTaskStatus = GeneratedTaskStatus
from adcp.types._generated import (
TextAsset as TextContent,
)
Expand Down Expand Up @@ -1498,6 +1503,7 @@ def __init__(self, *args: object, **kwargs: object) -> None:
"FrequencyCap",
"FrequencyCapScope",
"GeneratedTaskStatus",
"ProtocolTaskStatus",
"GeoCountry",
"GeoMetro",
"GeoRegion",
Expand Down
11 changes: 10 additions & 1 deletion src/adcp/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,16 @@ def _validate_security_constraints(self) -> AgentConfig:


class TaskStatus(str, Enum):
"""Task execution status."""
"""Client-side status of a :class:`TaskResult` (``adcp.TaskStatus``).

This is the SDK's summary of a call's outcome, not the AdCP wire enum: it
has ``NEEDS_INPUT`` where the protocol has ``input-required``, and no
``canceled``, ``rejected``, ``auth-required`` or ``unknown``. Compare
:attr:`TaskResult.status` with it. For a ``status`` field on a generated
request, response or webhook model, use
:data:`adcp.types.ProtocolTaskStatus` (also exported as
``GeneratedTaskStatus``).
"""

COMPLETED = "completed"
SUBMITTED = "submitted"
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/public_api_snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@
"PropertyTagActivationKey": "core.activation_key:ActivationKey2",
"Proposal": "core.proposal",
"Protocol": "adcp.types.core",
"ProtocolTaskStatus": "enums.task_status:TaskStatus",
"ProvidePerformanceFeedbackByBuyerRefRequest": "media_buy.provide_performance_feedback_request:ProvidePerformanceFeedbackRequest",
"ProvidePerformanceFeedbackByMediaBuyRequest": "media_buy.provide_performance_feedback_request:ProvidePerformanceFeedbackRequest",
"ProvidePerformanceFeedbackErrorResponse": "media_buy.provide_performance_feedback_response:ProvidePerformanceFeedbackResponse2",
Expand Down Expand Up @@ -1846,6 +1847,7 @@
"Protocol": "adcp.types.core",
"ProtocolEnvelope": "core.protocol_envelope",
"ProtocolResponse": "core.response",
"ProtocolTaskStatus": "enums.task_status:TaskStatus",
"Provenance": "core.provenance",
"ProvenanceDeclaredBy": "core.provenance:DeclaredBy",
"ProvidePerformanceFeedbackByBuyerRefRequest": "media_buy.provide_performance_feedback_request:ProvidePerformanceFeedbackRequest",
Expand Down
37 changes: 37 additions & 0 deletions tests/test_protocol_task_status_alias.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""``ProtocolTaskStatus`` names the wire task-status enum unambiguously (#2012)."""

from __future__ import annotations

import adcp
import adcp.types
from adcp.types.domains.enums.task_status import TaskStatus as WireTaskStatus


def test_protocol_task_status_is_the_generated_wire_enum() -> None:
assert adcp.types.ProtocolTaskStatus is WireTaskStatus
assert adcp.types.ProtocolTaskStatus is adcp.types.GeneratedTaskStatus
assert adcp.ProtocolTaskStatus is adcp.types.ProtocolTaskStatus
assert "ProtocolTaskStatus" in adcp.types.__all__
assert "ProtocolTaskStatus" in adcp.__all__


def test_media_buy_success_status_is_typed_by_the_wire_enum() -> None:
for model in (
adcp.types.CreateMediaBuyResponse1,
adcp.types.CreateMediaBuySuccessResponse,
adcp.types.UpdateMediaBuyResponse1,
adcp.types.UpdateMediaBuySuccessResponse,
):
assert model.model_fields["status"].annotation is adcp.types.ProtocolTaskStatus


def test_client_task_status_is_a_different_enum() -> None:
assert adcp.TaskStatus is not adcp.types.ProtocolTaskStatus
assert {m.value for m in adcp.TaskStatus} == {
"completed",
"submitted",
"needs_input",
"failed",
"working",
}
assert "input-required" in {m.value for m in adcp.types.ProtocolTaskStatus}
49 changes: 49 additions & 0 deletions tests/type_checks/protocol_task_status_narrowing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Adopter pattern: narrow a response's wire ``status`` in a subclass (#2012).

SDK 10 types ``status`` on the media-buy success arms
(``CreateMediaBuyResponse1``, ``UpdateMediaBuyResponse1`` and their
``*SuccessResponse`` / ``Legacy*`` names) as the generated wire enum, where
SDK 9 had ``Literal['completed']``. A subclass that re-declares
``status: Literal['completed']`` no longer type-checks: a string literal is not
a member of the enum. Narrow with an enum-member literal of
``ProtocolTaskStatus`` instead. ``adcp.TaskStatus`` is the client-side
``TaskResult`` enum and is the wrong type here.
"""

from __future__ import annotations

from typing import Literal

from typing_extensions import assert_type

from adcp import TaskResult, TaskStatus
from adcp.types import (
CreateMediaBuyResponse1,
CreateMediaBuySuccessResponse,
GeneratedTaskStatus,
ProtocolTaskStatus,
UpdateMediaBuySuccessResponse,
)


class CompletedCreateMediaBuy(CreateMediaBuySuccessResponse):
status: Literal[ProtocolTaskStatus.completed] = ProtocolTaskStatus.completed


class CompletedUpdateMediaBuy(UpdateMediaBuySuccessResponse):
status: Literal[ProtocolTaskStatus.completed] = ProtocolTaskStatus.completed


def wire_status(response: CreateMediaBuyResponse1) -> ProtocolTaskStatus:
assert_type(response.status, ProtocolTaskStatus)
return response.status


def same_enum(status: GeneratedTaskStatus) -> ProtocolTaskStatus:
# ``ProtocolTaskStatus`` is the stable name of ``GeneratedTaskStatus``.
return status


def client_status(result: TaskResult[object]) -> bool:
# ``TaskResult.status`` is the client-side enum, not the wire enum.
return result.status is TaskStatus.NEEDS_INPUT