Skip to content

Add routing drain and single-account modes - #863

Closed
Rtx09x wants to merge 4 commits into
Soju06:mainfrom
Rtx09x:boobie/routing-drain-single-account
Closed

Rtx09x wants to merge 4 commits into
Soju06:mainfrom
Rtx09x:boobie/routing-drain-single-account

Conversation

@Rtx09x

@Rtx09x Rtx09x commented May 31, 2026

Copy link
Copy Markdown

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_id field, 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 -q
  • uv run pytest tests/integration/test_migrations.py::test_run_startup_migrations_drops_accounts_email_unique_with_non_cascade_fks -q
  • uv run pytest tests/integration/test_settings_api.py -q
  • uv run python -m compileall app
  • npm 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=1
  • npm run build
  • git diff --check

@github-actions github-actions Bot added the db migration PR changes Alembic database migrations; maintainer must coordinate merge order label May 31, 2026
@Komzpa
Komzpa force-pushed the boobie/routing-drain-single-account branch from cf8165a to b30dd7d Compare June 1, 2026 16:54
@Komzpa
Komzpa marked this pull request as ready for review June 1, 2026 16:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b30dd7d708

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

Comment thread app/modules/settings/schemas.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77aa944d5a

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

@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58bacc6b4b

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

Comment thread app/core/balancer/logic.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

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

Komzpa added a commit to Komzpa/codex-lb that referenced this pull request Jun 1, 2026
# Conflicts:
#	app/core/balancer/logic.py
#	app/modules/proxy/load_balancer.py
#	app/modules/proxy/service.py
#	app/modules/settings/api.py
#	app/modules/settings/schemas.py
#	frontend/src/components/layout/status-bar.tsx
#	frontend/src/features/settings/components/routing-settings.tsx
#	frontend/src/features/settings/schemas.test.ts
#	frontend/src/features/settings/schemas.ts
#	frontend/src/test/mocks/handlers.ts
#	frontend/src/utils/constants.test.ts
#	frontend/src/utils/constants.ts
#	tests/integration/test_settings_api.py
@Komzpa

Komzpa commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Folded into #716.

#716 is the surviving main-based routing/quota branch for this bucket. It includes the routing/quota changes from this PR, has current-head CI green, and has a clean current-head Codex review, so this separate PR can be closed to keep the queue reviewable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

db migration PR changes Alembic database migrations; maintainer must coordinate merge order

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants