Repository navigation
feat(coderd/database): add the InsertChatSubagent fork query - #26
Conversation
Authorizes as an update of the owning chat, like InsertChatDebugRun. Adds dbgen.ChatSubagent and a database test that a chat takes one subagent row and reads it back.
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. |
|
@codex review
|
|
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". |
…ogether The W0a acceptance asks for a test that a rolled-back transaction which wrote a chat and its chat_subagents row leaves neither.
|
@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". |
|
Part of #5
Adds
InsertChatSubagent, the first fork write query, so the subagent work can record a row inchat_subagentswhen it creates a child chat.ActionUpdateon the chat), likeInsertChatDebugRun.dbgen.ChatSubagentinserts a row for tests.TestInsertChatSubagentwrites every column, reads the row back, and checks that a second row for the same chat is a unique violation.TestInTx/RollbackChatSubagentwrites a chat and its subagent row in oneforkdb.InTxtransaction, rolls it back, and finds neither.No user-visible behavior changes: nothing calls the new query yet.
Size: 185 added lines, about 130 hand-written
Generated:
chat_subagents.sql.go,querier.go,forkdbmock/forkdbmock.go(55 lines). About 88 lines are tests.Validation
go build ./coderd/...,go veton the touched packages,git diff --check.chatdmig check;chatdmigtests pass on Postgres.generate.sh: no drift.git diff origin/main -- coderd/database/dump.sql coderd/database/queries.sql.go coderd/database/querier.go coderd/database/dbmockis empty.go test ./coderd/database/forkdb/... ./coderd/database/dbauthz/ ./coderd/database/dbmetrics/ ./coderd/database/dbgen/ ./enterprise/dbcrypt/on Postgres 17.forkdb.InTxbuild its fork store from the outer database instead of the transaction fails everyTestInTxsubtest; swappingworktree_pathandbranchin the insert failsTestInsertChatSubagent; authorizing withActionReadfailsTestForkQuerier/InsertChatSubagent.56aabd9f12, the same change before the rebase ontomainafter feat: add chat plugins backed by a chatd fork node #2 merged.Code diff between the UAT SHA and the head
git range-diffpairs no commits, because the tests changed. Comparing the added and removed lines of the non-test files (queries/chat_subagents.sql,chat_subagents.sql.go,querier.go,forkdbmock, and thefork_forkdb.gofiles ofdbauthz,dbmetricsanddbgen) between99317f60ee..56aabd9f12andc479170b46..1356ff9633, the only differences are:InsertChatSubagentdoc comment in dbauthz now ends "like InsertChatDebugRun".dbgen/fork_forkdb.goand thepolicyimport in dbauthz already exist onmainfrom feat: add chat plugins backed by a chatd fork node #2, so the head adds only the function bodies.The query SQL, the generated code, the authorization check and the dbmetrics wrapper are the same. Tests: the UAT SHA carried chatdmig equivalence tests and a
TestInTxrewrite, which #2 replaced onmain; the head addsTestInsertChatSubagentandTestInTx/RollbackChatSubagentinstead.