test(provider): gate user-facing strings against the legacy provider names - #2019
Closed
code-yeongyu wants to merge 2 commits into
Closed
code-yeongyu wants to merge 2 commits into
code-yeongyu wants to merge 2 commits into
Conversation
…irectories Behaviour-free internal rename completing senpi#1989: TypeScript symbols, file names, the builtin extension directory and the matching test/QA script names now speak the canonical provider ids. - `CLAUDE_SDK_OAUTH_*` -> `ANTHROPIC_SUBSCRIPTION_*`, `ClaudeSdkOauth*` -> `AnthropicSubscription*`, `OpenAICodex*`/`openaiCodex*` -> `ChatGptSubscription*`/`chatgptSubscription*`, including the SCREAMING variants (`OPENAI_CODEX_MODELS`, `OPENAI_CODEX_PROVIDER_ID`, `OPENAI_CODEX_PROVIDER_LABEL`, the login-method and auth-claim constants). - `builtin/claude-sdk-oauth/` -> `builtin/anthropic-subscription/` (56 files), the provider/oauth/util modules and the catalog shard, plus the matching test and senpi-qa script names; the bundle script's oauth module map and every import follow. NOT renamed, because the symbol names the frozen WIRE API rather than the provider: `OPENAI_CODEX_RESPONSES_API`, `OpenAICodexResponsesOptions`, `CLAUDE_SDK_OAUTH_API_ID`, the `legacy-api-aliases.ts` export family, and the `api/openai-codex-responses/` directory itself. NOT renamed, because the NAME IS the compatibility window: the settings property `claudeSdkOauthProvider`, which `settings.ts` reads as `anthropicSubscriptionProvider ?? claudeSdkOauthProvider`. Renaming it would close the two-release legacy-read window early. Only the wrapping type symbol `SettingsWithClaudeSdkOauthProvider` was renamed. Every persisted VALUE is byte-identical: the seven frozen tokens, the `LEGACY_PROVIDER_IDS` map keys, and `claude-sdk-oauth-tool-watch`. Symbols holding those values were renamed; their string contents were not. Part of #1989
…names Extends the naming-boundary test into an enforced guard: it scans every shipped .ts under packages/coding-agent/src and packages/ai/src, extracts STRING AND TEMPLATE LITERALS ONLY (comments and identifiers are not user-facing), and fails on any literal carrying `openai-codex`, `OpenAI Codex`, `claude-sdk-oauth` or `Claude SDK OAuth` outside an explicit allowlist. The allowlist is (file, literal) PAIRS, not whole files, so a NEW legacy string in an already-listed file still fails. Every entry states why it is frozen: the wire api id `claude-sdk-oauth` and its two comparison sites, the persisted affinity key / binding entry type / legacy accounts dir, the builtin extension module id, and the retained KnownProvider legacy member. Substrings that ARE the contract (the seven frozen tokens, the env families, and the todo-9 rejection message, which must name the old id back to the user) are allowed anywhere. Four files whose entire job is knowing the legacy ids are allowed wholesale: legacy-provider-ids.ts, legacy-api-aliases.ts, auth-provider-key-migration.ts and settings-manager.ts. A third case pins the load-bearing direction: both LEGACY_PROVIDER_IDS map keys must stay reachable, since every normalization and every typed rejection reads them. Proven live: re-introducing `"OpenAI Codex"` as a display name in provider-display-names.ts turns the guard RED and names that file and literal. Part of #1989
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns "no leaked old name" into an enforced gate. Part of #1989 (todo 11). Stacked on #2018 (todo 10) — base it there, or rebase onto
mainafter #2018 merges.How it works
Scans every shipped
.tsunderpackages/coding-agent/srcandpackages/ai/src, extracts string and template literals only (comments and identifiers are not user-facing), and fails on any literal carryingopenai-codex,OpenAI Codex,claude-sdk-oauthorClaude SDK OAuthoutside the allowlist.The allowlist is (file, literal) PAIRS
Not whole files — so a new legacy string in an already-listed file still fails. Every entry states why it is frozen:
anthropic-subscription/api-id.tsclaude-sdk-oauthgoal/terminal-provider-error.ts,utils/prompt-cache-ttl.tsclaude-sdk-oauthmodel.api, the frozen wire idanthropic-subscription/affinity.tsclaude-sdk-oauth-defaultanthropic-subscription/session-binding.tsclaude-sdk-oauth-bindinganthropic-subscription/config-dir-credentials.tsclaude-sdk-oauth-accountsextensions/builtin/index.tsclaude-sdk-oauthpackages/ai/src/types.tsopenai-codexKnownProviderlegacy memberAllowed anywhere, because the string is the contract: the seven frozen tokens,
CLAUDE_CODE_OAUTH_TOKEN/SENPI_CLAUDE_SDK_OAUTH/claude_sdk_oauth_, and"was renamed to"— the todo-9 rejection message must name the old id back to the user.Allowed wholesale, because knowing the legacy ids is their entire job:
legacy-provider-ids.ts,legacy-api-aliases.ts,auth-provider-key-migration.ts,settings-manager.ts.Scope decisions worth reviewing
OPENAI_CODEX_*entirely; a one-sided gate would be blind to half the surface.changes.md/AGENTS.md. 166 of 201 legacy hits in the tree are dated design-history entries. A gate that demanded rewriting the fork's own record would be wrong.LEGACY_PROVIDER_IDSmap keys must stay reachable, since every normalization and every typed rejection reads them.Verification
bunx vitest run test/suite/anthropic-subscription-naming.test.ts— 3 passed.Proven live, as the plan requires: re-introducing
"OpenAI Codex"as a display name inprovider-display-names.tsturns the guard RED and names the offending file and literal:Restored afterwards; 3 passed again. Biome 0 errors; changelog gate PASS (test-only).
Observation for a follow-up, not fixed here
extensions/builtin/index.tsstill registers{ id: "claude-sdk-oauth" }while todo 10 moved its directory toanthropic-subscription/, so the builtin id no longer mirrors its directory. Keeping it is correct for a behaviour-free commit (the id is a stable module identifier), but whether it should be renamed with a migration is a real question worth its own issue.Summary by cubic
Completes the internal subscription-provider rename and turns "no leaked old name" into an enforced test gate. The rename is behaviour-free: symbols, module files, the builtin extension directory, and matching test/script names now read
anthropic-subscriptionandchatgpt-subscription; nothing observable changes.Frozen by design
claudeSdkOauthProviderstay byte-identical; the settings property keeps its legacy read window open.OpenAICodexResponsesOptions,CLAUDE_SDK_OAUTH_API_ID, theapi/openai-codex-responses/directory) were not renamed.The gate
.tsunderpackages/coding-agent/srcandpackages/ai/src, extracts string and template literals, and fails on any carryingopenai-codex,OpenAI Codex,claude-sdk-oauth, orClaude SDK OAuthoutside the allowlist.legacy-provider-ids.ts,legacy-api-aliases.ts,auth-provider-key-migration.ts,settings-manager.ts) are allowed wholesale."OpenAI Codex"as a display name turns the guard RED and names the file and literal.Written for commit 3173067. Summary will update on new commits.