05ae530442
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.
68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
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
|
|
}
|