feat: add chat hook dispatch storage and hook columns#27427
Conversation
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bdd280cb2
ℹ️ 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".
Adds the chat_hook_dispatches table, hook_allowed_tools and turn_id columns, sqlc queries, dbauthz policies, dbpurge retention, and the audit table entry for the upcoming chat lifecycle hooks feature.
8bdd280 to
5f61ea5
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f61ea5544
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
| DROP VIEW IF EXISTS chats_expanded; | ||
|
|
||
| ALTER TABLE chats ADD COLUMN hook_allowed_tools jsonb; | ||
| ALTER TABLE chat_messages ADD COLUMN turn_id uuid; |
There was a problem hiding this comment.
Why do we need a new identifier on chat_messages? Is snapshot_version / history_version not sufficient? Would a monotonically incrementing integer be more efficient w.r.t storage versus a UUID?

Stack Context
First PR of the chat lifecycle hooks stack (replaces the oversized #27275 split). This stack lets deployments register an external webhook that observes and steers agent chat lifecycles (session_start, user_prompt_submit, pre/post_tool_use, stop, pre/post_compact, subagent spawn).
Stack: #27427 (this) -> #27401 (dispatch backend) -> #27428 (chatstate transitions) -> #27429 (chatd wiring) -> #27430 (API + UI).
What
000551:chat_hook_dispatchestable (dispatch audit keyed by JWT jti) pluschats.hook_allowed_tools,chat_messages.turn_id, andchat_queued_messages.{turn_id,hook_prefix,hook_allowed_tools}columns.search_tsv).chatstateso exhaustruct passes; behavior is unchanged (zero UUIDs map to NULL in the insert queries).Why
Landing the schema first pins the migration number (no more renumber churn against main) and keeps the behavioral PRs above it review-focused. All columns and queries stay inert until #27429 wires dispatch.
Note for dev DBs that migrated the old branch-local 000551/000552: repair
schema_migrations.versionand_develop.applied_migrations, or use--db-reset.