diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 1ac1fee..cc19ec4 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -315,7 +315,7 @@ reserved-key compatibility impact remains an explicit release-preparation item. Complete when canonical documentation and a tested copyable example describe the implemented adoption, without promoting new restrictions to policy. -## Stage 7: Verify the assembled inspection workflow and close the feature +## Stage 7: Verify the assembled inspection workflow and close the feature [x] Purpose: establish that real command composition consumes the integrated configuration correctly and finish the upgrade as a reviewable baseline. diff --git a/internal/app/config_artifacts_test.go b/internal/app/config_artifacts_test.go index 817d9d7..6874c51 100644 --- a/internal/app/config_artifacts_test.go +++ b/internal/app/config_artifacts_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "io" "path/filepath" "reflect" "strings" @@ -110,6 +111,7 @@ func TestConfigArtifactsReportsOverlayFamilyContributors(t *testing.T) { } func TestConfigInspectionReportsInheritedCompositeSources(t *testing.T) { + t.Setenv("NARRATIO_CONFIG_INSPECTION_KEY", "synthetic-inspection-secret") pipelinePath, campaignPath := writeInspectionFamilyConfig(t) dir := filepath.Dir(pipelinePath) parentPath := filepath.Join(dir, "families", "parent.yml") @@ -125,6 +127,10 @@ campaigns: root: `+filepath.Join(dir, "campaigns")+` whisperx: transcribe_url: https://transcription.example.com/transcribe +audita: + credentials: [NARRATIO_CONFIG_INSPECTION_KEY] +scriptorium: + extends: audita `) mustWriteTestFile(t, parentPath, `scriptorium: artifact_families: @@ -156,8 +162,38 @@ whisperx: artifacts: notes: output_path: artifacts/notes-testing.md +`) + expandedOverlayPath := filepath.Join(dir, "overlays", "expanded.yml") + mustWriteTestFile(t, expandedOverlayPath, `scriptorium: + extends: null + credentials: [NARRATIO_CONFIG_INSPECTION_KEY] + artifact_families: + character_note: + enabled: false + for_each: party.characters + prompt_id: dnd.character_note.testing + profile_id: testing + output_path_pattern: artifacts/characters/{character_id}/note.md + artifacts: + notes: + output_path: artifacts/notes-testing.md `) args := []string{"--config", pipelinePath, "--campaign-file", campaignPath, "--overlay", "testing"} + if err := ConfigValidate(context.Background(), args, io.Discard); err != nil { + t.Fatalf("ConfigValidate() error = %v", err) + } + var effective bytes.Buffer + if err := ConfigShow(context.Background(), args, &effective); err != nil { + t.Fatalf("ConfigShow() error = %v", err) + } + for _, want := range []string{"NARRATIO_CONFIG_INSPECTION_KEY", "character_note_arannis:", "dnd.character_note.testing", "artifacts/characters/arannis/note.md"} { + if !strings.Contains(effective.String(), want) { + t.Errorf("effective show omitted %q:\n%s", want, effective.String()) + } + } + if strings.Contains(effective.String(), "synthetic-inspection-secret") { + t.Fatal("effective show exposed a credential value") + } var catalog bytes.Buffer if err := ConfigArtifacts(context.Background(), args, &catalog); err != nil { @@ -165,6 +201,9 @@ whisperx: } records := catalogRecordsByKey(t, catalog.String()) notes := records["notes"] + if strings.Contains(catalog.String(), "synthetic-inspection-secret") { + t.Fatal("artifact catalog exposed a credential value") + } if notes[4] != "artifacts/notes-testing.md" { t.Fatalf("composed artifact output = %#v", notes) } @@ -192,11 +231,25 @@ whisperx: "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, + "scriptorium.credentials\troot\t" + pipelinePath, } { if !strings.Contains(sources.String(), want) { t.Errorf("effective source output missing %q:\n%s", want, sources.String()) } } + if strings.Contains(sources.String(), "synthetic-inspection-secret") { + t.Fatal("source inspection exposed a credential value") + } + var diff bytes.Buffer + if err := ConfigDiff(context.Background(), []string{"testing", "expanded", "--config", pipelinePath, "--campaign-file", campaignPath}, &diff); err != nil { + t.Fatalf("ConfigDiff() error = %v", err) + } + if diff.String() != "no differences\n" { + t.Fatalf("equivalent inherited/expanded overlays diff = %q", diff.String()) + } + if strings.Contains(diff.String(), "synthetic-inspection-secret") { + t.Fatal("configuration diff exposed a credential value") + } } func TestConfigArtifactsReportsBaseAndOverlayContributors(t *testing.T) {