Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,20 @@ export function ProviderCapacityQuota({ report, pending }: { report: ProviderQuo
<div className="pws-capacity-incomplete">
{t("pws.capacity.incomplete", {
excluded: aggregation.excludedAccounts,
unknown: aggregation.unknownPlanAccounts,
})}
</div>
)}
{/*
Separate from the exclusion notice on purpose (#3155). An uncalibrated plan is
COUNTED, at the baseline seat weight, so folding it into "excluded" told an
operator their Premium seat was missing from a report that in fact included it.
What is true is narrower: the estimate is conservative for that seat.
*/}
{aggregation && aggregation.unknownPlanAccounts > 0 && (
<div className="pws-capacity-incomplete">
{t("pws.capacity.uncalibratedPlan", { count: aggregation.unknownPlanAccounts })}
Comment on lines +143 to +145

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not label excluded unknown-plan accounts as counted

When an uncalibrated account is paused, needs reauthentication, lacks quota, or has stale quota, unknownPlanAccounts is still incremented before the source excludes it from every window; nevertheless, this component tells the operator that every account in that count "is counted at the baseline seat weight." The coverage-only fixture demonstrates the contradiction with includedAccounts: 0 and unknownPlanAccounts: 1. Track included uncalibrated accounts separately or use wording that does not claim all of them contributed.

AGENTS.md reference: gui/AGENTS.md:L9-L10

Useful? React with 👍 / 👎.

</div>
)}
{aggregation && aggregation.partialWindowAccounts > 0 && (
<div className="pws-capacity-incomplete">
{t("pws.capacity.partial", { count: aggregation.partialWindowAccounts })}
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,8 @@ export const de: Record<TKey, string> = {
"pws.capacity.currentAccount": "Aktuelles effektives Konto",
"pws.capacity.nextRecovery": "Nächste Kapazitätswiederherstellung",
"pws.capacity.recoveryShare": "+{percent} % Pool-Kapazität",
"pws.capacity.incomplete": "Unvollständige Abdeckung: {excluded} Konten ausgeschlossen, davon {unknown} mit unbekanntem Tarif",
"pws.capacity.incomplete": "Unvollständige Abdeckung: {excluded} Konten ausgeschlossen",
"pws.capacity.uncalibratedPlan": "{count} Konten mit unkalibriertem Tarif werden mit dem Basisgewicht gezählt; diese Schätzung kann daher konservativ sein",
"pws.capacity.partial": "Teilweise Fensterabdeckung: {count} Konten melden nicht jedes angezeigte Limitfenster",
"pws.capacity.windowPartial": "Teilweise",
"pws.capacity.windowPartialA11y": "{window}: unvollständige Kontoabdeckung",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,8 @@ export const en = {
"pws.capacity.currentAccount": "Current effective account",
"pws.capacity.nextRecovery": "Next capacity recovery",
"pws.capacity.recoveryShare": "+{percent}% pool capacity",
"pws.capacity.incomplete": "Incomplete coverage: {excluded} account(s) excluded, including {unknown} unknown plan(s)",
"pws.capacity.incomplete": "Incomplete coverage: {excluded} account(s) excluded",
"pws.capacity.uncalibratedPlan": "{count} account(s) on an uncalibrated plan are counted at the baseline seat weight, so this estimate may be conservative",
"pws.capacity.partial": "Partial window coverage: {count} account(s) do not report every displayed limit window",
"pws.capacity.windowPartial": "Partial",
"pws.capacity.windowPartialA11y": "{window}: incomplete account coverage",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,8 @@ export const fr: Record<TKey, string> = {
"pws.capacity.currentAccount": "Compte effectif actuel",
"pws.capacity.nextRecovery": "Prochaine récupération de capacité",
"pws.capacity.recoveryShare": "+{percent}% de capacité du groupe",
"pws.capacity.incomplete": "Couverture incomplète : {excluded} compte(s) exclus, dont {unknown} forfait(s) inconnu(s)",
"pws.capacity.incomplete": "Couverture incomplète : {excluded} compte(s) exclus",
"pws.capacity.uncalibratedPlan": "{count} compte(s) sur un forfait non calibré sont comptés au poids de siège de base ; cette estimation peut donc être prudente",
"pws.capacity.partial": "Couverture partielle des fenêtres : {count} compte(s) ne signalent pas toutes les fenêtres de limite affichées",
"pws.capacity.windowPartial": "Partielle",
"pws.capacity.windowPartialA11y": "{window} : couverture incomplète des comptes",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,8 @@ export const ja: Record<TKey, string> = {
"pws.capacity.currentAccount": "現在の有効アカウント",
"pws.capacity.nextRecovery": "次の容量回復",
"pws.capacity.recoveryShare": "+{percent}% のプール容量",
"pws.capacity.incomplete": "対象範囲が不完全です: {excluded} 件を除外(不明なプラン {unknown} 件)",
"pws.capacity.incomplete": "対象範囲が不完全です: {excluded} 件を除外",
"pws.capacity.uncalibratedPlan": "未校正プランの {count} 件は基準シート重みで計上されるため、この推定値は控えめになる場合があります",
"pws.capacity.partial": "一部の期間の対象範囲が不完全です: {count} 件のアカウントでは表示中のすべての制限期間を取得できません",
"pws.capacity.windowPartial": "一部のみ",
"pws.capacity.windowPartialA11y": "{window}: アカウントの対象範囲が不完全です",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,8 @@ export const ko: Record<TKey, string> = {
"pws.capacity.currentAccount": "현재 유효 계정",
"pws.capacity.nextRecovery": "다음 용량 회복",
"pws.capacity.recoveryShare": "+{percent}% 풀 용량",
"pws.capacity.incomplete": "불완전한 범위: {excluded}개 계정 제외, 알 수 없는 요금제 {unknown}개 포함",
"pws.capacity.incomplete": "불완전한 범위: {excluded}개 계정 제외",
"pws.capacity.uncalibratedPlan": "보정되지 않은 요금제 {count}개는 기본 좌석 가중치로 계산되어, 이 추정치가 실제보다 낮을 수 있습니다",
"pws.capacity.partial": "일부 기간의 범위가 불완전합니다: {count}개 계정에서 표시된 모든 한도 기간을 확인할 수 없습니다",
"pws.capacity.windowPartial": "일부만",
"pws.capacity.windowPartialA11y": "{window}: 계정 범위가 불완전합니다",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,8 @@ export const ru: Record<TKey, string> = {
"pws.capacity.currentAccount": "Текущая активная учётная запись",
"pws.capacity.nextRecovery": "Следующее восстановление ёмкости",
"pws.capacity.recoveryShare": "+{percent}% ёмкости пула",
"pws.capacity.incomplete": "Неполное покрытие: исключено аккаунтов: {excluded}, в том числе с неизвестным планом: {unknown}",
"pws.capacity.incomplete": "Неполное покрытие: исключено аккаунтов: {excluded}",
"pws.capacity.uncalibratedPlan": "Аккаунтов с некалиброванным планом: {count}. Они учитываются с базовым весом места, поэтому оценка может быть заниженной",
"pws.capacity.partial": "Частичное покрытие окон: для {count} аккаунтов доступны не все показанные окна лимитов",
"pws.capacity.windowPartial": "Частично",
"pws.capacity.windowPartialA11y": "{window}: неполное покрытие аккаунтов",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,8 @@ export const tr: Record<TKey, string> = {
"pws.capacity.currentAccount": "Mevcut geçerli hesap",
"pws.capacity.nextRecovery": "Sonraki kapasite yenilenmesi",
"pws.capacity.recoveryShare": "+%{percent} havuz kapasitesi",
"pws.capacity.incomplete": "Kısmi pencere kapsamı ({unknown} bilinmeyen, {excluded} hariç tutuldu)",
"pws.capacity.incomplete": "Kısmi pencere kapsamı ({excluded} hariç tutuldu)",
"pws.capacity.uncalibratedPlan": "Kalibre edilmemiş plandaki {count} hesap temel koltuk ağırlığıyla sayılır; bu tahmin ihtiyatlı olabilir",
"pws.capacity.partial": "Kısmi ({count} hesap kota metriği bildiriyor)",
"pws.capacity.windowPartial": "Kısmi",
"pws.capacity.windowPartialA11y": "{window}: eksik hesap kapsamı",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,8 @@ export const zhTW: Record<TKey, string> = {
"pws.capacity.currentAccount": "目前有效帳號",
"pws.capacity.nextRecovery": "下一次容量復原",
"pws.capacity.recoveryShare": "+{percent}% 帳號池容量",
"pws.capacity.incomplete": "覆蓋不完整:已排除 {excluded} 個帳號,其中 {unknown} 個方案未知",
"pws.capacity.incomplete": "覆蓋不完整:已排除 {excluded} 個帳號",
"pws.capacity.uncalibratedPlan": "{count} 個帳號使用未校準方案,以基準席次權重計入,因此此估算可能偏保守",
"pws.capacity.partial": "部分視窗覆蓋:{count} 個帳號未回報所有顯示的限額視窗",
"pws.capacity.windowPartial": "部分",
"pws.capacity.windowPartialA11y": "{window}:帳號覆蓋不完整",
Expand Down
3 changes: 2 additions & 1 deletion gui/src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,8 @@ export const zh: Record<TKey, string> = {
"pws.capacity.currentAccount": "当前有效账户",
"pws.capacity.nextRecovery": "下一次容量恢复",
"pws.capacity.recoveryShare": "+{percent}% 账户池容量",
"pws.capacity.incomplete": "覆盖不完整:已排除 {excluded} 个账户,其中 {unknown} 个套餐未知",
"pws.capacity.incomplete": "覆盖不完整:已排除 {excluded} 个账户",
"pws.capacity.uncalibratedPlan": "{count} 个账户使用未校准套餐,按基准席位权重计入,因此该估算可能偏保守",
"pws.capacity.partial": "部分窗口覆盖不完整:{count} 个账户未报告所有显示的限额窗口",
"pws.capacity.windowPartial": "部分",
"pws.capacity.windowPartialA11y": "{window}:账户覆盖不完整",
Expand Down
8 changes: 6 additions & 2 deletions gui/tests/provider-capacity-shell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ test("provider quota fetch preserves aggregate capacity through shell state and
expect(text).toContain("31% used");
expect(text).toContain("Current effective account · pro");
expect(text).toContain("8%");
expect(text).toContain("Incomplete coverage: 1 account(s) excluded, including 1 unknown plan(s)");
// #3155 split these: an uncalibrated plan is COUNTED at baseline, so it is no longer
// reported as excluded. The exclusion line now says only what it can prove.
expect(text).toContain("Incomplete coverage: 1 account(s) excluded");
expect(text).toContain("1 account(s) on an uncalibrated plan are counted at the baseline seat weight");
expect(text).toContain("Next capacity recovery");
expect(text).toContain("+19.2% pool capacity");
const expectedRecoveryAt = new Intl.DateTimeFormat("en", {
Expand Down Expand Up @@ -350,7 +353,8 @@ test("coverage-only API report remains visible in the rate-limit overview", asyn

const text = host.textContent ?? "";
expect(text).toContain("OpenAI (Codex login)");
expect(text).toContain("Incomplete coverage: 3 account(s) excluded, including 1 unknown plan(s)");
expect(text).toContain("Incomplete coverage: 3 account(s) excluded");
expect(text).toContain("1 account(s) on an uncalibrated plan are counted at the baseline seat weight");
expect(text).not.toContain("No rate-limit data yet");
expect(text).not.toMatch(/\d+(?:\.\d+)?% used/);
});
Expand Down
38 changes: 34 additions & 4 deletions src/providers/codex-capacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ export const CODEX_CONFIGURED_CAPACITY_WEIGHTS = {
pro: 20,
} as const;

/**
* Weight for a plan the map above has not calibrated.
*
* `CodexAccount.plan` is an unrestricted upstream string and cannot be enumerated: the
* bundled model snapshot alone carries 21 distinct plan names (`edu_plus`, `finserv`,
* `k12`, `quorum`, `self_serve_business_usage_based`, …) against the five listed above.
* Treating an unlisted plan as unknown dropped the account from the estimate entirely and
* reported "incomplete coverage" — which is how a Business seat upgraded to Premium
* disappeared from its own capacity report (#3155), and it was already happening to the
* other sixteen snapshot plans without anyone noticing.
*
* `src/codex/quota.ts` reached the same conclusion about the same field: an allowlist is a
* list of the plans someone remembered. Counting an unfamiliar plan at the baseline seat
* weight — the value `plus`, `team`, and `business` already carry — under-states a large
* seat, which is a visibly conservative estimate. Excluding it silently overstates coverage
* the operator does not have, which is worse.
*
* Uncalibrated plans are still counted in `unknownPlanAccounts` so the estimate's
* uncertainty stays on screen.
*/
export const CODEX_DEFAULT_CAPACITY_WEIGHT = 1;

/** Match the provider-report last-good freshness bound. */
export const CODEX_CAPACITY_MAX_QUOTA_AGE_MS = 30 * 60_000;

Expand Down Expand Up @@ -85,11 +107,17 @@ type MutableWindow = {
oldestUpdatedAt: number;
};

function configuredWeight(plan: unknown): number | undefined {
/** True when this plan has a calibrated weight rather than falling back to the default. */
function isCalibratedPlan(plan: unknown): boolean {
const normalized = codexPlanKey(plan);
return !!normalized && Object.hasOwn(CODEX_CONFIGURED_CAPACITY_WEIGHTS, normalized);
}

function configuredWeight(plan: unknown): number {
const normalized = codexPlanKey(plan);
return normalized && Object.hasOwn(CODEX_CONFIGURED_CAPACITY_WEIGHTS, normalized)
? CODEX_CONFIGURED_CAPACITY_WEIGHTS[normalized as keyof typeof CODEX_CONFIGURED_CAPACITY_WEIGHTS]
: undefined;
: CODEX_DEFAULT_CAPACITY_WEIGHT;
Comment on lines +116 to +120

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the documented unknown-plan behavior

This fallback reverses the published contract in docs-site/src/content/docs/guides/providers.md:35-37, which still says an unknown plan cannot safely contribute and is a reason for incomplete coverage; after this change it contributes at weight 1 and can leave aggregation.incomplete false. Update that section and its translated copies so operators do not interpret the new estimate using the obsolete exclusion semantics.

AGENTS.md reference: AGENTS.md:L343-L344

Useful? React with 👍 / 👎.

}

function normalizedPercent(value: unknown): number | undefined {
Expand Down Expand Up @@ -188,7 +216,9 @@ export function aggregateCodexPoolCapacity(

for (const account of accounts) {
const weight = configuredWeight(account.plan);
if (weight === undefined) unknownPlanAccounts += 1;
// Still reported, so the operator can see the estimate is conservative for this seat —
// but no longer a reason to drop the account from the aggregate (#3155).
if (!isCalibratedPlan(account.plan)) unknownPlanAccounts += 1;
if (account.paused) pausedAccounts += 1;
if (account.needsReauth) reauthAccounts += 1;
const quota = account.quota;
Expand All @@ -204,7 +234,7 @@ export function aggregateCodexPoolCapacity(
const custom = quota?.customWindows ?? [];
const hasQuota = hasKnownQuotaWindow(quota);
if (!hasQuota) missingQuotaAccounts += 1;
if (account.paused || account.needsReauth || weight === undefined || !quota || !hasQuota || !quotaFresh) continue;
if (account.paused || account.needsReauth || !quota || !hasQuota || !quotaFresh) continue;

let contributed = false;
const contributionKeys = new Set<string>();
Expand Down
Loading
Loading