diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index 066849a..f5e3c56 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -226,6 +226,10 @@ objects are unchanged by the authoring update. ## 7. P3: Reuse enumerated source records and one inspection source index +Status: Complete. Source enumeration uses complete native records directly; +catalog projection shares one index and retained family sources. Nested empty +imports and existing composite/family inspection checks pass. + Stage: 9. Locations: `internal/config/effective_pipeline.go:57–75`, diff --git a/internal/config/artifact_catalog.go b/internal/config/artifact_catalog.go index c7a77b8..4252cc8 100644 --- a/internal/config/artifact_catalog.go +++ b/internal/config/artifact_catalog.go @@ -40,6 +40,7 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec } sort.Strings(keys) records := make([]EffectiveArtifactRecord, 0, len(keys)) + pathsByID := pipelineSourcePaths(cfg) for _, key := range keys { artifact := cfg.Scriptorium.Artifacts[key] record := EffectiveArtifactRecord{ @@ -50,13 +51,13 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec Dependencies: append([]string(nil), artifact.DependsOn...), } if member, ok := cfg.familyCatalog.Members[key]; ok { - record.DefinitionSources = artifactFamilyDefinitionSources(cfg, member.Family) + record.DefinitionSources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...) record.FamilyKey = member.Family record.CharacterID = member.CharacterID record.FamilySources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...) record.PartySource = strings.Join(partyCharacterSources(party, member.CharacterID), ",") } else { - record.DefinitionSources = artifactDefinitionSources(cfg, key) + record.DefinitionSources = declarationDefinitionSourcesWithIndex(cfg, configkit.Keys("scriptorium", "artifacts", key), pathsByID) } record.Dependencies = nonEmptySortedStrings(record.Dependencies) records = append(records, record) @@ -105,12 +106,6 @@ func partyCharacterSources(party ResolvedParty, id string) []string { return nonEmptySortedStrings(sources) } -func artifactDefinitionSources(cfg *PipelineConfig, key string) []string { - return declarationDefinitionSources(cfg, - configkit.Keys("scriptorium", "artifacts", key), - ) -} - func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string { return declarationDefinitionSources(cfg, configkit.Keys("scriptorium", "artifact_families", key), @@ -118,10 +113,13 @@ func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string { } func declarationDefinitionSources(cfg *PipelineConfig, declaration configkit.Path) []string { + return declarationDefinitionSourcesWithIndex(cfg, declaration, pipelineSourcePaths(cfg)) +} + +func declarationDefinitionSourcesWithIndex(cfg *PipelineConfig, declaration configkit.Path, pathsByID map[string]string) []string { if cfg == nil || cfg.resolution == nil { return nil } - pathsByID := pipelineSourcePaths(cfg) seen := map[string]struct{}{} for _, change := range cfg.resolution.configkitMetadata.History(declaration) { if change.Origin.Layer != configkit.LayerMain && change.Origin.Layer != configkit.LayerOverlay { diff --git a/internal/config/effective_pipeline.go b/internal/config/effective_pipeline.go index 7b17ac5..17710be 100644 --- a/internal/config/effective_pipeline.go +++ b/internal/config/effective_pipeline.go @@ -59,11 +59,7 @@ func emptyImportSelections[T any](result *configkit.Result[T]) []EmptyImportSele return nil } var selections []EmptyImportSelection - for _, listed := range result.Sources() { - source, ok := result.Source(listed.ID) - if !ok { - continue - } + for _, source := range result.Sources() { name := source.Path if name == "" { name = source.Label diff --git a/internal/config/empty_import_sources_test.go b/internal/config/empty_import_sources_test.go new file mode 100644 index 0000000..3876a53 --- /dev/null +++ b/internal/config/empty_import_sources_test.go @@ -0,0 +1,27 @@ +package config + +import "testing" + +func TestEmptyImportSourcesIncludeNestedDeclarations(t *testing.T) { + dir := t.TempDir() + root := writePipelineFixture(t, dir, "pipeline.yml", "config:\n imports:\n - path: fragment.yml\n - path: absent-root.yml\n") + fragment := writePipelineFixture(t, dir, "fragment.yml", "config:\n imports:\n - path: absent-child.yml\n") + cfg, err := LoadPipeline(root) + if err != nil { + t.Fatal(err) + } + selections := EffectiveEmptyImports(cfg, nil) + if len(selections) != 2 { + t.Fatalf("empty selections: %#v", selections) + } + seen := map[string]bool{} + for _, selection := range selections { + if selection.Selector != "path" || selection.Path == "" || selection.Line == 0 { + t.Fatalf("incomplete evidence: %#v", selection) + } + seen[selection.Source] = true + } + if !seen[root] || !seen[fragment] { + t.Fatalf("source evidence: %#v", selections) + } +} diff --git a/internal/config/pipeline_configkit.go b/internal/config/pipeline_configkit.go index ec38614..62644cc 100644 --- a/internal/config/pipeline_configkit.go +++ b/internal/config/pipeline_configkit.go @@ -345,11 +345,6 @@ func pipelineSourcePaths(cfg *PipelineConfig) map[string]string { return paths } for _, source := range cfg.resolution.configkitSources { - if cfg.resolution.authoring != nil { - if found, ok := cfg.resolution.authoring.Source(source.ID); ok { - source = found - } - } path := source.Path if path == "" { path = source.Label