Repository navigation
Description
Problem
packages/ai/src/quota/providers/meta.ts — keyUsageResult (the Meta key-endpoint cross-check, module-private) publishes a window for every subs_usage.window / subs_usage.weekly object that is present, even when the object carries no usable figure at all. An empty window object mints a phantom all-null window, violating window-contract rule 4 (types.ts: "No figure, no window — an empty/all-null/zero-limit window-shaped object publishes no window") and diverging from the codex #1762 disposition for the identical shape ("a window without a usable used_percent carries no quota figure, so it is dropped — an empty window object used to mint a phantom all-null window") and from claude's addWindow guard (percent === null && !valueLabel → no window).
Evidence (verified this run, main 69016ea)
Probe probe-meta-keyusage.ts in laptop worktree ~/git/fleet/probe-2026-11-06-meta-keyusage/wt (detached origin/main), driving the real provider.fetchQuota with a stubbed key-endpoint response and an unreachable CDP base (portal path fails closed, key endpoint answers):
subs_usage: { window: {}, weekly: { used_percent: 25, resets_at: 1893456000 } }→ok: truewith two windows: a phantomrollingwindow (usedPercent: null, remainingPercent: null, windowSeconds: null, resetAt: null, no label) beside the realweeklywindow. The CLI renderer prints this asrolling: unknownnext to real data.subs_usage: { window: {}, weekly: {} }→ok: truewith two all-null windows and no figure anywhere — the result's own no-data branch (Object.keys(windows).length === 0→no-datafailure / post-roll empty state) is bypassed because the phantom keys make the map non-empty.- Control, both windows carrying
used_percent→ both publish normally (unchanged by the fix).
Site: meta.ts keyUsageResult — the rolling block adds windows[...] unconditionally when asObject(subsUsage?.window) is non-null; the weekly block does the same. toUsedPercent already returns null for a missing/unusable percent; the result is never checked.
Why it matters
The key endpoint is the cross-check/fallback for the portal read (session-expired and portal-failure paths): a phantom window there reads as a real (empty) rolling window to the CLI renderer and to downstream quota consumers that group windows by provider, and an all-phantom answer masquerades as a successful quota read instead of the honest no-data/post-roll states the same function already implements.
Acceptance criteria
- A
subs_usagewindow object with no usableused_percentpublishes no window (per window: a missing-figure rolling window drops while a real weekly window still publishes, and vice versa). - When neither window carries a figure, the existing dispositions apply unchanged:
is_subs_active !== true→ theno-datafailure; active → the post-roll empty state. - Windows carrying a figure publish byte-for-byte as today (percent clamping, duration-derived key, reset handling unchanged; the fix(ai): meta quota rolling window keyed only by derived label — a weekly-length rolling window is silently overwritten by the weekly window #1777 key-collision behaviour is out of scope).
- Tests in
packages/ai/test/quota.test.tsdriveprovider.fetchQuotafor the key-endpoint path (empty window + real weekly, both empty, control) and pass; ai typecheck clean.
Activity
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
keyUsageResult) publishes phantom all-null windows for figure-lesssubs_usagewindow objects — verified by probe on main 69016ea (probe-meta-keyusage.ts, laptop worktree ~/git/fleet/probe-2026-11-06-meta-keyusage/wt: emptywindow:{}-> phantom rolling window beside a real weekly; both empty -> ok:true with no figure).dezren39 commentedon Nov 7, 2026
🤖 Agent note · picked up
Merge pull request #1908 from developing-today-forks/creator/1907-met…
dezren39 commentedon Nov 7, 2026
🤖 Agent note · done
keyUsageResultnow drops each key-endpoint window whoseused_percentis unusable; no-data / post-roll dispositions unchanged.