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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user