local F = require("flow_dsl")
local B = require("bp_dsl")
local flow = B.pipeline({
B.stage "prepare" {
agent = "prepare",
input = "$.d.prep",
out = "$.prepared",
},
B.stage "setup" {
agent = "setup",
input = "$.d.setup_dir",
out = "$.workspace",
},
B.stage "gather" {
agent = "gather",
input = "$.d.gather_ctx",
out = "$.context",
},
B.stage "implement" {
agent = "implement",
input = "$.d.impl",
out = "$.implemented",
},
B.stage "polish" {
agent = "polish",
input = "$.d.polish_rules",
out = "$.polished",
},
B.stage "review" {
agent = "review",
input = "$.d.review",
out = "$.review_verdict",
retry = {
max = 2,
counter = "$.rv_n",
fix = B.stage "fix" { agent = "fixer", input = B.from "review" },
},
},
B.stage "record" {
agent = "record",
input = "$.d.record",
out = "$.recorded",
},
B.stage "merge" {
agent = "merge",
input = "$.d.merge_target",
out = "$.merged",
},
halt_on = { "BLOCKED" },
halted_at = "$.halted_at",
done = "$.pipeline_complete",
})
local agents = {
B.agent({ md = "prepare.md", spec = { operator_ref = "main-ai" } }),
B.agent({ md = "setup.md", spec = { operator_ref = "main-ai" } }),
B.agent({ md = "gather.md", spec = { operator_ref = "main-ai" } }),
B.agent({ md = "implement.md", spec = { operator_ref = "main-ai" } }),
B.agent({ md = "polish.md", spec = { operator_ref = "main-ai" } }),
B.agent({
md = "review.md",
verdict = { channel = "part", values = { "PASS", "BLOCKED" } },
spec = { operator_ref = "main-ai" },
}),
B.agent({ md = "record.md", spec = { operator_ref = "main-ai" } }),
B.agent({ md = "merge.md", spec = { operator_ref = "main-ai" } }),
B.agent({ md = "fixer.md", spec = { operator_ref = "main-ai" } }),
}
local operators = {
{
name = "main-ai",
display_name = "Main operator",
kind = "main_ai",
spec = F.obj(),
},
}
return {
id = "sample-pipeline",
flow = flow,
agents = agents,
strategy = { strict_refs = true, strict_kind = true },
metadata = {
default_run_ttl_secs = 5400,
description = "Nine verdict-gated stages in sequence with a bounded fix-and-regate retry loop around the review stage. Callers seed per-stage directives under init_ctx.d and the retry counter rv_n=0. The review agent declares a verdict contract (channel=part, values=[PASS, BLOCKED]) so compile-time cond lint and submit-time gating protect the loop shape.",
},
operators = operators,
}