• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

umputun / ralphex / 26432277551

26 May 2026 04:27AM UTC coverage: 83.252% (-0.1%) from 83.363%
26432277551

Pull #364

github

umputun
fix(processor): guard external review phase holder
Pull Request #364: Refactor processor runner into phase engines

1114 of 1228 new or added lines in 15 files covered. (90.72%)

22 existing lines in 5 files now uncovered.

7680 of 9225 relevant lines covered (83.25%)

222.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.87
/pkg/processor/phase/finalize.go
1
package phase
2

3
import (
4
        "context"
5
        "errors"
6
        "fmt"
7

8
        "github.com/umputun/ralphex/pkg/status"
9
)
10

11
// FinalizePhase runs the optional finalize step.
12
type FinalizePhase struct {
13
        cfg         Config
14
        log         FinalizeLogger
15
        exec        Executor
16
        policy      Policy
17
        prompts     FinalizePrompts
18
        phaseHolder *status.PhaseHolder
19
}
20

21
// FinalizePhaseOpts contains dependencies for FinalizePhase.
22
type FinalizePhaseOpts struct {
23
        Cfg         Config
24
        Log         FinalizeLogger
25
        Exec        Executor
26
        Policy      Policy
27
        Prompts     FinalizePrompts
28
        PhaseHolder *status.PhaseHolder
29
}
30

31
// NewFinalizePhase creates a finalize phase engine.
32
func NewFinalizePhase(opts FinalizePhaseOpts) *FinalizePhase {
76✔
33
        return &FinalizePhase{
76✔
34
                cfg: opts.Cfg, log: opts.Log, exec: opts.Exec,
76✔
35
                policy: opts.Policy, prompts: opts.Prompts, phaseHolder: opts.PhaseHolder,
76✔
36
        }
76✔
37
}
76✔
38

39
// Run executes the optional finalize step; ordinary executor failures are logged and do not fail the pipeline.
40
func (p *FinalizePhase) Run(ctx context.Context) error {
6✔
41
        if !p.cfg.FinalizeEnabled {
7✔
42
                return nil
1✔
43
        }
1✔
44

45
        if p.phaseHolder != nil {
10✔
46
                p.phaseHolder.Set(status.PhaseFinalize)
5✔
47
        }
5✔
48
        p.log.PrintSection(status.NewGenericSection("finalize step"))
5✔
49

5✔
50
        execName := p.executorName()
5✔
51
        execResult := p.policy.Run(ctx, p.exec.Run, p.prompts.FinalizePrompt(), execName)
5✔
52
        result := execResult.Result
5✔
53

5✔
54
        if result.Error != nil {
8✔
55
                if errors.Is(result.Error, context.Canceled) || errors.Is(result.Error, context.DeadlineExceeded) {
4✔
56
                        return fmt.Errorf("finalize step: %w", result.Error)
1✔
57
                }
1✔
58
                if p.policy.HandlePatternMatchError(result.Error, execName) != nil {
3✔
59
                        return nil //nolint:nilerr // intentional: best-effort semantics, log but don't propagate
1✔
60
                }
1✔
61
                p.log.Print("finalize step failed: %v", result.Error)
1✔
62
                return nil
1✔
63
        }
64

65
        if result.Signal == SignalFailed {
3✔
66
                p.log.Print("finalize step reported failure (non-blocking)")
1✔
67
                return nil
1✔
68
        }
1✔
69

70
        p.log.Print("finalize step completed")
1✔
71
        return nil
1✔
72
}
73

74
func (p *FinalizePhase) executorName() string {
5✔
75
        if p.cfg.isCodexExecutor() {
5✔
NEW
76
                return "codex"
×
NEW
77
        }
×
78
        return "claude"
5✔
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc