fix: ensure errored myses can be restarted cleanly
When a mysis errors during execution, the goroutine may still be running but the state is set to errored. Attempting to restart without cleanup causes multiple goroutines to run simultaneously, leading to race conditions and immediate re-error. Root Cause: - setErrorState() changes state to errored but doesn't cancel context - Old run() goroutine continues running in background - Start() creates NEW context and goroutine - Two goroutines now running concurrently for same mysis - Results in immediate error and return to errored state Solution: - Detect errored state with existing context in Start() - Cancel old context and wait for goroutine to exit (2s timeout) - Then proceed with normal start sequence - Ensures clean slate before restarting Changes: - internal/core/mysis.go: Add cleanup logic in Start() for errored state - internal/core/mysis.go: Export SetErrorState() for testing - internal/core/commander_test.go: Add TestCommanderRestartErroredMysis - internal/core/commander_test.go: Add fmt import Test validates: 1. Mysis can be started normally 2. Error can be simulated with SetErrorState() 3. Errored mysis can be restarted successfully 4. State transitions to running (not back to errored) 5. LastError is cleared on restart All tests passing (76.9% core coverage, 86.2% TUI coverage)
xonecas2026-02-06
80fac3158fa236bd9c3012478629314398429047
parent ebccfa0