aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2026-01-22 14:36:25 +0100
committerDmitry Vyukov <dvyukov@google.com>2026-01-23 09:36:05 +0000
commit1aa92270bc0672eed4beb2d8d4556e9ee61d2cf2 (patch)
tree5b0f20ccf1b57dc9acaefa1eedb3e660ddb13c40 /pkg
parent8fb0f8fb04f74e0c849fb8e2ae236419ceae6fcf (diff)
pkg/aflow: unexport Pipeline type
I've added NewPipeline constructor for a bit nicer syntax, but failed to use it in actual workflows. Unexport Pipeline and rename NewPipeline to Pipeline. This slightly improves workflows definition syntax.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/aflow/action.go18
-rw-r--r--pkg/aflow/flow/assessment/kcsan.go36
-rw-r--r--pkg/aflow/flow/assessment/moderation.go38
-rw-r--r--pkg/aflow/flow/patching/patching.go68
-rw-r--r--pkg/aflow/flow_test.go4
-rw-r--r--pkg/aflow/llm_tool_test.go2
6 files changed, 80 insertions, 86 deletions
diff --git a/pkg/aflow/action.go b/pkg/aflow/action.go
index cd09466a4..741758845 100644
--- a/pkg/aflow/action.go
+++ b/pkg/aflow/action.go
@@ -8,21 +8,21 @@ type Action interface {
execute(*Context) error
}
-type Pipeline struct {
+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
+ actions []Action
}
-func NewPipeline(actions ...Action) *Pipeline {
- return &Pipeline{
- Actions: actions,
+func Pipeline(actions ...Action) *pipeline {
+ return &pipeline{
+ actions: actions,
}
}
-func (p *Pipeline) execute(ctx *Context) error {
- for _, sub := range p.Actions {
+func (p *pipeline) execute(ctx *Context) error {
+ for _, sub := range p.actions {
if err := sub.execute(ctx); err != nil {
return err
}
@@ -30,8 +30,8 @@ func (p *Pipeline) execute(ctx *Context) error {
return nil
}
-func (p *Pipeline) verify(ctx *verifyContext) {
- for _, a := range p.Actions {
+func (p *pipeline) verify(ctx *verifyContext) {
+ for _, a := range p.actions {
a.verify(ctx)
}
}
diff --git a/pkg/aflow/flow/assessment/kcsan.go b/pkg/aflow/flow/assessment/kcsan.go
index 6bfc7bb12..27ef7e907 100644
--- a/pkg/aflow/flow/assessment/kcsan.go
+++ b/pkg/aflow/flow/assessment/kcsan.go
@@ -23,26 +23,24 @@ func init() {
ai.WorkflowAssessmentKCSAN,
"assess if a KCSAN report is about a benign race that only needs annotations or not",
&aflow.Flow{
- Root: &aflow.Pipeline{
- Actions: []aflow.Action{
- kernel.Checkout,
- kernel.Build,
- codesearcher.PrepareIndex,
- &aflow.LLMAgent{
- Name: "expert",
- Model: aflow.GoodBalancedModel,
- Reply: "Explanation",
- Outputs: aflow.LLMOutputs[struct {
- Confident bool `jsonschema:"If you are confident in the verdict of the analysis or not."`
- Benign bool `jsonschema:"If the data race is benign or not."`
- }](),
- Temperature: 1,
- Instruction: kcsanInstruction,
- Prompt: kcsanPrompt,
- Tools: codesearcher.Tools,
- },
+ Root: aflow.Pipeline(
+ kernel.Checkout,
+ kernel.Build,
+ codesearcher.PrepareIndex,
+ &aflow.LLMAgent{
+ Name: "expert",
+ Model: aflow.GoodBalancedModel,
+ Reply: "Explanation",
+ Outputs: aflow.LLMOutputs[struct {
+ Confident bool `jsonschema:"If you are confident in the verdict of the analysis or not."`
+ Benign bool `jsonschema:"If the data race is benign or not."`
+ }](),
+ Temperature: 1,
+ Instruction: kcsanInstruction,
+ Prompt: kcsanPrompt,
+ Tools: codesearcher.Tools,
},
- },
+ ),
},
)
}
diff --git a/pkg/aflow/flow/assessment/moderation.go b/pkg/aflow/flow/assessment/moderation.go
index b13ee1e7d..f5b7a4bfb 100644
--- a/pkg/aflow/flow/assessment/moderation.go
+++ b/pkg/aflow/flow/assessment/moderation.go
@@ -33,27 +33,25 @@ func init() {
ai.WorkflowModeration,
"assess if a bug report is consistent and actionable or not",
&aflow.Flow{
- Root: &aflow.Pipeline{
- Actions: []aflow.Action{
- aflow.NewFuncAction("extract-crash-type", extractCrashType),
- kernel.Checkout,
- kernel.Build,
- codesearcher.PrepareIndex,
- &aflow.LLMAgent{
- Name: "expert",
- Model: aflow.GoodBalancedModel,
- Reply: "Explanation",
- Outputs: aflow.LLMOutputs[struct {
- Confident bool `jsonschema:"If you are confident in the verdict of the analysis or not."`
- Actionable bool `jsonschema:"If the report is actionable or not."`
- }](),
- Temperature: 1,
- Instruction: moderationInstruction,
- Prompt: moderationPrompt,
- Tools: codesearcher.Tools,
- },
+ Root: aflow.Pipeline(
+ aflow.NewFuncAction("extract-crash-type", extractCrashType),
+ kernel.Checkout,
+ kernel.Build,
+ codesearcher.PrepareIndex,
+ &aflow.LLMAgent{
+ Name: "expert",
+ Model: aflow.GoodBalancedModel,
+ Reply: "Explanation",
+ Outputs: aflow.LLMOutputs[struct {
+ Confident bool `jsonschema:"If you are confident in the verdict of the analysis or not."`
+ Actionable bool `jsonschema:"If the report is actionable or not."`
+ }](),
+ Temperature: 1,
+ Instruction: moderationInstruction,
+ Prompt: moderationPrompt,
+ Tools: codesearcher.Tools,
},
- },
+ ),
},
)
}
diff --git a/pkg/aflow/flow/patching/patching.go b/pkg/aflow/flow/patching/patching.go
index a0b8d4a6c..9959e0bdb 100644
--- a/pkg/aflow/flow/patching/patching.go
+++ b/pkg/aflow/flow/patching/patching.go
@@ -45,42 +45,40 @@ func init() {
ai.WorkflowPatching,
"generate a kernel patch fixing a provided bug reproducer",
&aflow.Flow{
- Root: &aflow.Pipeline{
- Actions: []aflow.Action{
- baseCommitPicker,
- kernel.Checkout,
- kernel.Build,
- // Ensure we can reproduce the crash (and the build boots).
- crash.Reproduce,
- codesearcher.PrepareIndex,
- &aflow.LLMAgent{
- Name: "debugger",
- Model: aflow.BestExpensiveModel,
- Reply: "BugExplanation",
- Temperature: 1,
- Instruction: debuggingInstruction,
- Prompt: debuggingPrompt,
- Tools: tools,
- },
- &aflow.LLMAgent{
- Name: "diff-generator",
- Model: aflow.BestExpensiveModel,
- Reply: "PatchDiff",
- Temperature: 1,
- Instruction: diffInstruction,
- Prompt: diffPrompt,
- Tools: tools,
- },
- &aflow.LLMAgent{
- Name: "description-generator",
- Model: aflow.BestExpensiveModel,
- Reply: "PatchDescription",
- Temperature: 1,
- Instruction: descriptionInstruction,
- Prompt: descriptionPrompt,
- },
+ Root: aflow.Pipeline(
+ baseCommitPicker,
+ kernel.Checkout,
+ kernel.Build,
+ // Ensure we can reproduce the crash (and the build boots).
+ crash.Reproduce,
+ codesearcher.PrepareIndex,
+ &aflow.LLMAgent{
+ Name: "debugger",
+ Model: aflow.BestExpensiveModel,
+ Reply: "BugExplanation",
+ Temperature: 1,
+ Instruction: debuggingInstruction,
+ Prompt: debuggingPrompt,
+ Tools: tools,
},
- },
+ &aflow.LLMAgent{
+ Name: "diff-generator",
+ Model: aflow.BestExpensiveModel,
+ Reply: "PatchDiff",
+ Temperature: 1,
+ Instruction: diffInstruction,
+ Prompt: diffPrompt,
+ Tools: tools,
+ },
+ &aflow.LLMAgent{
+ Name: "description-generator",
+ Model: aflow.BestExpensiveModel,
+ Reply: "PatchDescription",
+ Temperature: 1,
+ Instruction: descriptionInstruction,
+ Prompt: descriptionPrompt,
+ },
+ ),
},
)
}
diff --git a/pkg/aflow/flow_test.go b/pkg/aflow/flow_test.go
index 30bf23bf0..b8444e7c3 100644
--- a/pkg/aflow/flow_test.go
+++ b/pkg/aflow/flow_test.go
@@ -90,7 +90,7 @@ func TestWorkflow(t *testing.T) {
"SwarmInt": []int{1, 2},
"OutAggregator": "aggregated",
},
- NewPipeline(
+ Pipeline(
NewFuncAction("func-action",
func(ctx *Context, args firstFuncInputs) (firstFuncOutputs, error) {
assert.Equal(t, args.InFoo, 10)
@@ -317,7 +317,7 @@ func TestToolMisbehavior(t *testing.T) {
"Reply": "Finally done",
"AdditionalOutput": 2,
},
- NewPipeline(
+ Pipeline(
&LLMAgent{
Name: "smarty",
Model: "model",
diff --git a/pkg/aflow/llm_tool_test.go b/pkg/aflow/llm_tool_test.go
index e8597a67c..0cb7cd9fc 100644
--- a/pkg/aflow/llm_tool_test.go
+++ b/pkg/aflow/llm_tool_test.go
@@ -21,7 +21,7 @@ func TestLLMTool(t *testing.T) {
Something string `jsonschema:"something"`
}
testFlow[inputs, outputs](t, map[string]any{"Input": 42}, map[string]any{"Reply": "YES"},
- NewPipeline(
+ Pipeline(
&LLMAgent{
Name: "smarty",
Model: "model",