Reuse party provenance within each inspection
This commit is contained in:
@@ -263,6 +263,10 @@ output, including composite and inherited contributors, when refactoring.
|
|||||||
|
|
||||||
## 8. P3: Reuse party metadata and per-character provenance within inspection
|
## 8. P3: Reuse party metadata and per-character provenance within inspection
|
||||||
|
|
||||||
|
Status: Complete. Each source/catalog projection shares one native metadata
|
||||||
|
snapshot, one source index, and a per-character cache. Imported-party, composite
|
||||||
|
provenance, family, and command agreement tests pass under the race detector.
|
||||||
|
|
||||||
Stage: 9, consuming Stage 5's imported party result.
|
Stage: 9, consuming Stage 5's imported party result.
|
||||||
|
|
||||||
Locations: `internal/config/artifact_catalog.go:67–105` and
|
Locations: `internal/config/artifact_catalog.go:67–105` and
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
|||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
records := make([]EffectiveArtifactRecord, 0, len(keys))
|
records := make([]EffectiveArtifactRecord, 0, len(keys))
|
||||||
pathsByID := pipelineSourcePaths(cfg)
|
pathsByID := pipelineSourcePaths(cfg)
|
||||||
|
partySources := partyCharacterSourceLookup(party)
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
artifact := cfg.Scriptorium.Artifacts[key]
|
artifact := cfg.Scriptorium.Artifacts[key]
|
||||||
record := EffectiveArtifactRecord{
|
record := EffectiveArtifactRecord{
|
||||||
@@ -55,7 +56,7 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
|||||||
record.FamilyKey = member.Family
|
record.FamilyKey = member.Family
|
||||||
record.CharacterID = member.CharacterID
|
record.CharacterID = member.CharacterID
|
||||||
record.FamilySources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...)
|
record.FamilySources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...)
|
||||||
record.PartySource = strings.Join(partyCharacterSources(party, member.CharacterID), ",")
|
record.PartySource = strings.Join(partySources(member.CharacterID), ",")
|
||||||
} else {
|
} else {
|
||||||
record.DefinitionSources = declarationDefinitionSourcesWithIndex(cfg, configkit.Keys("scriptorium", "artifacts", key), pathsByID)
|
record.DefinitionSources = declarationDefinitionSourcesWithIndex(cfg, configkit.Keys("scriptorium", "artifacts", key), pathsByID)
|
||||||
}
|
}
|
||||||
@@ -65,45 +66,58 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
|||||||
return records, nil
|
return records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func partyCharacterSources(party ResolvedParty, id string) []string {
|
// partyCharacterSourceLookup owns a single inspection's detached native evidence.
|
||||||
if party.Canonical == nil || party.Canonical.authoring == nil {
|
func partyCharacterSourceLookup(party ResolvedParty) func(string) []string {
|
||||||
return nonEmptySortedStrings([]string{party.Source.Path})
|
var metadata configkit.Metadata
|
||||||
}
|
sources := map[string]string{}
|
||||||
result := party.Canonical.authoring
|
if party.Canonical != nil && party.Canonical.authoring != nil {
|
||||||
path := configkit.Keys("characters", id)
|
result := party.Canonical.authoring
|
||||||
var ids []string
|
metadata = result.Metadata()
|
||||||
add := func(origin configkit.Origin) {
|
for _, source := range result.Sources() {
|
||||||
for _, location := range origin.Locations {
|
|
||||||
ids = append(ids, location.SourceID)
|
|
||||||
}
|
|
||||||
for _, step := range origin.Inheritance {
|
|
||||||
for _, location := range step.Locations {
|
|
||||||
ids = append(ids, location.SourceID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if info, ok := result.Metadata().Lookup(path); ok {
|
|
||||||
add(info.Origin)
|
|
||||||
}
|
|
||||||
for _, change := range result.Metadata().History(path) {
|
|
||||||
if change.Origin.Layer == configkit.LayerMain || change.Origin.Layer == configkit.LayerOverlay {
|
|
||||||
add(change.Origin)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var sources []string
|
|
||||||
for _, id := range nonEmptySortedStrings(ids) {
|
|
||||||
if source, ok := result.Source(id); ok {
|
|
||||||
name := source.Path
|
name := source.Path
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = source.Label
|
name = source.Label
|
||||||
}
|
}
|
||||||
sources = append(sources, name)
|
sources[source.ID] = name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(sources) == 0 {
|
cache := map[string][]string{}
|
||||||
sources = append(sources, party.Source.Path)
|
return func(id string) []string {
|
||||||
|
if value, ok := cache[id]; ok {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
path := configkit.Keys("characters", id)
|
||||||
|
var ids []string
|
||||||
|
add := func(origin configkit.Origin) {
|
||||||
|
for _, location := range origin.Locations {
|
||||||
|
ids = append(ids, location.SourceID)
|
||||||
|
}
|
||||||
|
for _, step := range origin.Inheritance {
|
||||||
|
for _, location := range step.Locations {
|
||||||
|
ids = append(ids, location.SourceID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if info, ok := metadata.Lookup(path); ok {
|
||||||
|
add(info.Origin)
|
||||||
|
}
|
||||||
|
for _, change := range metadata.History(path) {
|
||||||
|
if change.Origin.Layer == configkit.LayerMain || change.Origin.Layer == configkit.LayerOverlay {
|
||||||
|
add(change.Origin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var paths []string
|
||||||
|
for _, id := range nonEmptySortedStrings(ids) {
|
||||||
|
if name := sources[id]; name != "" {
|
||||||
|
paths = append(paths, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(paths) == 0 {
|
||||||
|
paths = append(paths, party.Source.Path)
|
||||||
|
}
|
||||||
|
cache[id] = nonEmptySortedStrings(paths)
|
||||||
|
return cache[id]
|
||||||
}
|
}
|
||||||
return nonEmptySortedStrings(sources)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string {
|
func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string {
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ func EffectivePipelineSources(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
families := ArtifactFamilies(cfg)
|
families := ArtifactFamilies(cfg)
|
||||||
|
partySources := partyCharacterSourceLookup(party)
|
||||||
publishCount := 0
|
publishCount := 0
|
||||||
if cfg.Publish != nil {
|
if cfg.Publish != nil {
|
||||||
publishCount = len(cfg.Publish.Outputs)
|
publishCount = len(cfg.Publish.Outputs)
|
||||||
@@ -132,7 +133,7 @@ func EffectivePipelineSources(cfg *PipelineConfig, party ResolvedParty) ([]Effec
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if familyKey, ok := generatedArtifactFamilyForPath(path, families); ok {
|
if familyKey, ok := generatedArtifactFamilyForPath(path, families); ok {
|
||||||
records = appendGeneratedArtifactSources(records, path, familyKey, families, owners, party)
|
records = appendGeneratedArtifactSources(records, path, familyKey, families, owners, partySources)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
records = appendPipelineOwners(records, path, owners[path], cfg)
|
records = appendPipelineOwners(records, path, owners[path], cfg)
|
||||||
@@ -334,7 +335,7 @@ func generatedArtifactFamilyForPath(path string, families ArtifactFamilyCatalog)
|
|||||||
return member.Family, exists
|
return member.Family, exists
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendGeneratedArtifactSources(records []EffectivePipelineSourceRecord, path, familyKey string, families ArtifactFamilyCatalog, owners map[string][]string, party ResolvedParty) []EffectivePipelineSourceRecord {
|
func appendGeneratedArtifactSources(records []EffectivePipelineSourceRecord, path, familyKey string, families ArtifactFamilyCatalog, owners map[string][]string, partySources func(string) []string) []EffectivePipelineSourceRecord {
|
||||||
for _, source := range generatedArtifactSources(path, familyKey, families, owners) {
|
for _, source := range generatedArtifactSources(path, familyKey, families, owners) {
|
||||||
role := "family"
|
role := "family"
|
||||||
if source == pipelineDefaultOwnershipSource {
|
if source == pipelineDefaultOwnershipSource {
|
||||||
@@ -344,7 +345,7 @@ func appendGeneratedArtifactSources(records []EffectivePipelineSourceRecord, pat
|
|||||||
}
|
}
|
||||||
memberPath := strings.TrimPrefix(path, "scriptorium.artifacts.")
|
memberPath := strings.TrimPrefix(path, "scriptorium.artifacts.")
|
||||||
memberKey, _, _ := strings.Cut(memberPath, ".")
|
memberKey, _, _ := strings.Cut(memberPath, ".")
|
||||||
for _, source := range partyCharacterSources(party, families.Members[memberKey].CharacterID) {
|
for _, source := range partySources(families.Members[memberKey].CharacterID) {
|
||||||
records = append(records, EffectivePipelineSourceRecord{Path: path, Role: "party", Source: normalizedProvenancePath(source)})
|
records = append(records, EffectivePipelineSourceRecord{Path: path, Role: "party", Source: normalizedProvenancePath(source)})
|
||||||
}
|
}
|
||||||
return records
|
return records
|
||||||
|
|||||||
Reference in New Issue
Block a user