Repository navigation
Description
fix(ai): opendesign quota parseCodingPlanWindows publishes out-of-range remaining raw — "-50 / 100 credits" at 100% used, "150 / 100 credits" at 0% used
Verified 2026-11-06 on origin/main 90453b467f (merge of PR #1874), in a laptop worktree (~/git/probe-2026-11-06-creator-1235, kept). Gates this run: check:workflows, check:gates, check:doc-env-vars GREEN; check:bounded-http 7 / check:numeric-boundaries 3 / check:proto-reads 4 RED = exactly #1724's set — no new drift.
The defect
packages/ai/src/quota/providers/opendesign.ts:78-107 (parseCodingPlanWindows) guards the limit (limit <= 0 entries are dropped, :94 — the #1750 disposition) but never range-checks remainingCredits:
- :99 clamps the derived percent into [0, 100]:
Math.min(100, Math.max(0, (1 - remaining / limit) * 100)) - :104 publishes the raw remaining in the label:
`${remaining} / ${limit} credits`
Percent and label therefore derive from different figures and can contradict each other — the exact failure the window contract's rule 5 (whole-window clamp, #1821, implemented for command-code) exists to prevent: "percent and label derive from one clamped used figure, so they can never contradict each other."
Runtime probe (laptop worktree, probe-quota-caps.ts, kept in the worktree)
Against the real parseCodingPlanWindows imported from main, one 5h window (durationSeconds: 18000, limitCredits: 100, resetsAt: 1893456000):
remainingCredits: -50→ window published:usedPercent: 100,valueLabel: "-50 / 100 credits"— a negative remaining balance rendered to the user.remainingCredits: 150→ window published:usedPercent: 0,valueLabel: "150 / 100 credits"— 0% used alongside a label claiming 150 of 100 credits remain.- Control
remainingCredits: 25→usedPercent: 75,valueLabel: "25 / 100 credits"(correct).
Why it matters
The label is the user-facing figure in the opencode quota output. A negative-remaining label is nonsense on its face, and the over-limit case silently hides a real state: command-code's monthly window hit the same over-included-remaining shape and dispositions it explicitly (#1744: publish at 0% used with the real remaining figure annotated, ${used} / ${included} (${remaining} remaining)), because rollover/promo/higher-tier remaining above the nominal limit is information, not noise. OpenDesign currently gets the worst of both: the percent follows the clamp while the label follows the raw wire, with no annotation explaining the discrepancy.
Acceptance criteria
- Percent and valueLabel derive from one consistent disposition of an out-of-range
remainingCredits— they can never contradict (the fix(ai): command-code quota windows split their out-of-range disposition — percent clamped, label raw; non-positive resetAt published as a 1969/1970 date #1821 rule-5 shape). - Negative remaining never renders as a negative figure in the label (clamp to 0 remaining / 100% used, or an equally explicit disposition).
- Over-limit remaining follows an explicit disposition — the fix(ai): Command Code quota monthly window vanishes when remaining credits exceed the hard-coded 10 included — an over-limit payload reads as 'could not be parsed' #1744 annotation shape (0% used with the real remaining named) or a clamped label — chosen in the fix and pinned by a test; not the current silent raw label.
- Tests pin all three cases (negative, over-limit, in-range control) for
parseCodingPlanWindows; the existing quota suite still passes.
Activity
dezren39 commentedon Nov 6, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 7, 2026
🤖 Agent note · adopted as design phase 3 by repo design architect (opencode pass 2026-11-07)
9 remaining items
developing-today commentedon Nov 8, 2026
🤖 Agent note · picked up
developing-today commentedon Nov 8, 2026
🤖 Agent note · triaged
Merge pull request #2101 from developing-today-forks/queue/12850-1879…