feat(proxy): add opportunistic traffic class#567
feat(proxy): add opportunistic traffic class#567Komzpa wants to merge 10 commits intoSoju06:mainfrom
Conversation
c21f588 to
288ab6a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c21f58874b
ℹ️ 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".
| if _routing_policy(other) == ROUTING_POLICY_PRESERVE: | ||
| if _preserve_allows_opportunistic_burn(other, current, preserve_count=preserve_count): | ||
| return True |
There was a problem hiding this comment.
Treat preserve capacity as foreground in zero-burn eligibility
The zero-burn guard for normal/burn-first accounts only counts preserve peers when _preserve_allows_opportunistic_burn(...) returns true. That conflates “foreground capacity exists” with “preserve is also opportunistically burnable”: a preserve account at its opportunistic floor can still retain foreground reserve, but this code treats it as unavailable and blocks draining expendable accounts to zero. As a result, opportunistic admission can close earlier than intended whenever the only remaining foreground reserve is on preserve accounts.
Useful? React with 👍 / 👎.
1c72cbd to
e4a5f8f
Compare
e4a5f8f to
42d3f9f
Compare
a7adecf to
61cdd1c
Compare
61cdd1c to
8f7a0e2
Compare
Summary
traffic_classwithforegrounddefault andopportunisticrouting./backend-api/codex/opportunistic/admission.Retry-Afterwhen the opportunistic burn window is closed.burn_first,normal, andpreserveaccounts.Stack
codex_spark = burn_firstpolicy are intentionally in feat(accounts): add manual routing policy #553 now, so this PR stays focused on traffic class and admission control.Tests
uv run ty check/home/kom/proj/codex-lb/.venv/bin/python -m ruff check app/core/balancer app/db/models.py app/db/alembic/versions/20260509_000000_add_api_key_traffic_class.py app/modules/api_keys app/modules/proxy/api.py app/modules/proxy/load_balancer.py app/modules/proxy/service.py tests/unit/test_api_keys_service.py tests/unit/test_load_balancer.pyopenspec validate add-opportunistic-traffic-class --strict --no-interactive/home/kom/proj/codex-lb/.venv/bin/python -m pytest tests/unit/test_load_balancer.py tests/unit/test_api_keys_service.py tests/integration/test_load_balancer_integration.py tests/integration/test_settings_api.py tests/integration/test_additional_usage_flow.py tests/integration/test_migrations.py -q/home/kom/proj/codex-lb/.venv/bin/python -m ruff format --check app/core/balancer app/db/models.py app/db/alembic/versions/20260509_000000_add_api_key_traffic_class.py app/modules/api_keys app/modules/proxy/api.py app/modules/proxy/load_balancer.py app/modules/proxy/service.py tests/unit/test_api_keys_service.py tests/unit/test_load_balancer.py && git diff --check