Repository navigation
fix(quota): keep credit-backed accounts usable - #764
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Hermes review found one blocker before merge:
Reproducer on the PR merged onto current uv run python - <<'PY'
from app.db.models import Account, AccountStatus, UsageHistory
from app.modules.accounts.mappers import _effective_status_from_usage
acc = Account(id='a', email='[email protected]', status=AccountStatus.QUOTA_EXCEEDED, reset_at=1700003600)
primary = UsageHistory(account_id='a', window='primary', used_percent=40.0, reset_at=None, window_minutes=300)
secondary = UsageHistory(account_id='a', window='secondary', used_percent=100.0, reset_at=1700003600, window_minutes=10080, credits_has=False, credits_unlimited=False, credits_balance=25.0)
print(_effective_status_from_usage(acc, primary, primary.used_percent, secondary, secondary.used_percent).value)
PY
# => quota_exceededExpected: propagate the same usable-credit snapshot into the account-summary effective-status path (and add a regression test) so credit-backed accounts are not displayed/treated as quota-exceeded there while the proxy path considers them active. |
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Merge-gate hold: code/CI/Codex look good, but this changes quota/status behavior for credit-backed accounts and the PR has no active Please add the OpenSpec delta, or explicitly waive the OpenSpec gate for this small bugfix. Code-wise I did not find a remaining blocker; the previous status/dashboard mismatch appears addressed. |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Keep credit-backed accounts available when their secondary usage window is exhausted but usable credits remain. Apply the same credit-aware quota interpretation to proxy selection and account-summary status mapping while preserving primary-window rate-limit precedence and paused/deactivated states. Includes regression tests and OpenSpec coverage for the behavior.
Summary
Revives the useful quota-handling slice of #237 on a maintainer-owned branch because the original PR head has
maintainerCanModify=false.Credit: original implementation by @mws-weekend-projects in #237; this branch keeps only the current-main-compatible credit-backed quota fix.
Validation
uv run pytest tests/unit/test_load_balancer.py -qpassed: 67 passeduv run ruff check app/core/usage/quota.py app/modules/proxy/load_balancer.py tests/unit/test_load_balancer.pypasseduv run ty check app/core/usage/quota.py app/modules/proxy/load_balancer.py tests/unit/test_load_balancer.pypassedgit diff --check origin/main..HEADpassedRevives #237