From f03ccadd43e27216a3d774ca6236f72edcd7409f Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sun, 19 Apr 2026 16:25:43 +0200 Subject: [PATCH] agent: fix missed-wakeup race in WaitChange MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit notifyChange must hold changeMu when broadcasting. Without the lock, the broadcast can fire between the consumer's value check and its cond.Wait call — the signal is lost and the consumer sleeps until the next change, causing an apparent off-by-one lag. Co-Authored-By: Claude Sonnet 4.6 --- pkg/agent/core.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/agent/core.go b/pkg/agent/core.go index 8a1a8c6..10487ad 100644 --- a/pkg/agent/core.go +++ b/pkg/agent/core.go @@ -328,7 +328,9 @@ func (s *agentCore) State() string { } func (s *agentCore) notifyChange() { + s.changeMu.Lock() s.changeCond.Broadcast() + s.changeMu.Unlock() } // WaitChange blocks until the named field changes from current, then returns