Repository navigation
feat(coderd): expire chat secret answers after 24 hours - #125
Conversation
…hind fork-nested-subagents A delegated chat that is not an explore subagent gets a blocking ask_user_question tool. The call records the question in the new chatd.chat_descendant_questions table and ends the turn; the answer is the next user message. The parent's wait_agent reports needs_input while the child's question is unanswered and, when called while it is pending, waits for the answer before it waits for the child.
…c and cover the late question TestDescendantQuestionEndsTurn raced the child's turn against the root's wait_agent call: when the question was already pending, wait_agent waited the default five minutes and the test hit its deadline (about 1 in 3 to 1 in 15 runs). The root's wait_agent now starts once the question is pending, with a 1 second timeout. TestDescendantQuestionWaitAgent now also covers a question the child asks while the parent waits on it, which only the racy end-to-end path exercised. TestAppendForkTools now includes wait_agent, so wrapping it with the experiment off fails.
…ions-1-chatd-tool # Conflicts: # coderd/database/forkdb/forkdbmock/forkdbmock.go # coderd/database/forkdb/querier.go # coderd/database/forkdb/sqlc.yaml
Adds the forkdb query ListPendingChatDescendantQuestionsByRoot with its dbauthz (read access to the root chat) and dbmetrics wrappers.
Lists the unanswered ask_user_question calls of the unarchived descendants in a chat's family behind fork-nested-subagents, so the root chat UI and API clients can answer them. Adds the codersdk types and client method and the generated swagger, API docs and TypeScript types.
…tions wait_agent now always runs the wrapped tool, so include_tool_calls and its validation apply while a question is pending, a question asked before an inner timeout is reported, and a failed question lookup is an error. Model-only user rows from lifecycle hooks no longer answer a question.
…ions-1-chatd-tool # Conflicts: # coderd/database/forkdb/sqlc.yaml
…ions-1-chatd-tool # Conflicts: # coderd/x/chatd/fork_tools.go
…ndant-questions-2-questions-route
…ions-1-chatd-tool # Conflicts: # coderd/database/dbauthz/fork_forkdb_test.go
…ions-1-chatd-tool # Conflicts: # coderd/database/dbauthz/fork_forkdb.go # coderd/database/dbmetrics/fork_forkdb.go # coderd/database/forkdb/sqlc.yaml # coderd/x/chatd/ARCHITECTURE.md
…ions-2-questions-route # Conflicts: # coderd/database/dbauthz/fork_forkdb_test.go # coderd/database/forkdb/chat_descendant_questions.sql.go # coderd/database/forkdb/chat_descendant_questions_test.go # coderd/database/forkdb/queries/chat_descendant_questions.sql
…family question list
…ions-2-questions-route # Conflicts: # coderd/apidoc/docs.go # coderd/apidoc/swagger.json
…ions-4-secret-answers
…hitecture document
…ers in key commands
Also send an empty options array for questions without options, and match the secret-answer route ID to its summary.
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. |
…escendant-questions-5-secret-answer-ttl
…er insert no longer needs
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7308643f67
ℹ️ 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".
…acement Edits of a chat message or of a queued message's content now get the same refusal as a new message while a secret question is pending. Replacing an unreported answer now locks the chat row and rechecks, in the same transaction, that no queued or delivered message reports the answer.
…escendant-questions-5-secret-answer-ttl # Conflicts: # coderd/fork_chat_questions.go
|
@codex review
|
|
Codex Review: Didn't find any major issues. Delightful! 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". |
…escendant-questions-5-secret-answer-ttl
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1b0aeca3e
ℹ️ 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".
… replaced An answer past its TTL can be replaced while the message that reports it is still queued. The route now skips the send in that case, so the queued message reports the new answer and no second report reaches the child after the question is answered.
|
@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". |
…ions-5-secret-answer-ttl # Conflicts: # coderd/database/dbauthz/fork_forkdb.go # coderd/database/dbauthz/fork_forkdb_test.go # coderd/database/dbmetrics/fork_forkdb.go # coderd/database/forkdb/chat_secret_answers.sql.go # coderd/database/forkdb/forkdbmock/forkdbmock.go # coderd/database/forkdb/querier.go # coderd/database/forkdb/queries/chat_secret_answers.sql # coderd/fork_chat_questions.go # coderd/fork_chat_questions_internal_test.go # coderd/fork_chat_questions_test.go # coderd/x/chatd/ARCHITECTURE.md
Closing and reopening only to make GitHub recompute the merge ref against current main ( |
|
@codex review
|
The merge ref now points at current main ( |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
Merge evidence for head
|
Part of #73
This is the second of four PRs for secret answers to descendant questions (R8.3). It stacks on #119. A secret answer is now usable for 24 hours. After that, reads skip it, and dbpurge deletes it.
What changes
GetChatSecretAnswersByChatIDreturns only answers newer than 24 hours, so an answer expires on time even when the purge has not run yet.purgeForkInTxonce per tick, inside its transaction. It deletes up to 1000chat_secret_answersrows older than 24 hours withDeleteOldChatSecretAnswers, oldest first. The age is measured with PostgreSQL'snow(), the same clock ascreated_atand the read filter.coderd_dbpurge_records_purged_total{record_type="chat_secret_answers"}. In upstream'sdbpurge.go, the call, the log field and the metric line are the only changes. The fork code is infork_dbpurge.go.created_athas no index. An answer lives at most 24 hours plus one 10 minute purge interval, and the next question of its chat deletes it, so the table stays small.coderd/x/chatd/ARCHITECTURE.md: thechat_secret_answersTODO now mentions the expiry. The document's owner writes the text.Validation
TestDeleteOldChatSecretAnswers(dbpurge, Postgres): a 25 hour old answer is deleted, a 23 hour old one is kept, and the counter shows 1. With the metric line removed, the test fails.TestForkChatSecretAnswerExpired(coderd): a queued answer aged to 25 hours is replaced by a second answer, and the queue still holds exactly one report. Without the TTL check, the second answer gets a 409. With the second send restored, the queue holds two reports and the test fails.TestPurge,TestMetrics,TestDBPurgeAuthorizationand dbauthzTestForkQuerierpass.forkdb/generate.shleaves no diff, andgofmtandgo vetpass.main. This PR targets feat: accept secret answers to descendant questions outside chat messages #119's branch, so CI runs after feat: accept secret answers to descendant questions outside chat messages #119 merges and this PR moves tomain.cbff12ee9c,fork-nested-subagentson, no model turns). I staged answers in SQL: two expired ones (25 h and 24 h 1 min old) and one fresh one (23 h). The dbpurge tick at 11:02Z deleted both expired rows and kept the fresh one. An answer aged past 24 h on a question that was pending again was replaced by a new answer (204, new value, freshcreated_at). A database dump,chat_messagesand the server log held none of the staged values.