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:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.a-wan.net/alan/pipelines/internal/buildinfo"
|
||||
"git.a-wan.net/alan/pipelines/internal/cli"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
@@ -17,7 +18,38 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCLIPingReportsServerBuild(t *testing.T) {
|
||||
// Keep the host executable authoritative for CLI integration: a developer's
|
||||
// real Docker-linked harness profile must never influence an ephemeral test
|
||||
// endpoint. A missing native fixture matches an unconfigured setup.
|
||||
t.Setenv("PIPELINES_HARNESS_CONFIG", filepath.Join(t.TempDir(), "harnesses.json"))
|
||||
srv := httptest.NewServer(Handler(context.Background()))
|
||||
defer srv.Close()
|
||||
endpoint := "ws" + strings.TrimPrefix(srv.URL, "http") + "/connect"
|
||||
for _, jsonMode := range []bool{false, true} {
|
||||
var out bytes.Buffer
|
||||
app := cli.App{Out: &out, Err: &out, In: strings.NewReader("")}
|
||||
args := []string{"--url", endpoint, "ping"}
|
||||
if jsonMode {
|
||||
args = append(args, "--json")
|
||||
}
|
||||
if err := app.Run(context.Background(), args); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
build := buildinfo.Current()
|
||||
if !strings.Contains(out.String(), build.Version) || !strings.Contains(out.String(), build.Commit) {
|
||||
t.Fatal("ping omitted server version", out.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCLIHeadlessRunInspectionCancellationAndRPC(t *testing.T) {
|
||||
// Isolate harness configuration: this test's debug query builds a CLI prefix
|
||||
// locally, so a developer's real Docker-linked profile would fail closed
|
||||
// against this ephemeral httptest endpoint ("refusing to redirect"). A
|
||||
// missing native fixture keeps the host executable authoritative, matching
|
||||
// the isolation already used by internal/cli's setup.
|
||||
t.Setenv("PIPELINES_HARNESS_CONFIG", filepath.Join(t.TempDir(), "harnesses.json"))
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "cli-runs.db"))
|
||||
@@ -85,7 +117,7 @@ func TestCLIHeadlessRunInspectionCancellationAndRPC(t *testing.T) {
|
||||
if _, err = run("runs", "--pipeline", "workflow", "--json"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = run("run", "workflow", "exact task", "--yes", "--json", "--request-key", "same-key", "--wait", "--timeout", "100ms"); err == nil || !strings.Contains(err.Error(), "remains active") {
|
||||
if _, err = run("run", "workflow", "exact task", "--yes", "--json", "--request-key", "same-key", "--wait", "--wait-timeout", "100ms"); err == nil || !strings.Contains(err.Error(), "remains active") {
|
||||
t.Fatal("wait timeout canceled or incorrectly succeeded", err)
|
||||
}
|
||||
if _, err = run("cancel", "1", "--yes", "--json"); err != nil {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"strings"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
)
|
||||
|
||||
type memoryValue struct {
|
||||
output stage.Values
|
||||
sequence int
|
||||
}
|
||||
|
||||
// Serialize/decode to sever mutable aliases between stage work and retained state.
|
||||
func copyValues(values stage.Values) (stage.Values, error) {
|
||||
data, err := json.Marshal(values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(data) > 1<<20 {
|
||||
return nil, fmt.Errorf("shared memory value exceeds 1 MiB")
|
||||
}
|
||||
var result stage.Values
|
||||
decoder := json.NewDecoder(strings.NewReader(string(data)))
|
||||
decoder.UseNumber()
|
||||
if err := decoder.Decode(&result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func memoryInput(previous stage.Values, bindings map[string]string, memory map[string]memoryValue) (stage.Values, map[string]protocol.MemoryRead, error) {
|
||||
input := maps.Clone(previous)
|
||||
if len(bindings) > 0 {
|
||||
input = stage.Values{}
|
||||
}
|
||||
if input == nil {
|
||||
input = stage.Values{}
|
||||
}
|
||||
reads := map[string]protocol.MemoryRead{}
|
||||
for alias, ref := range bindings {
|
||||
optional := strings.HasSuffix(ref, "?")
|
||||
owner, field, _ := strings.Cut(strings.TrimSuffix(ref, "?"), ".")
|
||||
entry, ok := memory[owner]
|
||||
if !ok && optional {
|
||||
continue
|
||||
}
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("shared memory source %s has not completed in this run", owner)
|
||||
}
|
||||
value, ok := entry.output[field]
|
||||
if !ok && optional {
|
||||
continue
|
||||
}
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("shared memory field %s is missing", ref)
|
||||
}
|
||||
input[alias] = value
|
||||
reads[alias] = protocol.MemoryRead{Source: ref, Sequence: entry.sequence}
|
||||
}
|
||||
cloned, err := copyValues(input)
|
||||
return cloned, reads, err
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"git.a-wan.net/alan/pipelines/internal/harness"
|
||||
"os"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
@@ -24,7 +24,11 @@ func (r *runner) evidence(ctx context.Context, id int64) ([]protocol.SessionEvid
|
||||
owner, err := r.store.RunSessionOwner(ctx, id, step.Sequence)
|
||||
if err == nil {
|
||||
item.Backend = owner.Backend
|
||||
item.Data, err = (stage.OpenCodeClient{Directory: owner.Directory, Backend: owner.Backend}).SessionEvidence(ctx, owner.ID)
|
||||
if owner.Backend == "pi" {
|
||||
item.Data, err = stage.PiEvidence(owner.Reference)
|
||||
} else {
|
||||
item.Data, err = (stage.OpenCodeClient{Directory: owner.Directory, Backend: owner.Backend}).SessionEvidence(ctx, owner.ID)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
item.Diagnostic = stage.RedactEvidence(err.Error())
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/filediff"
|
||||
"git.a-wan.net/alan/pipelines/internal/harness"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
@@ -35,7 +36,12 @@ func newRunner(ctx context.Context, s *pipeline.Store) (*runner, error) {
|
||||
}
|
||||
for _, owner := range sessions {
|
||||
stop, cancel := context.WithTimeout(ctx, 20*time.Second)
|
||||
err := (stage.OpenCodeClient{Backend: owner.Backend, Directory: owner.Directory, Reference: owner.Reference}).Interrupt(stop, owner.ID)
|
||||
var err error
|
||||
if owner.Backend == "pi" {
|
||||
err = stage.InterruptPi(stop, owner.Reference)
|
||||
} else {
|
||||
err = (stage.OpenCodeClient{Backend: owner.Backend, Directory: owner.Directory, Reference: owner.Reference}).Interrupt(stop, owner.ID)
|
||||
}
|
||||
cancel()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot interrupt previously active agent %s: %w", owner.ID, err)
|
||||
@@ -119,6 +125,15 @@ func (r *runner) start(request protocol.Message, retryOf ...int64) (*protocol.Ru
|
||||
if stage.EffectiveType(s.Type) != stage.ModelType {
|
||||
continue
|
||||
}
|
||||
if s.Configs["harness"] == "pi" && r.execute == nil {
|
||||
configured, err := harness.Load()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, ok := configured.Profiles["pi"]; !ok {
|
||||
return nil, fmt.Errorf("Pi is not configured on this execution server; run pipelines harness setup pi there")
|
||||
}
|
||||
}
|
||||
tools, explicit, err := stage.ToolNames(pipeline.StageDefinition(s))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -252,6 +267,12 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
log.Printf("finish run %d: %v", id, err)
|
||||
}
|
||||
}
|
||||
original, copyErr := copyValues(stage.Values(request.Input))
|
||||
if copyErr != nil {
|
||||
finish("failed", "error", copyErr.Error())
|
||||
return
|
||||
}
|
||||
memory := map[string]memoryValue{"input": {output: original}}
|
||||
defer func() {
|
||||
if recovered := recover(); recovered != nil {
|
||||
finish("failed", "error", "stage execution panicked")
|
||||
@@ -268,9 +289,11 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
return
|
||||
}
|
||||
var def stage.Definition
|
||||
var selected protocol.Stage
|
||||
found := false
|
||||
for _, s := range d.Graph.Stages {
|
||||
if s.Key == key {
|
||||
selected = s
|
||||
def = pipeline.StageDefinition(s)
|
||||
found = true
|
||||
break
|
||||
@@ -280,6 +303,20 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
finish("failed", "error", "missing stage")
|
||||
return
|
||||
}
|
||||
maxVisits := 5
|
||||
if selected.Limits != nil {
|
||||
maxVisits = selected.Limits.MaxVisits
|
||||
}
|
||||
if visits[key] > maxVisits {
|
||||
finish("failed", "error", fmt.Sprintf("stage %s visit limit reached (%d)", key, maxVisits))
|
||||
return
|
||||
}
|
||||
var reads map[string]protocol.MemoryRead
|
||||
input, reads, copyErr = memoryInput(input, selected.Memory, memory)
|
||||
if copyErr != nil {
|
||||
finish("failed", "error", copyErr.Error())
|
||||
return
|
||||
}
|
||||
if err := r.store.BeginStep(ctx, id, sequence, key, input); err != nil {
|
||||
if ctx.Err() != nil {
|
||||
finish("canceled", "", ctx.Err().Error())
|
||||
@@ -307,6 +344,7 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
return r.store.RunSession(c, id, sequence, session, active, client.Backend, client.Reference)
|
||||
}
|
||||
var result stage.Result
|
||||
var piClient *stage.PiClient
|
||||
var err error
|
||||
stageCtx := ctx
|
||||
var modelConfig stage.ModelConfig
|
||||
@@ -325,6 +363,7 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
snapshotCtx, snapshotCancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
before := filediff.Capture(snapshotCtx, workspace)
|
||||
snapshotCancel()
|
||||
var stageSession string
|
||||
panicked := false
|
||||
func() {
|
||||
defer func() {
|
||||
@@ -338,13 +377,37 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
executeCtx, cancel := context.WithTimeout(stageCtx, timeout)
|
||||
defer cancel()
|
||||
result, err = r.execute(executeCtx, def, input)
|
||||
} else if modelConfig.Harness == "pi" {
|
||||
configured, configErr := harness.Load()
|
||||
if configErr != nil {
|
||||
err = configErr
|
||||
return
|
||||
}
|
||||
profile, ok := configured.Profiles["pi"]
|
||||
if !ok {
|
||||
err = fmt.Errorf("Pi is not configured on execution server")
|
||||
return
|
||||
}
|
||||
piClient = &stage.PiClient{Executable: profile.Executable, Directory: workspace, Tools: tools, WritePaths: request.WritePaths}
|
||||
piClient.OnOwnership = func(session, reference string, active bool) error {
|
||||
c, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
return r.store.RunSession(c, id, sequence, session, active, "pi", reference)
|
||||
}
|
||||
result, err = (stage.ModelStage{Client: piClient}).Run(stageCtx, def, input)
|
||||
stageSession = piClient.SessionID
|
||||
client.Transcript = piClient.Transcript
|
||||
} else if useAgent {
|
||||
result, err = (stage.ModelStage{Client: client}).Run(stageCtx, def, input)
|
||||
stageSession = client.SessionID
|
||||
} else if stage.EffectiveType(def.Type) == stage.ModelType {
|
||||
plain := &stage.OpenCodeClient{Directory: workspace, Operations: operations}
|
||||
plain.OnGenerationSession = func(session, backend, reference string, active bool) error {
|
||||
c, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if active {
|
||||
stageSession = session
|
||||
}
|
||||
return r.store.RunSession(c, id, sequence, session, active, backend, reference)
|
||||
}
|
||||
result, err = (stage.ModelStage{Client: plain}).Run(stageCtx, def, input)
|
||||
@@ -362,7 +425,7 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
changes.Status = "partial"
|
||||
changes.Diagnostic = "Agent cleanup was not confirmed; files may still be changing."
|
||||
}
|
||||
step := protocol.RunStep{Sequence: sequence, Stage: key, Status: "completed", Outcome: result.Outcome, Output: result.Output, Transcript: operations.Transcript(client.Transcript), FileChanges: changes}
|
||||
step := protocol.RunStep{Sequence: sequence, Stage: key, Status: "completed", Outcome: result.Outcome, Output: result.Output, Transcript: operations.Transcript(client.Transcript), SessionID: stageSession, FileChanges: changes}
|
||||
if budget := budgets[key]; budget != nil {
|
||||
step.Transcript = stage.BudgetTranscript(step.Transcript, budget, modelConfig.Timeout, modelConfig.Retries)
|
||||
}
|
||||
@@ -373,6 +436,17 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
step.Output = stage.Values{"error": err.Error(), "stage": key, "input": input}
|
||||
}
|
||||
step.Target = def.Edges[step.Outcome]
|
||||
step.Control = &protocol.ControlEvidence{Visit: visits[key], MaxVisits: maxVisits, Memory: reads}
|
||||
if err == nil && selected.Limits != nil && visits[key] >= maxVisits {
|
||||
for _, outcome := range selected.Limits.On {
|
||||
if outcome == step.Outcome {
|
||||
step.Control.LimitReached = true
|
||||
step.Control.ModelTarget = step.Target
|
||||
step.Target = protocol.FailureEnd
|
||||
step.Diagnostic = fmt.Sprintf("Pipelines stopped %s after %d visits on outcome %s", key, maxVisits, step.Outcome)
|
||||
}
|
||||
}
|
||||
}
|
||||
if panicked {
|
||||
step.Target = protocol.FailureEnd
|
||||
}
|
||||
@@ -383,6 +457,14 @@ func (r *runner) run(ctx context.Context, id int64, d *protocol.PipelineDetail,
|
||||
finish("failed", "error", persistErr.Error())
|
||||
return
|
||||
}
|
||||
if step.Status == "completed" {
|
||||
values, err := copyValues(stage.Values(step.Output))
|
||||
if err != nil {
|
||||
finish("failed", "error", err.Error())
|
||||
return
|
||||
}
|
||||
memory[key] = memoryValue{output: values, sequence: sequence}
|
||||
}
|
||||
for _, s := range d.Graph.Stages {
|
||||
if s.Key == key {
|
||||
r.notifyStep(id, d, workspace, s.Notify, step)
|
||||
|
||||
@@ -34,7 +34,7 @@ case "$3" in
|
||||
id=${3#/api/session/}; id=${id%%/prompt}
|
||||
touch %q/"$id"
|
||||
echo '{}' ;;
|
||||
*/wait) echo '{}' ;;
|
||||
/api/session/active) echo '{"data":{}}' ;;
|
||||
*/message*) echo '{"data":[{"finish":"stop","content":[{"type":"text","text":"{\"outcome\":\"success\",\"output\":{\"summary\":\"done\"}}"}]}]}' ;;
|
||||
*/interrupt) echo '{}' ;;
|
||||
/api/session/ses_budget_*)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -12,12 +11,14 @@ import (
|
||||
"github.com/coder/websocket/wsjson"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/examples"
|
||||
"git.a-wan.net/alan/pipelines/internal/buildinfo"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
// Handler serves the persistent connection. Canceling ctx stops active clients.
|
||||
func Handler(ctx context.Context, stores ...*pipeline.Store) http.Handler {
|
||||
build := buildinfo.Current()
|
||||
started := time.Now()
|
||||
mux := http.NewServeMux()
|
||||
var runs *runner
|
||||
@@ -73,11 +74,13 @@ func Handler(ctx context.Context, stores ...*pipeline.Store) http.Handler {
|
||||
response.Status = systemStatus(r, started, runErr)
|
||||
} else if request.Type == protocol.Ping {
|
||||
response.Time = time.Now().UTC().Format(time.RFC3339)
|
||||
response.Build = &build
|
||||
} else if request.Type == protocol.ListTemplates {
|
||||
response.Type = protocol.Templates
|
||||
response.Templates = examples.Catalog()
|
||||
model, backend := starterDefaults()
|
||||
for i := range response.Templates {
|
||||
response.Templates[i].Source = pipeline.WithDefaultModel(response.Templates[i].Source, os.Getenv("PIPELINES_DEFAULT_MODEL"))
|
||||
response.Templates[i].Source = pipeline.WithDefaults(response.Templates[i].Source, model, backend)
|
||||
}
|
||||
} else if request.Type == protocol.Validate {
|
||||
graph, err := pipeline.Parse(request.Source)
|
||||
@@ -122,7 +125,7 @@ func Handler(ctx context.Context, stores ...*pipeline.Store) http.Handler {
|
||||
}
|
||||
} else if request.Type == protocol.List && len(stores) > 0 {
|
||||
response.Type = protocol.PipelineList
|
||||
response.DefaultModel = os.Getenv("PIPELINES_DEFAULT_MODEL")
|
||||
response.DefaultModel, response.DefaultHarness = starterDefaults()
|
||||
items, err := stores[0].List(ctx)
|
||||
if err != nil {
|
||||
response.Type = protocol.Error
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/coder/websocket"
|
||||
"github.com/coder/websocket/wsjson"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/buildinfo"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
@@ -72,6 +73,10 @@ func TestPersistentConnection(t *testing.T) {
|
||||
if response.Type != protocol.Pong {
|
||||
t.Fatalf("expected pong, got %+v", response)
|
||||
}
|
||||
wantBuild := buildinfo.Current()
|
||||
if response.Build == nil || response.Build.Version != wantBuild.Version || response.Build.Commit != wantBuild.Commit {
|
||||
t.Fatalf("pong missing server build identity: %+v", response.Build)
|
||||
}
|
||||
stamp, err := time.Parse(time.RFC3339, response.Time)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user