Repository navigation
Decouple transports from token lifecycle - #16
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no new blocking issue remains. SummaryThis PR moves authentication policy out of transport execution and into optional adapters.
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]
Reviews (2) · Last reviewed commit: "Preserve explicit rejection policy and p..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 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".
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.