Replace starters with four graded examples seeded into new databases

The template catalog is now Example 1-4: one stage, two stages (handoff),
feedback loop (runner-owned limits, retries, timeout) and human decision
(type=human approve/revise/abort with notify hooks). All read-only or leave
changes uncommitted; none commits, pushes or deploys.

A brand-new database (schema created by this Open) gets the examples once at
server start, bound to the configured default model and harness. A
server_settings marker records the decision, so removed examples never come
back and existing installs are marked without any pipeline being added or
rewritten.
This commit is contained in:
2026-11-03 19:35:47 +00:00
parent fa6c0864db
commit a48e4a5b6a
38 changed files with 711 additions and 929 deletions
+11 -11
View File
@@ -123,13 +123,13 @@ run directory; no file list is required. `shell` supports commands appropriate t
the repository's language and tooling, not a language-specific allowlist. A missing
tools block uses local read/glob/grep/edit/shell tools; prefer explicit stage roles.
Planning stages must not label a task blocked simply because they defer edits to
an implementer stage. Bundled starters show the intended role split: a task stage
may read/edit/shell and conditionally use `websearch`/`webfetch`; a planner may
read plus conditional web search/fetch; a three-stage implementer has no web tools
and works from the planner's research with local read/glob/grep/edit/shell; a
reviewer may read plus conditional web; a source-only review stage has no
edit/shell; a research stage uses web search/fetch; a committer has read/glob/grep
and shell but no edit. Never force web access for
an implementer stage. The intended role split: an implementer may
read/glob/grep/edit/shell; a planner reads, plus conditional web search/fetch only
when external knowledge is needed; a reviewer reads and may run read-only checks
with shell but never edits; a source-only review stage has no edit/shell; a
research stage uses web search/fetch; a committer has read/glob/grep and shell but
no edit. The bundled examples (`one-stage`, `two-stages`, `feedback-loop`,
`human-decision`) follow it without web tools. Never force web access for
trivial, fully understood local edits, and return blocked only when required
reliable evidence cannot be obtained rather than whenever one search tool fails.
Keep examples and prompts language-neutral unless the task itself asks for a
@@ -231,9 +231,9 @@ State this pre-commit checklist in the prompt:
documentation writer folds notes later (`references/orchestration.md`). An item that
staled no shared document has no note and needs no step 6.
This list is the canonical checklist. The bundled starters `task`, `three-stage` and
`docs-fold` each repeat it in their committer prompt because a template is embedded and
published on its own; keep those copies in sync with this list.
This list is the canonical checklist. Repeat it in each committer prompt, because a
definition is published on its own; keep those copies in sync with this list. The
bundled examples leave changes uncommitted and have no committer.
The committer prepares the complete clean candidate and resolves integration conflicts.
When `delivery=true`, the server executes the declared checks and lands after the
@@ -274,6 +274,6 @@ stage parks the run), `artifacts=markdown`.
Read this skill's `references/notifications.md` for the minimal terminal-path
recipe and optional native publisher format. Prefer hooks for ordinary success/error
alerts; a request to notify is not a request for a new delivery stage. Do not scan
the user's repository for Pipelines docs. Bundled starters are generic and manual-only.
the user's repository for Pipelines docs. Bundled examples are generic and manual-only.
Notification attachment/report support and model availability need real runtime
tests; structural validation alone cannot confirm delivery.
@@ -10,8 +10,9 @@ parallel/distributed task engine or a guarantee that model reports are correct.
- Drafts are editable Markdown plus JSON metadata. Publishing validates and creates
immutable versions; drafts remain retained. Keep context create-only/base-version
guards. Five optional generic starters are task, three-stage, review, research
and debug; a fresh database starts empty. Templates can be created directly with
guards. The four generic examples (one-stage, two-stages, feedback-loop,
human-decision) are the template set; a brand-new database is seeded with them
once, and an existing or already-seeded database never is. Templates can be created directly with
an editable prefilled name or customized first. Editing a bundled repository
template changes no installed or published definition; only explicit authoring
then submission creates a new immutable version.
+2 -2
View File
@@ -96,7 +96,7 @@ func TestCLIStatusAndStatistics(t *testing.T) {
func TestCLIDraftValidateSubmitAndImmutableHistory(t *testing.T) {
run, store, _ := setup(t)
output, err := run("new", "example", "--template", "task", "--json")
output, err := run("new", "example", "--template", "one-stage", "--json")
if err != nil {
t.Fatal(err)
}
@@ -171,7 +171,7 @@ func TestCLIDraftValidateSubmitAndImmutableHistory(t *testing.T) {
if items[0].Version != 3 {
t.Fatal("invalid submission changed live version", items)
}
for _, command := range [][]string{{"list", "--json"}, {"show", "example", "--json"}, {"templates", "--json"}, {"template", "task", "--source"}, {"drafts", "--json"}, {"runs", "--json"}, {"connection", "--json"}, {"ping"}} {
for _, command := range [][]string{{"list", "--json"}, {"show", "example", "--json"}, {"templates", "--json"}, {"template", "one-stage", "--source"}, {"drafts", "--json"}, {"runs", "--json"}, {"connection", "--json"}, {"ping"}} {
if _, err = run(command...); err != nil {
t.Fatal(command, err)
}
+1 -1
View File
@@ -78,7 +78,7 @@ Examples:
Authoring examples — use only when the operator explicitly requested a definition change:
pipelines edit "bug fix" "Add a review step"
pipelines new "release notes" "Summarize changes and notify my phone"
pipelines new "Add a feature" --template task --no-open --json --yes
pipelines new "Add a feature" --template feedback-loop --no-open --json --yes
pipelines validate /path/to/draft.md --json
pipelines submit /path/to/draft.md
+1 -1
View File
@@ -10,7 +10,7 @@ import (
)
func TestShowcaseDefinitions(t *testing.T) {
for _, name := range []string{"task", "review", "research", "three-stage"} {
for _, name := range []string{"one-stage", "two-stages", "feedback-loop", "human-decision"} {
t.Run(name, func(t *testing.T) {
source, err := os.ReadFile(filepath.Join("..", "..", "examples", name+".md"))
if err != nil {
+51
View File
@@ -0,0 +1,51 @@
package pipeline
import (
"context"
"database/sql"
"fmt"
"strconv"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
// examplesSeededSetting is the server_settings key recording that the example
// pipelines were considered for this database. Once present, SeedExamples never
// adds anything again, so deleting the examples does not bring them back.
const examplesSeededSetting = "examples_seeded"
// SeedExamples publishes the given example definitions as ordinary pipelines,
// but only into a brand-new database: one whose schema this Open created, that
// has no pipelines and has never been seeded. Every call that gets past the
// marker check records the marker, so an existing install that upgrades is
// marked without gaining or rewriting anything, and a later start never seeds.
// Sources must already be bound to the server's default model and harness. It
// returns the number of pipelines created.
func (s *Store) SeedExamples(ctx context.Context, items []protocol.Template) (int, error) {
var marker string
err := s.db.QueryRowContext(ctx, `SELECT value FROM server_settings WHERE key=?`, examplesSeededSetting).Scan(&marker)
if err == nil {
return 0, nil
}
if err != sql.ErrNoRows {
return 0, err
}
seeded := 0
if s.created {
var count int
if err := s.db.QueryRowContext(ctx, `SELECT COUNT(*) FROM pipelines`).Scan(&count); err != nil {
return 0, err
}
if count == 0 {
for _, item := range items {
// Create-only: a seed never replaces or versions an existing pipeline.
if _, err := s.Submit(ctx, item.Name, item.Source, true); err != nil {
return seeded, fmt.Errorf("seed example %q: %w", item.Name, err)
}
seeded++
}
}
}
_, err = s.db.ExecContext(ctx, `INSERT INTO server_settings(key,value) VALUES(?,?) ON CONFLICT(key) DO NOTHING`, examplesSeededSetting, strconv.Itoa(seeded))
return seeded, err
}
+94
View File
@@ -0,0 +1,94 @@
package pipeline
import (
"context"
"path/filepath"
"testing"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
func seedItems() []protocol.Template {
return []protocol.Template{
{Key: "a", Name: "Example: a", Source: Template([]string{"one"}, true)},
{Key: "b", Name: "Example: b", Source: Template([]string{"one", "two"}, true)},
}
}
func TestSeedExamplesOnlyIntoABrandNewDatabase(t *testing.T) {
ctx := context.Background()
path := filepath.Join(t.TempDir(), "new.db")
store, err := Open(path)
if err != nil {
t.Fatal(err)
}
seeded, err := store.SeedExamples(ctx, seedItems())
if err != nil || seeded != 2 {
t.Fatal("brand-new database not seeded", seeded, err)
}
items, _ := store.List(ctx)
if len(items) != 2 || items[0].Name != "Example: a" || items[0].Version != 1 {
t.Fatal("examples are not ordinary version-1 pipelines", items)
}
// A second call in the same process is a no-op.
if seeded, err = store.SeedExamples(ctx, seedItems()); err != nil || seeded != 0 {
t.Fatal("seeded twice", seeded, err)
}
// Removing every example must not bring them back on the next start. There is
// no pipeline delete command yet, so remove the rows directly.
if _, err := store.db.Exec(`DELETE FROM submissions; DELETE FROM pipeline_versions; DELETE FROM pipelines`); err != nil {
t.Fatal(err)
}
store.Close()
store, err = Open(path)
if err != nil {
t.Fatal(err)
}
defer store.Close()
if seeded, err = store.SeedExamples(ctx, seedItems()); err != nil || seeded != 0 {
t.Fatal("deleted examples came back", seeded, err)
}
if items, _ = store.List(ctx); len(items) != 0 {
t.Fatal("deleted examples came back", items)
}
}
func TestSeedExamplesNeverChangesAnExistingInstall(t *testing.T) {
ctx := context.Background()
for _, name := range []string{"empty", "populated"} {
t.Run(name, func(t *testing.T) {
path := filepath.Join(t.TempDir(), "existing.db")
store, err := Open(path)
if err != nil {
t.Fatal(err)
}
if name == "populated" {
if _, err := store.Submit(ctx, "mine", Template([]string{"one"}, true)); err != nil {
t.Fatal(err)
}
}
// Simulate an install from before seeding existed: no marker.
store.Close()
store, err = Open(path)
if err != nil {
t.Fatal(err)
}
if seeded, err := store.SeedExamples(ctx, seedItems()); err != nil || seeded != 0 {
t.Fatal("upgrade seeded examples", seeded, err)
}
store.Close()
store, err = Open(path)
if err != nil {
t.Fatal(err)
}
defer store.Close()
if seeded, err := store.SeedExamples(ctx, seedItems()); err != nil || seeded != 0 {
t.Fatal("later start seeded examples", seeded, err)
}
items, _ := store.List(ctx)
if (name == "empty" && len(items) != 0) || (name == "populated" && (len(items) != 1 || items[0].Name != "mine" || items[0].Version != 1)) {
t.Fatal("upgrade changed pipelines", items)
}
})
}
}
+9 -1
View File
@@ -25,6 +25,9 @@ type Store struct {
runnerClaimed bool
done chan struct{}
closeOnce sync.Once
// created reports that this Open created the database schema, i.e. the
// database is brand new. Only then may SeedExamples add pipelines.
created bool
}
// openDB opens one SQLite connection pool for a DSN. Every open path shares it
@@ -44,6 +47,11 @@ func Open(path string) (*Store, error) {
if err != nil {
return nil, err
}
var existing int
if err := db.QueryRow(`SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='pipelines'`).Scan(&existing); err != nil {
db.Close()
return nil, err
}
_, err = db.Exec(`PRAGMA foreign_keys=ON; PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;
CREATE TABLE IF NOT EXISTS pipelines (id INTEGER PRIMARY KEY, name TEXT NOT NULL UNIQUE, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);
CREATE TABLE IF NOT EXISTS pipeline_versions (id INTEGER PRIMARY KEY, pipeline_id INTEGER NOT NULL REFERENCES pipelines(id), version INTEGER NOT NULL, source TEXT NOT NULL, content_hash TEXT NOT NULL, graph_json TEXT NOT NULL, created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, UNIQUE(pipeline_id, version));
@@ -52,7 +60,7 @@ CREATE TABLE IF NOT EXISTS submissions (id INTEGER PRIMARY KEY, name TEXT NOT NU
db.Close()
return nil, err
}
s := &Store{db: db, dir: filepath.Dir(path), path: path, done: make(chan struct{})}
s := &Store{db: db, dir: filepath.Dir(path), path: path, done: make(chan struct{}), created: existing == 0}
if err := s.initRuns(); err != nil {
db.Close()
return nil, err
+18 -1
View File
@@ -1,8 +1,12 @@
package server
import (
"git.a-wan.net/alan/pipelines/internal/harness"
"context"
"os"
"git.a-wan.net/alan/pipelines/examples"
"git.a-wan.net/alan/pipelines/internal/harness"
"git.a-wan.net/alan/pipelines/internal/pipeline"
)
func starterDefaults() (string, string) {
@@ -13,3 +17,16 @@ func starterDefaults() (string, string) {
}
return model, backend
}
// SeedExamples adds the bundled example pipelines to a brand-new database, bound
// to the server's configured default model and harness exactly as the template
// picker binds them. It is a no-op for an existing or already-seeded database
// (see pipeline.Store.SeedExamples) and returns the number created.
func SeedExamples(ctx context.Context, store *pipeline.Store) (int, error) {
model, backend := starterDefaults()
items := examples.Catalog()
for i := range items {
items[i].Source = pipeline.WithDefaults(items[i].Source, model, backend)
}
return store.SeedExamples(ctx, items)
}
+13 -12
View File
@@ -105,9 +105,10 @@ func TestStageNotificationEventsAndArtifactAudit(t *testing.T) {
}
}
// Regress the exact research -> report terminal-path recipe from the authoring guide.
// Regress the terminal-path recipe from the authoring guide (research -> report
// there) on the bundled two-stage example's draft -> check.
// A completion-alert request must not require native delivery or change run routing.
func TestResearchTerminalNotificationRecipe(t *testing.T) {
func TestTerminalNotificationRecipe(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
store, err := pipeline.Open(filepath.Join(t.TempDir(), "recipe.db"))
@@ -117,15 +118,15 @@ func TestResearchTerminalNotificationRecipe(t *testing.T) {
defer store.Close()
var source string
for _, template := range examples.Catalog() {
if template.Key == "research" {
if template.Key == "two-stages" {
source = template.Source
}
}
if source == "" {
t.Fatal("research template missing")
t.Fatal("two-stages template missing")
}
source = strings.Replace(source, "# stage research", "# stage research\n```notify\non=failure\n```", 1)
source = strings.Replace(source, "# stage report", "# stage report\n```notify\non=success,failure\n```", 1)
source = strings.Replace(source, "# stage draft", "# stage draft\n```notify\non=failure\n```", 1)
source = strings.Replace(source, "# stage check", "# stage check\n```notify\non=success,failure\n```", 1)
if _, err = store.Submit(ctx, "research notification recipe", source); err != nil {
t.Fatal(err)
}
@@ -159,12 +160,12 @@ func TestResearchTerminalNotificationRecipe(t *testing.T) {
name, stage, outcome, status string
executionError, deliveryError bool
}{
{"success", "report", "success", "succeeded", false, false},
{"research blocked", "research", "blocked", "failed", false, false},
{"research execution error", "research", "error", "failed", true, false},
{"report blocked", "report", "blocked", "failed", false, false},
{"report execution error", "report", "error", "failed", true, false},
{"delivery error preserves success", "report", "success", "succeeded", false, true},
{"success", "check", "success", "succeeded", false, false},
{"draft blocked", "draft", "blocked", "failed", false, false},
{"draft execution error", "draft", "error", "failed", true, false},
{"check blocked", "check", "blocked", "failed", false, false},
{"check execution error", "check", "error", "failed", true, false},
{"delivery error preserves success", "check", "success", "succeeded", false, true},
} {
t.Run(test.name, func(t *testing.T) {
deliveryFailure.Store(test.deliveryError)
+42 -1
View File
@@ -57,7 +57,7 @@ func TestTemplatesDoNotSeedDatabaseAndCreateOnlyPreservesExisting(t *testing.T)
t.Fatal("invalid template returned to web/CLI", item.Key, err)
}
for _, s := range graph.Stages {
if s.Configs["provider"] != "test-provider" || s.Configs["model"] != "test-model" || s.Configs["harness"] != "opencode" {
if s.Type == "model" && (s.Configs["provider"] != "test-provider" || s.Configs["model"] != "test-model" || s.Configs["harness"] != "opencode") {
t.Fatal("template did not inherit configured defaults", item.Key, s.Configs)
}
}
@@ -87,3 +87,44 @@ func TestTemplatesDoNotSeedDatabaseAndCreateOnlyPreservesExisting(t *testing.T)
t.Fatal("immutable source changed")
}
}
// A brand-new database gets the bundled examples once, bound to the configured
// defaults like the template picker; they are ordinary editable pipelines.
func TestSeedExamplesBindsDefaultsOnABrandNewDatabase(t *testing.T) {
t.Setenv("PIPELINES_HARNESS_CONFIG", filepath.Join(t.TempDir(), "harnesses.json"))
t.Setenv("PIPELINES_DEFAULT_MODEL", "test-provider/test-model")
t.Setenv("PIPELINES_DEFAULT_HARNESS", "opencode")
ctx := context.Background()
store, err := pipeline.Open(filepath.Join(t.TempDir(), "fresh.db"))
if err != nil {
t.Fatal(err)
}
defer store.Close()
catalog := examples.Catalog()
seeded, err := SeedExamples(ctx, store)
if err != nil || seeded != len(catalog) {
t.Fatal("examples not seeded", seeded, err)
}
items, err := store.List(ctx)
if err != nil || len(items) != len(catalog) {
t.Fatal("seeded pipelines missing", items, err)
}
for _, item := range items {
detail, err := store.Get(ctx, item.ID, 0)
if err != nil || detail.Version != 1 {
t.Fatal(item.Name, err)
}
for _, s := range detail.Graph.Stages {
if s.Type == "model" && (s.Configs["provider"] != "test-provider" || s.Configs["model"] != "test-model" || s.Configs["harness"] != "opencode") {
t.Fatal("seeded example did not bind configured defaults", item.Name, s.Key, s.Configs)
}
}
// Editing a seeded example is an ordinary new version.
if _, err := store.Submit(ctx, item.Name, detail.Source+"\n"); err != nil {
t.Fatal("seeded example not editable", item.Name, err)
}
}
if seeded, err = SeedExamples(ctx, store); err != nil || seeded != 0 {
t.Fatal("examples seeded twice", seeded, err)
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ import (
)
func TestShowcaseGraphsRender(t *testing.T) {
for _, name := range []string{"task", "review", "research", "three-stage"} {
for _, name := range []string{"one-stage", "two-stages", "feedback-loop", "human-decision"} {
t.Run(name, func(t *testing.T) {
source, err := os.ReadFile(filepath.Join("..", "..", "examples", name+".md"))
if err != nil {
+1 -1
View File
@@ -38,7 +38,7 @@ func TestTemplateSubmitNamesRetainsAndExplicitlyPublishesSelectedTemplate(t *tes
m.templateOpen, m.keys.templates = true, true
m.defaultModel = "fixture/model"
for i, item := range m.templates {
if item.Key == "review" {
if item.Key == "one-stage" {
m.templateIndex = i
}
}
+3 -3
View File
@@ -21,7 +21,7 @@ func TestUIUXReviewSnapshots(t *testing.T) {
if err := os.MkdirAll(directory, 0700); err != nil {
t.Fatal(err)
}
source, err := os.ReadFile("../../examples/three-stage.md")
source, err := os.ReadFile("../../examples/human-decision.md")
if err != nil {
t.Fatal(err)
}
@@ -36,7 +36,7 @@ func TestUIUXReviewSnapshots(t *testing.T) {
m.loaded = true
m.status = "127.0.0.1:8080"
m.notificationEndpoints = []protocol.NotificationEndpoint{{Destination: "system", ServerURL: "http://100.85.25.33:8090", Topic: "pipelines"}}
m.pipelines = []protocol.PipelineSummary{{ID: 8, Name: "Plan, implement, review", Version: 1, Stages: 3, CreatedAt: "2026-10-08T20:00:00Z", UpdatedAt: "2026-10-08T20:00:00Z"}}
m.pipelines = []protocol.PipelineSummary{{ID: 8, Name: "Example 4: human decision", Version: 1, Stages: 3, CreatedAt: "2026-10-08T20:00:00Z", UpdatedAt: "2026-10-08T20:00:00Z"}}
save := func(name string) {
t.Helper()
view := ansi.Strip(m.View())
@@ -66,7 +66,7 @@ func TestUIUXReviewSnapshots(t *testing.T) {
save("review-stage")
m.runOpen = true
m.keys.runs = true
m.runDetail = &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 1, Name: "Plan, implement, review", PipelineID: 8, Version: 1, Status: "succeeded", CreatedAt: "2026-10-08T20:00:00Z", FinishedAt: "2026-10-08T20:01:00Z"}, Graph: graph, Steps: []protocol.RunStep{{Sequence: 1, Stage: "planner", Status: "completed", Outcome: "success", Target: "implementer"}, {Sequence: 2, Stage: "implementer", Status: "completed", Outcome: "success", Target: "reviewer"}, {Sequence: 3, Stage: "reviewer", Status: "completed", Outcome: "success", Target: protocol.SuccessEnd, Output: map[string]any{"summary": "Fixture review report", "findings": "Fixture findings"}}}}
m.runDetail = &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 1, Name: "Example 4: human decision", PipelineID: 8, Version: 1, Status: "succeeded", CreatedAt: "2026-10-08T20:00:00Z", FinishedAt: "2026-10-08T20:01:00Z"}, Graph: graph, Steps: []protocol.RunStep{{Sequence: 1, Stage: "plan", Status: "completed", Outcome: "success", Target: "decide"}, {Sequence: 2, Stage: "decide", Status: "completed", Outcome: "approve", Target: "act"}, {Sequence: 3, Stage: "act", Status: "completed", Outcome: "success", Target: protocol.SuccessEnd, Output: map[string]any{"summary": "Fixture review report", "findings": "Fixture findings"}}}}
m.runStepIndex = 3
save("run")
}