Skip to content

[Code Quality] refactor: introduce named type LLMProvider string to replace bare string threading through ~8 functions #48439

Description

@github-actions

Description

The LLMProvider concept is threaded through approximately 8 functions as a bare string, including secret selection logic and gateway routing decisions. Using a named type improves type safety, enables exhaustive switch checking, and documents intent at call sites.

Current State

// Currently — bare string driving secret selection and gateway routing
func selectSecret(provider string) string { ... }
func routeToGateway(provider string) url.URL { ... }
// EngineConfig.LLMProvider is string

Suggested Changes

  1. Add type LLMProvider string with its constants (likely in pkg/types or pkg/cli)
  2. Update EngineConfig.LLMProvider field from string to LLMProvider
  3. Update the ~8 functions that accept/return provider values
  4. Add a String() string method for logging compatibility

Files Affected

  • Likely pkg/cli/ or pkg/types/ for the type definition
  • ~8 functions across compiler/gateway/secret-selection code (exact files to be identified at implementation time via grep -r "LLMProvider" --include=*.go)

Success Criteria

  • type LLMProvider string defined with named constants
  • EngineConfig.LLMProvider is LLMProvider not string
  • No bare string arguments for provider values at key routing/selection call sites
  • go build ./... and make test-unit pass

Source

Extracted from discussion #47781 — Typist Go Type Consistency Analysis

Priority

Medium — Improves type safety at gateway routing and secret selection boundaries

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · sonnet46 · 42.7 AIC · ⌖ 5.66 AIC · ⊞ 7.2K ·

  • expires on Jul 28, 2026, 11:13 AM UTC-08:00

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions