Skip to content

chore: drop chat gateway key columns - #27172

Closed
ibetitsmike wants to merge 4 commits into
mike/chat-synthetic-keys/stop-legacy-storagefrom
mike/chat-synthetic-keys/drop-columns
Closed

chore: drop chat gateway key columns#27172
ibetitsmike wants to merge 4 commits into
mike/chat-synthetic-keys/stop-legacy-storagefrom
mike/chat-synthetic-keys/drop-columns

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Mux is working on behalf of Mike.

Summary

Drop the unused api_key_id columns from chat messages and queued messages after #27171 stops reading and writing them, and remove the transitional query scaffolding that existed only to avoid referencing those columns during rolling deploys.

With the columns gone, sqlc generates database.ChatMessage and database.ChatQueuedMessage without api_key_id, so:

  • the *Raw chat message queries get their canonical names back
  • the extra chatMessageQuerier interface, pass-through wrappers, duplicated dbauthz methods, and row-projection types are deleted

The down migration re-adds nullable text columns without foreign keys so rollback reproduces the amended #27171 schema. Previous column values cannot be restored. Deploy only after #27171 is fully deployed.

Depends on #27171.

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Mux is working on behalf of Mike.

Dogfood migration UAT passed.

  • Started chore: drop chat gateway key columns #27172 against the preserved PR1 and PR2 database.
  • Verified both legacy columns and both legacy foreign keys were absent.
  • Verified the synthetic mapping primary key, uniqueness constraint, and cascading foreign keys remained.
  • Existing PR1 and PR2 chats loaded successfully.
  • A new PR3 chat completed with the expected response.
  • Deleted an ordinary session key during an active generation. The chat state was unchanged at deletion time and the generation completed normally with no error.
  • Captured real Agents UI evidence showing the preserved PR1/PR2 chats and new PR3 chat.

@ibetitsmike ibetitsmike changed the title chore(coderd/database): drop chat gateway key columns chore: drop chat gateway key columns Jul 10, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 72c2c0ad02

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch from 72c2c0a to d2c8c25 Compare July 10, 2026 18:21
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/stop-legacy-storage branch from 6635cd2 to 7557de2 Compare July 10, 2026 18:21
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/stop-legacy-storage branch from 7557de2 to 2a464a3 Compare July 10, 2026 19:01
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch from d2c8c25 to 7618beb Compare July 10, 2026 19:01
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/stop-legacy-storage branch from 2a464a3 to e6a9d4f Compare July 10, 2026 19:23
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch 2 times, most recently from c077b35 to 2de350a Compare July 10, 2026 19:37
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/stop-legacy-storage branch from e6a9d4f to 21f7269 Compare July 10, 2026 19:37
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 2de350aa78

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Mux is working on behalf of Mike.

Final-stack targeted dogfood passed after the FK-decoupling fix.

  • PR1 head 500b588185: both legacy API-key FKs were absent. Deleting the mapped synthetic key during an active generation left history_version, queue_version, and generation_attempt unchanged at deletion time. The generation completed normally, compatibility text IDs remained, and the next turn reminted a new synthetic key.
  • PR2 head 21f726957a: the preserved PR1 chat loaded, a new FINAL-PR2 chat completed, legacy columns remained nullable and unwritten, and the FKs remained absent.
  • PR3 head 2de350aa78: preserved PR1 and PR2 chats loaded, a new FINAL-PR3 chat completed, and the legacy columns and FKs were absent.

This supplements the earlier full UI/API/database UAT and validates the final rewritten stack heads.

@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch from 2de350a to 5cd4bec Compare July 13, 2026 19:13
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/stop-legacy-storage branch 2 times, most recently from a2c5a8f to f3a8581 Compare July 14, 2026 08:28
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch from 5cd4bec to 4f27e67 Compare July 14, 2026 08:28
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f27e67113

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch from 4f27e67 to d4ddfab Compare July 14, 2026 08:43
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: d4ddfab1da

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch from d4ddfab to ced7713 Compare July 14, 2026 09:15
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: ced7713115

ℹ️ 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".

Resolve the synthetic gateway key by deterministic token name
(chatd_<owner_id>_session_token) instead of a mapping table, mirroring
the provisionerd session token model. The lookup excludes login_type
'token' rows so a user-created token with the colliding name is never
picked up or extended. Near-expiry keys are extended in place under a
per-user advisory lock, keeping the key ID stable for in-flight
generations. New keys carry a minimal scope as defense in depth.
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/stop-legacy-storage branch from f3a8581 to b3b93ac Compare July 18, 2026 17:28
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/drop-columns branch from ced7713 to 29a32ce Compare July 18, 2026 17:28
@ibetitsmike
ibetitsmike force-pushed the mike/chat-synthetic-keys/stop-legacy-storage branch from b3b93ac to 9fabe24 Compare July 18, 2026 18:53
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Mux, on Mike's behalf.

Squashed into #27171 per review feedback there.

@ibetitsmike
ibetitsmike deleted the mike/chat-synthetic-keys/drop-columns branch July 18, 2026 18:55
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 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.

1 participant