Verify inherited configuration semantics
This commit is contained in:
@@ -184,7 +184,7 @@ Complete when native provenance remains useful and truthful, redundant tracking
|
|||||||
is removed where practical, and no acceptance rule depends on contributor count
|
is removed where practical, and no acceptance rule depends on contributor count
|
||||||
or an inferred defining file. Application derivation context remains available.
|
or an inferred defining file. Application derivation context remains available.
|
||||||
|
|
||||||
## Stage 4: Verify inherited presence, domain resolution, and path bases
|
## Stage 4: Verify inherited presence, domain resolution, and path bases [x]
|
||||||
|
|
||||||
Purpose: prevent Narratio's application defaults or normalization from undoing
|
Purpose: prevent Narratio's application defaults or normalization from undoing
|
||||||
the library's inherited explicit input.
|
the library's inherited explicit input.
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPipelineConfigKitImportsOverlayAndBaseSelection(t *testing.T) {
|
func TestPipelineConfigKitImportsOverlayAndBaseSelection(t *testing.T) {
|
||||||
@@ -178,6 +180,197 @@ whisperx:
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPipelineInheritancePreservesPresenceAndPathBases(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writePipelineFixture(t, dir, "pipeline.yml", `configkit:
|
||||||
|
imports:
|
||||||
|
- path: config/parent.yml
|
||||||
|
- path: config/children.yml
|
||||||
|
whisperx:
|
||||||
|
transcribe_url: https://transcription.example.test/transcribe
|
||||||
|
`)
|
||||||
|
writePipelineFixture(t, dir, "config/parent.yml", `scriptorium:
|
||||||
|
artifacts:
|
||||||
|
base:
|
||||||
|
enabled: false
|
||||||
|
prompt_id: dnd.base
|
||||||
|
render_debug: false
|
||||||
|
vars:
|
||||||
|
empty: ""
|
||||||
|
flag: false
|
||||||
|
null_base:
|
||||||
|
enabled: false
|
||||||
|
vars: null
|
||||||
|
`)
|
||||||
|
writePipelineFixture(t, dir, "config/children.yml", `scriptorium:
|
||||||
|
artifacts:
|
||||||
|
inherited:
|
||||||
|
extends: base
|
||||||
|
output_path: artifacts/inherited.md
|
||||||
|
overridden:
|
||||||
|
extends: base
|
||||||
|
output_path: artifacts/overridden.md
|
||||||
|
render_debug: false
|
||||||
|
null_child:
|
||||||
|
extends: null_base
|
||||||
|
output_path: artifacts/null.md
|
||||||
|
absent:
|
||||||
|
enabled: false
|
||||||
|
output_path: artifacts/absent.md
|
||||||
|
`)
|
||||||
|
writePipelineFixture(t, dir, "overlays/testing.yml", `scriptorium:
|
||||||
|
artifacts:
|
||||||
|
base:
|
||||||
|
prompt_id: dnd.overlay
|
||||||
|
render_debug: true
|
||||||
|
`)
|
||||||
|
|
||||||
|
cfg, err := LoadPipelineWithOptions(filepath.Join(dir, "pipeline.yml"), PipelineLoadOptions{Overlay: stringPointer("testing")})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("LoadPipelineWithOptions() error = %v", err)
|
||||||
|
}
|
||||||
|
artifacts := cfg.Scriptorium.Artifacts
|
||||||
|
if got := artifacts["inherited"]; got.PromptID != "dnd.overlay" || got.OutputPath != "artifacts/inherited.md" || got.RenderDebug == nil || !*got.RenderDebug {
|
||||||
|
t.Fatalf("inherited artifact after overlay = %#v", got)
|
||||||
|
}
|
||||||
|
if got := artifacts["overridden"]; got.PromptID != "dnd.overlay" || got.RenderDebug == nil || *got.RenderDebug {
|
||||||
|
t.Fatalf("child override after overlay = %#v", got)
|
||||||
|
}
|
||||||
|
if got := artifacts["inherited"].Vars["empty"]; got != "" {
|
||||||
|
t.Fatalf("inherited empty variable = %#v, want empty string", got)
|
||||||
|
}
|
||||||
|
if got := artifacts["inherited"].Vars["flag"]; got != false {
|
||||||
|
t.Fatalf("inherited false variable = %#v, want false", got)
|
||||||
|
}
|
||||||
|
if artifacts["null_child"].Vars != nil {
|
||||||
|
t.Fatalf("inherited null vars = %#v, want nil", artifacts["null_child"].Vars)
|
||||||
|
}
|
||||||
|
if artifacts["absent"].RenderDebug != nil {
|
||||||
|
t.Fatalf("absent render_debug = %#v, want nil", artifacts["absent"].RenderDebug)
|
||||||
|
}
|
||||||
|
if cfg.Scriptorium.Timeout != DefaultScriptoriumTimeout {
|
||||||
|
t.Fatalf("absent Scriptorium timeout = %q, want default %q", cfg.Scriptorium.Timeout, DefaultScriptoriumTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
metadata := cfg.resolution.configkitMetadata
|
||||||
|
for _, path := range []configkit.Path{
|
||||||
|
configkit.Keys("scriptorium", "artifacts", "inherited", "render_debug"),
|
||||||
|
configkit.Keys("scriptorium", "artifacts", "inherited", "vars", "empty"),
|
||||||
|
configkit.Keys("scriptorium", "artifacts", "inherited", "vars", "flag"),
|
||||||
|
configkit.Keys("scriptorium", "artifacts", "null_child", "vars"),
|
||||||
|
} {
|
||||||
|
if !metadata.IsExplicit(path) {
|
||||||
|
t.Errorf("inherited path %v is not explicit", path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if metadata.IsExplicit(configkit.Keys("scriptorium", "artifacts", "absent", "render_debug")) {
|
||||||
|
t.Fatal("absent render_debug is marked explicit")
|
||||||
|
}
|
||||||
|
if metadata.IsExplicit(configkit.Keys("scriptorium", "artifacts", "absent", "vars", "empty")) {
|
||||||
|
t.Fatal("absent variable is marked explicit")
|
||||||
|
}
|
||||||
|
if metadata.IsExplicit(configkit.Keys("scriptorium", "artifacts", "absent", "vars")) {
|
||||||
|
t.Fatal("absent vars mapping is marked explicit")
|
||||||
|
}
|
||||||
|
if metadata.IsExplicit(configkit.Keys("scriptorium", "timeout")) {
|
||||||
|
t.Fatal("defaulted Scriptorium timeout is marked explicit")
|
||||||
|
}
|
||||||
|
if err := ValidatePipelineConfig(cfg); err != nil {
|
||||||
|
t.Fatalf("ValidatePipelineConfig() error = %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPipelineInheritanceRetainsZeroTimeoutForDomainValidation(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writePipelineFixture(t, dir, "pipeline.yml", `configkit:
|
||||||
|
imports:
|
||||||
|
- path: artifacts.yml
|
||||||
|
whisperx:
|
||||||
|
transcribe_url: https://transcription.example.test/transcribe
|
||||||
|
`)
|
||||||
|
writePipelineFixture(t, dir, "artifacts.yml", `scriptorium:
|
||||||
|
artifacts:
|
||||||
|
base:
|
||||||
|
enabled: false
|
||||||
|
timeout: 0s
|
||||||
|
child:
|
||||||
|
extends: base
|
||||||
|
output_path: artifacts/child.md
|
||||||
|
`)
|
||||||
|
|
||||||
|
cfg, err := LoadPipeline(filepath.Join(dir, "pipeline.yml"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("LoadPipeline() error = %v", err)
|
||||||
|
}
|
||||||
|
if got := cfg.Scriptorium.Artifacts["child"].Timeout; got != "0s" {
|
||||||
|
t.Fatalf("inherited zero timeout = %q, want 0s", got)
|
||||||
|
}
|
||||||
|
if !cfg.resolution.configkitMetadata.IsExplicit(configkit.Keys("scriptorium", "artifacts", "child", "timeout")) {
|
||||||
|
t.Fatal("inherited zero timeout is not marked explicit")
|
||||||
|
}
|
||||||
|
if err := ValidatePipelineConfig(cfg); err == nil || !strings.Contains(err.Error(), "timeout must be positive") {
|
||||||
|
t.Fatalf("ValidatePipelineConfig() error = %v, want invalid zero timeout", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPipelineExplicitEmptyTimeoutDoesNotReceiveDefault(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writePipelineFixture(t, dir, "pipeline.yml", `configkit:
|
||||||
|
imports:
|
||||||
|
- path: timeout.yml
|
||||||
|
whisperx:
|
||||||
|
transcribe_url: https://transcription.example.test/transcribe
|
||||||
|
`)
|
||||||
|
writePipelineFixture(t, dir, "timeout.yml", "scriptorium:\n timeout: \"\"\n")
|
||||||
|
|
||||||
|
cfg, err := LoadPipeline(filepath.Join(dir, "pipeline.yml"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("LoadPipeline() error = %v", err)
|
||||||
|
}
|
||||||
|
if cfg.Scriptorium.Timeout != "" {
|
||||||
|
t.Fatalf("explicit empty Scriptorium timeout = %q, want empty", cfg.Scriptorium.Timeout)
|
||||||
|
}
|
||||||
|
if !cfg.resolution.configkitMetadata.IsExplicit(configkit.Keys("scriptorium", "timeout")) {
|
||||||
|
t.Fatal("explicit empty Scriptorium timeout is not marked explicit")
|
||||||
|
}
|
||||||
|
if err := ValidatePipelineConfig(cfg); err != nil {
|
||||||
|
t.Fatalf("ValidatePipelineConfig() error = %v, want existing empty-timeout behavior", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestImportedNotariusPathsKeepPipelineRootBase(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
pipelinePath := writePipelineFixture(t, dir, "pipeline.yml", `configkit:
|
||||||
|
imports:
|
||||||
|
- path: profiles/notarius.yml
|
||||||
|
whisperx:
|
||||||
|
transcribe_url: https://transcription.example.test/transcribe
|
||||||
|
`)
|
||||||
|
writePipelineFixture(t, dir, "profiles/notarius.yml", `notarius:
|
||||||
|
enabled: true
|
||||||
|
config_path: notarius/config.yml
|
||||||
|
pipeline_id: dnd-session
|
||||||
|
outputs:
|
||||||
|
npc_registry:
|
||||||
|
lane_id: npc-registry
|
||||||
|
media_type: application/json
|
||||||
|
schema_id: notarius.dnd.npc_registry
|
||||||
|
schema_version: v1
|
||||||
|
`)
|
||||||
|
|
||||||
|
cfg, err := LoadPipeline(pipelinePath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("LoadPipeline() error = %v", err)
|
||||||
|
}
|
||||||
|
wantConfigPath := filepath.Join(dir, "notarius", "config.yml")
|
||||||
|
if cfg.Notarius.ConfigPath != wantConfigPath {
|
||||||
|
t.Fatalf("imported Notarius config_path = %q, want pipeline-root path %q", cfg.Notarius.ConfigPath, wantConfigPath)
|
||||||
|
}
|
||||||
|
if got, want := cfg.Notarius.WorkingDirectory, filepath.Dir(wantConfigPath); got != want {
|
||||||
|
t.Fatalf("derived Notarius working_directory = %q, want pipeline-root directory %q", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPipelineConfigKitInheritsArtifactAcrossImports(t *testing.T) {
|
func TestPipelineConfigKitInheritsArtifactAcrossImports(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), `schema_version: narratio.party.v1
|
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), `schema_version: narratio.party.v1
|
||||||
|
|||||||
Reference in New Issue
Block a user