Repository navigation
refactor(coderd/x/chatd/chatdebug): delete the process-global step counters - #31008
ibetitsmike wants to merge 3 commits into
Conversation
…unters The database numbers debug steps now, so nothing reads the per-run counters. Delete stepCounters, runRefCounts, refCountMu, trackRunRef, releaseRunRef, nextStepNumber, syncStepCounter and CleanupStepCounter, the runtime.AddCleanup hook in ContextWithRun, the FinalizeRun cleanup calls, and the tests of those helpers.
|
@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. Bravo. 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". |
|
@codex review
|
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
|
@codex review
|
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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 chatdebug's process-global step counters: the
stepCountersandrunRefCountsmaps,refCountMu,trackRunRef,releaseRunRef,nextStepNumber,syncStepCounterandCleanupStepCounter, theruntime.AddCleanuphook thatContextWithRunregistered for every run context, and the twoCleanupStepCountercalls inFinalizeRun. Since #31007 the database numbers steps, so no production code reads them.Why it is safe: after #31007 no production code reads the counters. Production code only maintained them:
ContextWithRunregistered a reference for every run context andFinalizeRuncalledCleanupStepCounter, and this PR removes both. A search ofcoderd/andenterprise/for the deleted names finds nothing now. The deleted tests covered only the deleted code:TestNextStepNumber_ConcurrentandTestSyncStepCounter_AdvancesCounterchecked counter values, and the three garbage-collection tests incontext_internal_test.gochecked that a counter lives until the lastRunContextfor its run is collected. The 20t.Cleanup(func() { CleanupStepCounter(runID) })lines go with them.TestReuseStep_PreservesExistingHolderandTestBeginStepReuseStepstay. TheFinalizeRundoc comment no longer mentions the counter.Review focus:
ContextWithRunis now a plaincontext.WithValue. Code that copies aRunContext, such asrunnerDebugTurn.contextLocked, no longer affects anything, because no state is tied to the struct's lifetime.Validation:
go test -race -count=1 -p 4 -parallel 4 ./coderd/x/chatd/chatdebug/...passes.go test -count=1 -run Debug ./coderd/x/chatd/(19 tests) passes, and the 25 chatd debug-run tests pass under-race(go test -race -run '^(TestActiveServer_ChatTurnDebugRun.*|TestRunnerDebugTurn.*|TestProposeChatTitle_DebugRun|TestArchiveChatDeletesDebugRuns|TestEditMessageDebugCleanup.*|TestQuickgen.*|TestMaybeGenerateChatTitle.*|TestPrepareManualTitleDebugRunCreateFailure)$' ./coderd/x/chatd/).golangci-lint run --fix=false ./coderd/x/chatd/chatdebug/...reports 0 issues, and 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