Preserve composite ConfigKit provenance
This commit is contained in:
@@ -109,6 +109,96 @@ func TestConfigArtifactsReportsOverlayFamilyContributors(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigInspectionReportsInheritedCompositeSources(t *testing.T) {
|
||||
pipelinePath, campaignPath := writeInspectionFamilyConfig(t)
|
||||
dir := filepath.Dir(pipelinePath)
|
||||
parentPath := filepath.Join(dir, "families", "parent.yml")
|
||||
childPath := filepath.Join(dir, "families", "child.yml")
|
||||
overlayPath := filepath.Join(dir, "overlays", "testing.yml")
|
||||
mustWriteTestFile(t, pipelinePath, `configkit:
|
||||
imports:
|
||||
- path: families/parent.yml
|
||||
- path: families/child.yml
|
||||
workspace:
|
||||
root: `+filepath.Join(dir, "workspace")+`
|
||||
campaigns:
|
||||
root: `+filepath.Join(dir, "campaigns")+`
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.example.com/transcribe
|
||||
`)
|
||||
mustWriteTestFile(t, parentPath, `scriptorium:
|
||||
artifact_families:
|
||||
character_meta:
|
||||
enabled: false
|
||||
for_each: party.characters
|
||||
prompt_id: dnd.character_meta
|
||||
profile_id: production
|
||||
output_path_pattern: artifacts/characters/{character_id}/meta.md
|
||||
artifacts:
|
||||
notes:
|
||||
enabled: false
|
||||
prompt_id: dnd.notes
|
||||
`)
|
||||
mustWriteTestFile(t, childPath, `scriptorium:
|
||||
artifact_families:
|
||||
character_note:
|
||||
extends: character_meta
|
||||
profile_id: testing
|
||||
output_path_pattern: artifacts/characters/{character_id}/note.md
|
||||
artifacts:
|
||||
notes:
|
||||
output_path: artifacts/notes.md
|
||||
`)
|
||||
mustWriteTestFile(t, overlayPath, `scriptorium:
|
||||
artifact_families:
|
||||
character_note:
|
||||
prompt_id: dnd.character_note.testing
|
||||
artifacts:
|
||||
notes:
|
||||
output_path: artifacts/notes-testing.md
|
||||
`)
|
||||
args := []string{"--config", pipelinePath, "--campaign-file", campaignPath, "--overlay", "testing"}
|
||||
|
||||
var catalog bytes.Buffer
|
||||
if err := ConfigArtifacts(context.Background(), args, &catalog); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
records := catalogRecordsByKey(t, catalog.String())
|
||||
notes := records["notes"]
|
||||
if notes[4] != "artifacts/notes-testing.md" {
|
||||
t.Fatalf("composed artifact output = %#v", notes)
|
||||
}
|
||||
for _, contributor := range []string{parentPath, childPath, overlayPath} {
|
||||
if !strings.Contains(notes[2], contributor) {
|
||||
t.Errorf("composed artifact definitions %q omit %q", notes[2], contributor)
|
||||
}
|
||||
}
|
||||
|
||||
note := records["character_note_arannis"]
|
||||
if note[4] != "artifacts/characters/arannis/note.md" || note[6] != "character_note" || note[7] != "arannis" {
|
||||
t.Fatalf("inherited family catalog identity and output = %#v", note)
|
||||
}
|
||||
for _, contributor := range []string{parentPath, childPath, overlayPath} {
|
||||
if !strings.Contains(note[2], contributor) || !strings.Contains(note[8], contributor) {
|
||||
t.Errorf("family provenance = definitions %q, family sources %q; want %q", note[2], note[8], contributor)
|
||||
}
|
||||
}
|
||||
|
||||
var sources bytes.Buffer
|
||||
if err := ConfigSources(context.Background(), args, &sources); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, want := range []string{
|
||||
"scriptorium.artifacts.notes.output_path\toverlay\t" + overlayPath,
|
||||
"scriptorium.artifacts.character_note_arannis.output_path\tfamily\t" + childPath,
|
||||
"scriptorium.artifacts.character_note_arannis.prompt_id\tfamily\t" + overlayPath,
|
||||
} {
|
||||
if !strings.Contains(sources.String(), want) {
|
||||
t.Errorf("effective source output missing %q:\n%s", want, sources.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigArtifactsReportsBaseAndOverlayContributors(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pipelinePath := filepath.Join(dir, "pipeline.yml")
|
||||
|
||||
@@ -178,7 +178,7 @@ func configArtifactsWithDependencies(_ context.Context, args []string, out io.Wr
|
||||
strings.Join(record.Dependencies, ","),
|
||||
record.FamilyKey,
|
||||
record.CharacterID,
|
||||
config.NormalizedConfigurationPath(record.FamilySource),
|
||||
strings.Join(normalizedCatalogPaths(record.FamilySources), ","),
|
||||
config.NormalizedConfigurationPath(record.PartySource),
|
||||
}
|
||||
for index := range fields {
|
||||
|
||||
Reference in New Issue
Block a user