Repository navigation
Description
Summary
The Mistral quota budget parser (packages/ai/src/quota/providers/mistral.ts, parseBudget, mistral.ts:70-82) clamps usedPercent into [0, 100] but derives usedAmount from the unclamped percentage, so the two fields of the same window disagree whenever the console reports a percentage outside [0, 100]. The published valueLabel is built from the amount (budgetWindow, mistral.ts:96-104: $<usedAmount> / $<budgetAmount>), so the quota row can show e.g. 100% used alongside "$150.00 /
Evidence (verified this run, main 6c0063e)
Probe on the laptop (worktree of origin/main) importing the exported parseMistralBudget:
usage_percentage: 150, initial_budget: 100→{ usedPercent: 100, usedAmount: 150, budgetAmount: 100 }— percent clamped, amount not.usage_percentage: -20, initial_budget: 50→{ usedPercent: 0, usedAmount: -10, budgetAmount: 50 }— a negative dollar figure reachesformatMoneyand the valueLabel.- Control,
usage_percentage: 25, initial_budget: 100→{ usedPercent: 25, usedAmount: 25 }— consistent, as expected.
Code: mistral.ts:76-77 — usedPercent: Math.min(100, Math.max(0, usedPercent)) sits directly above usedAmount: (usedPercent / 100) * budgetAmount, where usedPercent is still the raw parsed value.
Why it matters
The Mistral console read is the only quota surface for the Mistral/Vibe account (the provider's own header comment: no API-key usage endpoint exists). The dollar label is what a reader uses to judge spend against budget; a label that contradicts the window's own percentage — or shows negative dollars — erodes trust in the one number the pool-rotation decisions read. Note the deliberate contrast with Turso, where over-100% is a published real state (turso.ts, code#6227): Mistral's parser already made the opposite disposition (clamp the percent) — the amount simply doesn't follow it.
Acceptance criteria
-
usedAmountis derived consistently with the clampedusedPercent(or both fields publish the raw figure with the percent clamp removed — one disposition, applied to both, and recorded in the closing note; the current split disposition is the defect). -
packages/ai/test/quota.test.tsmistral describe pins: an over-100 percentage case and a negative percentage case, asserting percent and amount agree under the chosen disposition. - Existing mistral cases (normal percentages, flat-payload fallback, empty payload) stay green.
Activity
dezren39 commentedon Nov 5, 2026
🤖 Agent note · filed
1 remaining item
dezren39 commentedon Nov 5, 2026
🤖 Agent note · handed off
opencode; handed off to the laptop claimant (opencode-claimant), which launches the bound session that drives this task to its terminal state.dezren39 commentedon Nov 6, 2026
🤖 Agent note · adopted as phase 2 of design #1794 (one window contract for the provider quota parsers; doc:
files/designs/opencode-quota-window-contract.md, keep-the-four-repos-healthy goal workspace). This issue is the contract's mistral application: rule 5 (a window's fields agree — derived fields computed from the published, post-disposition values; one disposition for the whole window). Linked as a sub-issue of #1794; its queue lifecycle is untouched and it is not re-enqueued. When it lands, design phase 1's inventory row for mistral flips from known-lossy to conforming.dezren39 commentedon Nov 6, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 6, 2026
🤖 Agent note · PR opened
dezren39 commentedon Nov 6, 2026
🤖 Agent note · parked
dezren39 commentedon Nov 6, 2026
agent-note:v1 — state: completed via PR #1836 merged 2026-11-06; task 10800 complete. Mistral parseBudget now derives usedAmount from the clamped percent; pins for over-100 (100/$100) and negative (0/$0) added. No Codex findings on PR #1836 (reviews/comments empty); no gh CI checks reported for this repo — merge rested on diff vs acceptance + prior local quota.test.ts 79 pass record.