Add routing drain and single-account modes#863
Draft
Rtx09x wants to merge 2 commits into
Draft
Conversation
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Adds dashboard-selectable routing modes for quota control:
sequential_drain: drains lower-capacity accounts first until exhausted.reset_drain: drains accounts whose weekly quota reset is nearest first, while still skipping exhausted primary/weekly windows.single_account: routes eligible proxy traffic through one selected account configured from dashboard settings.Also adds a nullable
dashboard_settings.single_account_idfield, a settings dropdown that appears when single-account routing is selected, and status/settings labels for the new modes.Behavior
Single-account mode scopes normal proxy account selection to the configured account using the existing account selection path, so account status, quota exhaustion, API-key account scope, sticky behavior, and failover error handling remain centralized.
Validation
uv run pytest tests/unit/test_load_balancer.py tests/integration/test_settings_api.py -quv run pytest tests/integration/test_migrations.py::test_run_startup_migrations_drops_accounts_email_unique_with_non_cascade_fks -quv run pytest tests/integration/test_settings_api.py -quv run python -m compileall appnpm run test -- --run src/features/settings/schemas.test.ts src/features/settings/components/routing-settings.test.tsx src/utils/constants.test.ts --pool=threads --maxWorkers=1npm run buildgit diff --check