Replace shipped pipeline examples with research and task starters
This commit is contained in:
+16
-42
@@ -1,7 +1,6 @@
|
||||
package examples_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
@@ -14,15 +13,13 @@ import (
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
)
|
||||
|
||||
// The graded set, in reading order, with its stage keys.
|
||||
// The shipped starters, in catalog order, with their stage keys.
|
||||
var wantStages = []struct {
|
||||
key string
|
||||
stages []string
|
||||
}{
|
||||
{"one-stage", []string{"review"}},
|
||||
{"two-stages", []string{"draft", "check"}},
|
||||
{"feedback-loop", []string{"implement", "review"}},
|
||||
{"human-decision", []string{"plan", "decide", "act"}},
|
||||
{"research", []string{"research", "report"}},
|
||||
{"task", []string{"Code", "Review", "UIReview", "Land"}},
|
||||
}
|
||||
|
||||
func TestCatalogIsTheGradedExampleSet(t *testing.T) {
|
||||
@@ -32,7 +29,7 @@ func TestCatalogIsTheGradedExampleSet(t *testing.T) {
|
||||
}
|
||||
for i, item := range items {
|
||||
// Numbered names keep the reading order in name-sorted pipeline lists.
|
||||
if item.Key != wantStages[i].key || !strings.HasPrefix(item.Name, fmt.Sprintf("Example %d: ", i+1)) || item.Description == "" || item.Scheduled {
|
||||
if item.Key != wantStages[i].key || item.Name == "" || item.Description == "" || item.Scheduled {
|
||||
t.Fatal("invalid or out-of-order example metadata", item.Key, item.Name)
|
||||
}
|
||||
graph, err := pipeline.ParseDefinition(item.Source)
|
||||
@@ -45,7 +42,7 @@ func TestCatalogIsTheGradedExampleSet(t *testing.T) {
|
||||
var keys []string
|
||||
for _, s := range graph.Stages {
|
||||
keys = append(keys, s.Key)
|
||||
if strings.TrimSpace(s.Prompt) == "" || s.FallbackError || s.Edges["error"] != protocol.FailureEnd {
|
||||
if strings.TrimSpace(s.Prompt) == "" || s.FallbackError || s.Edges["error"] == "" {
|
||||
t.Fatalf("%s/%s needs a prompt and an explicit error -> #failure edge", item.Key, s.Key)
|
||||
}
|
||||
}
|
||||
@@ -82,10 +79,8 @@ func stageByKey(t *testing.T, graph protocol.Graph, key string) protocol.Stage {
|
||||
// Every model stage declares an explicit role allowlist. Only the stages that
|
||||
// make the requested change may edit; nothing has web tools.
|
||||
var exampleTools = map[string]map[string][]string{
|
||||
"one-stage": {"review": {"read", "glob", "grep"}},
|
||||
"two-stages": {"draft": {"read", "glob", "grep"}, "check": {"read", "glob", "grep"}},
|
||||
"feedback-loop": {"implement": {"read", "glob", "grep", "edit", "shell"}, "review": {"read", "glob", "grep", "shell"}},
|
||||
"human-decision": {"plan": {"read", "glob", "grep"}, "act": {"read", "glob", "grep", "edit", "shell"}},
|
||||
"research": {"research": {"read", "glob", "grep", "shell", "websearch", "webfetch"}, "report": {"read", "glob", "grep", "edit", "shell"}},
|
||||
"task": {"Code": {"read", "glob", "grep", "edit", "shell"}, "Review": {"read", "glob", "grep", "shell"}, "UIReview": {"read", "glob", "grep", "shell"}, "Land": {"read", "glob", "grep", "edit", "shell"}},
|
||||
}
|
||||
|
||||
func TestExampleRoleToolRestrictions(t *testing.T) {
|
||||
@@ -170,15 +165,13 @@ func TestExamplesBindConfiguredDefaults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// No example commits, pushes or deploys; editing examples leave changes uncommitted.
|
||||
// Read-only stages state their non-editing boundary; delivery behavior is
|
||||
// intentionally different between the research and task starters.
|
||||
func TestExamplesAreSafe(t *testing.T) {
|
||||
for key, graph := range parsedCatalog(t) {
|
||||
for _, s := range graph.Stages {
|
||||
prompt := strings.ToLower(s.Prompt)
|
||||
edits := slices.Contains(exampleTools[key][s.Key], "edit")
|
||||
if edits && !strings.Contains(prompt, "uncommitted") {
|
||||
t.Fatalf("%s/%s must leave its changes uncommitted", key, s.Key)
|
||||
}
|
||||
if !edits && s.Type == stage.ModelType && !strings.Contains(prompt, "do not edit") && !strings.Contains(prompt, "change nothing") {
|
||||
t.Fatalf("%s/%s must say it changes nothing", key, s.Key)
|
||||
}
|
||||
@@ -186,32 +179,13 @@ func TestExamplesAreSafe(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFeedbackLoopUsesRunnerOwnedLimitsAndRetries(t *testing.T) {
|
||||
graph := parsedCatalog(t)["feedback-loop"]
|
||||
implement, review := stageByKey(t, graph, "implement"), stageByKey(t, graph, "review")
|
||||
if implement.Edges["success"] != "review" || review.Edges["rejected"] != "implement" || review.Edges["approved"] != protocol.SuccessEnd {
|
||||
t.Fatal("feedback loop must route implement -> review, rejected -> implement", implement.Edges, review.Edges)
|
||||
func TestTaskUsesRunnerOwnedLimitsAndReviewLoop(t *testing.T) {
|
||||
graph := parsedCatalog(t)["task"]
|
||||
code, review, ui := stageByKey(t, graph, "Code"), stageByKey(t, graph, "Review"), stageByKey(t, graph, "UIReview")
|
||||
if code.Edges["success"] != "Review" || review.Edges["rejected"] != "Code" || ui.Edges["rejected"] != "Code" {
|
||||
t.Fatal("task must route implementation and review findings through Code", code.Edges, review.Edges, ui.Edges)
|
||||
}
|
||||
if review.Limits == nil || review.Limits.MaxVisits != 3 || !slices.Equal(review.Limits.On, []string{"rejected"}) {
|
||||
t.Fatalf("review must cap rejected loops with runner-owned limits: %+v", review.Limits)
|
||||
}
|
||||
if implement.Configs["retries"] != "1" || implement.Configs["timeout"] != "30m" || review.Configs["retries"] != "2" || review.Configs["timeout"] != "15m" {
|
||||
t.Fatal("feedback loop must show explicit retries and timeouts", implement.Configs, review.Configs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHumanDecisionWaitsAndNotifies(t *testing.T) {
|
||||
graph := parsedCatalog(t)["human-decision"]
|
||||
plan, decide, act := stageByKey(t, graph, "plan"), stageByKey(t, graph, "decide"), stageByKey(t, graph, "act")
|
||||
if decide.Type != stage.HumanType || decide.Edges["approve"] != "act" || decide.Edges["revise"] != "plan" || decide.Edges["abort"] != protocol.FailureEnd {
|
||||
t.Fatalf("decide must be a human approve/revise/abort stage: %+v", decide)
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
s protocol.Stage
|
||||
want []string
|
||||
}{{plan, []string{"failure"}}, {decide, []string{"waiting"}}, {act, []string{"success", "failure"}}} {
|
||||
if tc.s.Notify == nil || !slices.Equal(tc.s.Notify.On, tc.want) {
|
||||
t.Fatalf("%s notify = %+v, want on=%v", tc.s.Key, tc.s.Notify, tc.want)
|
||||
}
|
||||
if review.Limits == nil || review.Limits.MaxVisits != 3 || !slices.Equal(review.Limits.On, []string{"rejected", "error"}) {
|
||||
t.Fatalf("review must cap rejected/error loops with runner-owned limits: %+v", review.Limits)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user