-
Notifications
You must be signed in to change notification settings - Fork 91
fix(auth): preserve provider-owned credential pools (LAB-100) #1262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
eddieparc
wants to merge
12
commits into
code-yeongyu:main
from
eddieparc:eddieparc/lab-100-claude-provider-resume-regression
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1ba8323
fix(auth): preserve selected Claude OAuth slot (OLI-281)
eddieparc 82efb6e
fix(auth): preserve provider-owned credential pools (LAB-100)
eddieparc e759820
docs(changes): record OAuth pool persistence fix (LAB-100)
eddieparc 6d4b212
fix(auth): merge overlapping provider-owned logins (LAB-100)
eddieparc 968d379
test(auth): assert pinned Claude account projection (LAB-100)
eddieparc 7911433
fix(retry): recover compacted Claude sessions (LAB-100)
eddieparc 471ff05
Merge origin/main into LAB-100 recovery
eddieparc 7197e3c
fix(auth): persist compacted session bindings (LAB-100)
eddieparc 31d3a77
docs(changes): cover fallback restore core seam (LAB-100)
eddieparc 5c587e4
Merge origin/main into LAB-100 recovery
eddieparc 97b3a84
fix(auth): resume through goal continuation suffix (LAB-100)
eddieparc 41aea64
fix(auth): persist closed resident bindings (LAB-100)
eddieparc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import { describe, expect, test } from "vitest"; | ||
| import { InMemoryCredentialStore } from "../src/auth/credential-store.ts"; | ||
| import { listSlots, type PooledCredential } from "../src/auth/pool/slots.ts"; | ||
| import type { AuthInteraction, OAuthCredential } from "../src/auth/types.ts"; | ||
| import { createModels, createProvider } from "../src/models.ts"; | ||
|
|
||
| const PROVIDER_ID = "provider-owned-pool"; | ||
| const EXPIRES = 4_102_444_800_000; | ||
| type ProviderOwnedOAuthCredential = OAuthCredential & PooledCredential; | ||
|
|
||
| function pool(...names: string[]): ProviderOwnedOAuthCredential { | ||
| return { | ||
| type: "oauth", | ||
| access: "managed", | ||
| refresh: "managed", | ||
| expires: EXPIRES, | ||
| accounts: names.map((name) => ({ | ||
| name, | ||
| access: `${name}-access`, | ||
| refresh: `${name}-refresh`, | ||
| expires: EXPIRES, | ||
| source: "login", | ||
| })), | ||
| }; | ||
| } | ||
|
|
||
| function interaction(): AuthInteraction { | ||
| return { | ||
| signal: AbortSignal.timeout(5_000), | ||
| prompt: async () => "unused", | ||
| notify: () => {}, | ||
| }; | ||
| } | ||
|
|
||
| function provider(login: () => Promise<ProviderOwnedOAuthCredential>) { | ||
| return createProvider({ | ||
| id: PROVIDER_ID, | ||
| name: "Provider-owned Pool", | ||
| baseUrl: "https://provider-owned-pool.example", | ||
| auth: { | ||
| oauth: { | ||
| name: "Provider-owned Pool", | ||
| login, | ||
| refresh: async (credential: OAuthCredential) => credential, | ||
| toAuth: async (credential) => ({ apiKey: credential.access }), | ||
| }, | ||
| }, | ||
| models: [], | ||
| api: "openai-responses" as never, | ||
| }); | ||
| } | ||
|
|
||
| function deferred<T>() { | ||
| let settle: ((value: T) => void) | undefined; | ||
| const promise = new Promise<T>((resolve) => { | ||
| settle = resolve; | ||
| }); | ||
| return { | ||
| promise, | ||
| resolve(value: T) { | ||
| if (!settle) throw new Error("deferred resolver was not initialized"); | ||
| settle(value); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| describe("provider-owned pool login persistence", () => { | ||
| test("merges accounts added by overlapping login flows", async () => { | ||
| const entered = deferred<void>(); | ||
| const first = deferred<ProviderOwnedOAuthCredential>(); | ||
| const second = deferred<ProviderOwnedOAuthCredential>(); | ||
| let callCount = 0; | ||
| const store = new InMemoryCredentialStore(); | ||
| const models = createModels({ credentials: store }); | ||
| models.setProvider( | ||
| provider(async () => { | ||
| const call = ++callCount; | ||
| if (call === 2) entered.resolve(); | ||
| return call === 1 ? first.promise : second.promise; | ||
| }), | ||
| ); | ||
| await store.modify(PROVIDER_ID, async () => pool("default")); | ||
|
|
||
| const firstLogin = models.login(PROVIDER_ID, "oauth", interaction()); | ||
| const secondLogin = models.login(PROVIDER_ID, "oauth", interaction()); | ||
| await entered.promise; | ||
| first.resolve(pool("default", "first")); | ||
| second.resolve(pool("default", "second")); | ||
| await Promise.all([firstLogin, secondLogin]); | ||
|
|
||
| const stored = (await store.read(PROVIDER_ID)) as PooledCredential; | ||
| expect(new Set(listSlots(stored).map((slot) => slot.name))).toEqual(new Set(["default", "first", "second"])); | ||
| }); | ||
|
|
||
| test("preserves an explicitly empty provider-owned pool", async () => { | ||
| const store = new InMemoryCredentialStore(); | ||
| await store.modify(PROVIDER_ID, async () => pool("default")); | ||
| const models = createModels({ credentials: store }); | ||
| models.setProvider(provider(async () => pool())); | ||
|
|
||
| await models.login(PROVIDER_ID, "oauth", interaction()); | ||
|
|
||
| const stored = (await store.read(PROVIDER_ID)) as PooledCredential; | ||
| expect(stored.accounts).toEqual([]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/coding-agent/src/core/extensions/builtin/claude-sdk-oauth/changes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The changelog says
/fallback restore"then clears the live fallback state", but restoreFallbackPrimary() restores the model and thinking level without clearing_retryFallback.activeState. After the command, getFallbackStatus() still reports the session active and the state survives until a later turn-boundary revert. Either clear the fallback controller state in the restore path or reword the entry.Prompt for AI agents