This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Add CPA auth maintenance queue and harden high-concurrency auth scheduling - #2
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an optional background “auth maintenance” queue to gradually remove invalid/quota-exhausted auth files, and hardens high-concurrency auth scheduling by returning detached auth snapshots and fixing a request-context cancellation race.
Changes:
- Add
AuthMaintenanceConfigto config and implement a background scan/delete loop that disables auths and cleans up token records. - Make auth scheduling safer under concurrency by cloning scheduler picks and decoupling scheduler snapshots from manager state.
- Add stress/maintenance tests (mixed-load maintenance deletion, long-TPM/high-RPM handler stress) plus management API tests for idempotent deletion.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/config/config.go | Exposes AuthMaintenanceConfig via SDK config type alias. |
| sdk/cliproxy/service.go | Implements auth maintenance worker/queue and candidate scanning/deletion helpers. |
| sdk/cliproxy/service_auth_maintenance_test.go | Adds coverage for scan grouping, delete behavior, and mixed-load background maintenance. |
| sdk/cliproxy/auth/types.go | Adds quota StrikeCount field for repeated-429 tracking. |
| sdk/cliproxy/auth/scheduler.go | Returns cloned auth snapshots from scheduler picks to avoid shared mutable state. |
| sdk/cliproxy/auth/scheduler_test.go | Verifies scheduler returns detached clones and manager snapshots don’t mutate scheduler state. |
| sdk/cliproxy/auth/conductor.go | Adds retry safety cap, strike count propagation, and detaches scheduler upserts from manager state. |
| sdk/cliproxy/auth/conductor_overrides_test.go | Extends retry-limit tests and covers new safety cap behavior. |
| sdk/api/handlers/handlers.go | Fixes a context cancellation goroutine race by avoiding capturing a mutable ctx variable. |
| sdk/api/handlers/openai/openai_responses_stress_test.go | Adds high-concurrency/large-payload stress test for OpenAI responses handler. |
| internal/config/config.go | Adds auth-maintenance config block, defaults, and status-code normalization. |
| internal/config/auth_maintenance_test.go | Tests status code normalization (preserves 429, dedupes, filters invalid). |
| internal/api/handlers/management/auth_files.go | Uses manager lookup helpers and makes delete idempotent when auth exists but file is missing. |
| internal/api/handlers/management/auth_files_delete_test.go | Adds tests for idempotent delete and concurrent delete storms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Testing
go test ./sdk/api/handlers/openai ./sdk/cliproxy ./sdk/cliproxy/auth ./internal/config ./internal/api/handlers/managementgo test -race ./sdk/api/handlers/openaigo test -race ./sdk/cliproxy/authgo test -race -v ./sdk/cliproxy -run TestAuthMaintenanceBackgroundQueue_MixedLoadGraduallyRemoves401And429