Repository navigation
feat: add AI provider schema expansion - #25412
Conversation
|
/coder-agents-review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28b6e9d6aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
First-pass review (Netero). This is a mechanical scan only; the full review panel has not yet reviewed this PR. The panel will review after these findings are addressed.
The schema expansion is well-structured: naming is consistent with the existing chat-provider patterns, dbauthz tests cover the authorization layer, and the cliutil rotation/decrypt extensions follow the established per-table crypto pattern.
1 P0, 1 P1, 1 Nit, 1 Note.
The P0 (gen failure) and P1 (missing dbcrypt tests) should be resolved before the panel spends parallel review time.
"5 of 7 query methods have no callers outside infrastructure. They exist for the next PR in the stack. If the stack stalls, these are orphaned exports."
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
1 similar comment
|
/coder-agents-review |
There was a problem hiding this comment.
Round 2 is blocked on one unresolved finding. DEREM-2 and DEREM-3 were addressed in commit 2fc890fe7 (tests added, comment added). DEREM-4 (informational note about dead code) is dropped.
DEREM-1 (P0): CI gen check was failing in round 1. The thread was resolved without explanation and no commit targets gen sync. The PR was rebased and CI is currently pending (gen is no longer listed as failed), so the rebase may have resolved it. Could you confirm whether make gen produces a clean diff? The full review panel will proceed once this is verified.
🤖 This review was automatically generated with Coder Agents.
Confirmed: I ran |
|
/coder-agents-review |
There was a problem hiding this comment.
Round 3 (Netero). All R1 findings verified as addressed (DEREM-1 gen check confirmed clean via make gen; DEREM-2/DEREM-3 fixed in 2fc890fe7). This is still a first-pass review; the full review panel has not yet reviewed this PR.
1 P2. The panel will review after this finding is addressed.
"Encrypted user_ai_provider_keys rows with orphaned cipher references will survive the purge. Since the column has CHECK (api_key != ''), you cannot blank them; they must be deleted."
enterprise/dbcrypt/cliutil.go:470
P2 [DEREM-5] sqlDeleteEncryptedUserTokens handles every other encrypted table (user_links, external_auth_links, user_chat_provider_keys, user_secrets, chat_providers, ai_providers, ai_provider_keys) but omits the new user_ai_provider_keys table. The Delete function executes this SQL as the last-resort path when encryption keys are lost. Encrypted user_ai_provider_keys rows with orphaned cipher references will survive the purge. Since the column has CHECK (api_key != ''), you cannot blank them; they must be deleted.
Add DELETE FROM user_ai_provider_keys WHERE api_key_key_id IS NOT NULL; between the ai_provider_keys delete and the COMMIT. This corroborates the unresolved external finding (Codex) on this same file. (Netero)
🤖
🤖 This review was automatically generated with Coder Agents.
There was a problem hiding this comment.
Round 4 is blocked. DEREM-5 (P2) has had no author response or fix since it was raised in round 3.
DEREM-5: sqlDeleteEncryptedUserTokens omits the new user_ai_provider_keys table. The coder server dbcrypt delete recovery path will leave encrypted rows behind, and the CHECK (api_key != '') constraint means they cannot be blanked. This also corroborates the unresolved Codex finding on the same file.
To unblock: push a fix adding the missing DELETE statement, or respond to the finding (acknowledge, contest, or defer with a ticket). The full review panel is waiting on this.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
Round 5, first panel review. 20 reviewers. All prior Netero findings (DEREM-1 through DEREM-5) verified as addressed.
This is a well-scoped schema expansion. The structural parallel with user_chat_provider_keys across every layer (queries, dbauthz, dbcrypt, tests) makes the change easy to audit. Authorization boundaries are correct: user-facing methods gate on personal actions, admin/maintenance paths gate on ResourceAIProvider. Encryption follows the established dbcrypt pattern with thorough test coverage. The migration ordering handles dependencies correctly, and the down migration reverses cleanly.
1 P2, 1 P3, 3 Nit, 3 Note.
The P2 (soft-delete trigger gap) is a data hygiene issue that grows with user churn. The P3 and nits are naming/documentation improvements.
Pariston: "I tried four different framings of this problem and could not build a case against the author's approach. The problem is correctly understood, the solution is proportional, and the fix is at the right causal level."
Process note (Mafu-san): the initial commit shipped dbcrypt wrappers and cliutil rotation/decrypt but missed tests (DEREM-2) and the DELETE cleanup (DEREM-5). Both were caught by review and fixed well. The dbauthz tests in the same initial commit prove the agent knows tests are expected; it skipped one category, not all. The fixes themselves are thorough (164 lines of test code, precise 2-line DELETE).
enterprise/dbcrypt/cliutil.go:505
P3 [DEREM-7] The PR added DELETE FROM user_ai_provider_keys to sqlDeleteEncryptedUserTokens but left the error message (line 505) as "delete encrypted tokens and chat provider keys" and the log (line 507) as "deleted encrypted user tokens and chat provider API keys". The SQL now touches 8 tables. An operator debugging a failed delete sees a message that covers about a third of the blast radius.
This is a pre-existing gap (predates this PR for user_secrets, ai_providers, ai_provider_keys) that this PR extends by one more table. Update both strings to reflect the actual scope. (Leorio)
🤖
enterprise/dbcrypt/cliutil.go:497
Nit [DEREM-10] The Delete doc comment says "deletes all user tokens" but the SQL purges 8 tables. The constant name sqlDeleteEncryptedUserTokens similarly understates scope. Someone deciding whether to invoke this destructive function needs to know the blast radius. Pre-existing gap, but this PR extends it. (Leorio, Gon)
🤖
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
1 similar comment
|
/coder-agents-review |
There was a problem hiding this comment.
Round 6 is blocked. No author response or code changes for any R5 panel findings (only docs-only merges since R5).
Open findings requiring response:
DEREM-6 (P2): delete_deleted_user_resources() trigger does not clean up user_ai_provider_keys on user soft-delete. Orphaned encrypted rows accumulate and tax every dbcrypt rotation cycle. Fix: add DELETE FROM user_ai_provider_keys WHERE user_id = OLD.id; to the trigger.
DEREM-7 (P3): Error/log messages in Delete don't mention user AI provider keys (pre-existing gap this PR extends).
DEREM-8, 9, 10 (Nit): Naming and documentation improvements (GetUserAIProviderKeyByProviderID name, GetUserAIProviderKeys purpose comment, Delete doc/constant scope).
To unblock: push fixes, or respond to the findings (acknowledge, contest, or defer with a ticket). DEREM-6 is the key item.
🤖 This review was automatically generated with Coder Agents.
There was a problem hiding this comment.
Round 7 is blocked. Same 5 findings have been silent for 2 consecutive rounds since the panel review (R5). No code changes or author responses, only docs merges.
DEREM-6 (P2) remains the key item: delete_deleted_user_resources() trigger needs DELETE FROM user_ai_provider_keys WHERE user_id = OLD.id; to clean up orphaned encrypted rows on user soft-delete.
DEREM-7 (P3), DEREM-8/9/10 (Nit) are also open. Any response (fix, acknowledge, contest, or defer with ticket) unblocks.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
Round 8. All findings resolved.
DEREM-6 (P2, soft-delete trigger) and DEREM-9 (Nit, purpose comment) addressed in commit 64402b5e4. The trigger now cleans up user_ai_provider_keys on user soft-delete, and GetUserAIProviderKeys has a purpose comment matching its sibling.
DEREM-7 (P3), DEREM-8 (Nit), DEREM-10 (Nit) dropped. All three concern pre-existing naming/documentation gaps in cliutil.go or debatable naming conventions that this PR marginally extends but did not introduce. The author's selective addressing (fixed every P0-P2 and the actionable Nit, left pre-existing gaps) is a reasonable scope boundary for a stack PR.
CI is green. 13 findings across 8 rounds: 7 fixed by author, 6 dropped by orchestrator. No open findings remain.
🤖 This review was automatically generated with Coder Agents.
Responses to the latest
|
|
/coder-agents-review |
There was a problem hiding this comment.
Round 9. Author responses received, all dispositions confirmed. Review complete.
DEREM-8 (Nit, query naming): author acknowledged, keeping name to avoid broad generated rename. DEREM-11 (Note, rotation model): author acknowledged, keeping bulk rotation by design. DEREM-12 (Note, upsert params): author added clarifying comment in 64402b5e4.
13 findings across 9 rounds. 7 fixed by author, 2 acknowledged by author, 4 dropped by orchestrator. No open findings. CI green.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
Round 10 re-review (4 panel reviewers). New commit 95499f5c0 removes a redundant index (idx_user_ai_provider_keys_user_id); the UNIQUE constraint on (user_id, ai_provider_id) already provides a leading-column B-tree usable for user_id-only lookups.
Netero and all 4 panel reviewers: no findings. 13 findings across 10 rounds, all closed. CI pending.
Meruem: "No implicit assumptions found that the code does not express."
🤖 This review was automatically generated with Coder Agents.
|
@codex review
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c1df773d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
0729220 to
9060800
Compare
06c0b16 to
222d76b
Compare
be8a005 to
9422812
Compare
… name collision The 000504 backfill previously raised an exception when a live ai_providers row already used an 'agents-*' name. That scenario should not occur since no other process writes to ai_providers before this migration, but the RAISE EXCEPTION path left no recovery option. The backfill now soft-deletes any conflicting live row (freeing the name under the partial unique index) and inserts the chat_providers-derived row as authoritative. Adds a migration test covering the override path.
9422812 to
2f67dd7
Compare
Stack Context
This stack migrates Agents chat provider configuration from legacy chat provider tables to the shared AI provider model.
Active Stack
This PR body is the source of truth for the active stack order and Graphite links. Stack-listing comments are intentionally removed to avoid drift.
mike/ai-providers/schema-expandmike/ai-providers/backend-cutovermike/ai-providers/frontend-cutovermike/ai-providers/legacy-cleanupPR #25411 is the merged docs glossary and is not in the active stack. PR #25413 is no longer part of the active stack.
What?
chat_model_configs.ai_provider_idso model configs can target concrete provider instances.ai_providersusing preserved IDs andagents-*names.000504_ai_providers_backfillwithout adding sync triggers between legacy and AI provider tables.000504_ai_providers_backfillto assert pre-backfill, post-backfill, and down-migration state across multiple legacy providers.Validation
make gengo test ./coderd -run TestUserSkillSoftDeleteCleanup -count=1go test -count=1 ./coderd/database/migrations -run 'TestMigrate/(Once|UpDownUp)'make pre-commitvia git hook