Skip to content

refactor(auth): route OAuth operation locks through one provider table (ENG-1066) - #345

Merged
lg2m merged 2 commits into
refactor/eng-1066-ap1-oauth-helpersfrom
refactor/eng-1066-ap2-refresh-lock
Oct 18, 2026
Merged

lg2m merged 2 commits into
refactor/eng-1066-ap1-oauth-helpersfrom
refactor/eng-1066-ap2-refresh-lock

Conversation

@lg2m

@lg2m lg2m commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

AP2: route OAuth operation locks through one provider table

Spec: docs/plans/auth-providers.md (AP2) Linear: ENG-1066 Stacked on: #343

Behaviour-preserving refactor. No user-visible change.

What changed

  • oauth::OAuthProvider (OpenAI Codex, xAI) owns each provider's credential-name prefix, lock file name and lock-unavailable error.
  • CredentialStore replaces its codex_refresh/xai_refresh mutexes with one per-provider array. CredentialPaths replaces codex_lock_file/xai_lock_file with a per-provider array. One lock_oauth_operation serves login, refresh, rotation and removal. set and remove look up the owning provider instead of trying each prefix in turn, and the refresh paths no longer .expect() on a prefix match.
  • Lock file names (openai-codex.lock, xai.lock) and acquisition order are unchanged: a credential name matches at most one provider.
  • The public CredentialPaths::{codex_lock_file, xai_lock_file} accessors become a crate-private oauth_lock_file(provider). Nothing outside qq-auth used them.

How verified

cargo xtask check

Head f79dfb12514d vs origin/main; 9 changed file(s); scope: qq, qq-auth, qq-harness, xtask.

Gate Result Tests Time Command
fmt pass 1.5s cargo fmt --all -- --check
lint pass 2.0s cargo xtask lint
clippy pass 0.2s cargo clippy --color never -p qq -p qq-auth -p qq-harness -p xtask --all-targets --all-features -- -D warnings
test pass 500/500 passed, 2 skipped 41.4s cargo nextest run --color never --profile default -p qq -p qq-auth -p qq-harness -p xtask

All gates passed in 45.2s.

  • cargo nextest run -p qq-auth: 77/77 before; 79/79 after. Existing tests are unchanged apart from the renamed lock-path accessor.
  • New, per the AP2 acceptance in the plan:
    • oauth_operations_lock_the_published_per_provider_files pins both lock file names and the prefix match.
    • an_xai_refresh_holds_xai_lock_against_a_second_store_rotation shows that a refreshing store holds xai.lock (and not the Codex lock), and that a second store's set waits for it. With the lock removed from set_with_metadata, this test fails ("a second store rotated an xAI credential during its refresh"). It passed 20/20 locally.
  • cargo xtask smoke: 6/6.
  • One gate run hit a timeout in xtask perf::tests::busy_workspace_fixture_seeds_a_long_history (run completion). The host was under load from another workload at the time. The test passed 3/3 in isolation and the gate passed on rerun. This PR doesn't touch xtask.

Compatibility

  • PROTOCOL / DESCRIPTOR / store schema / stored credential format / lock file names: unchanged.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-18T02:20:45.293392Z 4d201f3 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: f79dfb1251

ℹ️ 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".

@lg2m

lg2m commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review
Only change since your 👍 on f79dfb1: merged the base branch (plan-doc edit, docs/plans/auth-providers.md only) in b474a82.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: b474a82fb0

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review
Rebased onto main a9bff3e; this PR's own diff is unchanged (same patch-id) since your 👍.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 8077e32e97

ℹ️ 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".

lg2m added 2 commits October 17, 2026 19:19
…e (ENG-1066)

Slice AP2. CredentialStore kept a process mutex and CredentialPaths a lock
file per OAuth provider, and set/remove probed each provider's lock by name
prefix in turn. An OAuthProvider table now owns the name, lock file name and
lock-unavailable error; one lock_oauth_operation serves logins, refreshes,
rotations and removals. Lock file names and acquisition order are unchanged
(a credential name matches at most one provider). The public
codex_lock_file/xai_lock_file accessors are replaced by a crate-private
oauth_lock_file; nothing outside qq-auth used them.
…NG-1066)

Slice AP2 acceptance. Pin the openai-codex.lock and xai.lock names that
concurrently running QQ versions share, the credential-name prefix match,
and that a second store's rotation of an xAI credential waits for a
refresh in progress. Removing the operation lock from set_with_metadata
fails the second test.
@lg2m
lg2m force-pushed the refactor/eng-1066-ap2-refresh-lock branch from 8077e32 to 4d201f3 Compare October 18, 2026 02:20
@lg2m
lg2m merged commit 92554c9 into main Oct 18, 2026
6 checks passed
@lg2m
lg2m deleted the refactor/eng-1066-ap2-refresh-lock branch October 18, 2026 02:20
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