Skip to content

feat(issue-42): add provider-neutral multi-subscription routing#43

Open
konard wants to merge 4 commits into
mainfrom
issue-42-d7c61ae8a6dd
Open

feat(issue-42): add provider-neutral multi-subscription routing#43
konard wants to merge 4 commits into
mainfrom
issue-42-d7c61ae8a6dd

Conversation

@konard

@konard konard commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Extends multi-account routing from Claude-only pools to every subscription provider already supported by the router: Claude, Codex, Gemini, and Qwen. It also adds stable session assignment, strict token account pins, internal request caps, quota-aware selection/cooldowns, and Formal AI-style native protocol namespaces.

Root cause and reproduction

PR #38 added vendor credential readers and single-subscription forwarding, but AccountRouter still constructed Claude-only OAuthProvider instances. Codex, Gemini, and Qwen therefore bypassed account selection; refreshed credentials were cached only by provider; and OpenAI translation discarded session metadata before selection.

The regression tests added first reproduced those gaps as 26 missing API/type errors, including provider-neutral pool construction, strict session/pin selection, per-account refresh keys, request caps, and request-routing context extraction.

Routing behavior

  • One provider-neutral pool backed by SubscriptionReader for Claude, Codex, Gemini, or Qwen.
  • round-robin, priority / fill-first, and normalized least-used / quota-first selection for new sessions.
  • Atomic ACCOUNT_REQUEST_LIMITS accounting, including concurrent cap enforcement.
  • Session affinity copied from stable headers/body metadata before translation and renewed while active.
  • Router-token account claims and existing session bindings are strict: unavailable identities fail instead of silently moving.
  • Only HTTP 429 starts cooldown; standard Retry-After delta/date values extend the configured minimum.
  • Refresh cache isolation by (provider, account) and token-budget enforcement on subscription routes.
  • Account limits and remaining capacity in /v1/accounts, accounts list, and doctor.

Native protocol routes

Adds namespaced Anthropic, OpenAI, Codex, and Qwen aliases plus native Gemini generateContent / streamGenerateContent and Vertex publisher-model paths. Existing unprefixed APIs remain unchanged. Provider-specific namespaces use the matching configured UPSTREAM_PROVIDER; no cross-provider billing or protocol fallback is introduced.

Research and requirement trace

The case-study package at docs/case-studies/issue-42/ records immutable Claudexor and Formal AI snapshots, related-project research, adopted design rules, deliberate boundaries, and an R1-R17 implementation/test trace.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-features — 137 unit, 50 integration, and 10 release-workflow tests pass; doc tests pass
  • cargo doc --no-deps --all-features
  • repository-wide Rust file-size policy — every file is under 1,000 lines
  • real cargo run -- serve startup — Axum route table starts without conflicts
  • CLI smoke checks for accounts list and doctor

This is a backend/configuration change, so no UI screenshots apply. The minor-release changelog fragment is included; release automation owns the version bump.

Closes #42

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #42
@konard konard self-assigned this Jul 22, 2026
@konard konard changed the title [WIP] Use best practices from https://github.com/razzant/claudexor for multi subscription switching and support as well as support for single subscriptions feat(issue-42): add provider-neutral multi-subscription routing Jul 22, 2026
@konard
konard marked this pull request as ready for review July 22, 2026 07:26
@konard

konard commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

Completed and marked ready for review: PR #43.

  • Added provider-neutral Claude, Codex, Gemini, and Qwen subscription pools with routing strategies, session affinity, request caps, quota tracking, and cooldowns.
  • Added native provider namespaces and Gemini/Vertex routes.
  • Added regression tests and an issue case study, informed by pinned Claudexor and Formal AI snapshots.
  • Local formatting, Clippy, documentation, runtime smoke checks, and all tests passed.
  • Final-SHA CI passed on Ubuntu, macOS, and Windows.
  • Branch is synchronized with main, pushed, clean, and mergeable.

This summary was automatically extracted from the AI working session output.

@konard

konard commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $33.058331

📊 Context and tokens usage:

  • 773.7K / 200K (387%) input tokens, 88.7K / 128K (69%) output tokens

Total: (773.7K + 21.3M cached) input tokens, 88.7K output tokens, $33.058331 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Thinking level: xhigh (~31999 tokens)
  • Model: GPT-5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (10575KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

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.

Use best practices from https://github.com/razzant/claudexor for multi subscription switching and support as well as support for single subscriptions

1 participant