Skip to content

feat(server): serve extra wire versions through version_aliases - #2013

Merged
bokelley merged 9 commits into
nextfrom
claude/issue-2009-version-aliases
Dec 5, 2026
Merged

bokelley merged 9 commits into
nextfrom
claude/issue-2009-version-aliases

Conversation

@bokelley

@bokelley bokelley commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2007, #2008, #2009
Refs adcontextprotocol/adcp#9223, adcontextprotocol/adcp#9370

From the Apostra migration to AdCP 3.3 GA, with a Python 10.0.0 seller and a TS 17.0.0 buyer. Each commit is one conventional change, in this order:

  1. fix: never echo adcp_version into a response schema that forbids it (Alias echo stamps adcp_version into closed compact 3.2 responses #2007). The alias echo now checks the served release's response schema for that response variant first, using the new response_admits_property. Compact 3.2 roots that are closed and don't declare the field get no echo: list_products, buy_products, control_media_buy, accept_proposal and decline_proposals. The echo now reads the caller's raw claim, from before pre-validation hooks ran.
  2. feat: version_aliases (serve(version_aliases=...): a supported way for a seller to serve an extra wire version #2009). This is a supported way to serve an extra wire version, and it adds the built-in 3.3-rc.3 → 3.3 alias (adcp#9223). The alias is deprecated and goes away in 11.0.
  3. fix: VERSION_UNSUPPORTED reports the effective served list, aliases included (Pre-validation hooks: document ordering, add a global hook, and report the server's versions in VERSION_UNSUPPORTED #2008.3).
  4. feat: a "*" pre-validation hook key for every tool, plus the middleware/hook ordering contract, documented and pinned by a test (Pre-validation hooks: document ordering, add a global hook, and report the server's versions in VERSION_UNSUPPORTED #2008.1, Pre-validation hooks: document ordering, add a global hook, and report the server's versions in VERSION_UNSUPPORTED #2008.2).
  5. Follow-ups: create_mcp_tools accepts version_aliases, an adopter type-check fixture, and a docstring fix.
  6. Review fixes: an alias key must be a prerelease of its target's own line (3.3-rc.3 → 3.3; 3.4 → 3.3 and 3.3-beta.1 → 3.2 raise). The testing helpers check the handler pin like serve(). "*" hooks explicitly never apply to comply_test_controller. The default-on rc.3 alias and its client-side effect are documented in the validation contract and the migration notes.

Public API

serve(handler, *, supported_versions=None, version_aliases: Mapping[str, str] | None = None, ...)

The same keyword is on ServeConfig.version_aliases, create_mcp_server, create_a2a_server, ADCPAgentExecutor, MCPToolSet, create_mcp_tools, create_tool_caller, adcp.decisioning.serve, build_asgi_app and build_test_client. It also adds adcp.server.GLOBAL_PRE_VALIDATION_HOOK_KEY == "*", and adcp.server.version_policy.ServedVersions, a tuple of served wire versions with .aliases and .explicit.

An alias:

  • is accepted on every tool and transport, get_task_status, list_tasks and comply_test_controller included;
  • is routed, converted and validated as its target, and ToolContext.resolved_adcp_version is the target;
  • is advertised in get_adcp_capabilities adcp.supported_versions while its target is, applied again after the response enhancer runs;
  • is listed in VERSION_UNSUPPORTED details;
  • is echoed under the rule below.

Bad configurations raise ConfigurationError at construction.

Echo rule (docs/validation-contract.md)

The SDK adds adcp_version to a response only where the served release's response schema admits it:

  1. A converted response carries the release it was served as. This is the existing behavior.
  2. An aliased claim is echoed back as the caller's alias. The claim is the raw request's value; if the caller sent none, a version a hook supplied counts.

Otherwise the SDK adds nothing. The spec question is still open in adcp#9370.

Design calls to review

  • Carrier: ServedVersions is a tuple subclass, so the aliases reach every path that already takes supported_versions without new plumbing. With version_aliases but no supported_versions, the selection is non-explicit: the server keeps the default handler release and the handler's advertised list, and appends the aliases to that list.
  • Admits check: the check is structural and conservative. If any composed object schema is closed without declaring the field, there is no echo. Version conversion has its own branch-picking _admits_version_envelope, so the SDK now has two definitions.
  • Built-in rc.3 alias (on by default): a server without supported_versions accepts and advertises 3.3-rc.3. It changes the client side too. negotiate_version(["3.3-rc.3", "3.2"]) now returns 3.3-rc.3 (speaking 3.3 to an rc.3 seller) instead of 3.2. An rc.3 payload over a new 3.3.0 bound now gets VALIDATION_ERROR, where it used to get VERSION_UNSUPPORTED. This reverses the "no rc.3 alias" note in MIGRATION_v9_to_v10.md, which this PR updates.
  • Key rules: an alias key must be a release-precision prerelease of its target's own release line, and not natively served. Targets must be native, non-legacy releases in the selection.
  • Hook order: "*" hooks run before the tool's own hooks and never apply to comply_test_controller. The managed controller runs no hooks at all.
  • VERSION_UNSUPPORTED: commit 3 makes the source of details.supported_versions explicit. The behavior change, aliases appearing in the list, comes with commit 2.

Tests

New files: tests/test_version_aliases.py (MCP and A2A over HTTP, task polling, test controller, decisioning testing client, capabilities, configuration errors, hooks, middleware ordering), tests/test_response_version_echo.py, and tests/type_checks/server_version_aliases.py. Existing tests that asserted rc.3 is refused were updated.

Results:

  • Full suite: 23,279 passed, 3,322 skipped. One conformance test, test_large_received_decimal_cannot_replay_a_different_filter, fails the same way on unmodified origin/next in this environment.
  • make typecheck-all and ruff are clean.

BEGIN_COMMIT_OVERRIDE
fix(server): never echo adcp_version into a response schema that forbids it
feat(server): serve extra wire versions through version_aliases
feat(server): accept and advertise 3.3-rc.3 by default as a built-in alias of 3.3, deprecated and removed in 11.0; a seller that must refuse rc.3 passes an explicit supported_versions that omits it
fix(client): negotiate a seller's 3.3-rc.3 as AdCP 3.3; responses from such a seller are checked against the 3.3.0 bounds, strict by default and warn under ADCP_ENV=production
fix(server): report the served versions, aliases included, in VERSION_UNSUPPORTED
feat(server): run star pre-validation hooks for every tool except comply_test_controller
END_COMMIT_OVERRIDE

🤖 Generated with Claude Code

bokelley and others added 6 commits December 5, 2026 11:57
…ids it

The alias echo stamped the caller's version into every response before
validation. The compact AdCP 3.2 roots of list_products, buy_products,
control_media_buy, accept_proposal and decline_proposals are closed and
declare no adcp_version, so a 3.2-rc.7 caller of those tools got a
response-validation failure.

The echo now checks the served release's response schema for the
response variant first (response_admits_property, a conservative
structural check: any composed object schema that is closed without
declaring the field suppresses the echo). The claim is read from the
caller's raw request, before pre-validation hooks, so a hook that
rewrites the version no longer loses the caller's alias; a version a
hook supplies to an envelope-less request still counts. Only a claim
that is an alias of the served release is echoed.

docs/validation-contract.md documents the echo rule the SDK follows
(spec question: adcontextprotocol/adcp#9370).

Refs #2007

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serve, ServeConfig, create_mcp_server, create_a2a_server,
adcp.decisioning.serve, MCPToolSet, create_tool_caller and the testing
helpers accept version_aliases, a mapping of extra wire version to a
release the server serves, for example {"3.3-rc.2": "3.3"}.

A request claiming an alias is accepted on every tool and transport,
task polling and comply_test_controller included, and is routed,
converted and validated as its target; ToolContext.resolved_adcp_version
is the target. get_adcp_capabilities advertises each alias in
adcp.supported_versions while it advertises the target, re-applied after
the response enhancer. Responses echo the alias where the target's
response schema admits adcp_version.

The selection travels as ServedVersions, a tuple of the accepted wire
versions that carries the server's alias map, so every path that already
receives supported_versions honors the aliases. Without
supported_versions the server keeps the SDK default set and default
handler release, plus the aliases. Keys must be release-precision
versions of this major that the SDK does not serve natively; targets
must be native releases in the selection. Bad configurations raise
ConfigurationError at construction.

3.3-rc.3 is now a built-in alias of 3.3, beside 3.2-rc.7, per
adcontextprotocol/adcp#9223: the rc.3 to 3.3.0 schema delta only adds
maxItems and maxLength bounds. It is deprecated and removed in 11.0.
A client that negotiates with a seller advertising only 3.3-rc.3 now
speaks 3.3 to it under that alias instead of falling back to 3.2.

Refs #2009
Refs adcontextprotocol/adcp#9223

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_UNSUPPORTED

The dispatcher and comply_test_controller filled
details.supported_versions from whichever check raised. Both now report
the server's effective served list: its supported_versions selection, or
every version the SDK serves, followed by its version_aliases. Tests pin
the list for explicit claims, omitted envelopes outside an explicit
selection, the default set with aliases, and comply_test_controller on
MCP and A2A.

Refs #2008

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pre_validation_hooks accepts a "*" key, exported as
adcp.server.GLOBAL_PRE_VALIDATION_HOOK_KEY. Its hooks run for every tool,
before that tool's own hooks, on MCP and A2A, so a cross-cutting hook
such as a version bridge or unknown-field policy covers tools added
later without listing them. compose_pre_validation_hooks composes the
key like any other.

The SkillMiddleware docs now state the ordering contract the SDK keeps:
middleware wraps the tool caller and receives the caller's raw request;
pre-validation hooks run inside call_next and each receives a shallow
copy, so top-level rewrites never reach the dict middleware holds. A test
pins it on both transports.

Refs #2008

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…typed surface

create_mcp_tools forwards version_aliases to MCPToolSet like the other
factories. A strict mypy and pyright adopter fixture covers
version_aliases on every public server factory, ServedVersions, and a
global pre-validation hook keyed by GLOBAL_PRE_VALIDATION_HOOK_KEY.

Refs #2009

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er docstring

A converted response carries the release it was converted to, besides
the alias echo; the docstring said the echo was the only source.

Refs #2007

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bokelley and others added 3 commits December 5, 2026 12:29
Review follow-ups for version_aliases:

- An alias key must be a release-precision prerelease of its target's
  own release line: 3.3-rc.3 for 3.3 is accepted; a stable key such as
  3.4 for 3.3, or another line's prerelease such as 3.3-beta.1 for 3.2,
  raises ConfigurationError. Such a key would advertise a release the
  server does not serve and break the spec's downshift rule.
- build_asgi_app and build_test_client check the handler's pin against
  the served set the way serve does.
- The "*" pre-validation hook chain never applies to
  comply_test_controller, and the A2A executor no longer builds a hooked
  caller for it before the managed controller replaces it.
- The validation contract and v9 to v10 migration notes state that the
  built-in 3.3-rc.3 alias is accepted and advertised by default, how to
  refuse it, and that a client speaks 3.3 to an rc.3 seller and checks
  its responses against the 3.3.0 bounds.

Refs #2009

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rding test

On Python 3.10 the dotted target adcp.server.serve.serve resolves
adcp.server.serve to the re-exported serve function rather than the
submodule, so mock.patch failed. Patch the module object instead.

Refs #2009

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve MIGRATION_v9_to_v10.md and the create_mcp_server signature
against #2014 and #2015, and update the README, migration notes and
3.3 inventory statements that 3.3-rc.3 has no alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bokelley
bokelley merged commit 7e8d7e4 into next Dec 5, 2026
39 checks passed
@bokelley
bokelley deleted the claude/issue-2009-version-aliases branch December 5, 2026 15:07
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.

1 participant