Files
alan 9130ae8c7a Add stage-exclusive resource waiting
Add durable FIFO capacity-one resource leases for executable stages, including cleanup-confirmed release, conservative restart quarantine, queue state events, and CLI/TUI/Android waiting presentation. Add scheduler, cleanup, protocol, client, and Android coverage plus a proposed Android v3 resource draft.

Checked packaged templates and authoring skill references: neither needs updating in this item. The per-item docs note records the shared documentation that docs-fold must update; no shared README or packaged reference was edited.
2026-10-18 12:30:30 +01:00

48 lines
1.3 KiB
Go

package pipeline
import (
"maps"
"sort"
"strings"
"git.a-wan.net/alan/pipelines/internal/stage"
)
// StageDefinition adapts normalized/persisted graph data for type implementations.
// Copies keep implementations from accidentally modifying immutable graph history.
func StageDefinition(s Stage) stage.Definition {
blocks := maps.Clone(s.Blocks)
if blocks == nil {
blocks = map[string]string{}
}
delete(blocks, "input") // Retired contracts in historical graph JSON are ignored.
delete(blocks, "limits")
delete(blocks, "memory")
delete(blocks, "resources")
for name, value := range map[string]string{"output": s.Output, "prompt": s.Prompt} {
if value != "" {
blocks[name] = value
}
}
configs := maps.Clone(s.Configs)
keys := make([]string, 0, len(configs))
for key := range configs {
keys = append(keys, key)
}
sort.Strings(keys)
lines := []string{"type=" + stage.EffectiveType(s.Type)}
for _, key := range keys {
lines = append(lines, key+"="+configs[key])
}
blocks["configs"] = strings.Join(lines, "\n")
def := stage.Definition{Key: s.Key, Type: stage.EffectiveType(s.Type), Blocks: blocks, Configs: configs, Edges: maps.Clone(s.Edges)}
if s.Notify != nil {
for _, kind := range s.Notify.Artifacts {
if kind == "files" {
def.ReportFileArtifacts = true
}
}
}
return def
}