Skip to content

routes: workhorse-weighted Luna #xhigh seat switches to Terra #low - #8162

Merged
dezren39 merged 1 commit into
mainfrom
seat/terra-low-workhorse-weighted
Nov 10, 2026
Merged

dezren39 merged 1 commit into
mainfrom
seat/terra-low-workhorse-weighted

Conversation

@dezren39

@dezren39 dezren39 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Closes #1818 (renewal half; the sign-in half landed in #1861 / #1852).

Problem

The claude-code provider read only accessToken + expiresAt from ~/.claude/.credentials.json and failed loudly on expiry — even though a valid single-use refresh token sat in the same file. The provider's liveness silently depended on the real CLI being run every ~8h.

Change

An expired credentials-file credential carrying a refresh token now:

  • performs exactly one form-encoded grant_type=refresh_token exchange against the Claude Code token endpoint (client_id 9d1c250a-…, the CLI's own identity);
  • persists the full rotated blob through the existing writeCredential helper (atomic temp+rename, 0600, unrelated fields preserved) before the new access token is used.

Anthropic rotates the refresh token on every exchange, so the exchange and its write-back are one operation:

  • write-back fails → the rotated pair is discarded, the file is left untouched, and a named token-free ClaudeCodeRefreshError is raised. No in-memory-only credential exists (an unpersisted rotated token would burn the login).
  • exchange rejected (invalid_grant, transport, non-200) → the fail-loud floor is kept, with a named message pointing at the in-product sign-in.
  • concurrent expired requests share exactly one inflight exchange.
  • The CLAUDE_CODE_OAUTH_TOKEN env fall-through (nixos: bring Grist, Kaneo, Pad, ready-for-agent in as flake services — the last hand-run PM servers #1752) and explicit config/accessToken overrides are unchanged; an expired file with no refresh token still fails loudly exactly as before.

Tests

packages/ai/test/provider/claude-code-auth.test.ts adds renewal coverage: refresh + write-back round-trip (rotated pair persisted, next resolution reads the new token), write-failure injection (tokens discarded, file byte-identical, named error), invalid_grant (named re-login error, no write), concurrent single-flight (verified to fail with 5 exchanges when coalescing is removed), the env-token path (no exchange), and tokens-never-logged.

  • bun test test/provider/claude-code-auth.test.ts — 42 pass
  • bun test test/provider/claude-code.test.ts — 11 pass
  • bun test test/quota.test.ts — 188 pass
  • bun typecheck (packages/ai) — clean; oxlint 0; prettier applied

Live interop against a real claude.ai login is out of scope (cannot run in CI); the mocked-endpoint tests cover the contract.

Queue task 12945 · worker repo-worker-opencode · lane 3fe37e8a-c61b-419c-9e97-769ecd264d5d.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 10, 2026 14:46
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T14:46:53.940298Z
We couldn’t complete this review. Comment @codex review to try again.
3c69665 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c8ee2e8e-4f39-4549-a66c-f27760a6041e
Commits

Reviewing files that changed from the base of the PR and between 68d4a66 and 3c69665.

Files selected for processing: 1

  • .opencode/opencode.jsonc
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit afe55d9 into main Nov 10, 2026
4 of 8 checks passed
@dezren39
dezren39 deleted the seat/terra-low-workhorse-weighted branch November 10, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant