Repository navigation
refactor(coderd/x/chatd): create and finalize debug runs through one helper - #30934
ibetitsmike wants to merge 5 commits into
Conversation
…helper Chat turns, manual titles, automatic titles and turn status labels each created a debug run on a detached, time-bounded context, rebuilt its run context from the returned row and finalized it by hand. Add chatdebug.Service.BeginRun and StartRun and route those call sites through them. This deletes prepareQuickgenDebugCandidate, shortTextCandidate, chatdebugRunContext, debugCreateRunTimeout and a literal 5 second insert timeout. Create and finalize failures now log through the chatdebug logger with one message each. The compaction copy is unchanged.
|
@codex review |
Codex Review SummaryThis 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: 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". |
prepareManualTitleDebugRun is a plain function on this branch, so the merged test calls it directly.
|
@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". |
Chat turns, manual titles, automatic titles and turn status labels each created a debug run on a detached, time-bounded context, rebuilt the run context from the row, and finalized the run by hand. This PR adds
chatdebug.Service.BeginRunandStartRunand routes all four through them. It deletesprepareQuickgenDebugCandidate,shortTextCandidate,chatdebugRunContext,debugCreateRunTimeoutand a literal 5 second insert timeout.BeginRuninserts the run on a context that ignores the caller's cancellation, with a 5 second limit, and builds theRunContextfrom its parameters. Chat turns call it and still finalize inrunnerDebugTurn.StartRunwrapsBeginRunfor one model call and returns a context that carries the run plus a function that finalizes it from the call's error. Titles and status labels use it.TestService_StartRuncovers a finalized run, a failed insert and a failed finalize with a mock store, including the warning each failure logs.Why it is safe: #30933 pins the insert parameters, the run context, the finalize status and summary, and the failed insert for all four call sites. Those tests and the other debug-run, title and quickgen tests pass before and after.
CreateRunstores its parameters unchanged, so aRunContextbuilt from the parameters equals one built from the row. A repo-wide search finds no reference to the deleted symbols. Of 13 mutants ofBeginRunandStartRun, 12 failTestService_StartRun; the survivor shortens the insert limit from 5 seconds to 1.Review focus: log output. Create and finalize failures now log through the chatdebug logger as
failed to create debug runandfailed to finalize debug run. Before, each call site used its own logger and message. Compaction still creates its debug run by hand, because #30766 changes that code; it can move toStartRunafter that PR merges.Validation:
go test -race -count=1 -p 4 -parallel 4 ./coderd/x/chatd/ -run '^(TestActiveServer_ChatTurnDebugRun.*|TestRunnerDebugTurn.*|TestProposeChatTitle_DebugRun|TestArchiveChatDeletesDebugRuns|TestEditMessageDebugCleanup.*|TestQuickgen.*|TestMaybeGenerateChatTitle.*|TestPrepareManualTitleDebugRunCreateFailure)$': the same 25 tests pass before and after.go test -race -count=1 -p 4 -parallel 4 ./coderd/x/chatd/chatdebug/...passes.golangci-lint run --fix=false ./coderd/x/chatd/chatdebug/... ./coderd/x/chatd/reports 0 issues, and the pre-commit hook passed.Stack
This stack simplifies the chatdebug heartbeat, debug-run and stream wrapper code. Each refactor sits on a test-only layer that pins the behavior it keeps.