Repository navigation
Description
test(ai): quota figure contract — figure inventory + shared figure probe matrix for the 13 quota providers (design #1942, phase 1)
Phase 1 of design #1942 ("a figure that cannot exist is not a figure"). Design doc: files/designs/opencode-quota-figure-contract.md in the keep-the-four-repos-healthy goal workspace.
Task
For the thirteen provider quota parsers in packages/ai/src/quota/providers/:
(a) State the design's six figure-contract rules where the parsers live — in packages/ai/src/quota/types.ts beside the window contract (#1794), in the module's existing comment style:
- Impossible figures read as absent (zero is a real figure and publishes).
- A pair is judged as a pair; the impossible-pair disposition is whole-window and named per provider in the inventory — never split between percent and label.
- Scaling inputs are figures too (wire exponent/divisor/multiplier validated to its closed range before scaling; out-of-range reads the scaled figure as absent, sibling figures still publish).
- Precision is part of the figure (rounding is a display act, never a parser act).
- A result whose only figure is impossible is no result (the provider's existing no-data contract fires).
- Every figure path is pinned against this contract. Named exception: turso's stated publish-truthfully over-100% disposition stands.
(b) Add a figure section to the same parser inventory in types.ts (not a second table): per provider, the figures it publishes (percent / money amount / balance / count) and each figure's named disposition for the impossible cases. Mark the known-lossy rows with links and do NOT assert them as conforming: deepseek negative balance → #1928, codex negative credits → #1924, claude negative spend → #1919, groq pair → #1897, opendesign pair → #1879, claude exponent → #1920, antigravity precision → #1941 (design phases 2–3 adopt those issues; they keep their own lifecycles).
(c) Add the shared figure probe matrix in packages/ai/test/quota.test.ts (or a wired sibling): one case per rule (negative figure reads as absent; zero control publishes unchanged; impossible pair under one consistent disposition; out-of-range scaling input reads the scaled figure as absent; sub-percent precision preserved) run against the parsers that already conform — meta parseBillingBanner (negative minor → null), opencode-go toMicroCents (negative → null) and its balance path, command-code's clamp-both windows (#1821), turso's numNonNegative path — with the suite header naming the contract as the oracle.
Acceptance criteria
- The six figure-contract rules are stated in
packages/ai/src/quota/types.tsbeside the window contract, where a new parser author will read them. - The inventory's figure section covers all 13 registered providers with figures-published + named dispositions, and marks the seven known-lossy rows with links (fix(ai): deepseek quota publishes a negative balance — the no-positive fallback bypasses its own >0 filter, so a negative-only payload returns "$-5.00" with ok:true #1928, fix(ai): codex quota credits publishes a negative balance — "-5" as the credits_balance label, and a negative-only payload still returns ok:true #1924, fix(ai): claude quota extra-usage spend publishes negative amounts — "$-5.00 / $10.00", and a negative-only payload still returns ok:true #1919, fix(ai): groq quota accepts remaining above the limit — "150 / 100 requests remaining" publishes beside 0% used / 100% remaining #1897, fix(ai): opendesign quota parseCodingPlanWindows publishes out-of-range remaining raw — "-50 / 100 credits" at 100% used, "150 / 100 credits" at 0% used #1879, fix(ai): claude quota spend toAmount trusts the wire exponent — exponent 999 publishes "$0.00 / $0.00" for a real $5/$10 spend, exponent -2 inflates it 100x #1920, fix(ai): antigravity quota publishes integer-quantized percents — 99.9% used reads as 100% / 0% remaining, 0.1% used reads as 0% #1941).
- The probe matrix passes on current main for the conforming parsers listed, with one named case per contract rule per parser family, and its header names the contract as the oracle.
- The matrix demonstrably fails if a conforming parser's figure disposition changes without the contract changing.
- No production behaviour changes: no parser logic under
packages/ai/src/quota/providers/changes (doc comments / the contract statement excepted). - Existing quota suite stays green; gate state not regressed.
Parent design: #1942. Sibling contract: #1794 (windows). Do not fix the known-lossy sites in this issue — phases 2–3 are the adopted per-site issues themselves.
Activity
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed by repo design architect (opencode pass 2026-11-07)
packet-opencode-1943.json, dedupe keyrepo-health:v1:triage:developing-today/opencode:issue:1943).files/designs/opencode-quota-figure-contract.md(keep-the-four-repos-healthy goal workspace)dezren39 commentedon Nov 8, 2026
agent-note:v1
state: picked_up
worker: repo-worker-opencode
task: 11283
queue: repo-health-opencode-pilot
note: Claimed and revalidated — issue open, no held labels (held/user-owned/do-not-merge/do-not-auto-edit absent), no competing PR found. Implementing design #1942 phase 1: figure contract + inventory in types.ts and shared figure probe matrix, no production parser changes.
Merge pull request #2125 from developing-today-forks/queue/11283-1943…
dezren39 commentedon Nov 8, 2026
agent-note:v1
state: done
worker: repo-worker-opencode
task: 11283
queue: repo-health-opencode-pilot
note: Figure contract (design #1942 phase 1) landed in PR #2125, merged a34791c. types.ts states the six figure rules beside the window contract and carries a figure inventory for all 13 providers; quota.test.ts gains the shared figure probe matrix (oracle: the contract). Fresh-state correction: the seven packet-marked lossy issues (#1928/#1924/#1919/#1897/#1879/#1920/#1941) are all closed/landed, so dispositions are stated and pinned rather than marked lossy. Tests: bun test test/quota.test.ts (packages/ai, laptop) 188 pass / 0 fail. No provider parser logic changed.