Repository navigation
refactor(auth): one OAuth grant contract and device-poll loop for every provider (ENG-1066) - #376
Conversation
…ry provider (ENG-1066)
The Codex token, Codex device and xAI token client traits, and their three
fields on CredentialStore, become one OAuthTransport that every exchange,
refresh, device start and device poll goes through. Codex and xAI keep
only their endpoint specs and response mapping. xAI's device login and
Codex's device flow run on one RFC 8628 poll loop with an injectable
clock, cancellation and sleep. Operation lock files are derived as
{provider}.lock, which keeps openai-codex.lock and xai.lock.
Codex Review SummaryThis 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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1951729cbf
ℹ️ 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".
…NG-1066) A stalled token endpoint could hold an xAI login past its device code's lifetime and end it as a failed request. Each poll now carries the time left as its request timeout, and a poll that runs it out ends the login as AuthorizationTimedOut.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ecd759b6f
ℹ️ 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".
…ep body timeouts (ENG-1066)
OAuthProvider becomes a table of rows (name and lock error), so set,
remove and refresh find a new provider's {provider}.lock from its
credential prefix without per-variant matches. A response body that
stalls past the request timeout is now TransportError::TimedOut instead
of an unreadable body.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54996f1f58
ℹ️ 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".
…deadline errors (ENG-1066) A request's deadline now only shortens the transport's 60-second cap, so a stalled xAI poll with a long device lifetime still fails at the cap. Only a timeout the request's own shorter deadline caused is DeadlineReached; the browser Codex exchange carries none, so a stalled body there is an ordinary exchange failure, not a device-authorization timeout.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a9233445d
ℹ️ 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".
… rejection statuses (ENG-1066) A timeout is DeadlineReached only when the call actually ran out the caller's shorter deadline; a connect-timeout or the transport cap firing first is an ordinary failure. A non-success response keeps its status when its body stalls, so providers map it from the status as before.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Slice AP8 of the auth-providers plan (ENG-1066), after #373.
What changed
No user-visible change. OAuth grants in
qq-authno longer have one client per provider:CodexTokenClient,CodexDeviceClient,XaiTokenClientand their three fields onCredentialStorebecome oneoauth::OAuthTransport(post(OAuthRequest) -> OAuthResponse | TransportError). Every token exchange, refresh, device start and device poll goes through it.OAuthResponsecarries the status and a bounded body (Nonewhen unreadable or oversized).SystemTransportis the HTTPS client from before (https-only, no redirects, same timeouts).codex.rsandxai.rsbuild their requests: Codex sends a form exchange and a JSON refresh, its device endpoints take JSON, and xAI uses forms. Each decodes into its own unchanged error enum, so error variants and text stay the same.oauth::poll_devicetakes an injectable clock, cancellation and sleep, and handles pending, slow_down (+5s, capped), denied, expired, deadline and cancellation. It checks cancellation and the deadline around every wait and poll. xAI'sXaiLogin::completenow runs on it instead of its ownthread::sleeploop. Codex's non-standard device flow (403/404 means pending, then a PKCE exchange) stays a Codex grant: it uses the shared loop for polling and the shared exchange afterwards, with every deadline and cancellation check it had.{provider}.lock(CredentialPaths::provider_lock_file,CredentialStore::lock_provider_file), which reproducesopenai-codex.lockandxai.lock. A new OAuth provider needs no lock definition.CredentialStore::offline()andOfflineTokenCalls(used by the perf fixtures) implement the transport and still count every refused call.Verification
qq-authtests keep their scenarios and assertions. Their fakes keep their names and recorded calls, now as test-only traits behind oneFakeOAuthtransport that decodes each request and encodes the response the real endpoint would send.device_polling_waits_one_interval_per_pending_poll_then_completes,…_slows_down_by_five_seconds_up_to_the_cap,…_reports_denial_and_expiry,…_stops_at_the_deadline_without_oversleeping,…_stops_when_cancelled_without_polling_again,lock_files_are_derived_from_the_provider_name, anda_new_provider_serialises_independent_stores_through_its_derived_lock(afixture-oauthprovider with no legacy file; a second store waits on the derived lock while the legacy locks stay free).oauth_operations_lock_the_published_per_provider_filesstill pins both legacy names.cargo xtask checkpassed;cargo xtask smoke9/9; xtask credential perf fixtures pass.Known differences
xtask/src/legacy-sleeps.txt: one existing entry moved lines; no new sleeps.