Repository navigation
refactor(coderd/x/chatd): set the chatdebug stale threshold at construction - #30932
ibetitsmike wants to merge 3 commits into
Conversation
…uction chatd sets the debug stale threshold once, inside debugSvcFactory, before any caller can see the service. Replace Service.SetStaleAfter with a WithStaleAfter option and delete the atomic, mutex and wakeup channel that let running heartbeats pick up a runtime change, along with the subtest that exercised that path. The step and run heartbeat launchers now share one loop, and the test-only WithClock option is gone.
|
@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. 👍 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". |
…ds keep the default
|
@codex review |
|
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". |
|
Closing this PR. Mike chose to delete the stale debug-run sweep as dead code instead of reworking it. This PR set the stale threshold at construction, and #30989 deletes that threshold. The replacement stack:
The rest of the old stack now sits on #30995. The branch stays in place.
|
chatd sets the debug stale threshold once, in
debugSvcFactory, before any caller can reach the service. This PR replacesService.SetStaleAfterwith aWithStaleAfteroption and deletes the code that let a running heartbeat pick up a later change: the atomic threshold, the mutex, the wake-up channel, and theresets_ticker_on_threshold_changesubtest that tested them. The step and run heartbeat launchers now share one loop, and the test-onlyWithClockoption is gone.It also deletes a
chatd.gocomment that said debug runs do not heartbeat during model streams. Both launchers do.Why it is safe:
SetStaleAfterhad one production caller, indebugSvcFactory, which ran before the factory returned the service. A repo-wide search finds no reference toSetStaleAfter,thresholdChan,staleThreshold,staleAfterNanosor the chatdebugWithClock.TestLaunchHeartbeat(#30931) andTestService_FinalizeStale_UsesConfiguredThresholdcover the new code. The second is now a table that also checks that a zero or negativeWithStaleAfterkeepsDefaultStaleThreshold. All 13 mutants of the option, the shared loop, both launchers andFinalizeStalefail these tests, including ones that makeWithStaleAfteraccept zero or negative values.Review focus: the shared
heartbeatloop inservice.go. The one visible change is a log message: run heartbeat failures now logheartbeat touch failed, the message step heartbeats already used, instead ofrun heartbeat touch failed.Validation:
go test -race -count=1 -p 4 -parallel 4 ./coderd/x/chatd/chatdebug/...passes before and after.go test -race -count=1 -p 4 -parallel 4 ./coderd/x/chatd/ -run '^(TestActiveServer_ChatTurnDebugRun.*|TestRunnerDebugTurn.*|TestProposeChatTitle_DebugRun|TestArchiveChatDeletesDebugRuns|TestEditMessageDebugCleanup.*)$': the same 16 tests pass before and after.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.