Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: adcontextprotocol/adcp-client-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.2.0
Choose a base ref
...
head repository: adcontextprotocol/adcp-client-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.3.0
Choose a head ref
  • 16 commits
  • 39 files changed
  • 3 contributors

Commits on May 12, 2026

  1. fix(server): preserve Starlette lifespan when public_url is callable (#…

    …680)
    
    create_a2a_server returned a raw ASGI callable when public_url was a
    PublicUrlResolver, so the unified-transport composer's
    a2a_inner.router.lifespan_context access raised AttributeError at
    startup and the process exited 0 with no requests served.
    
    Install the per-request card intercept as a Starlette middleware via
    add_middleware so the returned object stays a Starlette app with
    .router intact. The static and None public_url paths are unchanged.
    
    Fixes #676
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    8632847 View commit details
    Browse the repository at this point in the history
  2. fix(compat): extract hostname from brand_manifest URLs with paths (#679)

    strip_url_scheme only stripped the scheme prefix; for URLs like
    "https://acme.com/.well-known/brand.json" it produced
    "acme.com/.well-known/brand.json", which fails BrandReference.domain's
    regex and surfaces as a confusing INVALID_REQUEST[brand.domain] error.
    
    Adds extract_brand_domain() to _url.py — uses urlparse().hostname to
    isolate the hostname, falling back to strip_url_scheme for bare-domain
    inputs (no scheme). Both adapter call sites (get_products.adapt_request
    and _media_buy_helpers.adapt_brand_manifest_to_brand) now use the new
    helper. Regression tests cover the exact URL-with-path case from #677
    and URL-with-port.
    
    Fixes #677
    
    https://claude.ai/code/session_01YX14H75zYWQ1BYuopyUL34
    
    Co-authored-by: Claude <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    6bb2c26 View commit details
    Browse the repository at this point in the history
  3. feat(testing): add SellerTestClient for in-process handler testing (#666

    )
    
    * feat(testing): add SellerTestClient for in-process handler testing
    
    Eliminates the per-test-file boilerplate of constructing JSON-RPC
    envelopes, calling mcp.call_tool(), and extracting adcp_error from
    structuredContent. SellerTestClient.invoke() wraps all three steps
    into a single typed call that returns ToolInvokeResult with a
    .passed property and a typed AdcpErrorPayload.
    
    Refs #662
    
    https://claude.ai/code/session_01VZRaadSyoHDm7CU945e3Ba
    
    * fix(testing): add asyncio.Lock + shape guard to SellerTestClient
    
    - _ensure_mcp now holds asyncio.Lock to prevent double-initialization
      when concurrent coroutines call invoke() before _mcp is set
    - FastMCP return-shape handling now guards against unknown shapes with
      an explicit RuntimeError instead of a silent type: ignore unpack
    - Removes unused # type: ignore[misc] comment flagged by mypy
    
    https://claude.ai/code/session_01VZRaadSyoHDm7CU945e3Ba
    
    * fix(testing): freeze ToolInvokeResult and rename raw to structured_content
    
    ToolInvokeResult is the captured outcome of a single tool call — making it
    mutable invited surprising patterns (the deleted test asserted you could
    mutate adcp_error to flip passed). Match AdcpErrorPayload's frozen=True.
    
    The raw field is structuredContent from FastMCP's call_tool result, not
    the underlying CallToolResult or 2-tuple — rename so adopters reaching
    for an escape hatch get an accurate name.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(testing): address expert review on SellerTestClient
    
    Independent dx-expert + code-reviewer pass surfaced four issues:
    
    - Rename .passed -> .ok. `assert result.passed` inside a pytest function
      reads as a tautology with the test runner's own pass/fail vocabulary;
      .ok is unambiguous before the API is publicly importable.
    - Raise on missing required adcp_error fields. The harness exists to catch
      server non-conformance — silently substituting "UNKNOWN" for a missing
      code hid exactly the spec-violation cases adopters need surfaced.
    - Document the FastMCP-coupling accurately. The 2-tuple success shape is
      produced by this SDK's _AdcpFuncMetadata.convert_result override, not
      the public FastMCP.call_tool contract. Add a defensive plain-dict branch
      so a FastMCP minor-version bump doesn't silently break the harness.
    - Drop two tests that asserted on the private _mcp attribute; testing
      implementation, not behavior.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    ---------
    
    Co-authored-by: Claude <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    965eeda View commit details
    Browse the repository at this point in the history
  4. fix(compat): handle inline BrandManifest object in v2.5 adapters (#685)

    * fix(compat): handle inline BrandManifest object in v2.5 adapters (#684)
    
    Both get_products and create_media_buy adapters only handled the URL
    string branch of v2.5 brand_manifest. The spec defines brand_manifest
    as a oneOf (URL string OR inline BrandManifest object), so inline
    objects were silently dropped — brand was never set, causing confusing
    downstream validation failures.
    
    Add elif isinstance(brand_manifest, dict) branch at both sites: extract
    domain from the object's url field when present; when url is absent
    (spec-valid per brand-manifest.json which only requires name), brand is
    omitted and v3 validation decides. Adds 8 new tests covering the dict
    happy path, no-url pass-through, url-with-path, and brand-wins cases.
    
    https://claude.ai/code/session_01Nz3E58qfSW4X6fdJngTxKt
    
    * fix(compat): guard whitespace-only url in inline BrandManifest dict branch
    
    url.strip() prevents a whitespace-only url (e.g. "   ") from passing the
    truthiness check and producing {"domain": ""} via extract_brand_domain,
    which would hit a noisy v3 validation error instead of the clean silent-skip
    the no-url branch provides.
    
    https://claude.ai/code/session_01Nz3E58qfSW4X6fdJngTxKt
    
    ---------
    
    Co-authored-by: Claude <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    edd7d0a View commit details
    Browse the repository at this point in the history
  5. feat(types): Sequence[T] on response-only list fields for covariant a…

    …doption (#635)
    
    * feat(types): Sequence[T] on response-only list fields for covariant adoption
    
    Adopters who subclass SDK response models and narrow the element type
    (e.g. list[MyPackage] instead of list[Package]) get mypy[assignment]
    errors because list[T] is invariant. Changing affected_packages,
    media_buys, packages (on MediaBuy), and media_buy_deliveries to
    Sequence[T] removes those errors — Sequence is covariant so
    Sequence[MyPackage] is a valid subtype of Sequence[Package].
    
    Response-only fields are safe because adopters receive these, they do
    not construct or mutate them. Request-side list fields (packages/
    creatives on request types) remain list[T] because adopters call
    .append() on those. See issue #624 for the full 4-category analysis.
    
    The rewrite is implemented in post_generate_fixes.py via a new
    rewrite_response_list_to_sequence() function so it re-applies on
    every codegen run and survives schema regeneration.
    
    Closes #624 (Category A)
    
    https://claude.ai/code/session_019aVaC1DXjVH6Kan4gBe1sb
    
    * fix(types): Sequence consistency in ergonomic coercion + import ordering
    
    Fix two issues surfaced in pre-PR expert review:
    
    1. _ergonomic.py was patching media_buy_deliveries back to list[MediaBuyDelivery]
       at import time, overwriting the Sequence[MediaBuyDelivery] annotation set by
       post_generate_fixes.py. The generate_ergonomic_coercion.py generator now
       detects Sequence[T] fields (via updated is_list_of) and emits Sequence[T]
       in the coercion patch, preserving source/runtime consistency. _ergonomic.py
       regenerated to reflect this.
    
    2. Import ordering in generated files: from collections.abc import Sequence was
       inserted after from enum import Enum. Fixed insertion anchor in
       post_generate_fixes.py and corrected the two affected generated files.
    
    https://claude.ai/code/session_019aVaC1DXjVH6Kan4gBe1sb
    
    ---------
    
    Co-authored-by: Claude <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    19be8db View commit details
    Browse the repository at this point in the history
  6. fix(compat): warn when brand_manifest non-standard path is flattened …

    …to domain (#686)
    
    Resolves silent information loss introduced by the v2.5→v3 adapter: a
    brand_manifest URL like https://cdn.acmecorp.com/brand-manifest.json is
    correctly translated to BrandReference.domain but the path is dropped,
    so v3 sellers will attempt https://cdn.acmecorp.com/.well-known/brand.json
    which typically 404s with no signal to the operator.
    
    Both adapter call sites (get_products.adapt_request and
    _media_buy_helpers.adapt_brand_manifest_to_brand) now emit a
    logging.WARNING when urlparse detects a non-standard path. The warning
    is deduplicated per URL via a module-level set so high-RPS buyers do not
    saturate log pipelines. Bare-domain inputs (no scheme, urlparse returns
    hostname=None) are guarded against false positives.
    
    Fixes #683.
    
    https://claude.ai/code/session_01X44xueoHmfHRYeKL8giv2F
    
    Co-authored-by: Claude <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    0568d2e View commit details
    Browse the repository at this point in the history
  7. fix(compat): warn on non-standard brand_manifest path in inline-objec…

    …t branch (#688)
    
    The non-standard-path warning was applied only on the v2.5 brand_manifest
    URL-string branch. The inline BrandManifest object's url field can carry
    the same path (v2.5 spec example points at https://cdn.example.com/brand-manifest.json),
    and the same information loss applies — v3 sellers will fetch the canonical
    {domain}/.well-known/brand.json path and likely 404.
    
    Centralize the warning helper + dedup state in _url.py alongside
    extract_brand_domain so get_products and _media_buy_helpers share one
    implementation. Both adapters now call warn_brand_manifest_path_lossy
    from both the string and the inline-object branches.
    
    Fixes #687
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    840e6b3 View commit details
    Browse the repository at this point in the history
  8. test(compat): autouse fixture + cross-adapter dedup test for brand_ma…

    …nifest warning (#690)
    
    * Autouse fixture in tests/conftest.py clears the v2.5 ``_url._brand_manifest_path_warned``
      set between every test, removing the per-test ``monkeypatch.setattr(...)``
      boilerplate from the 10 existing warning tests. A future test that forgets
      the reset can no longer flake on inherited state.
    
    * New ``test_brand_manifest_dedup_is_cross_adapter`` asserts that the same
      offending URL through ``get_products`` and then ``create_media_buy`` warns
      exactly once per process — documents the shared-state semantic introduced
      in #687 and catches a regression back to per-module dedup.
    
    Fixes #689
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    3a68c3f View commit details
    Browse the repository at this point in the history
  9. refactor(compat): normalize + cap brand_manifest warning dedup (#691)

    Three follow-up nits raised during the brand_manifest cluster reviews,
    combined in one PR since they all touch _url.py:
    
    * Inline the single-call-site ``strip_url_scheme`` as a private ``_bare_domain``
      fallback inside ``extract_brand_domain``. The name reflects the role it
      plays today — a fallback for scheme-less inputs.
    
    * Normalize the dedup key to ``(scheme, netloc, path)`` and strip a single
      trailing slash from the path before the standard-paths check. Query
      strings and fragments are excluded so cache-buster variants of the same
      URL collapse to one dedup slot; ``/.well-known/brand.json/`` is now
      treated the same as the canonical form.
    
    * Cap the dedup set at 1024 entries with clear-on-overflow. Distinct
      brand_manifest URLs per deployment are typically a handful; the cap is
      defense-in-depth against pathological cardinality. Memory stays bounded;
      the same URL may warn again after a full cycle (acceptable — operators
      still see the signal).
    
    Docstring on ``extract_brand_domain`` updated to explain the IPv6 path:
    the helper does not pre-validate, so callers who need DNS-only hostnames
    should regex-check the result. v3 Pydantic validation already produces a
    clear pattern-mismatch error downstream, so no behaviour change is needed.
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    75ef329 View commit details
    Browse the repository at this point in the history
  10. feat(server): boot validator for webhook_signing.supported capability…

    … invariant (#695)
    
    When capabilities.webhook_signing.supported=True, every outbound webhook
    must carry RFC 9421 Signature/Signature-Input headers; a bearer/HMAC
    sender (or a JWK sender whose alg isn't in the advertised algorithms)
    produces silent blackout for any buyer enforcing RFC 9421. New boot
    validator validate_webhook_signing_for_capabilities fails fast in
    create_adcp_server_from_platform with INVALID_REQUEST (terminal) when
    the wired sender is missing, non-JWK, or alg-misaligned. Custom
    Protocol-only supervisors with no introspectable _sender log a WARNING
    so the gap stays observable.
    
    v3 reference seller wires a webhook supervisor via WebhookSender.from_pem
    from ADCP_WEBHOOK_SIGNING_KEY_PATH + ADCP_WEBHOOK_SIGNING_KEY_ID env vars
    (separate from request-signing material per AdCP key-separation), and
    advertises webhook_signing.supported=True with the matching algorithm
    only when the supervisor is wired. WebhookSender exposes
    signs_with_rfc9421 for the validator to read.
    
    Closes #384.
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    7e9a734 View commit details
    Browse the repository at this point in the history
  11. feat(buyer-agent-registry): with_caching factory auto-invalidates on …

    …mutations (#692)
    
    Closes #380.
    
    Adopters wiring `Caching(Pg(...))` today must remember to call
    `cache.invalidate(...)` after every `pg.upsert / set_status / delete`
    or risk serving stale resolutions for up to ttl_seconds. That's a
    real security footgun — an operator suspending an agent expects the
    next dispatch to deny, not to honor a cached "active" entry.
    
    Wire-and-forget path:
    
        pg = PgBuyerAgentRegistry(pool=pool)
        registry = pg.with_caching(ttl_seconds=60)
        serve(buyer_agent_registry=registry, ...)
    
        # Cache auto-invalidates:
        pg.set_status("https://agent/", "suspended")
    
    Implementation:
    
    - PgBuyerAgentRegistry grows `add_mutation_observer(callback)` and a
      `_notify_mutation` fire-and-log helper that runs after each
      successful DB commit. Observer exceptions are logged and swallowed
      so a broken hook can never block a real mutation.
    - New `with_caching(**cache_kwargs)` factory builds a
      CachingBuyerAgentRegistry and registers a `clear_sync` observer.
    - CachingBuyerAgentRegistry exposes `clear_sync()` — sync-callable,
      no event loop required, atomic via GIL on `dict.clear()`. Full-flush
      rather than per-key drop: mutations are admin-rare and the next
      traffic burst rebuilds the working set within TTL.
    
    Adopters with external mutation paths (separate process writing the
    same DB) still have `.invalidate(tenant_id=..., lookup_key=...)` for
    explicit, finer-grained drops.
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    de65957 View commit details
    Browse the repository at this point in the history
  12. feat(testing): add SellerA2AClient for in-process A2A handler testing (…

    …#694)
    
    * feat(testing): add SellerA2AClient for in-process A2A handler testing
    
    Refs #678.
    
    A2A sibling to SellerTestClient. Same call shape (`await client.invoke(skill, payload)`),
    same return type (ToolInvokeResult), but routes through the A2A executor +
    event-queue dispatch path instead of MCP's tool call.
    
    This eliminates the same boilerplate adopters currently rewrite in every A2A
    test file: ADCPAgentExecutor construction, RequestContext + SendMessageRequest
    + DataPart proto plumbing, EventQueueLegacy drain loop, terminal-Task
    projection back to a dict, plus separate handling of the structured (adcp_error
    in DataPart) vs. unstructured (FAILED Task without adcp_error) error paths.
    
    The harness drains the event queue with a bounded loop + per-event timeout so
    a buggy handler that never publishes a terminal event can't hang the test
    runner. Unstructured A2A failures (unknown skill, unparseable message) are
    synthesized into an INTERNAL_ERROR-coded AdcpErrorPayload so callers can
    assert on `result.adcp_error` uniformly across both failure modes.
    
    Explicitly out of scope for this PR (tracked as follow-ups on #678):
    - Push-notification capture sink for asserting on outbound signed webhooks
    - Intermediate-state observation (working/input_required transitions)
    - Task cancellation harness
    
    These depend on the TaskStore + push-notification + middleware hooks
    that are themselves deferred per the framework's A2A adoption roadmap.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * test(testing): validation round-trip on SellerA2AClient
    
    Per PR #694 review: prove the `validation=` parameter actually engages
    the validation hook chain end-to-end, not just that __init__ accepts it.
    
    The stub returns `creative_formats: []` while the spec requires
    `formats`. With validation off (the test default) this passes through;
    with SERVER_DEFAULT_VALIDATION the response-side validator rejects
    and surfaces a structured VALIDATION_ERROR with `side: response` in
    details. Asserting on that proves the harness threads validation
    through the A2A executor's event-queue → terminal-Task path.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    2d1ae2f View commit details
    Browse the repository at this point in the history
  13. feat(adagents): ads.txt MANAGERDOMAIN fallback discovery (#704) (#705)

    * feat(adagents): add ads.txt MANAGERDOMAIN fallback discovery (#704)
    
    Implements RFC 4175: when /.well-known/adagents.json returns 404 on a
    publisher, consult /ads.txt for a MANAGERDOMAIN= directive and attempt
    discovery one hop later on the manager. The fallback only kicks in for
    the directive form — pure-comment lines like `# managerdomain=` are
    rejected — and follows IAB last-wins resolution when a file declares
    multiple MANAGERDOMAIN entries. Manager-domain 404 is a terminal
    failure, not a silent pass.
    
    `AdAgentsValidationResult` and the `DiscoveryMethod` literal are added
    to the public API, exposing which path produced the data (direct,
    authoritative_location, or ads_txt_managerdomain) plus the resolved
    `manager_domain` for diagnostics. `fetch_adagents` transparently
    benefits from the fallback while keeping its dict return shape; callers
    who need provenance use the new `validate_adagents_domain`.
    
    Refs: adcontextprotocol/adcp#4173, adcontextprotocol/adcp#4175
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(adagents): close SSRF + size + redirect-404 gaps on MANAGERDOMAIN fallback
    
    Reviewer follow-ups on #705 / #704:
    
    - SSRF: a publisher-controlled MANAGERDOMAIN=169.254.169.254 (or any
      loopback / private / link-local literal) would have passed
      `_validate_publisher_domain` and forced the SDK into a cross-origin
      HTTPS GET against internal services. The fallback now routes every
      manager domain through `_ensure_safe_manager_domain`, which composes
      the existing `_validate_redirect_url` SSRF gate with the publisher
      domain validator.
    - ads.txt size: the body was passed to `_parse_managerdomains` with no
      cap, so a hostile publisher could force the SDK to buffer arbitrary
      data. Bodies over MAX_ADS_TXT_BYTES (1 MiB) are now discarded.
    - Redirect-target 404: a 404 from a followed authoritative_location
      target previously bubbled up as AdagentsNotFoundError and triggered
      the ads.txt MANAGERDOMAIN fallback on the original publisher, which
      conflates a broken pointer with a missing manifest. It now surfaces
      as AdagentsValidationError so the fallback only fires on the
      publisher's own direct 404.
    
    Also documents the publisher-scope caveat on `validate_adagents_domain`
    — callers wiring `ads_txt_managerdomain` results into authorization
    decisions must verify the manager's adagents.json explicitly scopes
    the source publisher (per the TS reference's `hasExplicitPublisherScope`
    gate). Adding that gate as a default is tracked as a follow-up.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    fddea1a View commit details
    Browse the repository at this point in the history
  14. fix(ci): v3 reference seller storyboard job actually asserts on resul…

    …ts (#693)
    
    * fix(ci): v3 reference seller storyboard job actually asserts on results
    
    Closes #410.
    
    The storyboard-v3-reference-seller job advertised itself as gating
    "every PR's translator-pattern conformance" but ended its storyboard
    invocation with `|| true`, so a failing run silently passed CI. The
    artifact path also pointed at examples/v3_reference_seller/ while the
    file was written to workspace root, so post-mortem inspection landed
    on a warning instead of the actual result.
    
    Three changes:
    
    1. Drop `|| true` from the storyboard invocation. Move into
       examples/v3_reference_seller so the result file matches the
       upload-artifact path.
    2. Add an "Assert storyboard passed" step matching the seller_agent
       job's pattern: overall_status == 'passing' AND controller_detected.
       On failure, dump the full JSON so the PR diagnostic is the raw
       storyboard report, not a partial cat | head -50.
    3. Add an "Assert upstream traffic" step that GETs /_debug/traffic
       and fails if all per-method counts are zero. This is the
       anti-façade gate the issue called for: a seller that returns
       stub data without translating to upstream calls would have passed
       the storyboard but emitted no traffic. The gate makes that mode
       detectable in CI instead of in production.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(v3-ref-seller): admit storyboard credential + emit spec error codes
    
    Brings the v3 reference seller from 12 storyboard failures down to (hopefully)
    0 + #702 (storyboard YAML bug, upstream). Four changes:
    
    1. CI storyboard step gets `--auth dev-bearer-token-acme-1` so the runner's
       requests resolve through PgBuyerAgentRegistry to ba_acme_bearer (seeded in
       seed.py). Without this, 7 storyboard steps fail with PERMISSION_DENIED.
    
    2. update_media_buy validates inputs against the upstream BEFORE bailing
       with UNSUPPORTED_FEATURE. Unknown media_buy_id resolves to MEDIA_BUY_NOT_FOUND
       (via SDK 404 projection on get_order). Unknown package_id resolves to
       PACKAGE_NOT_FOUND. Closes the 2 invalid_transitions storyboard probes that
       asserted on the specific code.
    
    3. create_media_buy gains _reject_unworkable_terms. When a buyer proposes
       measurement_terms.billing_measurement.max_variance_percent <= 0 we raise
       TERMS_REJECTED. Zero variance on third-party measurement is unworkable for
       any real vendor. Closes the measurement_terms_rejected/aggressive_terms
       probe that asserted TERMS_REJECTED.
    
    4. Tests grow three new cases covering the three new error paths, and the
       existing UNSUPPORTED_FEATURE smoke test gains a respx mock for the new
       upstream-existence check.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(v3-ref-seller): wire bearer auth so the registry can resolve credentials
    
    Closes the root-cause behind the 12-failure cluster surfaced by the
    storyboard gate in #410. The v3 reference seller had no bearer auth
    middleware wired in serve(), so every storyboard request arrived with
    ``Authorization: Bearer dev-bearer-token-acme-1`` but the framework
    never extracted it into a credential — BuyerAgentRegistry dispatch
    saw credential=None and returned PERMISSION_DENIED on every call.
    
    Three coordinated changes in app.py:
    
    1. ``_make_validate_token(sessionmaker)`` — async validator that looks up
       a bearer token against the seeded ``BuyerAgent.api_key_id`` column and
       returns a Principal with ``caller_identity=agent_url`` and
       ``metadata={"api_key_id": token}`` so the raw token survives the
       middleware → dispatch handoff.
    
    2. ``_build_context_factory()`` — replaces the simple tenant-pinning
       factory with one that wraps ``adcp.server.auth.auth_context_factory``
       and upgrades the bearer-flow ``adcp.auth_info`` from
       ``credential=None`` to ``credential=ApiKeyCredential(key_id=token)``.
       That's exactly what auth_context_factory's docstring tells adopters
       to do when they wire BuyerAgentRegistry alongside bearer auth.
    
    3. ``serve()`` gains ``auth=BearerTokenAuth(validate_token=...)`` so the
       middleware is actually installed.
    
    With these wired together the storyboard runner's --auth flag finally
    resolves through to ``BuyerAgentRegistry.resolve_by_credential`` and the
    seeded ``ba_acme_bearer`` admits the request. The platform fixes for
    MEDIA_BUY_NOT_FOUND / PACKAGE_NOT_FOUND / TERMS_REJECTED (already in
    this branch) then run for the negative-path probes.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix: pre-load bearer token map at boot + recognize git-merge commits
    
    Two CI failures on commit 1ec1f1a:
    
    1. v3 ref seller boot crashed with TypeError because BearerTokenAuth
       rejects async validators when transport='both' (the A2A leg's
       middleware cannot await). Fix: load the BuyerAgent.api_key_id rows
       into a token-to-Principal map at boot, swap the async DB-lookup
       validator for a sync dict lookup. The bootstrap function does
       schema-create + token-load in the same event loop, disposes the
       engine before returning so uvicorn opens a fresh asyncpg pool.
    
    2. conventional-commits gate rejected commit 63453bb ("Merge branch
       'main' into ...") because the skip regex only matched the
       merge-queue API shape ("Merge <sha> into <sha>"), not the shape
       gh pr update-branch and git merge produce. Widen the regex.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(v3-ref-seller): resolve brand-shaped account references
    
    Closes the ACCOUNT_NOT_FOUND cluster surfaced by the storyboard gate
    after bearer auth started working. The seller previously used
    ExplicitAccounts which requires account.account_id on every request,
    but AdCP storyboards send account: {brand: ..., operator: ...} with
    no account_id during the discover-products phase.
    
    Replace ExplicitAccounts with a custom AccountStore that handles both
    reference shapes:
    
    1. Explicit {account_id} ref - direct lookup against the accounts
       table's account_id column (existing behavior).
    2. Brand-shaped {brand, operator} ref with no account_id - resolve
       to the first active account associated with the authenticated
       buyer agent (via auth_info.principal -> agent_url -> buyer_agent
       row -> first matching account). This is the path AdCP storyboards
       exercise before the buyer has been issued a per-relationship
       account_id.
    
    The row-to-Account projection is factored out so both paths share
    the same upstream-routing metadata stamping (network_code,
    advertiser_id, mock_upstream_url).
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(v3-ref-seller): sync-poll upstream approval so create returns media_buy_id
    
    After bearer auth + AccountStore brand-fallback landed, the storyboard
    gate's remaining 5 create_buy failures all shared the same root cause:
    seller returns Submitted({task_id, status: 'submitted'}) when the upstream
    order lands in pending_approval, and the storyboard validation expects
    media_buy_id in the response body.
    
    The reference seller runs against a fast mock upstream that auto-approves
    in milliseconds, so awaiting the polling synchronously is the right
    behavior for this example. Adopters with slow real-world approvals
    swap to ctx.handoff_to_task(...) per the documented escape hatch.
    
    Tests updated:
    - test_create_media_buy_returns_task_handoff_on_pending_approval renamed
      to test_create_media_buy_sync_polls_to_success_on_pending_approval;
      mocks the task-completion poll and the post-completion order refetch,
      asserts CreateMediaBuySuccessResponse with media_buy_id.
    - test_create_media_buy_raises_when_polling_times_out simplified to
      await directly (no TaskHandoff._fn indirection).
    - test_create_media_buy_raises_when_task_rejected likewise.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(v3-ref-seller): echo packages with minted ids + pending_creatives status
    
    create_media_buy now mints a deterministic package_id per requested
    package and echoes the spec-marked echo fields (targeting_overlay,
    measurement_terms, creative_assignments, etc.) so AdCP storyboards can
    capture packages[0].package_id and verify list-targeting / measurement-
    terms persistence. When the buyer supplies no creatives anywhere, the
    response surfaces status='pending_creatives' so the next step is
    sync_creatives. This unblocks the inventory_list_targeting,
    invalid_transitions, creative_fate_after_cancellation, and
    pending_creatives_to_start storyboard create steps.
    
    * ci(v3-ref-seller): soft-gate residual storyboard failures (#706)
    
    The v3 storyboard runner job now passes 19/25 active steps but reports
    overall_status='partial' on a handful of scenarios that require feature
    work tracked under #706 — update_media_buy operations on persisted
    state, get_media_buys per-package projection, list_accounts/sync_accounts
    (#377), and an upstream storyboard YAML bug (adcp#702). Split the
    assert into a hard gate (runner produced output + controller_detected)
    and a soft gate (overall_status == passing), so the anti-façade work
    in #410 stays enforced while the residuals are tracked openly.
    
    * ci(v3-ref-seller): drop controller_detected gate (translator topology)
    
    controller_detected has never been true for the v3 reference seller's
    translator topology — the runner detects DemoStore overrides only for
    the examples/seller_agent.py stub-mode shape. The previous "Assert
    storyboard passed" step never reached the controller_detected check
    because overall_status != 'passing' tripped first. Splitting the
    asserts surfaced this latent gate as a hard failure even when the
    soft gate is suppressed. Anti-façade enforcement is unchanged: the
    "Assert upstream traffic" step still requires non-zero per-method
    upstream-call counts.
    
    * feat(v3-ref-seller): persist packages upstream + implement update_media_buy
    
    create_media_buy now POSTs each requested package as an upstream line
    item (POST /v1/orders/{id}/lineitems) and returns the line_item_id as
    the AdCP package_id. update_media_buy is no longer UNSUPPORTED_FEATURE:
    cancel / pause / creative-assignment patches are applied to a
    seller-local shadow store (self._buy_state), and creative_assignments
    flow upstream via POST .../lineitems/{li}/creative-attach. get_media_buys
    projects each line item plus its shadow-store entry so list-targeting,
    measurement_terms, and per-package cancel/pause survive create → get.
    Per-buy double-cancel raises NOT_CANCELLABLE.
    
    Unblocks the storyboard residuals tracked in #706: pending_creatives_to_start,
    inventory_list_targeting, invalid_transitions, and creative_fate_after_cancellation.
    
    * fix(v3-ref-seller): filter media_buy_ids + preserve buyer creative_id
    
    get_media_buys now narrows to the requested media_buy_ids when the
    buyer supplies them — without the filter, the response leaks every
    advertiser-scoped buy and the storyboard's media_buys[0] lookup hits
    a different scenario's order. Adds a bidirectional buyer-creative-id ↔
    upstream-creative-id map so sync_creatives can echo the buyer's id on
    list_creatives and update_media_buy can translate before attach_creative
    (the upstream mints cr_<uuid> regardless of client_request_id).
    
    * fix(v3-ref-seller): apply package patches + filter list_creatives
    
    update_media_buy now applies the buyer's package echo fields (targeting_overlay,
    measurement_terms, etc.) to the shadow store using replacement semantics, so
    inventory_list_targeting's swap step reads back the new list_id values.
    list_creatives now honors the request's filters.creative_ids — without the
    filter the storyboard's creatives[0] lookup picks up a different scenario's
    creative.
    
    * feat(v3-ref-seller): re-sync no-op + assignments + allowlist CI gate
    
    sync_creatives now treats a re-sync of a known buyer creative_id as a
    no-op upload (action='unchanged') instead of letting the upstream's
    idempotency-conflict fire. The assignments[] field on the request is
    applied via attach_creative + shadow store, mirroring the path
    update_media_buy uses. Replaces the storyboard's continue-on-error
    soft gate with an explicit allowlist of expected failures — only
    adcp#702 (refine_products) and #377 (account_discovery) are allowed.
    Any new failure fails the job; any allowlisted failure that newly
    passes also fails the job so the list gets pruned as upstream issues
    close.
    
    * feat(v3-ref-seller): sync_accounts/list_accounts via AccountStore (closes #377)
    
    Moves the sync_accounts / list_accounts implementations off the platform
    class (where they were dead code — the framework never dispatched there)
    onto the AccountStore returned by _make_account_store. The framework's
    tool-advertising layer probes platform.accounts.upsert and
    platform.accounts.list as callables; without them every sales-* agent
    silently dropped both tools and the AdCP 3.0.9 §accounts/overview probe
    failed.
    
    upsert(refs, ctx) persists the buyer's AccountReference (full
    billing_entity, bank and all) and returns SyncAccountsResultRow per
    account. The framework projects through to_wire_sync_accounts_row,
    applying the billing_entity.bank write-only strip on emit.
    
    list(filter, ctx) returns Account[TMeta] with the billing_entity
    populated from Postgres; framework's to_wire_account strips bank on
    emit. Per-principal scoping by buyer-agent agent_url is enforced —
    unauthenticated callers see an empty list.
    
    Tests cover both projections end-to-end (bank persists on write, never
    appears on the wire) plus a surface-check that AccountStore exposes
    upsert/list callables.
    
    Drops account_discovery from the storyboard allowlist; allowlist now
    covers only the refine_products feature gap.
    
    * feat(v3-ref-seller): implement refine_get_products (delegates to base fetch)
    
    The reference seller has no pricing / forecasting model upstream — the
    mock-server returns the same product set regardless of refinements.
    The new refine_get_products re-fetches the base product list via
    get_products and reports each refine[] entry as RefinementOutcome
    (status='partial', notes=<no engine>). Adopters with a real forecaster
    swap the outcomes to 'applied' and project pricing changes onto products.
    
    With refine_get_products in place AND sync_accounts/list_accounts on the
    AccountStore from the previous commit, every in-scope storyboard
    scenario passes. Drops the allowlist step in favor of a strict
    overall_status == 'passing' gate.
    
    ---------
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    27a5866 View commit details
    Browse the repository at this point in the history
  15. feat(adagents): add validate_adagents_structure helper (#708)

    * feat(adagents): add validate_adagents_structure helper (#707)
    
    Distinguishes a schema-invalid adagents.json from a valid file that
    doesn't list the caller's agent. get_properties_by_agent() collapses
    both cases into [], which makes "publisher hasn't authorized us yet"
    indistinguishable from "publisher's file is structurally broken" and
    forces callers to inspect entries themselves.
    
    The new validate_adagents_structure(data) -> AdagentsValidationReport
    checks every authorized_agents entry against the AdCP schema's oneOf
    discriminated union (six authorization_type variants, each with a
    required matching selector). Returns per-entry errors with index, url,
    kind, and message — so callers like aao_lookup_service can show
    "publisher's file is invalid" vs "you aren't listed" without
    re-implementing the schema.
    
    The companion helper validate_adagents_domain (network fetch +
    discovery) is unchanged. Naming pairs with that existing function;
    avoids collision with the legacy adcp.validation.validate_adagents.
    
    Closes #707
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * fix(adagents): address expert review of validate_adagents_structure
    
    - Add is_reference flag on AdagentsValidationReport so callers can
      distinguish a legitimate authoritative_location URL-reference file
      from an inline file with zero entries (which is itself invalid).
    - Enforce authorized_agents minItems: 1 on inline variant via new
      empty_authorized_agents error kind (file-level error, index=-1).
    - Tighten authorized_for check to require a non-empty string; previously
      truthy non-strings (e.g., numbers, lists) silently passed.
    - Normalize empty-string url to None so AdagentsEntryError.url is
      always either a usable identifier or None.
    - Export EntryErrorKind from top-level adcp so callers can pattern-match
      exhaustively.
    - Cross-link validate_adagents_structure from fetch_adagents docstring;
      document 3.0 schema target and selector-item validation as
      out-of-scope.
    - Tests: 3 new (authoritative_location is_reference, empty array
      invalid, non-string authorized_for/url) + tighten FrozenInstanceError
      assertion + non-empty fixture for the immutability test.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    * chore: regenerate public API snapshot for new adagents validator exports
    
    Adds AdagentsEntryError, AdagentsValidationReport, EntryErrorKind, and
    validate_adagents_structure to the snapshot — all intentional additions
    in this PR.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
    bokelley and claude authored May 12, 2026
    Configuration menu
    Copy the full SHA
    ccd1955 View commit details
    Browse the repository at this point in the history
  16. chore(main): release 5.3.0 (#682)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored May 12, 2026
    Configuration menu
    Copy the full SHA
    116cddb View commit details
    Browse the repository at this point in the history
Loading