Repository navigation
feat(chatd): wake wait_agent on the child's state channel - #333
Conversation
chat_descendant_questions now stores the family root and whether the question is answered. The chatstate message insert marks the question answered in the same transaction as the user message that answers or retires it: a visible user message, the secret answer message, or a compressed context boundary. A new question clears the state. Reads of the pending question and the questions endpoint no longer scan chat_messages. The chatdmig node backfills root_chat_id from the family root and marks rows that the old rule treats as answered with answered_by = 'migrated'. Pending rows stay pending. Part of #300.
wait_agent on a child with a pending question no longer polls every two seconds. It subscribes to the child's state channel before the first read and reads the question again on each notification. Every event that retires the question commits through the child's state machine, which publishes on that channel. A 5 second fallback tick covers a lost notification. Closes #300.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Require answered_by on an answered row; a NULL passed the CHECK. Label a prefixed answer to a question that is not secret as message, so secret_answer means a secret question. Index root_chat_id fully, so the cascade from a deleted chat can use it. Say in ARCHITECTURE.md that the chatstate insert writes this table through a fork hook. Cover deleted, compressed and secret rows in the backfill test.
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e94182c0e
ℹ️ 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 The ARCHITECTURE.md text is required by acceptance criterion 7 of #300 (final text, no TODOs); see the answered thread. |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
# Conflicts: # coderd/database/forkdb/sqlc.yaml # coderd/x/chatd/ARCHITECTURE.md
Merged the updated bottom branch, which now contains origin/main 9308bf6 (#330). @codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
…-state-opus-80f083c4 # Conflicts: # coderd/database/forkdb/chat_descendant_questions_test.go # coderd/database/forkdb/models.go # coderd/database/migrations/chatdmig/nodes/01a1da95-80da-7dd4-a368-4b8bf0e1f65f_chat_descendant_questions_answered.up.sql # coderd/x/chatd/fork_descendant_questions_internal_test.go
Retargeted to main after #332 merged (5f049c1) and merged main in (ebf7a71, no conflicts left; the diff against main is the 4 files of this PR). Tests run on this head: @codex review |
|
Codex Review: Didn't find any major issues. 👍 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". |
Merged as 3f37f49 (squash, Gates on head ebf7a71, with main at 5f049c1 (live on the server at merge time):
Tests run on this head:
Not exercised: the subscribe-failure fallback path, a wake that does not retire the question (a plain message to a secret-question child), and the secret answer route waking a waiting |
Top of a two PR stack for #300. It is based on #332 (
mike/issue-300-answered-state), which stores the answered state. Merge #332 first; this PR then needs a retarget tomainso fork-ci runs on it.What changed
descendantQuestionPollInterval(2 s) is gone.awaitDescendantAnswersubscribes toChatStateUpdateChannel(childID)before its first read, then reads the question again on each notification. Every event that retires a question commits through the child's state machine, which publishes on that channel after commit (feat(chatd): store the answered state of descendant questions #332 setsanswered_atinside that transaction).subagentAwaitFallbackPoll(5 s) covers a lost notification and a new question, which commits outside the state machine. If the subscription fails, the wait falls back tosubagentAwaitPollInterval, asawaitSubagentCompletiondoes.pendingDescendantQuestionhelper had no caller left.coderd/x/chatd/ARCHITECTURE.mddescribes the wake.Tests
All run locally with
flock ~/.fork-go.lock:go test ./coderd/x/chatd/ -run TestDescendantQuestion -v: pass.TestDescendantQuestionWaitAgentanswers throughServer.SendMessage. The call wakes with no clock advance: the child wait timer starts with the full 10 s.TestDescendantQuestionWaitReadscountsGetPendingChatDescendantQuestioncalls throughdbmetricsover 60 s of mock time on an unanswered question. Logged result:question reads in 60s: 13(the initial read, one per 5 s fallback tick, and the read after the short wait for the child). It asserts at most 13.go test ./coderd/x/chatd/... -count=1: pass.golangci-lint run --fix=false ./coderd/x/chatd/: no finding on changed lines. New-code config: 0 issues.Not verified
Closes #300.