fix: prevent WaitGroup negative counter panic on restart
Critical bug: WaitGroup counter goes negative when restarting errored myses, causing panic: 'sync: negative WaitGroup counter' Root Cause: 1. StartMysis() calls wg.Add(1) 2. mysis.Start() detects errored state with old goroutine 3. Cancels old context, old goroutine exits and calls wg.Done() 4. NEW goroutine starts and will call wg.Done() when it exits 5. Result: ONE Add(1), TWO Done() calls → negative counter → PANIC Solution: - Move wg.Add(1) from StartMysis() to mysis.Start() - Add(1) called AFTER old goroutine cleanup completes - Add(1) called immediately before launching new goroutine - Ensures 1:1 Add/Done pairing Sequence when restarting errored mysis: 1. Start() detects errored state 2. Cancels old context, waits for old goroutine to exit 3. Old goroutine calls wg.Done() (from previous Add) 4. wg.Add(1) called for NEW goroutine 5. New goroutine starts 6. Eventually new goroutine calls wg.Done() Result: Balanced Add/Done calls Changes: - internal/core/commander.go: Remove wg.Add/Done from StartMysis - internal/core/mysis.go: Add wg.Add(1) before launching goroutine All tests passing (77.0% core coverage, 86.2% TUI coverage)
xonecas2026-02-06
2a0db995e3948b6776b241f07ef1fdf2ee5f7d37
parent 80fac31