Complete artifact provenance reporting

This commit is contained in:
2026-09-07 12:08:19 +00:00
parent 3ec54b8c72
commit 0ac8072a9a
5 changed files with 144 additions and 6 deletions

View File

@@ -227,9 +227,39 @@ func effectivePipelineOwners(cfg *PipelineConfig) map[string][]string {
for _, ownership := range cfg.resolution.ownership {
owners[ownership.path] = append([]string(nil), ownership.sources...)
}
if cfg.Scriptorium != nil {
for key, artifact := range cfg.Scriptorium.Artifacts {
paths := artifactDependencyOwnershipPaths(key, artifact)
if sources := sourcesForPipelinePaths(owners, paths); len(sources) != 0 {
sort.Strings(sources)
owners["scriptorium.artifacts."+key+".depends_on"] = sources
}
}
}
return owners
}
func artifactDependencyOwnershipPaths(artifactKey string, artifact ScriptoriumArtifactConfig) []string {
var paths []string
for _, dependency := range artifact.DependsOn {
for _, origin := range artifact.dependencyOrigins[dependency] {
prefix := "scriptorium.artifacts." + artifactKey
if origin.family != "" {
prefix = "scriptorium.artifact_families." + origin.family
}
switch {
case origin.inputName != "":
paths = append(paths, prefix+".inputs."+origin.inputName+".source")
case origin.family != "":
paths = append(paths, prefix+".member_dependencies")
default:
paths = append(paths, prefix+".depends_on")
}
}
}
return paths
}
func generatedArtifactFamilyForPath(path string, families ArtifactFamilyCatalog) (string, bool) {
const prefix = "scriptorium.artifacts."
if !strings.HasPrefix(path, prefix) {
@@ -269,7 +299,7 @@ func generatedArtifactSources(path, familyKey string, families ArtifactFamilyCat
case suffix == "output_path":
candidates = []string{familyPrefix + "output_path_pattern"}
case suffix == "depends_on":
candidates = []string{familyPrefix + "depends_on", familyPrefix + "member_dependencies"}
candidates = []string{path, familyPrefix + "depends_on", familyPrefix + "member_dependencies"}
case strings.HasPrefix(suffix, "vars."):
variable := strings.TrimPrefix(suffix, "vars.")
candidates = []string{familyPrefix + "vars." + variable, familyPrefix + "member_vars." + variable}