From 3bfafbc8664a2a1ba8efc3f64376ff63c3dc11b9 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 21:26:12 +0200 Subject: plan 9: apply logs each step as it completes and stops a chain that landed elsewhere --- internal/engine/apply.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'internal/engine') diff --git a/internal/engine/apply.go b/internal/engine/apply.go index ce05636..83ea4fe 100644 --- a/internal/engine/apply.go +++ b/internal/engine/apply.go @@ -110,11 +110,13 @@ func (e *Engine) applyFile(dirName string, c plan.Chain, approved bool, j *journ return FileResult{File: c.File, Steps: steps}, nil } - results := apply.Chain(c) - for i, sr := range results { - if err := e.logStep(j, run, dirName, rel, i+1, c.Steps[i], sr); err != nil { - return FileResult{}, err - } + // Each step is logged the moment it has run (review M9), not after the + // whole chain: a run killed mid-chain must leave what it did undoable. + results, err := apply.ChainLogged(c, func(i int, sr apply.StepResult) error { + return e.logStep(j, run, dirName, rel, i+1, c.Steps[i], sr) + }) + if err != nil { + return FileResult{}, err } return FileResult{File: c.File, Steps: results}, nil } -- cgit v1.3