Files
alan a48e4a5b6a 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.
2026-11-03 19:35:47 +00:00

33 lines
1.1 KiB
Go

package server
import (
"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) {
model, backend := os.Getenv("PIPELINES_DEFAULT_MODEL"), os.Getenv("PIPELINES_DEFAULT_HARNESS")
if c, err := harness.Load(); err == nil && c.Default != "" {
model = c.Profiles[c.Default].PipelineModel
backend = c.Default
}
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)
}