Skip to content

chore: surface key add/remove/keep counts in audit log#25484

Merged
dannykopping merged 2 commits into
mainfrom
dk/aibridge-providers-audit
May 20, 2026
Merged

chore: surface key add/remove/keep counts in audit log#25484
dannykopping merged 2 commits into
mainfrom
dk/aibridge-providers-audit

Conversation

@dannykopping
Copy link
Copy Markdown
Contributor

No description provided.

@dannykopping dannykopping force-pushed the dk/aibridge-providers-audit branch from eb8169a to ed242f5 Compare May 19, 2026 13:03
@dannykopping dannykopping force-pushed the dk/aibridge-providers-handlers branch from 610edd5 to a1a65c8 Compare May 19, 2026 13:22
@dannykopping dannykopping force-pushed the dk/aibridge-providers-audit branch from ed242f5 to 0e7201d Compare May 19, 2026 13:22
@dannykopping dannykopping changed the base branch from dk/aibridge-providers-handlers to graphite-base/25484 May 20, 2026 08:21
@dannykopping dannykopping force-pushed the graphite-base/25484 branch from a1a65c8 to dd32234 Compare May 20, 2026 08:39
@dannykopping dannykopping force-pushed the dk/aibridge-providers-audit branch from 0e7201d to 06945f3 Compare May 20, 2026 08:39
@dannykopping dannykopping changed the base branch from graphite-base/25484 to main May 20, 2026 08:39
@dannykopping dannykopping changed the title fix(coderd/ai_providers): surface key add/remove/keep counts in audit log chore: surface key add/remove/keep counts in audit log May 20, 2026
@dannykopping dannykopping force-pushed the dk/aibridge-providers-audit branch from 06945f3 to db7051b Compare May 20, 2026 08:48
dannykopping and others added 2 commits May 20, 2026 14:20
… log

A PATCH that only rotates API keys produced an audit entry with an
empty diff: keys live in a separate table, so the provider-level
diff missed every change. Per-key audit events were removed when
the AIProviderKey resource was dropped, so key rotation was
invisible in the log.

applyAIProviderKeyOps now returns counts, and the update handler
attaches them to the audit entry's additional_fields as
keys_added / keys_removed / keys_kept. An operator can now answer
"was anything rotated on this PATCH?" from the audit log even when
the top-level diff is empty.

Also fix sqlc casing so database.ResourceTypeAIProvider matches the
acronym convention used elsewhere in the codebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…per-key detail

Collapse aiProviderKeyOpsCounts into aiProviderKeyOpsAudit. Added and
removed now carry per-key {id, masked}; kept stays as a count since a
steady-state rotation can retain many keys and per-entry detail there
is noise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dannykopping dannykopping force-pushed the dk/aibridge-providers-audit branch from db7051b to 286f036 Compare May 20, 2026 12:23
@dannykopping dannykopping marked this pull request as ready for review May 20, 2026 12:24
@dannykopping dannykopping requested a review from ibetitsmike May 20, 2026 12:24
Comment thread coderd/audit/request.go
return database.ResourceTypeAiSeat
case database.AIProvider:
return database.ResourceTypeAiProvider
return database.ResourceTypeAIProvider
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

are you sure you are actually consistent with this casing throughout the codebase?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's super unfortunate that the other ones were Ai and not corrected to AI.

I've added a follow-up item to correct the others: https://linear.app/codercom/issue/AIGOV-369/change-ai-references-in-coderddatabasemodelsgo-to-ai

@dannykopping dannykopping merged commit 00e8b40 into main May 20, 2026
28 checks passed
@dannykopping dannykopping deleted the dk/aibridge-providers-audit branch May 20, 2026 12:45
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants