Skip to content

refactor: finish canonical provider identifier audit#1030

Open
WebMad wants to merge 5 commits into
Zoo-Code-Org:mainfrom
WebMad:feat/960-canonical-provider-identifier-audit
Open

refactor: finish canonical provider identifier audit#1030
WebMad wants to merge 5 commits into
Zoo-Code-Org:mainfrom
WebMad:feat/960-canonical-provider-identifier-audit

Conversation

@WebMad

@WebMad WebMad commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace remaining raw API-provider comparisons in protocol selection with the canonical providerIdentifiers registry
  • use canonical identifiers for configuration-free, Kimi Code OAuth, and Zoo Gateway session-auth readiness checks
  • preserve serialized values and separate code-index, embedding, terminal, protocol, and model identifier domains
  • add focused mutation-based regression coverage proving runtime consumers read the canonical registry

Closes #960

TDD

Each migrated branch was driven by an observed red-green cycle:

  • Vertex Claude protocol routing
  • Vercel AI Gateway and Zoo Gateway Anthropic protocol routing
  • OpenCode Go model-specific protocol routing
  • configuration-free provider readiness
  • Kimi Code OAuth readiness
  • Zoo Gateway session-auth readiness

Verification

  • cd packages/types && npx vitest run src/__tests__/provider-settings.test.ts src/__tests__/provider-identifiers.test.ts src/__tests__/provider-default-model.test.ts — 38 passed
  • cd src && npx vitest run shared/__tests__/checkExistApiConfig.spec.ts shared/__tests__/ProfileValidator.spec.ts — 50 passed
  • types package type-check and changed-file ESLint — passed
  • extension package type-check and changed-file ESLint — passed
  • repository commit-time lint — passed

Known unrelated environment issue

The repository pre-push type-check reaches the new Playwright visual-test files and fails because local dependencies @playwright/experimental-ct-react, @playwright/test, and monocart-reporter are unavailable. The types and extension packages affected by this PR type-check successfully. The local runtime is Node 24.7.0 while the repository requests Node 22.23.1.

Summary by CodeRabbit

  • Bug Fixes

    • Improved API protocol detection across Anthropic-style, OpenAI-style, gateway, Vertex, and Opencode Go models.
    • Improved authentication and configuration checks for keyless, OAuth, and session-based providers.
    • Added more reliable handling for unknown, empty, undefined, and case-insensitive model identifiers.
  • Tests

    • Expanded coverage for provider routing, gateway identifiers, authentication modes, and model-format detection.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change centralizes provider and protocol constants, updates getApiProtocol routing for Anthropic-style providers, and replaces provider literals in authentication checks and their tests.

Changes

Provider identifier centralization

Layer / File(s) Summary
Protocol constants and routing
packages/types/src/providers/*.ts, packages/types/src/provider-settings.ts
Adds shared Anthropic/OpenAI protocol and model matching constants, then uses canonical identifiers for gateway, Vertex, Anthropic-style, and Opencode Go routing.
Protocol routing coverage
packages/types/src/__tests__/provider-settings.test.ts
Updates protocol tests to use canonical identifiers and covers gateway, Vertex, Opencode Go, fallback, and edge-case behavior.
Authentication provider checks
src/shared/checkExistApiConfig.ts, src/shared/__tests__/checkExistApiConfig.spec.ts
Uses canonical identifiers for configuration-free, Kimi Code OAuth, and Zoo Gateway session authentication checks and adds corresponding test coverage.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Zoo-Code-Org/Zoo-Code issue 958 — Covers related provider identifier centralization for API protocol selection and authentication checks.
  • Zoo-Code-Org/Zoo-Code issue 944 — Tracks the broader provider-literal replacement advanced by these changes.

Possibly related PRs

Suggested labels: awaiting-review

Suggested reviewers: edelauna, navedmerchant

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the PR’s main work on canonical provider identifier auditing.
Description check ✅ Passed The description covers the change summary, testing, and verification, and includes the linked issue reference.
Linked Issues check ✅ Passed The code changes align with #960 by replacing remaining provider literals with canonical identifiers and adding focused regression tests.
Out of Scope Changes check ✅ Passed The diff stays focused on provider-identifier cleanup and related tests, with no clear unrelated feature work.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
Comment thread packages/types/src/provider-settings.ts Outdated
Comment thread packages/types/src/__tests__/provider-settings.test.ts Outdated
@WebMad
WebMad marked this pull request as ready for review July 26, 2026 16:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/shared/__tests__/checkExistApiConfig.spec.ts`:
- Around line 69-72: Update the keyless-provider tests around checkExistKey to
exercise providerIdentifiers.openaiCodex and providerIdentifiers.qwenCode in
addition to providerIdentifiers.fakeAi. Replace any hard-coded openaiCodex or
qwenCode identifiers in the nearby cases with their corresponding registry
values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 73331000-75cf-46be-b611-189c7fe8291a

📥 Commits

Reviewing files that changed from the base of the PR and between c52f118 and 14f7277.

📒 Files selected for processing (6)
  • packages/types/src/__tests__/provider-settings.test.ts
  • packages/types/src/provider-settings.ts
  • packages/types/src/providers/anthropic.ts
  • packages/types/src/providers/openai.ts
  • src/shared/__tests__/checkExistApiConfig.spec.ts
  • src/shared/checkExistApiConfig.ts

Comment on lines +69 to +72
it("recognizes keyless providers through their canonical identifiers", () => {
expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exercise all configuration-free provider identifiers.

This regression test covers only providerIdentifiers.fakeAi; the openaiCodex and qwenCode paths still rely on hard-coded strings at Lines 73-85. A bad registry value for either identifier could therefore pass the suite while breaking the new production path. Add both canonical identifiers to this test or update those existing cases to use the registry.

Suggested test update
 it("recognizes keyless providers through their canonical identifiers", () => {
 	expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true)
+	expect(checkExistKey({ apiProvider: providerIdentifiers.openaiCodex })).toBe(true)
+	expect(checkExistKey({ apiProvider: providerIdentifiers.qwenCode })).toBe(true)
 })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it("recognizes keyless providers through their canonical identifiers", () => {
expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true)
})
it("recognizes keyless providers through their canonical identifiers", () => {
expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true)
expect(checkExistKey({ apiProvider: providerIdentifiers.openaiCodex })).toBe(true)
expect(checkExistKey({ apiProvider: providerIdentifiers.qwenCode })).toBe(true)
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/shared/__tests__/checkExistApiConfig.spec.ts` around lines 69 - 72,
Update the keyless-provider tests around checkExistKey to exercise
providerIdentifiers.openaiCodex and providerIdentifiers.qwenCode in addition to
providerIdentifiers.fakeAi. Replace any hard-coded openaiCodex or qwenCode
identifiers in the nearby cases with their corresponding registry values.

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Replace remaining production provider literals and verify canonical identifier coverage

1 participant