feat(strategy): add quota-awareness to hybrid account selection

The hybrid strategy now considers account quota levels when selecting
accounts, preventing any single account from being drained to 0%.

- Add QuotaTracker class to track per-account quota levels
- Exclude accounts with critical quota (<5%) from selection
- Add quota component to scoring formula (weight: 3)
- Fall back to critical accounts when no alternatives exist
- Add 18 new tests for quota-aware selection

Scoring formula: Health×2 + Tokens×5 + Quota×3 + LRU×0.1

An attempt at resolving  badrisnarayanan/antigravity-claude-proxy#171
This commit is contained in:
jgor20
2026-01-21 11:15:38 +00:00
parent e51e3ff56a
commit 2f5babba99
5 changed files with 422 additions and 7 deletions

View File

@@ -34,6 +34,12 @@ const DEFAULT_CONFIG = {
maxTokens: 50, // Maximum token capacity
tokensPerMinute: 6, // Regeneration rate
initialTokens: 50 // Starting tokens
},
quota: {
lowThreshold: 0.10, // 10% - reduce score
criticalThreshold: 0.05, // 5% - exclude from candidates
staleMs: 300000, // 5 min - max age of quota data to trust
weight: 3 // Scoring weight (same scale as health/tokens)
}
}
};