-
Notifications
You must be signed in to change notification settings - Fork 1.1k
test(oauth): prove the unobservable quorum staleness window is harmless #3533
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -249,6 +249,19 @@ export function getEligibleAnthropicAccounts(now = Date.now()): string[] { | |
| * enough that a login in another window is visible before the operator can switch back and send a | ||
| * prompt, long enough that a burst of requests shares one read. The cache holds a BOOLEAN derived | ||
| * from a count — never a credential, never an account id. | ||
| * | ||
| * Staleness is bounded by consequence, not only by the TTL. Explicit invalidation covers the | ||
| * roster mutations this module can see (rotation, pool-state reset, affinity clear on account | ||
| * removal, manual selection), but not one it cannot: a 401 elsewhere flagging an account | ||
| * `needsReauth` drops the real quorum to one while a cached `true` survives for up to 2s. | ||
| * | ||
| * That window is harmless in both directions, which is why it is left rather than plumbed | ||
| * through the store. A stale `true` only lets the caller ASK for an alternate; | ||
| * `pickAlternateAnthropicAccount` re-reads the roster through `getEligibleAnthropicAccounts`, | ||
| * skips the reauth-flagged account and returns `null`, so the 429 surfaces exactly as it would | ||
| * have. A stale `false` costs one un-rotated 429 and self-corrects on the next read. Neither | ||
| * can dispatch on an unusable credential, which is the only outcome worth adding a store hook | ||
|
Comment on lines
+262
to
+263
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Correct the stale- A stale 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| * to prevent. | ||
| */ | ||
| const QUORUM_CACHE_TTL_MS = 2_000; | ||
|
|
||
|
|
||
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.
When a second login arrives while
falseis cached, every request initialized before the two-second TTL expires receives that cached value atsrc/server/responses/core.ts:3486, leavesanthropicPoolAccountIdnull, and therefore skips the Anthropic rotation arms if it later receives a 429. Under a burst this can strand many requests, not just the single unrotated 429 claimed here, and the added test covers only staletrue. Either invalidate the cache when an Anthropic credential is added or document and test the actual multi-request consequence rather than using this assertion to justify omitting the store hook.Useful? React with 👍 / 👎.