Preserve composite ConfigKit provenance

This commit is contained in:
2026-10-04 13:34:27 +00:00
parent 428f435734
commit f1672f6f95
13 changed files with 200 additions and 145 deletions

View File

@@ -20,7 +20,7 @@ type EffectiveArtifactRecord struct {
Dependencies []string
FamilyKey string
CharacterID string
FamilySource string
FamilySources []string
PartySource string
}
@@ -53,7 +53,7 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
record.DefinitionSources = artifactFamilyDefinitionSources(cfg, member.Family)
record.FamilyKey = member.Family
record.CharacterID = member.CharacterID
record.FamilySource = member.Source
record.FamilySources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...)
record.PartySource = party.Source.Path
} else {
record.DefinitionSources = artifactDefinitionSources(cfg, key)
@@ -67,60 +67,52 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
func artifactDefinitionSources(cfg *PipelineConfig, key string) []string {
return declarationDefinitionSources(cfg,
configkit.Keys("scriptorium", "artifacts", key),
"scriptorium.artifacts."+key,
)
}
func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string {
return declarationDefinitionSources(cfg,
configkit.Keys("scriptorium", "artifact_families", key),
"scriptorium.artifact_families."+key,
)
}
func declarationDefinitionSources(cfg *PipelineConfig, declaration configkit.Path, prefix string) []string {
func declarationDefinitionSources(cfg *PipelineConfig, declaration configkit.Path) []string {
if cfg == nil || cfg.resolution == nil {
return nil
}
pathsByID := make(map[string]string, len(cfg.resolution.configkitSources))
for _, source := range cfg.resolution.configkitSources {
path := source.Path
if path == "" {
path = source.Label
}
pathsByID[source.ID] = path
}
pathsByID := pipelineSourcePaths(cfg)
seen := map[string]struct{}{}
for _, change := range cfg.resolution.configkitMetadata.History(declaration) {
if change.Origin.Layer != configkit.LayerBase && change.Origin.Layer != configkit.LayerOverlay {
continue
}
for _, location := range change.Origin.Locations {
source := pathsByID[location.SourceID]
if source == "" {
source = location.SourceID
seen[location.SourceID] = struct{}{}
}
for _, inheritance := range change.Origin.Inheritance {
for _, location := range inheritance.Locations {
seen[location.SourceID] = struct{}{}
}
seen[source] = struct{}{}
}
}
if len(seen) == 0 {
for _, ownership := range cfg.resolution.ownership {
if ownership.path != prefix && !strings.HasPrefix(ownership.path, prefix+".") {
continue
if info, ok := cfg.resolution.configkitMetadata.Lookup(declaration); ok {
for _, location := range info.Origin.Locations {
seen[location.SourceID] = struct{}{}
}
for _, source := range ownership.sources {
if source != pipelineDefaultOwnershipSource && source != "resolution" {
seen[source] = struct{}{}
for _, inheritance := range info.Origin.Inheritance {
for _, location := range inheritance.Locations {
seen[location.SourceID] = struct{}{}
}
}
}
}
if len(seen) == 0 && cfg.resolution.rootPath != "" {
seen[cfg.resolution.rootPath] = struct{}{}
}
result := make([]string, 0, len(seen))
for source := range seen {
for sourceID := range seen {
source := pathsByID[sourceID]
if source == "" {
source = sourceID
}
result = append(result, source)
}
sort.Strings(result)