refactor: rename Ai* database identifiers to AI* (AIGOV-369) (#26327)

Adds `ai` to sqlc's `gen.go.initialisms` in `coderd/database/sqlc.yaml`
so the generated DB code follows Go's initialism convention. Adds the
matching `ai` -> `AI` case to the dbgen PascalCase helper
(`scripts/dbgen/main.go`) so the corresponding `dbmem` / mock
identifiers stay in sync. `make gen` regenerates the rest; hand-written
call sites that consume DB-generated identifiers
(`enterprise/audit/table.go`, `coderd/database/modelmethods.go`,
`enterprise/coderd/aigatewaykeys.go`, `coderd/database/dbauthz/*`, etc.)
are updated to match.

Scope is deliberately limited to the database layer:

- `coderd/rbac/*` (resource and scope generators) is untouched —
`ResourceAi*` / `ScopeAi*` constants stay on main's casing.
- `codersdk/*` (Go SDK) is untouched — `codersdk.ResourceAi*` /
`codersdk.APIKeyScopeAi*` constants stay on main's casing, so external
Go SDK consumers see no source-level break.
- `Aibridge*` identifiers (one SQL token `aibridge`, not `ai_bridge`)
are out of scope.

On-the-wire values are unchanged: enum strings, RBAC resource type
strings, API key scope strings, and JSON tags all stay the same. The
HTTP/JSON surface is unaffected.

Refs:
[AIGOV-369](https://linear.app/codercom/issue/AIGOV-369/change-ai-references-in-coderddatabasemodelsgo-to-ai)

🤖 Generated with [Coder Agents](https://coder.com)
This commit is contained in:
Danny Kopping
2026-06-16 09:01:43 +00:00
committed by GitHub
parent 00a08f35cc
commit a1330e3a8c
53 changed files with 612 additions and 605 deletions
+7 -7
View File
@@ -3074,26 +3074,26 @@ func ReadAIProvidersFromEnv(logger slog.Logger, environ []string) ([]codersdk.AI
// BEDROCK_* fields are accepted on anthropic (mutually exclusive
// with KEYS) and required on bedrock. Any other TYPE rejecting
// them prevents silently-ignored credentials.
isBedrockType := providerType == database.AiProviderTypeBedrock
isAnthropicType := providerType == database.AiProviderTypeAnthropic
isBedrockType := providerType == database.AIProviderTypeBedrock
isAnthropicType := providerType == database.AIProviderTypeAnthropic
if !isAnthropicType && !isBedrockType && isBedrock {
return nil, xerrors.Errorf("provider %d (%s): BEDROCK_* fields are only supported with TYPE %q or %q",
i, p.Type, database.AiProviderTypeAnthropic, database.AiProviderTypeBedrock)
i, p.Type, database.AIProviderTypeAnthropic, database.AIProviderTypeBedrock)
}
if isBedrockType && !isBedrock {
return nil, xerrors.Errorf("provider %d (%s): TYPE %q requires BEDROCK_* fields to be configured",
i, p.Type, database.AiProviderTypeBedrock)
i, p.Type, database.AIProviderTypeBedrock)
}
if isBedrockType && len(p.Keys) > 0 {
return nil, xerrors.Errorf("provider %d (%s): KEY/KEYS are not supported for TYPE %q (use BEDROCK_* fields)",
i, p.Type, database.AiProviderTypeBedrock)
i, p.Type, database.AIProviderTypeBedrock)
}
if providerType == database.AiProviderTypeCopilot && len(p.Keys) > 0 {
if providerType == database.AIProviderTypeCopilot && len(p.Keys) > 0 {
return nil, xerrors.Errorf("provider %d (%s): KEY/KEYS are not supported for TYPE %q",
i, p.Type, database.AiProviderTypeCopilot)
i, p.Type, database.AIProviderTypeCopilot)
}
// An Anthropic provider authenticates either via a bearer