From 95b0a9962861b2aef4a3e9538dd38608aca4bcfc Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 16 Mar 2026 04:33:36 +0200 Subject: Document lock ordering, fix test data races, correct stateMu guard - Add doc comments clarifying Server.mu and completionState.stateMu are independent (no ordering constraint). - Fix test using wrong lock (s.mu instead of stateMu) for lastLLMCall. - Replace time.Sleep polling in 7 tests with s.inflight.Wait() to eliminate data races under -race. Co-Authored-By: Claude Opus 4.6 --- internal/lsp/completion_state.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'internal/lsp/completion_state.go') diff --git a/internal/lsp/completion_state.go b/internal/lsp/completion_state.go index 9f034ab..692eafe 100644 --- a/internal/lsp/completion_state.go +++ b/internal/lsp/completion_state.go @@ -6,6 +6,9 @@ import ( "time" ) +// completionState manages the LRU completion cache, pending completions, and +// throttle timing. Its stateMu is independent of Server.mu — the two locks +// are never held simultaneously, so there is no ordering constraint. type completionState struct { stateMu sync.RWMutex compCache map[string]string -- cgit v1.2.3