Skip to content

Decouple transports from token lifecycle - #16

Merged
kdubb merged 6 commits into
mainfrom
codex/direct-adapter-security-metadata
Nov 11, 2026
Merged

kdubb merged 6 commits into
mainfrom
codex/direct-adapter-security-metadata

Conversation

@kdubb

@kdubb kdubb commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Transports perform no authentication or authorization by default. Remove token-provider constructor options and authentication-specific replay; requests and responses pass through independently installed adapters. Cancellation-marked errors stop the exchange, retries, and SSE reconnections without authentication classification in the transport.

AuthenticationAdapter remains an optional provider bridge for acquisition, missing-provider checks, and rejection feedback. BearerTokenRejectionAdapter is a separate opt-in response policy: a sent bearer credential plus a 401 Bearer invalid_token challenge cancels the exchange. It does not consume bodies, refresh, or replay, and can follow provider feedback in a response chain. External Auth0 integrations can own both hooks directly. Legacy error-type and automatic-replay parity are intentionally not restored; security-package extraction remains separate work.

Delete the unused AuthenticationRecoveryBudget. HTTPX diagnostics now use bare rethrow when no replacement is needed, preserving exception identity and explicit causes for request adaptation, native send, and response processing. Deliberate credential redaction still replaces unsafe diagnostics. transport_from_settings remains an opt-in provider-composition helper outside the transport.

Validation: Ruff and strict mypy passed; all 1,143 runtime tests passed. New tests cover cause preservation at all three boundaries for cancellation and ordinary errors, plus opt-in rejection filtering without body consumption.

Required by TurnPost/tp-sdk-python#43, pinned to the exact source revision until publication. Ready for review.

Explicit standard composition: StandardAuthenticationAdapter combines credential attachment, missing-provider checks, rejection feedback, and terminal bearer-rejection cancellation using the existing adapter chains. It does not wrap supplied providers, add a cache, acquire eagerly, or own provider/storage shutdown. Applications select TokenManager explicitly for Sunday-managed OAuth caching and renewal. Ordinary transports and direct Auth0 adapters remain independent.

README examples show both generated settings factories and custom transport injection. New tests exercise the same generated operation contract through standard, custom, and unauthenticated transports, including controlled-time expiry/renewal, feedback before cancellation, a later explicit request, missing credentials, and no hidden replay.

Existing settings-based transport helpers now select this complete standard composition. Lower-level AuthenticationAdapter remains available for feedback-only integrations.

The standard composition also enforces explicit bearer rejection cancellation when provider feedback fails. Existing cancellation signals propagate, while temporary acquisition failures remain retryable. This policy remains confined to the opt-in standard adapter; ordinary transports and custom authentication are unchanged. Private per-exchange adapter receipts are detached at native export and diagnostic boundaries. Factory-built SSE requests receive explicit operation bindings before adaptation, while factory-owned bindings survive when the spec omits security.

@kdubb kdubb changed the title Support token-independent HTTPX adapters Decouple transports from token lifecycle Nov 10, 2026
@kdubb
kdubb marked this pull request as ready for review November 11, 2026 15:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T15:32:45.250623Z f02275f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue remains.

Summary

This PR moves authentication policy out of transport execution and into optional adapters.

  • HTTPX transports leave authentication and retries to selected adapters.
  • Settings-based transports can opt into standard provider authentication.
  • A bearer rejection adapter can stop matching unauthorized exchanges.
  • HTTPX diagnostics keep original errors unless credentials need redaction.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Build request with operation bindings] --> B[Request adapters]
  B --> C[HTTPX send]
  C --> D[Response adapters]
  D --> E{Cancellation raised?}
  E -- Yes --> F[Close response and stop]
  E -- No --> G[Return or stream response]
  G --> H[Diagnostic copy without private receipts]
Loading

Reviews (2) · Last reviewed commit: "Preserve explicit rejection policy and p..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a776db144a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sunday/httpx/_diagnostics.py Resolved
Comment thread src/sunday/httpx/_sse.py Resolved
@kdubb
kdubb merged commit e0ce179 into main Nov 11, 2026
6 checks passed
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