Skip to content

feat(chatd): add chat_wakeup_watches rows for events wake-ups - #339

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/issue-293-watch-rows
Nov 15, 2026
Merged

ibetitsmike merged 3 commits into
mainfrom
mike/issue-293-watch-rows

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Bottom of a stack for #293. The top PR switches chatd to these rows.

What changes

The table is additive: nothing reads or writes it until the top PR, so this PR deploys on its own.

Tests

  • TestListReadyChatWakeupWatches: 1 chat, 3 children, one wake-up watching them. Nothing while all run; exactly the finished child after one finishes; nothing while the parent is running; nothing for a child with an open watch of its own; nothing for a child with an unanswered question; an archived child is ready; a delivered watch delivers once; a paused wake-up delivers nothing.
  • TestChatWakeupWatchRows: target checks, the cascade of a deleted child, output-line deliveries that keep a watch open, stale delivery counts, failed_at.
  • TestListReadyChatWakeupWatchesPlan: 10,000 completed wake-ups (each with its own chat, a message and a delivered watch), ANALYZE, then EXPLAIN of ListReadyChatWakeupWatches: no Seq Scan on chat_wakeups, chats, chat_messages or chat_wakeup_watches.

Ran: go test ./coderd/database/dbauthz/ ./coderd/database/dbmetrics/ ./coderd/database/migrations/... ./coderd/database/forkdb/... -count=1 (pass), the chatdmig tests with CHATDMIG_TEST_DATABASE_URL (pass), chatdmig check (pass), golangci-lint run on the changed packages (0 issues).

Adds a chatdmig node with one row per thing an events wake-up watches,
and the forkdb queries that find the ready watches of the whole
deployment in one statement. Nothing reads the table yet; the switch of
chatd follows in a stacked change.

Refs #293
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T14:10:25.538000Z 8a2a231 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

ibetitsmike commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: d233bb4261

ℹ️ 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
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@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: 8def5b79ed

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

… chats

MarkChatWakeupWatchDelivered clears fired_at and fired_payload, so an
open watch is not ready again for the event it just delivered.
ListReadyChatWakeupWatches leaves out chats in error with queued
messages, as ClaimDueChatWakeups does.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 8a2a231c65

ℹ️ 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 merged commit 61fcbfd into main Nov 15, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-293-watch-rows branch November 15, 2026 14:38
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged as 61fcbfd (squash, --match-head-commit). Bottom of the #293 stack; #340 follows after the next deploy.

Gates on head 8a2a231, with main at 99ced87 (live on the server at merge time):

Tests I ran on this head:

  • go test -count=1 -v -run 'TestListReadyChatWakeupWatches|TestChatWakeupWatchRows|TestListReadyChatWakeupWatchesPlan' ./coderd/database/forkdb/: 3 of 3 pass (the plan test asserts no sequential scan with 10,000 completed wake-ups).
  • go test -count=1 ./coderd/database/migrations/chatdmig/ ./coderd/database/dbauthz/: ok.
  • Negative control: disabling the unanswered chat_descendant_questions clause in the generated ready query makes TestListReadyChatWakeupWatches fail at chat_wakeup_watches_test.go:122. Restored, it passes.

Not exercised: nothing calls the new queries until #340, so there is no runtime behavior to test on a live server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant