From 75ad09189847dd33c1ce0100de59c6c0e65586af Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sat, 4 Apr 2026 22:37:00 -0300 Subject: [PATCH] hecate: auto-clear stale startup intent on lock --- internal/cluster/orchestrator.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/cluster/orchestrator.go b/internal/cluster/orchestrator.go index b28409c..76cb422 100644 --- a/internal/cluster/orchestrator.go +++ b/internal/cluster/orchestrator.go @@ -107,6 +107,13 @@ func (o *Orchestrator) Startup(ctx context.Context, opts StartupOptions) (err er if readErr != nil { return fmt.Errorf("read startup intent: %w", readErr) } + if currentIntent.State == state.IntentStartupInProgress { + o.log.Printf("warning: detected stale startup intent from a previous interrupted run; clearing it before continuing") + if clearErr := state.MustWriteIntent(o.cfg.State.IntentPath, state.IntentNormal, "auto-clear stale startup intent", "startup"); clearErr != nil { + return fmt.Errorf("clear stale startup intent: %w", clearErr) + } + currentIntent = state.Intent{State: state.IntentNormal} + } if currentIntent.State == state.IntentShuttingDown { return fmt.Errorf("startup blocked: shutdown intent is active (%s)", currentIntent.Reason) }