Skip to content

chore(decisioning): AuthInfo flat-field synthesis emits DeprecationWarning (#358)#363

Merged
bokelley merged 1 commit intomainfrom
bokelley/v3-tier2-authinfo-deprecation
May 2, 2026
Merged

chore(decisioning): AuthInfo flat-field synthesis emits DeprecationWarning (#358)#363
bokelley merged 1 commit intomainfrom
bokelley/v3-tier2-authinfo-deprecation

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented May 2, 2026

Summary

  • Flat-field synthesis of AuthInfo.credential from kind/key_id/principal/scopes now emits DeprecationWarning. Removal target: adcp 4.5.0.
  • Synthesis still fires for api_key/bearer/oauth so existing adopter code keeps working through 4.4.x.
  • New AuthInfo._from_legacy_dict classmethod for the framework-internal ctx.metadata['adcp.auth_info'] dict path — pre-synthesizes and passes credential= explicitly so the warning isn't fired from framework code (it would point at framework, not adopter code, and be unactionable).
  • The flat fields themselves stay forever (audit/log context); only the synthesis-from-flat path is on the removal track.

Closes #358.

Test plan

  • pytest tests/ — full suite 3032 passed (was 3030; +2 new deprecation tests)
  • pytest -W error::DeprecationWarning tests/test_decisioning_buyer_agent_dispatch.py — all targeted tests use pytest.warns(DeprecationWarning) for the synthesis path; framework-internal _from_legacy_dict does not warn
  • ruff check clean on touched files
  • mypy clean on src/adcp/decisioning/
  • Manual smoke: examples/buyer_agent_registry_sqlalchemy.py runs without warnings (already used the typed ApiKeyCredential form)

🤖 Generated with Claude Code

…rning (#358)

Adopters constructing ``AuthInfo`` with the flat
``kind`` / ``key_id`` / ``principal`` / ``scopes`` fields still get a
typed bearer credential synthesized — and now also see a
DeprecationWarning pointing at the migration path. Synthesis is
removal-tracked for adcp 4.5.0; adopter code constructs the typed
``credential=`` directly going forward.

The flat fields themselves stay (audit / log context); only the
synthesis-from-flat path is on the removal track.

* Refactor synthesis into ``AuthInfo._synthesize_bearer_credential``
  (static helper), reusable from both ``__post_init__`` and the
  framework-internal dict shim.
* New classmethod ``AuthInfo._from_legacy_dict`` pre-synthesizes the
  credential and passes it via ``credential=`` so ``__post_init__``
  skips synthesis (and the warning) when the framework's
  ``_extract_auth_info`` translates ``ctx.metadata['adcp.auth_info']``
  dicts. Pointing the warning at framework code on every request
  would be noise the adopter can't fix by changing their own code.
* ``_extract_auth_info`` now uses ``_from_legacy_dict`` instead of
  inline construction.
* Tests: synthesis tests assert the warning fires via
  ``pytest.warns(DeprecationWarning)``; explicit-credential tests
  assert NO warning fires; new test confirms ``_from_legacy_dict``
  is silent. Incidental synthesis usage in dispatch tests migrated
  to explicit ``credential=ApiKeyCredential(...)`` pattern that
  adopters should follow.

Closes #358.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit dc37318 into main May 2, 2026
12 checks passed
@bokelley bokelley deleted the bokelley/v3-tier2-authinfo-deprecation branch May 2, 2026 19:39
bokelley added a commit that referenced this pull request May 2, 2026
… verifier (#365)

Closes the migration loop the AuthInfo flat-field deprecation
(shipped in #363) points adopters at. The deprecation message says
"use the bundled signed-request verifier middleware" — but the
SDK didn't ship a helper that converts the verifier's
``VerifiedSigner`` output into typed ``AuthInfo`` /
``HttpSigCredential``. Adopters had to construct it themselves.

* Add ``AuthInfo.from_verified_signer(signer, ...)`` classmethod —
  the supported v3 migration target. Takes the ``VerifiedSigner``
  produced by ``adcp.signing.verify_request_signature``, projects
  ``key_id`` / ``verified_at`` / ``agent_url`` into a typed
  ``HttpSigCredential``, and returns ``AuthInfo`` ready for the
  registry dispatch.
* Raises ``ValueError`` when ``signer.agent_url is None`` — the
  verifier wasn't configured to extract the AdCP v3 agent_url
  claim, and the registry has no key to dispatch on. Server-boot
  error rather than silent dispatch fallthrough.
* Three new tests: typed projection roundtrip, missing-agent_url
  rejection, end-to-end VerifiedSigner → AuthInfo → registry
  resolves. No deprecation warning fires on the supported path.

Adopter Flask middleware migrates from::

    AuthInfo(kind="signed_request", key_id=signer.key_id, ...)

to::

    AuthInfo.from_verified_signer(signer, scopes=...)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

chore(decisioning): AuthInfo migration to kind-discriminated credential variant

1 participant