fix(grok): classify missing billing methods by RPC code - #3947
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 6:04 AM ET / 10:04 UTC. ClawSweeper reviewWhat this changesThe branch preserves Grok JSON-RPC error codes and uses the missing-method code to decide when a team account retains identity and local token history after billing fails. Merge readiness✅ Ready for maintainer review The Grok fallback defect is still present on current main and in v0.65.0. This owner-authored PR provides a narrow, source-supported repair; it should remain open for normal review. The separate dashboard omission in #3716 remains unresolved. Priority: P2 Review scores
Verification
How this fits togetherCodexBar's Grok provider asks the Grok CLI for billing data and turns the result into usage shown in the menu and spend views. When CLI billing fails, the provider decides whether to retain a team identity snapshot or continue to web billing. flowchart LR
A[Grok CLI] --> B[Billing RPC reply]
B --> C[Error code check]
C --> D[Team credential check]
D --> E[Local token scan]
E --> F[Usage snapshot]
C --> G[Web billing fallback]
Before mergeNone. Agent review detailsSecurityNone. Review metricsNone. Technical reviewBest possible solution: Land the coded-error classification with its team, personal, and transport regression coverage; investigate the reported account-specific dashboard loss separately. Do we have a high-confidence way to reproduce the issue? Yes: the source and stub-CLI cases define a deterministic missing-method response whose alternate wording fails on current main. This read-only review did not execute the tests or verify the behavior against a live Grok account. Is this the best way to solve the issue? Yes: preserving the RPC code and classifying -32601 at the existing fallback decision is a narrow repair, while keeping unrelated RPC and transport errors outside that fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 01c81fa1352a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Grok discarded JSON-RPC error codes and recognized a missing billing method only from its English message. A valid
-32601with different wording therefore bypassed the team identity fallback and its local token summary; a different code sayingMethod not foundincorrectly entered that fallback. Preserve the code and classify on-32601, retaining the original diagnostic message and leaving local transport errors unclassified.The new stub-CLI cases fail on unchanged production code and pass with this change, including publication of 42 local tokens. The existing personal Auto RPC-to-proxy-to-Usage & Spend/share test already passes on main. Usage JSON intentionally omits live-only
costUsage; this PR does not claim to fix the separate account-specific dashboard loss reported in #3716. Current main already handles #1805's weekly billing periods, including near-reset labeling and measured monthly windows.Validation:
Test run with 238 tests in 19 suites passed(237 passed, one opt-in live test skipped, zero failures), covering Grok, RPC teardown/timeouts, bounded child processes, and provider architecture.make checkpassed: 0/2,617 files require formatting; SwiftLint found zero violations in 2,616 files. One unrelated synthetic packaging receipt test failed under load, then passed in isolation and in the complete gate; one test-line wrapping violation was corrected.git diff --checkpassed.config show --jsonandusage --provider grok --jsontimed out after 90 seconds (exit 124, no JSON). Live reproduction and Grok's configured state remain unverified. No app relaunch, login, or settings/account change.Exact regression commands (the first intentionally records the pre-fix failures):
Refs #3716
Refs #1805
Refs #3805