Render final configuration through native snapshots

This commit is contained in:
2026-11-17 22:31:03 +00:00
parent ed7e722077
commit ce661252d0
7 changed files with 156 additions and 77 deletions

View File

@@ -4,11 +4,13 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
configkit "go.maximumdirect.net/configkit"
)
const (
pipelineDefaultOwnershipSource = "default"
effectivePipelineDigestVersion = "narratio-effective-pipeline-v3\n"
effectivePipelineDigestVersion = "narratio-effective-pipeline-v4\n"
)
// PipelineOverlayProvenance identifies the overlay selected while resolving a
@@ -51,12 +53,22 @@ func recomputePipelineEffectiveDigest(cfg *PipelineConfig) error {
if cfg == nil || cfg.resolution == nil {
return fmt.Errorf("pipeline resolution metadata is required")
}
canonical, err := projectionJSON(projectEffectivePipeline(cfg))
snapshot, err := newPipelineInspection(cfg)
if err != nil {
return err
}
canonical, err := projectionJSON(snapshot.Config)
if err != nil {
return err
}
digestInput := append([]byte(effectivePipelineDigestVersion), canonical...)
digest := sha256.Sum256(digestInput)
cfg.resolution.effectiveDigest = hex.EncodeToString(digest[:])
cfg.resolution.inspection = snapshot
return nil
}
func newPipelineInspection(cfg *PipelineConfig) (*configkit.Result[effectivePipelineProjection], error) {
projection := projectEffectivePipeline(cfg)
return configkit.Load(configkit.NoSource(), configkit.Options[effectivePipelineProjection]{Definition: configkit.Definition[effectivePipelineProjection]{Defaults: func() effectivePipelineProjection { return projection }}})
}