Skip to content

feat(proxy): restore opportunistic traffic class on main - #716

Merged
Soju06 merged 138 commits into
Soju06:mainfrom
Komzpa:fix/opportunistic-traffic-class-main
Jun 4, 2026
Merged

Soju06 merged 138 commits into
Soju06:mainfrom
Komzpa:fix/opportunistic-traffic-class-main

Conversation

@Komzpa

@Komzpa Komzpa commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This is the consolidated routing/quota/account-dashboard branch rebased onto current main.

The branch keeps the original opportunistic traffic-class restoration and folds the overlapping routing/quota work that was otherwise split across several open PRs. The goal is one reviewable main-based PR for account identity, additional-quota routing, sticky/fill-first selection, manual account routing policy, reset-window preference, single-account/drain behavior, security-work account authorization, live credits display, and quota phase planning.

Current head: 3a8c639b41793a33bbb56b926ada4300d32d3fa3
Base head: 47b0c3624faf9c40211cbf52957d91ddce4bb5cb
Current CI: https://github.com/Soju06/codex-lb/actions/runs/26843390719

Folded here:

Issue relationships:

Kept separate:

Latest rebase/follow-up fixes:

  • Merged current origin/main into the PR branch and resolved backend/frontend/test conflicts.
  • Preserved main's account workspace/auth cache behavior while keeping the PR routing and split-threshold settings.
  • Kept request-log failure metadata and traffic-class logging on a single RequestLog.request_kind column.
  • Added a quota planner OpenSpec change covering the new warmup/cancel state transition guarantees.
  • Changed quota warmup so a planned decision is claimed as executing before synthetic traffic/API-key reservation, and final writes only complete an executing decision.
  • Changed cancel behavior so already executing decisions are reported as not_cancelable instead of being rewritten under the warmup worker.
  • Added a no-op Alembic merge revision so the rebased branch upgrades to a single current head.
  • Added missing all-contributors entries for PR commit authors required by the repository attribution check.
  • Added automatic remap support for the legacy live aggregate revision 20260525_000000_merge_routing_settings_security_heads.
  • Tolerated the known legacy live SQLite drift for request_logs.slim_summary_json and sticky-threshold REAL/Float affinity after migration.
  • Repaired stale frontend tests for the unified account auth export hook and full settings save payload.
  • Mirrored the canonical request_logs.request_kind backfill/default/non-null behavior in the quota-planner migration when that column is missing or was created earlier by a parallel branch.
  • Kept quota-planner downgrade from dropping the canonical request_kind column.

Validation

Local validation after the rebase/fix:

  • uv run pytest tests/integration/test_quota_planner_api.py -q (16 passed)
  • uv run pytest tests/integration/test_settings_api.py tests/integration/test_proxy_chat_completions.py tests/unit/test_limit_warmup.py tests/unit/test_proxy_http_bridge.py tests/unit/test_proxy_utils.py -q (622 passed)
  • uv run openspec validate --all --strict (48 passed, 0 failed)
  • uv run ruff check app tests
  • uv run ty check app tests
  • uv run pytest tests/integration/test_quota_planner_api.py tests/unit/test_limit_warmup.py -q (28 passed)
  • bun run typecheck
  • bun run test src/features/settings/components/routing-settings.test.tsx src/features/settings/schemas.test.ts src/features/settings/payload.test.ts src/features/accounts/components/account-list-item.test.tsx src/features/accounts/components/account-actions.test.tsx src/features/accounts/components/account-detail.test.tsx src/features/accounts/hooks/use-accounts.test.ts src/features/accounts/schemas.test.ts src/test/mocks/handler-coverage.test.ts (9 test files passed, 52 tests passed)
  • make lint
  • make migration-check
  • python .github/scripts/check_all_contributors.py
  • make frontend-lint
  • make frontend-test (81 test files passed, 500 tests passed)
  • uv run pytest tests/unit/test_db_migrate.py::test_check_schema_drift_ignores_legacy_live_extra_request_log_column tests/unit/test_db_migrate.py::test_check_schema_drift_ignores_sqlite_real_float_reflection_for_sticky_thresholds tests/unit/test_db_migrate.py::test_check_schema_drift_detects_rogue_table tests/unit/test_db_migrate.py::test_run_upgrade_auto_remaps_legacy_routing_security_merge_head -q (4 passed)
  • uv run pytest tests/unit/test_db_migrate.py::test_check_schema_drift_ignores_sqlite_real_float_reflection_for_sticky_thresholds tests/unit/test_db_migrate.py::test_check_schema_drift_detects_rogue_table -q (2 passed)
  • uv run pytest tests/unit/test_quota_planner.py tests/integration/test_quota_planner_api.py -q (28 passed)
  • uv run ruff check app/modules/quota_planner/logic.py tests/unit/test_quota_planner.py
  • uv run ty check app/modules/quota_planner tests/unit/test_quota_planner.py
  • uv run pytest tests/unit/test_db_migrate.py::test_quota_planner_migration_repairs_preexisting_request_kind_column -q (1 passed)
  • uv run pytest tests/unit/test_db_migrate.py -q (35 passed)
  • uv run ruff check app/db/alembic/versions/20260520_030000_add_quota_planner.py tests/unit/test_db_migrate.py
  • uv run ruff format --check .
  • uv run ty check app/db/alembic/versions/20260520_030000_add_quota_planner.py tests/unit/test_db_migrate.py
  • uv run pytest tests/unit/test_quota_planner.py tests/integration/test_quota_planner_api.py -q (28 passed)

GitHub CI is green for the current head after the request-kind migration follow-up commit. The repository label synchronizer has also proved green current-head CI plus a clean current-head Codex review, so the PR currently carries 🤖 codex: ok.

@Komzpa
Komzpa force-pushed the fix/opportunistic-traffic-class-main branch from 42a6cff to 5a3b7be Compare May 19, 2026 19:37

@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: 42a6cff511

ℹ️ 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/proxy/load_balancer.py Resolved
@Komzpa

Komzpa commented May 19, 2026

Copy link
Copy Markdown
Collaborator Author

@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: 5a3b7be84f

ℹ️ 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/proxy/load_balancer.py Resolved
@Komzpa
Komzpa force-pushed the fix/opportunistic-traffic-class-main branch 3 times, most recently from fa13a43 to bad03a4 Compare May 20, 2026 13:57
@Komzpa

Komzpa commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

@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: bad03a4b42

ℹ️ 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/proxy/load_balancer.py Resolved
@Komzpa
Komzpa force-pushed the fix/opportunistic-traffic-class-main branch from bad03a4 to f411de9 Compare May 20, 2026 15:50
@Komzpa

Komzpa commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

@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: f411de94d3

ℹ️ 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/proxy/load_balancer.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label May 20, 2026
@Komzpa
Komzpa force-pushed the fix/opportunistic-traffic-class-main branch from f411de9 to 7327639 Compare May 20, 2026 16:27
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label May 20, 2026
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 21, 2026
@Komzpa
Komzpa force-pushed the fix/opportunistic-traffic-class-main branch 2 times, most recently from b8c5b02 to 7f80220 Compare May 21, 2026 10:27
@Soju06

Soju06 commented May 21, 2026

Copy link
Copy Markdown
Owner

@codex review

1 similar comment
@Soju06

Soju06 commented May 21, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

ℹ️ 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 Komzpa added 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: needs work [@codex review] raised an issue labels May 21, 2026
@Soju06 Soju06 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: ok [@codex review] says no issues found. labels May 21, 2026
@Komzpa Komzpa added 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: needs work [@codex review] raised an issue labels May 21, 2026
@Soju06 Soju06 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: ok [@codex review] says no issues found. labels May 21, 2026
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@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: 4f2342ca1e

ℹ️ 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/quota_planner/logic.py Resolved
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

@Komzpa

Komzpa commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up on the remaining comments/blockers for current head 8416af916eb3e93e3c00ee7ffe8e0ed8b1324cf2:

  • The warmup decision race is addressed: planned warmups are claimed as executing before synthetic traffic/API-key reservation, final writes are conditional on the executing state, and cancel reports already executing decisions as not_cancelable.
  • The quota planner behavior now has an OpenSpec change folder, and uv run openspec validate --all --strict passes.
  • The branch is rebased onto current main; GitHub reports merge state CLEAN.
  • The current-head Codex quota-forecast thread about normal request logs is fixed by 8416af91 and resolved. Forecast demand now accepts current request_kind="normal" proxy history while still excluding warmup rows.

Current CI is green: https://github.com/Soju06/codex-lb/actions/runs/26836346731

@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: 8416af916e

ℹ️ 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 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@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: 72822c1862

ℹ️ 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/proxy/load_balancer.py Resolved
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

1 similar comment
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@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: cbb996d4c4

ℹ️ 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/proxy/service.py Resolved
Comment thread app/modules/proxy/service.py Resolved
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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 commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Hermes follow-up on current head 3a8c639b41793a33bbb56b926ada4300d32d3fa3: I don't see a code/test blocker in the folded routing/quota implementation, but the issue-closing claim still looks too broad.

The PR body says Closes #428, while #428 asks for manual account priority / ordered fallback, including an operator-defined sequence like A → B → C. The folded add-manual-account-routing-policy OpenSpec only defines three coarse policy tiers: per-account normal, burn_first, and preserve, plus additional-quota overrides (openspec/changes/add-manual-account-routing-policy/specs/account-routing/spec.md). That covers a useful burn/preserve fallback subset, but it does not implement an arbitrary manual priority order or drag/drop ordered account list.

Please either:

@Soju06

Soju06 commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Follow-up fixed and merged.

  • Updated the PR body from Closes #428 to partial issue wording: Addresses part of #428.
  • Removed hermes: needs-followup after the metadata blocker was addressed.
  • Pre-merge gates were clean: MERGEABLE/CLEAN, no pending/failing checks, 🤖 codex: ok, zero unresolved review threads.
  • Squash-merged as 52445aa70b700e08875c70dadcac18bdb92bdb04.
  • Feature request: allow manual account priority / ordered fallback routing #428 remains open for the remaining arbitrary ordered-priority fallback scope.

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

Labels

🤖 codex: ok [@codex review] says no issues found. 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.

6 participants