Skip to content

feat(claude): opt-in routed-only refusal of official Anthropic models - #7347

Closed
garysassano wants to merge 1 commit into
lidge-jun:devfrom
garysassano:feat/claude-routed-only
Closed

garysassano wants to merge 1 commit into
lidge-jun:devfrom
garysassano:feat/claude-routed-only

Conversation

@garysassano

@garysassano garysassano commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds an opt-in claudeCode.routedOnly mode that makes proxied Claude sessions refuse official Anthropic models instead of serving them from Anthropic, so a proxied session cannot produce Anthropic-bound traffic even when auth mode auto resolves to subscription.
  • Server-side refusal, because the launcher env cannot guarantee routing. A native claude…/anthropic… selector that no alias or modelMap entry claims is refused before the caller-credential passthrough can forward it verbatim, and again where the route settles if it would land on the built-in Anthropic account pool (the managed native Messages lane and its bridge twin alike — this also covers interaction targets mapped into the pool). count_tokens refuses the same ids before its passthrough branch; its local estimate stays available for routed selectors. Refusals are HTTP 403 permission_error, code claude_routed_only, with a message that names the resolve paths.
  • Everything not Anthropic-bound keeps working: provider-prefixed ids on other providers, alias/model-map targets that route elsewhere, tier slots, count-token estimates. Custom providers speaking the Anthropic wire format against their own base URLs are deliberately not refused.
  • Surfaces: PUT/GET /api/claude-code (routedOnly boolean, unset-is-off), ocx claude config set --routed-only <on|off>, capability registry entry, GUI Claude page settings-card toggle (Save-committed like the other card fields) with an active/defaults reminder, locale catalogs updated in all 11 locales, generated skill surface refreshed.
  • No auto-selection of routed defaults: with no tier slot or helper model mapped, the GUI shows a reminder pointing at CLI tier defaults / model map, and the refusal message names them. Implementation notes live in devlog/_plan/261002_claude_ux/060_routed_only.md.

Verification

  • bun scripts/test.ts tests/claude-integration/claude-routed-only.test.ts — new suite (7 tests): refusal before the passthrough with and without an sk-ant- caller credential (the without-flag control attempts the verbatim forward through a stubbed global fetch), refusal where a mapped target settles on the OAuth pool, the without-flag control keeping the native lane open, count_tokens refusal vs. local estimate, the management round-trip, and the config-schema rejection; global fetch is stubbed to throw so any real network call fails the case.
  • bun scripts/test.ts tests/claude-integration/claude-messages-endpoint.test.ts tests/claude-integration/claude-management-api.test.ts tests/claude-integration/messages-native.test.ts (214 pass) and bun scripts/test.ts tests/cli/cli-capabilities.test.ts tests/cli/cli-headless-parity.test.ts (125 pass).
  • bun run typecheck, bun run skill:surface:check, bun run structure:check, and the file-size ratchet all pass; bun x tsc -b in gui/ passes; gui tests for the touched surfaces (claude-code-save, claude-code-types, claude-code-first-party, 78 pass) and pinned oxlint pass.
  • Screenshot of the GUI toggle will be added to this description.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (docs-site guide, devlog/_plan/261002_claude_ux, skill surface).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (the feature reduces credential exposure; refusal logic never logs or echoes credentials).

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

claudeCode.routedOnly makes proxied Claude sessions refuse official
Anthropic models instead of serving them from Anthropic, so a proxied
session produces no Anthropic-bound traffic even with authMode auto in
subscription mode.

A native claude*/anthropic* selector that no alias or modelMap entry
claims is refused before the caller-credential passthrough can forward
it verbatim, and, when routing would settle it on the built-in Anthropic
account pool (the managed native Messages lane and its bridge twin),
refused again where the route settles - which also covers interaction
targets mapped into the pool. count_tokens refuses the same ids before
its passthrough branch; its local estimate stays available for routed
selectors. Responses are 403 permission_error with code
claude_routed_only; custom anthropic-wire relay providers are not
refused.

Surfaces: GET/PUT /api/claude-code, ocx claude config --routed-only,
capability registry, GUI Claude page settings toggle with an
active/defaults reminder in all 11 locales, generated skill surface.
Tests cover both refusal homes, claimed selectors, count_tokens, the
management round-trip, and the config schema refinement.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • UI screenshot required.

What to do

  • Add a screenshot of the UI change to the PR description.
  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.
@garysassano Tick the boxes once required local validation has passed with commands, results, and any full-suite exception documented, your branch is on the latest dev commit, and every correct Codex and CodeRabbit finding is resolved.

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Contract/coverage changes requested at 2a491d1.

  1. Register tests/claude-integration/claude-routed-only.test.ts in BOTH the current test-layout explicit map (or its domain shard) and the independent tests/fixtures/test-layout-expected*.json membership oracle. The complete 27-file diff adds the test but changes neither map. Regex placement alone is not the required independent membership registration.
  2. Update the owning structure contract for the new routed-only setting and Messages/count_tokens refusal boundary. The guide and planning note are useful, but this diff changes shared config, routing eligibility, CLI/management settings and native/translated Messages behavior without any structure update. Document the native-selector vs mapped target rules, built-in pool vs custom Anthropic-wire destination distinction, default-off behavior and count-token behavior in the existing authority; keep rationale in its ADR scheme.

The live readiness gate also requests a UI screenshot. Retain Draft until those requirements, the author checklist and current-head functional CI are satisfied. UI/product disposition and the credential/destination refusal review remain separate requirements. This is a static contract review; no local suite, live provider call, security scan or fork-workflow approval was performed.

@lidge-jun

Copy link
Copy Markdown
Owner

Thank you for the work here. We're closing this to keep the review queue manageable: the review findings are still unresolved and the change is mainly in the dashboard, which is outside the current sweep. You're welcome to reopen this or open a smaller PR against dev.

@lidge-jun lidge-jun closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants