aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/aflow/action.go
blob: cd09466a4427837e1c3b7fa70e69606902000e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2025 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package aflow

type Action interface {
	verify(*verifyContext)
	execute(*Context) error
}

type Pipeline struct {
	// These actions are invoked sequentially,
	// but dataflow across actions is specified by their use
	// of variables in args/instructions/prompts.
	Actions []Action
}

func NewPipeline(actions ...Action) *Pipeline {
	return &Pipeline{
		Actions: actions,
	}
}

func (p *Pipeline) execute(ctx *Context) error {
	for _, sub := range p.Actions {
		if err := sub.execute(ctx); err != nil {
			return err
		}
	}
	return nil
}

func (p *Pipeline) verify(ctx *verifyContext) {
	for _, a := range p.Actions {
		a.verify(ctx)
	}
}