Unify effective config projection

This commit is contained in:
2026-09-07 03:35:46 +00:00
parent 10a2e89965
commit 0e6ba414b3
7 changed files with 336 additions and 268 deletions

View File

@@ -5,14 +5,13 @@ import (
"encoding/hex"
"fmt"
"path/filepath"
"sort"
"strings"
"gopkg.in/yaml.v3"
)
const (
pipelineDefaultOwnershipSource = "default"
effectivePipelineDigestVersion = "narratio-effective-pipeline-v2\n"
effectivePipelineDigestVersion = "narratio-effective-pipeline-v3\n"
)
// PipelineProfileProvenance identifies the profile selected while resolving a
@@ -49,15 +48,7 @@ func finalizePipelineResolution(cfg *PipelineConfig) error {
for _, ownership := range cfg.resolution.ownership {
declared[ownership.path] = append([]string(nil), ownership.sources...)
}
data, err := yaml.Marshal(cfg)
if err != nil {
return fmt.Errorf("serialize normalized effective pipeline: %w", err)
}
document, err := parseCompositionBytes("normalized effective pipeline", data)
if err != nil {
return err
}
records, err := document.semanticRecords()
records, err := projectionValueRecords(projectEffectivePipeline(cfg, true))
if err != nil {
return err
}
@@ -71,6 +62,12 @@ func finalizePipelineResolution(cfg *PipelineConfig) error {
path: record.Path, sources: append([]string(nil), sources...),
})
}
for path, sources := range declared {
if strings.HasPrefix(path, "scriptorium.artifact_families.") {
ownership = append(ownership, pipelineFieldOwnership{path: path, sources: append([]string(nil), sources...)})
}
}
sort.Slice(ownership, func(i, j int) bool { return ownership[i].path < ownership[j].path })
cfg.resolution.ownership = ownership
return recomputePipelineEffectiveDigest(cfg)
}
@@ -82,22 +79,7 @@ func recomputePipelineEffectiveDigest(cfg *PipelineConfig) error {
if cfg == nil || cfg.resolution == nil {
return fmt.Errorf("pipeline resolution metadata is required")
}
digestConfig := *cfg
if cfg.Notarius != nil && cfg.resolution.logicalNotariusCaptured {
notarius := *cfg.Notarius
notarius.ConfigPath = cfg.resolution.logicalNotariusConfig
notarius.WorkingDirectory = cfg.resolution.logicalNotariusWorking
digestConfig.Notarius = &notarius
}
data, err := yaml.Marshal(&digestConfig)
if err != nil {
return fmt.Errorf("serialize normalized effective pipeline: %w", err)
}
document, err := parseCompositionBytes("normalized effective pipeline", data)
if err != nil {
return err
}
canonical, err := document.canonicalDigestInput()
canonical, err := projectionJSON(projectEffectivePipeline(cfg, true))
if err != nil {
return err
}