From 14fe31e29aa76f19afe41720149eecd9e6375f59 Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Wed, 25 Nov 2026 18:01:46 +0000 Subject: [PATCH] fix(version): retire the 3.3-rc.0 -> 3.3-rc.3 bridge alias The alias from #1964 let the managed sales agent serve buyers still pinned to 3.3-rc.0 while agentic-api moved to rc.3. agentic-api production now speaks 3.3-rc.3 (v5.2153.0), so the bridge has done its job. A buyer that pins 3.3-rc.0 is refused with VERSION_UNSUPPORTED again, like any other superseded prerelease. The managed reporting fallback keeps leaving out aliases that never serve subscriptions; that part of #1964 stays. Co-Authored-By: Claude Opus 5.5 --- README.md | 15 +- docs/decisioning-capabilities.md | 2 +- src/adcp/_version.py | 22 +- src/adcp/reporting/service.py | 4 +- src/adcp/validation/envelope.py | 5 +- tests/test_adcp_3_3_0_rc_3_adoption.py | 11 +- tests/test_rc0_version_bridge.py | 276 ------------------- tests/test_reporting_subscription_managed.py | 8 +- 8 files changed, 20 insertions(+), 323 deletions(-) delete mode 100644 tests/test_rc0_version_bridge.py diff --git a/README.md b/README.md index a1851da98c..a6b698f3a7 100644 --- a/README.md +++ b/README.md @@ -404,19 +404,8 @@ The SDK also accepts and advertises `"3.2-rc.7"` as an explicit compatibility alias for buyers shipped with `adcp==8.0.0rc3`. These requests use the stable 3.2 validators and responses retain the `"3.2-rc.7"` alias so strict rc3 clients can select their bundled response validator. -Constructor pins to that alias resolve to `"3.2"`. - -`"3.3-rc.0"` is likewise an explicit alias for `"3.3-rc.3"`, so a seller can -serve buyers still pinned to the first 3.3 release candidate while both sides -move to rc.3. rc.0 requests are validated against rc.3 and responses echo -`"3.3-rc.0"`. rc.3 withdrew performance-standard `metric_id`: a `buy_products` -purchase that sends it fails validation, and package standards and -`get_products` filters accept it but no longer act on it. Responses are -rc.3-shaped, which rc.0 buyers read except for values rc.3 added to closed -enums, such as the `postal_area` reporting dimension; a seller bridging rc.0 -buyers must not emit those. A client pinned to `"3.3-rc.0"` also resolves to -rc.3. The alias is advertised only while rc.3 is the packaged release. Other -prereleases are not automatically aliased. +Constructor pins to that alias resolve to `"3.2"`. Other prereleases are +not automatically aliased. If you talk to an agent on a newer spec than this SDK validates, the response still parses — unknown fields are preserved on the model (but not surfaced as diff --git a/docs/decisioning-capabilities.md b/docs/decisioning-capabilities.md index aa34e34025..4e18de3d6d 100644 --- a/docs/decisioning-capabilities.md +++ b/docs/decisioning-capabilities.md @@ -68,7 +68,7 @@ alongside the spec; they line up. - **`adcp.supported_versions`** — exact releases you serve. Boot validation rejects entries outside the SDK's accepted wire set or without installed request and response validators. The SDK includes `"3.2-rc.7"` as a - compatibility alias for `"3.2"`, and `"3.3-rc.0"` as one for `"3.3-rc.3"`. For a 3.2-only seller, declare + compatibility alias for `"3.2"`. For a 3.2-only seller, declare `Adcp(major_versions=[3], supported_versions=["3.2"], idempotency={"supported": False})`; the deprecated `list_creative_formats_legacy` method is then optional even with diff --git a/src/adcp/_version.py b/src/adcp/_version.py index e5d1436c86..2be0be9832 100644 --- a/src/adcp/_version.py +++ b/src/adcp/_version.py @@ -29,22 +29,11 @@ # definition, so making them part of the pin is a category error. COMPATIBLE_ADCP_VERSIONS: tuple[str, ...] = ("3.0", "3.1", "3.2", "3.3") -# Explicit compatibility bridges. Other prereleases retain their own schema -# contracts; never infer aliases by pattern. -# -# - 3.2-rc.7: buyers shipped with adcp 8.0.0rc3. rc.7 requests remain valid -# under the additive 3.2.1 contract. -# - 3.3-rc.0: buyers still pinned to the first 3.3 release candidate, so a -# seller can serve rc.0 and rc.3 buyers during a lockstep preview move. -# rc.0 requests validate against rc.3 except performance-standard -# ``metric_id``, which rc.3 withdrew: the compact standard on buy_products -# purchases rejects it, and package standards and get_products filters -# accept it but no longer act on it. Responses are rc.3-shaped; rc.0 reads -# them except values rc.3 added to closed enums (reporting dimension -# ``postal_area``), so a bridging seller must not emit those. -# +# Explicit compatibility bridge for buyers shipped with adcp 8.0.0rc3. +# rc.7 requests remain valid under the additive 3.2.1 contract. Other +# prereleases retain their own schema contracts; never infer aliases by pattern. # An alias is advertised only while its target is. -_ADCP_VERSION_ALIASES: dict[str, str] = {"3.2-rc.7": "3.2", "3.3-rc.0": "3.3-rc.3"} +_ADCP_VERSION_ALIASES: dict[str, str] = {"3.2-rc.7": "3.2"} def resolve_adcp_version_alias(version: str) -> str: @@ -216,8 +205,7 @@ def resolve_adcp_version(pin: str | None) -> str: is advertised by this SDK. - Cross-major pin → raises :class:`ConfigurationError`. - Unparseable string → raises :class:`ConfigurationError`. - - The explicit compatibility aliases resolve to their targets: - ``3.2-rc.7`` to ``3.2`` and ``3.3-rc.0`` to ``3.3-rc.3``. + - The explicit ``3.2-rc.7`` compatibility alias resolves to ``3.2``. All resolved pins are normalized to release-precision before being returned, per the spec's wire-value rule diff --git a/src/adcp/reporting/service.py b/src/adcp/reporting/service.py index 1220ab2d2f..3d7543993e 100644 --- a/src/adcp/reporting/service.py +++ b/src/adcp/reporting/service.py @@ -2042,8 +2042,8 @@ def inject_capabilities( # Leave out compatibility aliases that never reach # subscriptions (3.2-rc.7), never the packaged release, - # which can itself be a candidate (3.3-rc.3), nor an alias - # of it (3.3-rc.0) that buyers still pin. + # which can itself be a candidate (3.3-rc.3), nor an + # alias of it that buyers still pin. adcp["supported_versions"] = [ item for item in get_supported_adcp_versions() diff --git a/src/adcp/validation/envelope.py b/src/adcp/validation/envelope.py index 820d2383e8..8f79f3a6d5 100644 --- a/src/adcp/validation/envelope.py +++ b/src/adcp/validation/envelope.py @@ -82,9 +82,8 @@ def detect_wire_version( 1. ``payload['adcp_version']`` — string, normalized to release precision (``"3.0.7"`` → ``"3.0"``). Must be in ``supported`` or - raises :class:`UnsupportedVersionError`. The explicit compatibility - aliases resolve to their targets (``3.2-rc.7`` to ``3.2``, - ``3.3-rc.0`` to ``3.3-rc.3``). + raises :class:`UnsupportedVersionError`. The explicit ``3.2-rc.7`` + compatibility alias resolves to ``3.2``. 2. ``payload['adcp_major_version']`` — int. Prefer ``MAJOR.0`` when supported because this legacy field predates release-precision negotiation and the 3.1 response envelope split. If ``MAJOR.0`` is diff --git a/tests/test_adcp_3_3_0_rc_3_adoption.py b/tests/test_adcp_3_3_0_rc_3_adoption.py index 2474c113d2..b3f5479628 100644 --- a/tests/test_adcp_3_3_0_rc_3_adoption.py +++ b/tests/test_adcp_3_3_0_rc_3_adoption.py @@ -7,8 +7,8 @@ buyers opt into the exact prerelease they validated against (DR-0024). The superseded ``3.3-beta.0`` through ``3.3-beta.6`` are no longer advertised or accepted as pins, like the 3.2 candidates before them; their caches stay in the source tree as history -but leave the wheel. ``3.3-rc.0`` is an explicit compatibility alias for ``3.3-rc.3`` -(see ``tests/test_rc0_version_bridge.py``). +but leave the wheel. ``3.3-rc.0`` served as an alias for ``3.3-rc.3`` while +agentic-api moved from rc.0 to rc.3 and is refused again now that it has. """ from __future__ import annotations @@ -66,7 +66,6 @@ def test_current_pin_and_historical_roots(): "3.2", WIRE_VERSION, "3.2-rc.7", - "3.3-rc.0", } with pytest.raises(ConfigurationError): resolve_adcp_version("3.3") @@ -91,11 +90,11 @@ def test_current_pin_and_historical_roots(): "3.3.0-beta.5", "3.3-beta.6", "3.3.0-beta.6", + "3.3-rc.0", + "3.3.0-rc.0", ): with pytest.raises(ConfigurationError): resolve_adcp_version(previous) - for bridged in ("3.3-rc.0", "3.3.0-rc.0"): - assert resolve_adcp_version(bridged) == "3.3-rc.3" for previous in ( "3.3-beta.0", "3.3-beta.1", @@ -104,9 +103,9 @@ def test_current_pin_and_historical_roots(): "3.3-beta.4", "3.3-beta.5", "3.3-beta.6", + "3.3-rc.0", ): assert previous not in get_supported_adcp_versions() - assert "3.3-rc.0" in get_supported_adcp_versions() assert schema_loader._resolve_schema_root("3.3.0-beta.1") is not None assert schema_loader._resolve_schema_root("3.3.0-beta.2") is not None assert schema_loader._resolve_schema_root("3.3.0-beta.3") is not None diff --git a/tests/test_rc0_version_bridge.py b/tests/test_rc0_version_bridge.py deleted file mode 100644 index 5ce1a2d296..0000000000 --- a/tests/test_rc0_version_bridge.py +++ /dev/null @@ -1,276 +0,0 @@ -"""Explicit compatibility bridge for buyers still pinned to AdCP 3.3-rc.0. - -A seller on this wheel (packaged 3.3.0-rc.3) serves rc.0 buyers during a -lockstep move: rc.0 claims validate against the rc.3 contract and responses -echo ``"3.3-rc.0"`` so the buyer selects its own bundled response validator. -""" - -from __future__ import annotations - -from types import SimpleNamespace -from typing import Any - -import pytest -from starlette.testclient import TestClient - -from adcp import ADCPClient -from adcp._version import get_supported_adcp_versions, resolve_adcp_version -from adcp.exceptions import ADCPTaskError, ConfigurationError -from adcp.reporting.service_subscriptions import advertise_subscriptions -from adcp.reporting.subscriptions import ReportingSubscriptionSupport, serves_subscriptions -from adcp.server import ADCPHandler, ToolContext, create_a2a_server, resolve_requested_adcp_version -from adcp.server.a2a_server import ADCPAgentExecutor -from adcp.server.mcp_tools import MCPToolSet, create_tool_caller -from adcp.server.responses import capabilities_response -from adcp.types.core import AgentConfig, Protocol -from adcp.validation import ValidationHookConfig, get_validator, validate_request -from adcp.validation.envelope import UnsupportedVersionError, detect_wire_version - -ALIAS = "3.3-rc.0" -TARGET = "3.3-rc.3" -REQUEST = {"buying_mode": "brief", "brief": "sports"} - - -class Seller(ADCPHandler[ToolContext]): - advertised_tools = {"get_products"} - - def __init__(self) -> None: - self.versions: list[str | None] = [] - - async def get_products( - self, params: dict[str, Any], context: ToolContext | None = None - ) -> dict[str, Any]: - assert context is not None - self.versions.append(context.resolved_adcp_version) - return {"products": [], "cache_scope": "public"} - - -def _client(version: str) -> ADCPClient: - return ADCPClient( - AgentConfig(id="seller", agent_uri="http://localhost/mcp/", protocol=Protocol.MCP), - adcp_version=version, - ) - - -# --- 1. resolution ----------------------------------------------------------- - - -@pytest.mark.parametrize("version", [ALIAS, "3.3.0-rc.0"]) -def test_rc0_claim_resolves_to_rc3(version: str) -> None: - assert detect_wire_version({"adcp_version": version}) == TARGET - assert resolve_requested_adcp_version({"adcp_version": version}) == TARGET - assert resolve_adcp_version(version) == TARGET - assert _client(version).get_adcp_version() == TARGET - - -# --- 2. advertising ---------------------------------------------------------- - - -def test_alias_is_advertised_and_has_rc3_validators() -> None: - assert ALIAS in get_supported_adcp_versions() - assert ALIAS in capabilities_response(["media_buy"])["adcp"]["supported_versions"] - for tool in ("create_media_buy", "get_media_buy_delivery", "get_products"): - for direction in ("request", "sync"): - aliased = get_validator(tool, direction, version=ALIAS) - target = get_validator(tool, direction, version=TARGET) - assert aliased is not None and target is not None, (tool, direction) - assert aliased.schema == target.schema, (tool, direction) - - -# --- 3. MCP ------------------------------------------------------------------ - - -@pytest.mark.asyncio -@pytest.mark.parametrize("selection", [None, [TARGET, ALIAS]]) -@pytest.mark.parametrize( - "validation", [None, ValidationHookConfig(requests="strict", responses="strict")] -) -async def test_mcp_serves_rc0_claim_and_echoes_it(selection: Any, validation: Any) -> None: - seller = Seller() - caller = create_tool_caller( - seller, "get_products", validation=validation, supported_versions=selection - ) - response = await caller({**REQUEST, "adcp_version": ALIAS}) - assert response["products"] == [] - assert response["adcp_version"] == ALIAS - assert seller.versions == [TARGET] - - -@pytest.mark.asyncio -async def test_mcp_toolset_serves_rc0_claim() -> None: - seller = Seller() - tools = MCPToolSet(seller, supported_versions=[TARGET, ALIAS], advertise_all=True) - response = await tools.call_tool("get_products", {**REQUEST, "adcp_version": ALIAS}) - assert response["adcp_version"] == ALIAS - assert seller.versions == [TARGET] - - -@pytest.mark.asyncio -@pytest.mark.parametrize("claim", [ALIAS, "3.3.0-rc.0"]) -async def test_mcp_selection_excluding_alias_refuses_it(claim: str) -> None: - seller = Seller() - caller = create_tool_caller(seller, "get_products", supported_versions=[TARGET]) - with pytest.raises(ADCPTaskError) as caught: - await caller({**REQUEST, "adcp_version": claim}) - assert caught.value.errors[0].code == "VERSION_UNSUPPORTED" - assert caught.value.errors[0].details["supported_versions"] == [TARGET] - assert seller.versions == [] - - -def test_explicit_supported_set_can_exclude_alias() -> None: - with pytest.raises(UnsupportedVersionError): - detect_wire_version({"adcp_version": ALIAS}, supported=(TARGET,)) - - -# --- 4. A2A ------------------------------------------------------------------ - - -@pytest.mark.asyncio -@pytest.mark.parametrize("selection", [None, [TARGET, ALIAS]]) -async def test_a2a_executor_serves_rc0_claim_and_echoes_it(selection: Any) -> None: - seller = Seller() - executor = ADCPAgentExecutor(seller, validation=None, supported_versions=selection) - response = await executor._tool_callers["get_products"]( - {**REQUEST, "adcp_version": ALIAS}, ToolContext() - ) - assert response["products"] == [] - assert response["adcp_version"] == ALIAS - assert seller.versions == [TARGET] - - -@pytest.mark.asyncio -async def test_a2a_executor_selection_excluding_alias_refuses_it() -> None: - seller = Seller() - executor = ADCPAgentExecutor(seller, validation=None, supported_versions=[TARGET]) - with pytest.raises(ADCPTaskError) as caught: - await executor._tool_callers["get_products"]( - {**REQUEST, "adcp_version": ALIAS}, ToolContext() - ) - assert caught.value.errors[0].code == "VERSION_UNSUPPORTED" - assert seller.versions == [] - - -def _a2a_send(client: TestClient, params: dict[str, Any]) -> str: - body = { - "jsonrpc": "2.0", - "id": 1, - "method": "message/send", - "params": { - "message": { - "messageId": "m1", - "role": "user", - "parts": [ - {"kind": "data", "data": {"skill": "get_products", "parameters": params}} - ], - } - }, - } - response = client.post("/", json=body, headers={"accept": "application/json"}) - assert response.status_code == 200 - return response.text - - -def test_a2a_wire_serves_rc0_claim_and_the_response_carries_it() -> None: - seller = Seller() - app = create_a2a_server(seller, supported_versions=[TARGET, ALIAS], validation=None) - with TestClient(app, base_url="http://localhost:3001") as client: - text = _a2a_send(client, {**REQUEST, "adcp_version": ALIAS}) - assert "VERSION_UNSUPPORTED" not in text - assert '"products"' in text - assert f'"adcp_version":"{ALIAS}"' in text.replace(" ", "") - assert seller.versions == [TARGET] - - -def test_a2a_wire_refuses_rc0_claim_when_alias_is_not_selected() -> None: - seller = Seller() - app = create_a2a_server(seller, supported_versions=[TARGET], validation=None) - with TestClient(app, base_url="http://localhost:3001") as client: - text = _a2a_send(client, {**REQUEST, "adcp_version": ALIAS}) - assert "VERSION_UNSUPPORTED" in text - assert seller.versions == [] - - -# --- 5. other prereleases stay refused --------------------------------------- - - -@pytest.mark.parametrize("version", ["3.3-rc.1", "3.3-rc.2", "3.3-beta.6"]) -def test_bridge_does_not_accept_other_prereleases(version: str) -> None: - with pytest.raises(UnsupportedVersionError): - detect_wire_version({"adcp_version": version}) - with pytest.raises(ConfigurationError): - _client(version) - - -# --- 6. known gap: rc.3 withdrew performance-standard metric_id (adcp#8854) -- - - -_STANDARD = { - "metric": "viewability", - "threshold": 0.7, - "standard": "mrc", - "vendor": {"domain": "ias.example"}, -} - - -def _buy_products(standard: dict[str, Any]) -> dict[str, Any]: - return { - "adcp_version": ALIAS, - "idempotency_key": "k" * 16, - "account": {"account_id": "acct_1"}, - "brand": {"domain": "brand.example"}, - "feed_version": "feed_1", - "start_time": "2026-12-01T00:00:00Z", - "end_time": "2026-12-31T00:00:00Z", - "purchases": [ - {"product_id": "p1", "pricing_option_id": "po1", "performance_standards": [standard]} - ], - } - - -def test_buy_products_without_metric_id_validates_under_the_alias() -> None: - assert validate_request("buy_products", _buy_products(_STANDARD), version=ALIAS).valid - - -def test_rc0_buy_products_metric_id_is_rejected_under_the_alias() -> None: - """Known gap: the rc.3 compact standard is ``additionalProperties: false``.""" - outcome = validate_request( - "buy_products", _buy_products({**_STANDARD, "metric_id": "viewable_rate"}), version=ALIAS - ) - assert not outcome.valid - assert any( - issue.pointer == "/purchases/0/performance_standards/0" - and issue.keyword == "additionalProperties" - for issue in outcome.issues - ) - - -def test_create_media_buy_package_performance_standard_validates() -> None: - request = { - "adcp_version": ALIAS, - "idempotency_key": "k" * 16, - "account": {"account_id": "acct_1"}, - "brand": {"domain": "brand.example"}, - "start_time": "2026-12-01T00:00:00Z", - "end_time": "2026-12-31T00:00:00Z", - "packages": [ - { - "product_id": "p1", - "pricing_option_id": "po1", - "budget": 100, - "performance_standards": [_STANDARD], - } - ], - } - assert validate_request("create_media_buy", request, version=ALIAS).valid - - -# --- 7. reporting ------------------------------------------------------------ - - -def test_reporting_subscription_advertisement_is_not_withheld_from_rc0() -> None: - options = SimpleNamespace(engine=SimpleNamespace(support=ReportingSubscriptionSupport())) - response = {"adcp": {"principal": {"supported_sections": []}}, "experimental_features": []} - served = advertise_subscriptions(response, options, adcp_version=ALIAS) # type: ignore[arg-type] - assert served == advertise_subscriptions(response, options, adcp_version=TARGET) # type: ignore[arg-type] - assert "reporting_subscriptions" in served["adcp"]["principal"]["supported_sections"] - assert not serves_subscriptions("3.2") diff --git a/tests/test_reporting_subscription_managed.py b/tests/test_reporting_subscription_managed.py index 239ce5da9d..df08ec3e7f 100644 --- a/tests/test_reporting_subscription_managed.py +++ b/tests/test_reporting_subscription_managed.py @@ -633,13 +633,11 @@ async def capabilities(self: Any, params: Any, context: Any = None) -> Any: @pytest.mark.asyncio -async def test_managed_capabilities_advertise_the_rc0_bridge_but_not_rc7() -> None: +async def test_managed_capabilities_leave_out_the_rc7_alias() -> None: world = _World() - served = await world.platform.get_adcp_capabilities({"adcp_version": "3.3-rc.0"}, _ctx()) + served = await world.platform.get_adcp_capabilities({"adcp_version": "3.3-rc.3"}, _ctx()) supported = served["adcp"]["supported_versions"] - # Buyers still pinned to 3.3-rc.0 reach subscriptions through the alias; - # 3.2-rc.7 never serves them, so it stays out of the fallback. - assert "3.3-rc.0" in supported + # 3.2-rc.7 never serves subscriptions, so it stays out of the fallback. assert "3.3-rc.3" in supported assert "3.2-rc.7" not in supported