diff --git a/src/providers/codex-capacity.ts b/src/providers/codex-capacity.ts index 2cb2dc4864..be40a2eb60 100644 --- a/src/providers/codex-capacity.ts +++ b/src/providers/codex-capacity.ts @@ -2,6 +2,7 @@ import { codexPlanKey, codexPlanValue } from "../codex/plan"; export const CODEX_CONFIGURED_CAPACITY_WEIGHTS = { plus: 1, + team: 1, business: 1, prolite: 5, pro: 20, diff --git a/tests/provider-capacity.test.ts b/tests/provider-capacity.test.ts index 42508e8d59..a10572f9f8 100644 --- a/tests/provider-capacity.test.ts +++ b/tests/provider-capacity.test.ts @@ -44,6 +44,34 @@ describe("configured-weight Codex pool capacity", () => { expect(aggregateCodexPoolCapacity(rows(9), NOW).quota?.weeklyPercent).toBeCloseTo(39.33333333, 8); }); + test("legacy Team and Business plans share configured weight", () => { + const result = aggregateCodexPoolCapacity([ + account("team", 20, { isMain: true, active: true }), + account("business", 60), + ], NOW); + expect(result.quota?.weeklyPercent).toBe(40); + expect(result.aggregation).toMatchObject({ + includedAccounts: 2, + excludedAccounts: 0, + unknownPlanAccounts: 0, + incomplete: false, + }); + }); + + test("an all-Team pool has complete configured-weight coverage", () => { + const result = aggregateCodexPoolCapacity([ + account("team", 20, { isMain: true, active: true }), + account("team", 60), + ], NOW); + expect(result.quota?.weeklyPercent).toBe(40); + expect(result.aggregation).toMatchObject({ + includedAccounts: 2, + excludedAccounts: 0, + unknownPlanAccounts: 0, + incomplete: false, + }); + }); + test("same-time resets group partial consumed capacity and expose only recovery percent", () => { const result = aggregateCodexPoolCapacity([ account("pro", 25, { weeklyResetAt: NOW + 10_000 }), @@ -66,7 +94,7 @@ describe("configured-weight Codex pool capacity", () => { test("unknown, missing, paused, and reauth rows are excluded with incomplete coverage", () => { const result = aggregateCodexPoolCapacity([ account("pro", 10, { active: true, isMain: true }), - account("team", 50), + account("future-plan", 50), account("plus", undefined), account("prolite", 20, { paused: true }), account("business", 30, { needsReauth: true }), @@ -109,7 +137,7 @@ describe("configured-weight Codex pool capacity", () => { ], NOW); expect(expired.aggregation?.weekly).not.toHaveProperty("nextRecoveryAt"); const fallback = aggregateCodexPoolCapacity([ - account("team", 70, { active: true, isMain: true }), + account("future-plan", 70, { active: true, isMain: true }), account("go", 80), ], NOW); expect(fallback.aggregation).toMatchObject({ @@ -209,7 +237,7 @@ describe("configured-weight Codex pool capacity", () => { const stale = account("pro", 90); stale.quota = { ...stale.quota!, updatedAt: NOW - CODEX_CAPACITY_MAX_QUOTA_AGE_MS - 1 }; const result = aggregateCodexPoolCapacity([ - account("team", 10, { active: true, isMain: true }), + account("future-plan", 10, { active: true, isMain: true }), account("plus", undefined), account("prolite", 20, { paused: true }), account("business", 30, { needsReauth: true }),