Make Pipelines Docker-only with OpenCode and Pi
Install current verified harness releases inside Docker, preserve persistent accounts and settings, and provide separate interactive and pipeline model defaults with terminal onboarding and fuzzy pickers. Add Docker-aware authoring transport, Pi stage execution, bounded workflow controls, reliable final-result readback and usage settlement, and finite short-lived CLI pipe draining. Keep dated installation evidence and packaged authoring guidance consistent. Verified with a real Docker installation, both harness stages and interactive authors, the built-in plan/implement/review starter, independent host race/vet checks, installer tests, and packaged skill tests. Generated release receipts stay ignored in clean checkouts.
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
)
|
||||
|
||||
func TestRuntimeLimitAndSelectedMemory(t *testing.T) {
|
||||
for _, approveLast := range []bool{false, true} {
|
||||
t.Run(map[bool]string{false: "exhaustion", true: "last review approves"}[approveLast], func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "run.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer store.Close()
|
||||
source := pipeline.Template([]string{"planner", "worker", "review"}, true)
|
||||
source = strings.Replace(source, "# stage worker", "# stage worker\n\n```memory\n{\"task\":\"input.prompt\",\"plan\":\"planner.plan\",\"findings\":\"review.findings?\"}\n```", 1)
|
||||
source = strings.Replace(source, "# stage review", "# stage review\n\n```limits\n{\"max_visits\":3,\"on\":[\"rejected\"]}\n```\n\n```memory\n{\"task\":\"input.prompt\",\"checks\":\"planner.checks\"}\n```", 1)
|
||||
source = strings.Replace(source, "success -> #success", "success -> #success\nrejected -> worker", 1)
|
||||
if _, err := store.Submit(ctx, "bounded", source); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
items, _ := store.List(ctx)
|
||||
runner, err := newRunner(ctx, store)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
calls := map[string]int{}
|
||||
runner.execute = func(_ context.Context, def stage.Definition, input stage.Values) (stage.Result, error) {
|
||||
calls[def.Key]++
|
||||
if _, ok := def.Blocks["limits"]; ok {
|
||||
t.Fatal("policy exposed to model")
|
||||
}
|
||||
switch def.Key {
|
||||
case "planner":
|
||||
return stage.Result{Outcome: "success", Output: stage.Values{"plan": "do task", "checks": "inspect actual files"}}, nil
|
||||
case "worker":
|
||||
if input["task"] != "task" || input["plan"] != "do task" {
|
||||
t.Error("lost shared task context", input)
|
||||
}
|
||||
if calls["worker"] > 1 && input["findings"] != "fix layout" {
|
||||
t.Error("missing revision feedback", input)
|
||||
}
|
||||
return stage.Result{Outcome: "success", Output: stage.Values{"ui_revision": 0, "previous_verdict": "rejected"}}, nil
|
||||
default:
|
||||
if len(input) != 2 || input["checks"] != "inspect actual files" {
|
||||
t.Error("review context contaminated", input)
|
||||
}
|
||||
if approveLast && calls["review"] == 3 {
|
||||
return stage.Result{Outcome: "success", Output: stage.Values{"summary": "approved"}}, nil
|
||||
}
|
||||
return stage.Result{Outcome: "rejected", Output: stage.Values{"findings": "fix layout", "ui_revision": 0}}, nil
|
||||
}
|
||||
}
|
||||
run, err := runner.start(protocol.Message{PipelineID: items[0].ID, Version: 1, RequestKey: "test", Workspace: t.TempDir(), Input: map[string]any{"prompt": "task"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runner.wg.Wait()
|
||||
retained, err := store.GetRun(ctx, run.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if calls["review"] != 3 || calls["worker"] != 3 || len(retained.Steps) != 7 {
|
||||
t.Fatal("model evaded runtime limit", calls, len(retained.Steps))
|
||||
}
|
||||
last := retained.Steps[6]
|
||||
if last.Control == nil || last.Control.Visit != 3 || last.Control.Memory["checks"].Sequence != 1 {
|
||||
t.Fatal("missing retained control evidence", last)
|
||||
}
|
||||
if approveLast {
|
||||
if retained.Status != "succeeded" || last.Control.LimitReached {
|
||||
t.Fatal("last visit could not approve", retained)
|
||||
}
|
||||
} else if retained.Status != "failed" || !last.Control.LimitReached || last.Outcome != "rejected" || last.Target != protocol.FailureEnd {
|
||||
t.Fatal("limit did not override route", last)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user