Repository navigation
test(provider): gate user-facing strings against the legacy provider names - #2020
Merged
Merged
Conversation
…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). Rebased onto
mainnow that #2018 (todo 10) has merged; the gate is verified 3/3 against the post-rename tree.(Reopened from #2019, whose base branch was deleted on #2018's merge — that froze its head at the pre-rebase sha and GitHub will not retarget a PR with a deleted base ref.)
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 — a new legacy string in an already-listed file still fails. Each 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_*; a one-sided gate would be blind to half its surface.changes.md/AGENTS.md. 166 of 201 legacy hits in the tree are dated design-history entries; a gate demanding those be rewritten would attack the fork's own record.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, run on the rebased head whose base contains the full rename.Proven live, as the plan requires: re-introducing
"OpenAI Codex"as a display name inprovider-display-names.tsturns the guard RED naming the offending file and literal:Restored afterwards; 3 passed again. Biome 0 errors; changelog gate PASS (test-only diff).
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 (it is a stable module identifier), but whether it should be renamed with a migration deserves its own issue.Part of #1989
Summary by cubic
Adds a test that makes "no leaked old provider name" an enforced gate across
packages/coding-agent/srcandpackages/ai/src.openai-codex,OpenAI Codex,claude-sdk-oauth, orClaude SDK OAuth.LEGACY_PROVIDER_IDSmap keys stay reachable since every normalization and rejection reads them.Part of #1989.
Written for commit c947b4a. Summary will update on new commits.