Repository navigation
refactor(coderd): delete the chat debug run and step heartbeats - #30988
Conversation
The heartbeats only refreshed updated_at on in-progress debug runs and steps so that FinalizeStale would not sweep them. FinalizeStale has no production caller, so the heartbeats kept nothing alive. Delete both launchers, Service.TouchStep, Service.TouchRun, the threshold-change wake-up channel, and the TouchChatDebugStepAndRun and TouchChatDebugRunUpdatedAt queries with their authz wrappers.
|
@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. Nice work! 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". |
…he WithClock doc This PR deletes the heartbeat tickers, so the WithClock doc no longer names them.
|
@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". |
Deletes the chat debug heartbeats. Model calls and streams started a goroutine that touched the step and its run on a ticker, and runner debug turns started a second one that touched the run. Both existed so that
FinalizeStalewould not mark a live run as interrupted, but nothing in production callsFinalizeStalesince #26270. Mike chose to delete the stale sweep as dead code. This PR is the first of three that do it.chatdebug/model.go:Generate,GenerateObjectand both stream wrappers no longer startlaunchHeartbeat.active_turn_debug.go: the runner debug turn no longer startsLaunchRunHeartbeat.chatdebug/service.go: deletesTouchStep,TouchRun,LaunchRunHeartbeat,heartbeatInterval, and the channel thatSetStaleAfterclosed to wake the heartbeats. TheWithClockdoc no longer names the heartbeat tickers.TouchChatDebugStepAndRunandTouchChatDebugRunUpdatedAtqueries with their dbauthz wrappers and tests, andTestLaunchHeartbeat.TestFinalizeStaleChatDebugRowsnow backdates its run withUpdateChatDebugRuninstead of the deleted test-only query.Why it is safe: the heartbeats wrote only
updated_atonchat_debug_runsandchat_debug_steps. These read it:FinalizeStaleChatDebugRowsand the partial indexesidx_chat_debug_runs_staleandidx_chat_debug_steps_staleDeleteOldChatDebugRuns(dbpurge)DebugPanel.tsxrun sortstarted_at || updated_at, andstarted_atisNOT NULL, so it never falls back toupdated_at.updated_atas data. Nothing uses it to decide whether a run is alive.dbpurge deletes runs whose
updated_atis older than the debug retention window, whatever their status, and their steps cascade. The window isagents_chat_debug_retention_days: 30 days by default, and 0 turns the purge off, so dbpurge never deletes a run that was written in the last day. A run'supdated_atstill moves when the run is created, when each step is inserted (theInsertChatDebugStepCTE), and on every run update and finalize. So dbpurge could only delete a live run if one model call plus the tool calls after it ran for more than a day. The runner finalizes its debug run when the runner context ends, arequires_actionwait times out after 5 minutes (the caseTouchRuncovered), and chatloop aborts a stream that is silent for--chat-stream-silence-timeout, 10 minutes by default (0 turns that guard off).Mike accepted the cost: a run or step orphaned by a crashed replica stays
in_progressuntil dbpurge deletes it. That is already true onmain, because nothing runs the sweep.This does not touch the chat worker's
chat_heartbeatsloop that ARCHITECTURE.md describes, and no ARCHITECTURE.md sentence about debug runs becomes false.Review focus: nothing uses
WithClockafter this PR, but deleting it here would take this PR past 500 changed lines, so it goes withFinalizeStalein the next PR.Validation:
make gen/db,go build ./coderd/..., andgolangci-lint runon the touched packages (0 issues).go test -count=1passes for./coderd/x/chatd/chatdebug/...,./coderd/database/dbauthz/ -run TestMethodTestSuite,./coderd/database/ -run ChatDebug,./coderd/x/chatd/ -run Debugand./coderd/database/dbpurge/. The pre-commit hook passed.Stack
This stack deletes the stale debug-run sweep, then simplifies the chatdebug debug-run, stream wrapper and step numbering code, drops the indexes the sweep used, and last deletes a runner debug field that lost its only reader with the heartbeats. The debug-run and stream wrapper refactors each sit on a test-only layer that pins the behavior they keep.
FinalizeStaleand the stale thresholdFinalizeStaleChatDebugRowsqueryrunnerCtxfrom the runner debug turn