Skip to content

feat: add Grok SuperGrok paste and source picker - #3014

Merged
steipete merged 14 commits into
mainfrom
fix/3010-grok-supergrok-paste
Aug 17, 2026
Merged

feat: add Grok SuperGrok paste and source picker#3014
steipete merged 14 commits into
mainfrom
fix/3010-grok-supergrok-paste

Conversation

@steipete

Copy link
Copy Markdown
Owner

Summary

Supersedes #3010 while preserving @oakimov's commits and credit.

  • Adds the Grok Auto / Grok CLI / SuperGrok OAuth / Browser cookies source picker and pasted SuperGrok bearer or grok.com cookie accounts.
  • Keeps bearer credentials on the Grok OAuth path, cookie headers on Grok web billing, and rejects xai- management keys.
  • Preserves provider/account siloing: cookie-authenticated usage does not inherit auth-file identity or plan data, and credential values are not logged.
  • Merges current main and retains the full 0.52.1 — Unreleased changelog union.

CI failure root causes

  • ProviderCredentialCharacterizationTests did not include Grok in its expected token-account catalog. Grok is now registered under its declared GROK_OAUTH_TOKEN environment injection contract; provider-owned routing still projects cookie-shaped accounts into Grok web settings at fetch time.
  • ProviderArchitectureGatekeeperTests still pointed at pre-refresh line numbers and anchors in UsageStore+TokenAccounts.swift. All exact suppressions and allowlisted cluster fingerprints now target the current source without weakening the gate.

Verification

  • swiftformat Sources Tests
  • swiftlint --strict
  • make check
  • swift test --filter 'ProviderCredentialCharacterization|ProviderArchitectureGatekeeper|Grok' — 156 tests passed
  • Structured autoreview of the committed repair delta — no actionable findings

Thanks @oakimov for the original implementation and review iterations.

oakimov and others added 14 commits August 17, 2026 13:40
Keep Auto-only remapping for selected SuperGrok accounts so CLI/web
stay authoritative. Prefer GROK_OAUTH_TOKEN over a valid auth.json so
a selected pasted bearer cannot display the local grok login account.
Project Cookie: token accounts into the Grok settings snapshot so Auto
and Web fetches use the selected header instead of a configured or
browser cookie.
Preserve the existing Grok Auto fallback: CLI, then browser cookies,
then OAuth. Selected pasted bearers and explicit SuperGrok OAuth still
use the OAuth path only.
Auto is CLI, then SuperGrok OAuth CLI-proxy, then browser cookies.
A failed Auto proxy no longer falls through to bearer gRPC, so cookies
still run next. Explicit SuperGrok OAuth keeps proxy-then-gRPC.
Auto is now CLI, SuperGrok OAuth CLI-proxy, browser cookies, then
bearer gRPC. Explicit SuperGrok OAuth stays cookie-free proxy-then-gRPC.
Co-authored-by: Oleksiy Akimov <o.akimov@akimov-inc.com>
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f888f8456

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +22 to +24
return GrokCredentialRouting.resolve(
tokenAccountToken: account.token,
manualCookieHeader: nil).sourceMode ?? base

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail closed when the selected Grok credential is rejected

When a selected token is deliberately rejected, such as an xai- management key, GrokCredentialRouting.resolve returns .none and this fallback retains .auto. The Auto pipeline can then fetch through the Grok CLI, auth.json, or configured browser cookies and publish that unrelated usage under the selected token account. A non-nil but unrecognized selected account should produce a credential error instead of falling back to other accounts.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 17, 2026, 1:05 PM ET / 17:05 UTC.

ClawSweeper review

What this changes

Adds a Grok source picker and supports pasted SuperGrok bearer or grok.com cookie token accounts for usage fetching.

Merge readiness

Blocked by patch quality or review findings - 3 items remain

Keep open: the current head has a P2 credential-routing defect where a selected rejected Grok management key falls back to unrelated Auto credentials.

Priority: P2
Reviewed head: 2f888f8456e636822d6e20592e7583d3d4ad5f78

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The intended OAuth flow has visible proof and focused tests, but a concrete selected-credential routing defect blocks merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This owner-authored PR is outside the external-contributor real-behavior-proof gate; the supplied screenshot visibly demonstrates the intended OAuth settings flow but not the rejected-key edge case.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This owner-authored PR is outside the external-contributor real-behavior-proof gate; the supplied screenshot visibly demonstrates the intended OAuth settings flow but not the rejected-key edge case.
Evidence reviewed 5 items Rejected selected key falls through: A selected account whose routing result is .none retains .auto; Auto then tries CLI, OAuth, cookies, and bearer gRPC rather than reporting the selected credential as invalid.
Invalid token loses its selected-account environment: Environment resolution scrubs the selected account’s credential variables and only injects an override when classification succeeds, leaving Auto free to use the local CLI, auth file, or cookie configuration.
Documented contract conflicts with behavior: The new Grok documentation says xai- management keys are rejected, while normalization returns nil and the selected-source resolver falls back to Auto.
Findings 1 actionable finding [P2] Fail closed for rejected selected Grok credentials
Security None None.

How this fits together

CodexBar turns Grok settings and a selected token account into a credential-specific usage-fetch pipeline. That pipeline supplies account and usage data to the menu-bar provider card.

flowchart LR
A[Grok settings] --> C[Selected token account]
B[Saved credentials] --> C
C --> D[Credential classifier]
D --> E[OAuth usage path]
D --> F[Cookie usage path]
D --> G[Auto fallback pipeline]
E --> H[Menu-bar usage card]
F --> H
G --> H
Loading

Before merge

  • Fail closed for rejected selected Grok credentials (P2) - A selected xai- key resolves to .none, but this resolver keeps .auto. Environment setup then injects no selected credential, so the Auto pipeline can publish CLI, auth-file, or cookie usage under that selected account. Return a credential error or unavailable state instead and add the rejected-token regression case.
  • Resolve merge risk (P1) - A user who selects an xai- management key can be shown usage from their CLI login, auth file, or configured browser cookies under the selected account label.
  • Improve patch quality - Add a regression test and fail-closed behavior for a selected rejected management key.

Findings

  • [P2] Fail closed for rejected selected Grok credentials — Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift:20-25
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +933/-295; tests +365/-73 The credential-routing feature has substantial focused coverage, but its rejected-selection boundary still lacks a passing regression.

Root-cause cluster

Relationship: canonical
Canonical: #3014
Summary: This owner-authored integration branch explicitly supersedes the earlier Grok implementation branch while retaining its feature work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Reject unsupported selected credentials (recommended)
    Return an unavailable or credential error before entering Auto when a selected Grok token cannot be classified, and cover the management-key case with a regression test.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve valid bearer and cookie routes; add a regression test proving a selected xai- key cannot fall back to CLI, auth-file, or cookie usage.

Technical review

Best possible solution:

Fail closed for any selected Grok token that is neither a supported bearer nor a valid cookie, while preserving valid bearer and cookie routing.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: select an xai- token in Auto mode; normalization rejects it, but source resolution retains Auto and reaches unrelated configured credentials.

Is this the best way to solve the issue?

No. The patch recognizes management keys as unsupported but does not enforce that rejection at source selection; a fail-closed selected-account path is the narrower fix.

Full review comments:

  • [P2] Fail closed for rejected selected Grok credentials — Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift:20-25
    A selected xai- key resolves to .none, but this resolver keeps .auto. Environment setup then injects no selected credential, so the Auto pipeline can publish CLI, auth-file, or cookie usage under that selected account. Return a credential error or unavailable state instead and add the rejected-token regression case.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 716a326daf00.

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. This owner-authored PR is outside the external-contributor real-behavior-proof gate; the supplied screenshot visibly demonstrates the intended OAuth settings flow but not the rejected-key edge case.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This owner-authored PR is outside the external-contributor real-behavior-proof gate; the supplied screenshot visibly demonstrates the intended OAuth settings flow but not the rejected-key edge case.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: The defect has a bounded but user-visible provider-account correctness impact.
  • merge-risk: 🚨 auth-provider: Merging changes selected credential classification and can route usage through an unintended authenticated source.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This owner-authored PR is outside the external-contributor real-behavior-proof gate; the supplied screenshot visibly demonstrates the intended OAuth settings flow but not the rejected-key edge case.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. This owner-authored PR is outside the external-contributor real-behavior-proof gate; the supplied screenshot visibly demonstrates the intended OAuth settings flow but not the rejected-key edge case.

Evidence

Acceptance criteria:

  • [P1] swift test --filter 'GrokSettingsReaderTests|ProviderEnvironmentResolverTests'.
  • [P1] make test.
  • [P1] make check.

What I checked:

Likely related people:

  • steipete: Current-head blame and commit metadata connect this owner to the provider-routing integration and its final merge resolution. (role: current integration author; confidence: high; commits: 2f888f8456e6; files: Sources/CodexBarCore/Providers/Grok/GrokProviderDescriptor.swift, Sources/CodexBar/ProviderRegistry.swift, Sources/CodexBar/UsageStore+TokenAccounts.swift)
  • oakimov: The retained feature commits and PR body identify this contributor as the original author of the Grok source-picker implementation. (role: original feature contributor; confidence: medium; commits: d8c4fb4c7a3c, 615be3ba6271; files: Sources/CodexBarCore/Providers/Grok/GrokCredentialRouting.swift, Tests/CodexBarTests/GrokSettingsReaderTests.swift)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit f7723d3 into main Aug 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants