diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 09f7b0ac..24fa1176 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -138,6 +138,15 @@ to compile against the new APIs yet. ## Stage 2: Introduce The Native Version 6 Configuration Definition +**Status:** Complete. Native settings and composed rules retain the original +application result for direct engine handoff. Version 6 numeric/string loads, +version 5 rejection, application origins, native inheritance, imported message +origins, and secret-aware inspection are covered by the passing +`GOWORK=off go test ./internal/core/config`. `git diff --check` passed. +The old CLI compile check is blocked by old-path ConfigKit importing the removed +`go.yaml.in/yaml/v4/plugin/limit`; later caller migration and dependency removal +own that integration. Source assembly remains assigned to Stage 5. + **Goal:** preserve one typed ConfigKit load and its original result evidence. **Inspect/change:** `internal/core/config/document.go`, `load.go`, diff --git a/go.mod b/go.mod index 27437ee0..673087af 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( gitea.maximumdirect.net/eric/promptkit v0.12.0 github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 go.maximumdirect.net/configkit v1.4.0 + go.maximumdirect.net/promptkit v0.24.0 go.yaml.in/yaml/v4 v4.0.0 golang.org/x/text v0.44.0 ) @@ -20,5 +21,4 @@ require ( go.maximumdirect.net/ckconfig v0.10.0 // indirect go.maximumdirect.net/ckprompt v0.11.0 // indirect go.maximumdirect.net/commandkit v0.7.0 // indirect - go.maximumdirect.net/promptkit v0.24.0 // indirect ) diff --git a/internal/core/config/collection_composition_test.go b/internal/core/config/collection_composition_test.go index a37bc9b5..dd340ab4 100644 --- a/internal/core/config/collection_composition_test.go +++ b/internal/core/config/collection_composition_test.go @@ -21,7 +21,7 @@ func TestStepCompositionAcrossSourcesAndOverlays(t *testing.T) { t.Fatal(err) } } - write("notarius.yml", `version: 5 + write("notarius.yml", `version: 6 config: imports: - path: one/pipeline.yml @@ -132,7 +132,7 @@ func TestStepIdentityRejectsDuplicatePeersWithoutRegisteringOtherLists(t *testin t.Run(tc.name, func(t *testing.T) { root := t.TempDir() for name, data := range map[string]string{ - "main.yml": "version: 5\nconfig:\n imports:\n - path: one.yml\n - path: two.yml\n", + "main.yml": "version: 6\nconfig:\n imports:\n - path: one.yml\n - path: two.yml\n", "one.yml": "pipelines:\n session:\n " + tc.first + "\n", "two.yml": "pipelines:\n session:\n " + tc.second + "\n", } { @@ -150,7 +150,7 @@ func TestStepIdentityRejectsDuplicatePeersWithoutRegisteringOtherLists(t *testin func TestStepRecordInheritanceReplacesMatchingRecord(t *testing.T) { root := t.TempDir() main := filepath.Join(root, "main.yml") - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 pipelines: parent: input: {module: input} @@ -182,7 +182,7 @@ pipelines: func TestIdentifiedStepInheritanceDoesNotCreateTemplateSteps(t *testing.T) { main := filepath.Join(t.TempDir(), "main.yml") - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 pipelines: session: input: {module: input} @@ -213,7 +213,7 @@ pipelines: func TestIdentifiedValidatorRecordInheritanceResolves(t *testing.T) { main := filepath.Join(t.TempDir(), "main.yml") - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 config: sequences: - destination: [pipelines, session, artifacts, result, extract, validators] @@ -257,7 +257,7 @@ pipelines: func TestEmptyStepOperationsAndOptionalImports(t *testing.T) { root := t.TempDir() main := filepath.Join(root, "main.yml") - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 config: imports: - path: absent.yml diff --git a/internal/core/config/config.go b/internal/core/config/config.go index a0a31e06..08037240 100644 --- a/internal/core/config/config.go +++ b/internal/core/config/config.go @@ -5,7 +5,6 @@ import ( ) type Config struct { - PromptKit PromptKitConfig `json:"promptkit,omitempty"` Pipelines map[string]pipeline.PipelineProfile `json:"pipelines"` Concurrency ConcurrencyConfig `json:"concurrency"` Output OutputConfig `json:"output"` @@ -13,26 +12,13 @@ type Config struct { Debug DebugConfig `json:"debug"` } -type PromptKitConfig struct { - ProfileDir string `json:"profile_dir,omitempty"` - ProfileFile string `json:"profile_file,omitempty"` - TransientRetries int `json:"transient_retries"` - LocalBackend *PromptKitLocalBackendConfig `json:"local_backend,omitempty"` -} - -type PromptKitLocalBackendConfig struct { - Endpoint string `json:"endpoint"` - ConcurrencyLimit int `json:"concurrency_limit"` -} - type ConcurrencyConfig struct { TotalLLM int `json:"total_llm"` StageWorkers map[string]int `json:"stage_workers"` } const ( - defaultLLMConcurrency = 16 - defaultTransientRetries = 2 + defaultLLMConcurrency = 16 ) type OutputConfig struct { @@ -59,7 +45,6 @@ type DebugConfig struct { func Default() Config { return Config{ - PromptKit: PromptKitConfig{TransientRetries: defaultTransientRetries}, Pipelines: map[string]pipeline.PipelineProfile{}, Concurrency: ConcurrencyConfig{ TotalLLM: defaultLLMConcurrency, @@ -73,10 +58,6 @@ func Default() Config { func cloneConfig(in Config) Config { out := in - if in.PromptKit.LocalBackend != nil { - localBackend := *in.PromptKit.LocalBackend - out.PromptKit.LocalBackend = &localBackend - } out.Concurrency.StageWorkers = cloneIntMap(in.Concurrency.StageWorkers) out.Pipelines = make(map[string]pipeline.PipelineProfile, len(in.Pipelines)) for key, profile := range in.Pipelines { diff --git a/internal/core/config/document.go b/internal/core/config/document.go index c99b0924..59a561c7 100644 --- a/internal/core/config/document.go +++ b/internal/core/config/document.go @@ -1,13 +1,16 @@ package config -import "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" +import ( + "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" + "go.maximumdirect.net/promptkit" +) -// Document is the version 5 configuration shape decoded by ConfigKit. It is +// Document is the version 6 configuration shape decoded by ConfigKit. It is // deliberately separate from Config so YAML presence and composition concerns // do not reach runtime pipeline types. type Document struct { Version string `yaml:"version"` - PromptKit *PromptKitDocument `yaml:"promptkit,omitempty"` + PromptKit promptkit.Settings `yaml:"promptkit"` Pipelines map[string]PipelineDocument `yaml:"pipelines,omitempty"` Concurrency *ConcurrencyDocument `yaml:"concurrency,omitempty"` Output *OutputDocument `yaml:"output,omitempty"` @@ -15,18 +18,6 @@ type Document struct { Debug *DebugDocument `yaml:"debug,omitempty"` } -type PromptKitDocument struct { - ProfileDir *string `yaml:"profile_dir,omitempty"` - ProfileFile *string `yaml:"profile_file,omitempty"` - TransientRetries *int `yaml:"transient_retries,omitempty"` - LocalBackend *PromptKitLocalBackendDocument `yaml:"local_backend,omitempty"` -} - -type PromptKitLocalBackendDocument struct { - Endpoint *string `yaml:"endpoint,omitempty"` - ConcurrencyLimit *int `yaml:"concurrency_limit,omitempty"` -} - type PipelineDocument struct { LLMProfile *string `yaml:"llm_profile,omitempty"` StructuredOutputRepairAttempts *int `yaml:"structured_output_repair_attempts,omitempty"` @@ -75,7 +66,7 @@ type ValidatorDocument struct { Options map[string]any `yaml:"options,omitempty"` } -// ReferenceDocument is the explicit version 5 union. Later document +// ReferenceDocument is the explicit version 6 union. Later document // validation establishes which locations permit generated references and // requires exactly one populated branch. type ReferenceDocument struct { diff --git a/internal/core/config/document_paths.go b/internal/core/config/document_paths.go index fac2371d..dbccc1fe 100644 --- a/internal/core/config/document_paths.go +++ b/internal/core/config/document_paths.go @@ -13,10 +13,6 @@ func normalizeDocumentPaths(document *Document, resolution *configkit.Resolution return } initializeDocumentMainDirectory(resolution, state) - if document.PromptKit != nil { - normalizeDocumentPath(resolution, state, configkit.Keys("promptkit", "profile_dir"), &document.PromptKit.ProfileDir, false, "resolved PromptKit profile directory") - normalizeDocumentPath(resolution, state, configkit.Keys("promptkit", "profile_file"), &document.PromptKit.ProfileFile, false, "resolved PromptKit profile file") - } if document.Output != nil { normalizeDocumentPath(resolution, state, configkit.Keys("output", "directory"), &document.Output.Directory, false, "resolved output directory") } diff --git a/internal/core/config/document_paths_test.go b/internal/core/config/document_paths_test.go index 42e65f20..ab17ff27 100644 --- a/internal/core/config/document_paths_test.go +++ b/internal/core/config/document_paths_test.go @@ -64,7 +64,7 @@ func TestDocumentPathsUseDeclaringFilesAcrossImports(t *testing.T) { `), 0o600); err != nil { t.Fatal(err) } - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 config: imports: - path: fragments/pipelines.yml @@ -102,7 +102,7 @@ func TestDiscoveredMainAndStepReferenceNormalization(t *testing.T) { } main := filepath.Join(root, "notarius.yml") fragment := filepath.Join(fragmentDir, "pipeline.yml") - if err := os.WriteFile(main, []byte("version: 5\nconfig:\n imports:\n - path: fragments/pipeline.yml\n required: true\n"), 0600); err != nil { + if err := os.WriteFile(main, []byte("version: 6\nconfig:\n imports:\n - path: fragments/pipeline.yml\n required: true\n"), 0600); err != nil { t.Fatal(err) } if err := os.WriteFile(fragment, []byte(`pipelines: @@ -144,7 +144,7 @@ func TestDocumentPathsUseInvocationDirectoryForOverrides(t *testing.T) { root := t.TempDir() configPath := filepath.Join(root, "notarius.yml") - if err := os.WriteFile(configPath, []byte("version: 5\n"), 0o600); err != nil { + if err := os.WriteFile(configPath, []byte("version: 6\n"), 0o600); err != nil { t.Fatal(err) } invocation := t.TempDir() @@ -167,7 +167,7 @@ func TestDiscoveredSymlinkUsesCanonicalMainDirectory(t *testing.T) { t.Fatal(err) } main := filepath.Join(realDir, "main.yml") - if err := os.WriteFile(main, []byte("version: 5\n"), 0600); err != nil { + if err := os.WriteFile(main, []byte("version: 6\n"), 0600); err != nil { t.Fatal(err) } link := filepath.Join(root, "notarius.yml") @@ -200,7 +200,7 @@ func TestDocumentPathsUseOverlayDeclarationDirectory(t *testing.T) { t.Fatal(err) } main := filepath.Join(root, "notarius.yml") - if err := os.WriteFile(main, []byte("version: 5\n"), 0o600); err != nil { + if err := os.WriteFile(main, []byte("version: 6\n"), 0o600); err != nil { t.Fatal(err) } if err := os.WriteFile(filepath.Join(overlays, "development.yml"), []byte("output: {directory: ./overlay-output}\n"), 0o600); err != nil { @@ -220,7 +220,7 @@ func TestDocumentLoadDoesNotFallBackToLegacyProfileDirectory(t *testing.T) { root := t.TempDir() main := filepath.Join(root, "notarius.yml") - if err := os.WriteFile(main, []byte("version: 5\n"), 0o600); err != nil { + if err := os.WriteFile(main, []byte("version: 6\n"), 0o600); err != nil { t.Fatal(err) } legacy := filepath.Join(root, "profiles", "development.yml") @@ -242,7 +242,7 @@ func TestDocumentPathsKeepEmptyCacheDirectoriesAndAbsolutePaths(t *testing.T) { root := t.TempDir() configPath := filepath.Join(root, "notarius.yml") abs := filepath.Join(t.TempDir(), "outside.txt") - if err := os.WriteFile(configPath, []byte("version: 5\ncache:\n chunk_plans: {directory: ''}\n checkpoints: {directory: ''}\npipelines:\n main:\n input: {module: input}\n references:\n outside: {path: "+abs+"}\n"), 0o600); err != nil { + if err := os.WriteFile(configPath, []byte("version: 6\ncache:\n chunk_plans: {directory: ''}\n checkpoints: {directory: ''}\npipelines:\n main:\n input: {module: input}\n references:\n outside: {path: "+abs+"}\n"), 0o600); err != nil { t.Fatal(err) } loaded, err := loadConfig(configPath, LoadOptions{}) diff --git a/internal/core/config/document_test.go b/internal/core/config/document_test.go index 5738e034..eaf7ca19 100644 --- a/internal/core/config/document_test.go +++ b/internal/core/config/document_test.go @@ -8,11 +8,11 @@ import ( configkit "go.maximumdirect.net/configkit" ) -func TestDocumentLoadAcceptsVersion5AndCanonicalShapes(t *testing.T) { +func TestDocumentLoadAcceptsVersion6AndCanonicalShapes(t *testing.T) { t.Parallel() for _, source := range []string{ - `version: 5 + `version: 6 pipelines: session: input: @@ -41,7 +41,7 @@ pipelines: extract: module: dnd/locations `, - `version: "5" + `version: "6" pipelines: session: input: @@ -70,8 +70,8 @@ func TestDocumentLoadRejectsUnsupportedVersionsBeforeDocumentDecoding(t *testing {name: "missing", source: "unknown: value\n", code: configkit.CodeVersionError}, {name: "null", source: "version: null\nunknown: value\n", code: configkit.CodeVersionError}, {name: "version four", source: "version: 4\nunknown: value\n", code: configkit.CodeVersionError}, - {name: "unsupported", source: "version: 6\nunknown: value\n", code: configkit.CodeVersionError}, - {name: "noninteger", source: "version: 5.0\n", code: configkit.CodeVersionType}, + {name: "version five", source: "version: 5\nunknown: value\n", code: configkit.CodeVersionError}, + {name: "noninteger", source: "version: 6.0\n", code: configkit.CodeVersionType}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { @@ -102,19 +102,19 @@ func TestDocumentLoadRejectsShorthandAndUnknownFields(t *testing.T) { }{ { name: "binding shorthand", - source: "version: 5\npipelines:\n session:\n input: seriatim\n", + source: "version: 6\npipelines:\n session:\n input: seriatim\n", code: configkit.CodeDecodeType, path: "/pipelines/session/input", }, { name: "validator nested producer field", - source: "version: 5\npipelines:\n session:\n input:\n module: seriatim\n validators:\n - module: generic/valid_json\n validators: []\n", + source: "version: 6\npipelines:\n session:\n input:\n module: seriatim\n validators:\n - module: generic/valid_json\n validators: []\n", code: configkit.CodeDecodeUnknownField, path: "/pipelines/session/input/validators/0/validators", }, { name: "unknown field", - source: "version: 5\npipelines:\n session:\n input:\n module: seriatim\n unknown: true\n", + source: "version: 6\npipelines:\n session:\n input:\n module: seriatim\n unknown: true\n", code: configkit.CodeDecodeUnknownField, path: "/pipelines/session/input/unknown", }, @@ -137,14 +137,14 @@ func TestDocumentLoadRejectsShorthandAndUnknownFields(t *testing.T) { func TestDocumentDefinitionReturnsIndependentDefaults(t *testing.T) { t.Parallel() - first, err := loadDocumentSource(configkit.Bytes("first.yml", []byte("version: 5\n")), LoadOptions{}) + first, err := loadDocumentSource(configkit.Bytes("first.yml", []byte("version: 6\n")), LoadOptions{}) if err != nil { t.Fatal(err) } first.Config.Pipelines["changed"] = PipelineDocument{} first.Config.Concurrency.StageWorkers["extract"] = 3 - second, err := loadDocumentSource(configkit.Bytes("second.yml", []byte("version: 5\n")), LoadOptions{}) + second, err := loadDocumentSource(configkit.Bytes("second.yml", []byte("version: 6\n")), LoadOptions{}) if err != nil { t.Fatal(err) } diff --git a/internal/core/config/effective_config_contract_test.go b/internal/core/config/effective_config_contract_test.go index fe6e4bd1..21ef4e79 100644 --- a/internal/core/config/effective_config_contract_test.go +++ b/internal/core/config/effective_config_contract_test.go @@ -84,56 +84,6 @@ func TestEffectiveConfigMaterializesDefaultBindingsThroughCatalog(t *testing.T) } } -func TestEffectiveConfigPreservesPromptKitProfileSource(t *testing.T) { - tests := []struct { - name string - profileSource PromptKitConfig - }{ - {name: "profile directory", profileSource: PromptKitConfig{ProfileDir: "./profiles"}}, - {name: "profile file", profileSource: PromptKitConfig{ProfileFile: "./profiles.yml"}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cfg := configForEffectiveTests(t, effectiveProfile()) - cfg.PromptKit = tt.profileSource - effective, err := cfg.Resolve(ResolveInput{PipelineID: "main", Catalog: effectiveCatalog(t)}) - if err != nil { - t.Fatalf("Resolve() error = %v", err) - } - if effective.Config.PromptKit != cfg.PromptKit { - t.Fatalf("effective PromptKit config = %#v, want %#v", effective.Config.PromptKit, cfg.PromptKit) - } - }) - } -} - -func TestEffectiveConfigOwnsPromptKitLocalBackend(t *testing.T) { - cfg := configForEffectiveTests(t, effectiveProfile()) - cfg.PromptKit.LocalBackend = &PromptKitLocalBackendConfig{ - Endpoint: "http://localhost:8000/v1", - ConcurrencyLimit: 2, - } - effective, err := cfg.Resolve(ResolveInput{PipelineID: "main", Catalog: effectiveCatalog(t)}) - if err != nil { - t.Fatalf("Resolve() error = %v", err) - } - if effective.Config.PromptKit.LocalBackend == nil { - t.Fatal("effective local backend = nil") - } - if effective.Config.PromptKit.LocalBackend == cfg.PromptKit.LocalBackend { - t.Fatal("effective local backend aliases input config") - } - - cfg.PromptKit.LocalBackend.Endpoint = "http://changed-input.example/v1" - if effective.Config.PromptKit.LocalBackend.Endpoint != "http://localhost:8000/v1" { - t.Fatalf("input mutation changed effective config: %#v", effective.Config.PromptKit.LocalBackend) - } - effective.Config.PromptKit.LocalBackend.ConcurrencyLimit = 9 - if cfg.PromptKit.LocalBackend.ConcurrencyLimit != 2 { - t.Fatalf("effective mutation changed input config: %#v", cfg.PromptKit.LocalBackend) - } -} - func TestEffectiveConfigResolutionFailuresRetainContext(t *testing.T) { tests := []struct { name string diff --git a/internal/core/config/inheritance_test.go b/internal/core/config/inheritance_test.go index 6ea3445f..e88d732b 100644 --- a/internal/core/config/inheritance_test.go +++ b/internal/core/config/inheritance_test.go @@ -37,7 +37,7 @@ func TestPipelineInheritancePreservesAndUpsertsSteps(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - source := `version: 5 + source := `version: 6 pipelines: parent: input: {module: input} @@ -110,7 +110,7 @@ pipelines: func TestArtifactLaneInheritanceUsesSiblingMappingComposition(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("lanes.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("lanes.yml", []byte(`version: 6 pipelines: session: input: {module: input} @@ -140,7 +140,7 @@ pipelines: func TestInheritedPresenceOverridesRemainExplicit(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("presence.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("presence.yml", []byte(`version: 6 pipelines: parent: input: {module: input} @@ -209,7 +209,7 @@ pipelines: func TestInheritedFalseOptionRetainsExplicitMetadata(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("false-option.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("false-option.yml", []byte(`version: 6 pipelines: parent: input: {module: input} @@ -244,7 +244,7 @@ func TestInheritedAndDirectNullRepairBudgetsRemainInvalid(t *testing.T) { }{ { name: "child null", - source: `version: 5 + source: `version: 6 pipelines: parent: {input: {module: input}, structured_output_repair_attempts: 2} child: @@ -255,7 +255,7 @@ pipelines: }, { name: "inherited null", - source: `version: 5 + source: `version: 6 pipelines: parent: {input: {module: input}, structured_output_repair_attempts: null} child: {extends: parent} @@ -279,7 +279,7 @@ func TestOverlayInheritancePrecedesOverrides(t *testing.T) { t.Fatal(err) } main := filepath.Join(root, "config.yml") - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 pipelines: parent: input: {module: input} @@ -393,7 +393,7 @@ func TestInheritedReferencePathsKeepDeclaringSource(t *testing.T) { t.Fatal(err) } main := filepath.Join(root, "notarius.yml") - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 config: imports: - path: parents/pipelines.yml @@ -490,7 +490,7 @@ func TestInheritedInspectionRetainsOriginsRedactionAndOwnership(t *testing.T) { t.Fatal(err) } main := filepath.Join(root, "notarius.yml") - if err := os.WriteFile(main, []byte(`version: 5 + if err := os.WriteFile(main, []byte(`version: 6 config: imports: - path: parents/pipelines.yml diff --git a/internal/core/config/load.go b/internal/core/config/load.go index b45b4018..38146206 100644 --- a/internal/core/config/load.go +++ b/internal/core/config/load.go @@ -4,6 +4,7 @@ import ( "path/filepath" configkit "go.maximumdirect.net/configkit" + "go.maximumdirect.net/promptkit" ) // LoadOptions contains configuration selections supplied by an application @@ -15,7 +16,7 @@ type LoadOptions struct { InvocationDirectory string } -// loadDocument composes and validates a version 5 file with ConfigKit before +// loadDocument composes and validates a version 6 file with ConfigKit before // runtime conversion, retaining source provenance and frozen inspection output. func loadDocument(path string, options LoadOptions) (*configkit.Result[Document], error) { return loadDocumentWithSource(configkit.File(path), options, true) @@ -47,7 +48,7 @@ func cleanInvocationDirectory(value string) string { } func documentDefinition(state *documentLoadState) configkit.Definition[Document] { - return configkit.Definition[Document]{ + definition := configkit.Definition[Document]{ Defaults: documentDefaults, Resolve: func(document *Document, resolution *configkit.Resolution) error { return resolveDocumentOperations(document, resolution, state) @@ -66,13 +67,11 @@ func documentDefinition(state *documentLoadState) configkit.Definition[Document] }, "id"), }, } + return promptkit.Configure(definition, func(document *Document) *promptkit.Settings { return &document.PromptKit }) } func documentDefaults() Document { return Document{ - PromptKit: &PromptKitDocument{ - TransientRetries: documentValue(defaultTransientRetries), - }, Pipelines: map[string]PipelineDocument{}, Concurrency: &ConcurrencyDocument{ TotalLLM: documentValue(defaultLLMConcurrency), @@ -100,11 +99,7 @@ func validateDocumentVersion(version configkit.Version, validation *configkit.Va validation.Error(configkit.Keys("version"), "configuration version is required") return nil } - if version.Text == "4" { - validation.Error(configkit.Keys("version"), "configuration version 4 is no longer supported; migrate to version 5") - return nil - } - if version.Text != "5" { + if version.Text != "6" { validation.Error(configkit.Keys("version"), "unsupported configuration version") } return nil diff --git a/internal/core/config/loaded_config.go b/internal/core/config/loaded_config.go index e36c9af4..ae0e4648 100644 --- a/internal/core/config/loaded_config.go +++ b/internal/core/config/loaded_config.go @@ -16,6 +16,15 @@ type LoadedConfig struct { result *configkit.Result[Document] } +// Result returns the original application-owned load for native library handoff. +// Its typed values and resource contexts must not be reconstructed from rendered YAML. +func (loaded *LoadedConfig) Result() *configkit.Result[Document] { + if loaded == nil { + return nil + } + return loaded.result +} + // RuntimeConfig returns an independently owned runtime configuration. func (loaded *LoadedConfig) RuntimeConfig() Config { if loaded == nil { @@ -53,7 +62,7 @@ func loadConfig(path string, options LoadOptions) (*LoadedConfig, error) { return newLoadedConfig(result) } -// Load reads a version 5 configuration file into runtime configuration and a +// Load reads a version 6 configuration file into runtime configuration and a // private inspection snapshot. func Load(path string, options LoadOptions) (*LoadedConfig, error) { return loadConfig(path, options) @@ -109,27 +118,6 @@ func documentToConfig(document Document) (Config, error) { config.Concurrency.TotalLLM = *document.Concurrency.TotalLLM } } - if document.PromptKit != nil { - if document.PromptKit.ProfileDir != nil { - config.PromptKit.ProfileDir = *document.PromptKit.ProfileDir - } - if document.PromptKit.ProfileFile != nil { - config.PromptKit.ProfileFile = *document.PromptKit.ProfileFile - } - if document.PromptKit.TransientRetries != nil { - config.PromptKit.TransientRetries = *document.PromptKit.TransientRetries - } - if document.PromptKit.LocalBackend != nil { - backend := PromptKitLocalBackendConfig{} - if document.PromptKit.LocalBackend.Endpoint != nil { - backend.Endpoint = *document.PromptKit.LocalBackend.Endpoint - } - if document.PromptKit.LocalBackend.ConcurrencyLimit != nil { - backend.ConcurrencyLimit = *document.PromptKit.LocalBackend.ConcurrencyLimit - } - config.PromptKit.LocalBackend = &backend - } - } if document.Output != nil && document.Output.Directory != nil { config.Output.Directory = *document.Output.Directory } diff --git a/internal/core/config/loaded_config_test.go b/internal/core/config/loaded_config_test.go index eebf78ff..c476c11b 100644 --- a/internal/core/config/loaded_config_test.go +++ b/internal/core/config/loaded_config_test.go @@ -4,7 +4,6 @@ import ( "bytes" "os" "path/filepath" - "strconv" "strings" "testing" @@ -21,7 +20,7 @@ func TestLoadSourceRetainsMainFileAndLoadsImports(t *testing.T) { if err := os.WriteFile(fragment, []byte("output:\n directory: imported-output\n"), 0600); err != nil { t.Fatal(err) } - if err := os.WriteFile(main, []byte("version: 5\nconfig:\n imports:\n - path: fragment.yml\n required: true\n"), 0600); err != nil { + if err := os.WriteFile(main, []byte("version: 6\nconfig:\n imports:\n - path: fragment.yml\n required: true\n"), 0600); err != nil { t.Fatal(err) } loaded, err := LoadSource(configkit.File(main), LoadOptions{}) @@ -34,7 +33,7 @@ func TestLoadSourceRetainsMainFileAndLoadsImports(t *testing.T) { if got := loaded.Config.Output.Directory; got != filepath.Join(dir, "imported-output") { t.Fatalf("imported output directory = %q", got) } - bytesLoaded, err := loadConfigSource(configkit.Bytes("memory.yml", []byte("version: 5\n")), LoadOptions{}) + bytesLoaded, err := loadConfigSource(configkit.Bytes("memory.yml", []byte("version: 6\n")), LoadOptions{}) if err != nil { t.Fatal(err) } @@ -46,7 +45,7 @@ func TestLoadSourceRetainsMainFileAndLoadsImports(t *testing.T) { func TestLoadedConfigConvertsDocumentsAndResolvesRuntimePipeline(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 6 pipelines: session: llm_profile: local @@ -90,48 +89,10 @@ pipelines: } } -func TestLoadedConfigResolvesPromptKitTransientRetriesAndRetainsInspection(t *testing.T) { - t.Parallel() - - for _, test := range []struct { - name string - document string - want int - }{ - {name: "omitted", document: "version: 5\n", want: defaultTransientRetries}, - {name: "disabled", document: "version: 5\npromptkit:\n transient_retries: 0\n", want: 0}, - {name: "configured", document: "version: 5\npromptkit:\n transient_retries: 5\n", want: 5}, - } { - t.Run(test.name, func(t *testing.T) { - loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(test.document)), LoadOptions{}) - if err != nil { - t.Fatal(err) - } - if got := loaded.Config.PromptKit.TransientRetries; got != test.want { - t.Fatalf("transient retries = %d, want %d", got, test.want) - } - var effective bytes.Buffer - if err := loaded.WriteEffective(&effective); err != nil { - t.Fatal(err) - } - if !strings.Contains(effective.String(), "transient_retries: "+strconv.Itoa(test.want)) { - t.Fatalf("effective configuration = %q", effective.String()) - } - var explanation bytes.Buffer - if err := loaded.WriteExplanation(&explanation, "/promptkit/transient_retries"); err != nil { - t.Fatal(err) - } - if !strings.Contains(explanation.String(), strconv.Itoa(test.want)) { - t.Fatalf("explanation = %q", explanation.String()) - } - }) - } -} - func TestLoadedConfigOwnsRuntimeValuesAndKeepsFrozenInspection(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 6 pipelines: session: input: {module: input} @@ -166,7 +127,7 @@ pipelines: func TestLoadedConfigPreservesConfigKitIntegerOptionsForModules(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 6 pipelines: session: input: {module: input} @@ -198,7 +159,7 @@ pipelines: } func TestNestedConfigOptionRemainsApplicationData(t *testing.T) { - loaded, err := loadConfigSource(configkit.Bytes("options.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("options.yml", []byte(`version: 6 pipelines: session: input: @@ -216,7 +177,7 @@ pipelines: } func TestOverrideCannotRepairTypedDecodeFailure(t *testing.T) { - _, err := loadConfigSource(configkit.Bytes("invalid.yml", []byte("version: 5\nconcurrency: {total_llm: invalid}\n")), LoadOptions{ + _, err := loadConfigSource(configkit.Bytes("invalid.yml", []byte("version: 6\nconcurrency: {total_llm: invalid}\n")), LoadOptions{ Overrides: []configkit.Override{{Path: configkit.Keys("concurrency", "total_llm"), Value: 2, Flag: "--total-llm"}}, }) if err == nil { @@ -227,7 +188,7 @@ func TestOverrideCannotRepairTypedDecodeFailure(t *testing.T) { func TestLoadedConfigRedactsSensitiveNestedOptions(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 6 pipelines: session: input: diff --git a/internal/core/config/native_settings_test.go b/internal/core/config/native_settings_test.go new file mode 100644 index 00000000..d1727529 --- /dev/null +++ b/internal/core/config/native_settings_test.go @@ -0,0 +1,114 @@ +package config + +import ( + "bytes" + "context" + "os" + "path/filepath" + "testing" + + "go.maximumdirect.net/configkit" + "go.maximumdirect.net/promptkit" +) + +func TestLoadedConfigHandsNativeSettingsAndOriginsToEngine(t *testing.T) { + t.Parallel() + dir := t.TempDir() + resources := filepath.Join(dir, "resources") + if err := os.Mkdir(resources, 0755); err != nil { + t.Fatal(err) + } + write := func(path, content string) { + t.Helper() + if err := os.WriteFile(path, []byte(content), 0600); err != nil { + t.Fatal(err) + } + } + main := filepath.Join(dir, "config.yml") + fragment := filepath.Join(resources, "prompts.yml") + write(main, "version: 6\nconfig:\n imports:\n - path: resources/prompts.yml\n required: true\n") + write(filepath.Join(resources, "message.txt"), "Imported message for {{.topic}}") + write(fragment, `output: + directory: delivered +promptkit: + backends: + - id: local + endpoint: https://example.invalid/v1 + profiles: + - id: base + backend: local + model: fixture-model + extra_params: + token: fixture-secret + - id: child + extends: {id: base} + temperature: 0 + prompts: + - id: imported + default_profile: child + messages: + - role: user + content_file: message.txt + output: {format: text, validation_mode: none} +`) + loaded, err := Load(main, LoadOptions{}) + if err != nil { + t.Fatal(err) + } + result := loaded.Result() + value, ok := result.Value(configkit.Keys("promptkit")) + if _, typed := value.(promptkit.Settings); !ok || !typed { + t.Fatalf("native settings handoff = %T, present %t", value, ok) + } + if loaded.Config.Output.Directory != filepath.Join(resources, "delivered") { + t.Fatalf("application source origin lost: %s", loaded.Config.Output.Directory) + } + var effective bytes.Buffer + if err := loaded.WriteEffective(&effective); err != nil { + t.Fatal(err) + } + if bytes.Contains(effective.Bytes(), []byte("fixture-secret")) { + t.Fatal("native secret exposed in inspection") + } + // Construction must use the captured result, not reload either YAML source. + if err := os.Remove(main); err != nil { + t.Fatal(err) + } + if err := os.Remove(fragment); err != nil { + t.Fatal(err) + } + engine, err := promptkit.NewFromConfig(result, promptkit.RuntimeConfig{}) + if err != nil { + t.Fatal(err) + } + prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{ + PromptID: "imported", Vars: map[string]string{"topic": "testing"}, + }) + if err != nil { + t.Fatal(err) + } + if len(prepared.Messages) != 1 || prepared.Messages[0].Content != "Imported message for testing" { + t.Fatalf("source-relative native messages = %#v", prepared.Messages) + } + profile, err := engine.InspectProfile(context.Background(), "child") + if err != nil { + t.Fatal(err) + } + if profile.Model == nil || *profile.Model != "fixture-model" || profile.Temperature == nil || *profile.Temperature != 0 { + t.Fatalf("native identity/inheritance/presence lost: %#v", profile) + } + if loaded.Result() != result { + t.Fatal("load evidence was replaced") + } +} + +func TestDocumentUsesNativeResourceValidation(t *testing.T) { + t.Parallel() + _, err := loadDocumentSource(configkit.Bytes("invalid.yml", []byte(`version: 6 +promptkit: + backends: + - id: local + concurrency_limit: -1 +`)), LoadOptions{}) + assertDocumentDiagnosticAt(t, err, "/promptkit/backends/0/concurrency_limit") +} diff --git a/internal/core/config/operational_document.go b/internal/core/config/operational_document.go index 3fec3ab9..d5825eeb 100644 --- a/internal/core/config/operational_document.go +++ b/internal/core/config/operational_document.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "net/url" "sort" "strings" @@ -14,7 +13,6 @@ func resolveDocumentOperations(document *Document, resolution *configkit.Resolut if document == nil { return nil } - normalizeDocumentPromptKit(document.PromptKit, resolution) normalizeDocumentState(document, resolution) normalizeDocumentPaths(document, resolution, state) normalizeDocumentPipelines(document, resolution, state) @@ -27,33 +25,6 @@ func resolveDocumentOperations(document *Document, resolution *configkit.Resolut return nil } -func normalizeDocumentPromptKit(promptKit *PromptKitDocument, resolution *configkit.Resolution) { - if promptKit == nil { - return - } - profileDirPath := configkit.Keys("promptkit", "profile_dir") - profileFilePath := configkit.Keys("promptkit", "profile_file") - if promptKit.ProfileDir == nil && resolution.IsExplicit(profileDirPath) { - resolution.Error(profileDirPath, "must not be null") - } - if promptKit.ProfileFile == nil && resolution.IsExplicit(profileFilePath) { - resolution.Error(profileFilePath, "must not be null") - } - normalizeDocumentString(resolution, profileDirPath, &promptKit.ProfileDir, "trimmed PromptKit profile directory") - normalizeDocumentString(resolution, profileFilePath, &promptKit.ProfileFile, "trimmed PromptKit profile file") - - if promptKit.LocalBackend == nil { - return - } - endpointPath := configkit.Keys("promptkit", "local_backend", "endpoint") - limitPath := configkit.Keys("promptkit", "local_backend", "concurrency_limit") - normalizeDocumentString(resolution, endpointPath, &promptKit.LocalBackend.Endpoint, "trimmed PromptKit local backend endpoint") - if promptKit.LocalBackend.ConcurrencyLimit == nil && !resolution.IsExplicit(limitPath) { - configkit.Default(resolution, limitPath, &promptKit.LocalBackend.ConcurrencyLimit, - documentValue(0), "defaulted PromptKit local backend concurrency limit") - } -} - func normalizeDocumentState(document *Document, resolution *configkit.Resolution) { if document.Output != nil { normalizeDocumentString(resolution, configkit.Keys("output", "directory"), &document.Output.Directory, "trimmed output directory") @@ -104,7 +75,6 @@ func validateDocumentOperations(document *Document, validation *configkit.Valida return } validateDocumentConcurrency(document.Concurrency, validation) - validateDocumentPromptKit(document.PromptKit, validation) validateDocumentState(document, validation) validateDocumentPipelines(document, validation) } @@ -144,57 +114,6 @@ func validateDocumentConcurrency(concurrency *ConcurrencyDocument, validation *c } } -func validateDocumentPromptKit(promptKit *PromptKitDocument, validation *configkit.Validation) { - if promptKit == nil { - return - } - profileDirPath := configkit.Keys("promptkit", "profile_dir") - profileFilePath := configkit.Keys("promptkit", "profile_file") - profileDir := "" - if promptKit.ProfileDir != nil { - profileDir = *promptKit.ProfileDir - if strings.TrimSpace(profileDir) == "" { - validation.Error(profileDirPath, "must not be empty when set") - } - } - profileFile := "" - if promptKit.ProfileFile != nil { - profileFile = *promptKit.ProfileFile - if strings.TrimSpace(profileFile) == "" { - validation.Error(profileFilePath, "must not be empty when set") - } - } - if err := validatePromptKitProfileSources(profileDir, profileFile); err != nil { - validation.Error(configkit.Keys("promptkit"), err.Error()) - } - if promptKit.TransientRetries == nil { - validation.Error(configkit.Keys("promptkit", "transient_retries"), "must be an integer") - } else if err := validatePromptKitTransientRetries(*promptKit.TransientRetries); err != nil { - validation.Error(configkit.Keys("promptkit", "transient_retries"), err.Error()) - } - if promptKit.LocalBackend == nil { - return - } - endpointPath := configkit.Keys("promptkit", "local_backend", "endpoint") - limitPath := configkit.Keys("promptkit", "local_backend", "concurrency_limit") - if promptKit.LocalBackend.Endpoint == nil { - validation.Error(endpointPath, "must be nonempty when local backend is configured") - } - if promptKit.LocalBackend.ConcurrencyLimit == nil { - validation.Error(limitPath, "must be an integer when local backend is configured") - } - if promptKit.LocalBackend.Endpoint != nil { - if err := validatePromptKitLocalBackendEndpoint(*promptKit.LocalBackend.Endpoint); err != nil { - validation.Error(endpointPath, err.Error()) - } - } - if promptKit.LocalBackend.ConcurrencyLimit != nil { - if err := validatePromptKitLocalBackendConcurrencyLimit(*promptKit.LocalBackend.ConcurrencyLimit); err != nil { - validation.Error(limitPath, err.Error()) - } - } -} - func validateDocumentState(document *Document, validation *configkit.Validation) { if document.Output == nil || document.Output.Directory == nil { validation.Error(configkit.Keys("output", "directory"), "must not be empty") @@ -249,52 +168,6 @@ func validateExtractWorkerCount(workers, total int) error { return nil } -func validatePromptKitProfileSources(profileDir, profileFile string) error { - if strings.TrimSpace(profileDir) != "" && strings.TrimSpace(profileFile) != "" { - return fmt.Errorf("promptkit profile_dir and profile_file are mutually exclusive") - } - return nil -} - -func validatePromptKitLocalBackend(endpoint string, concurrencyLimit int) error { - if err := validatePromptKitLocalBackendEndpoint(endpoint); err != nil { - return err - } - return validatePromptKitLocalBackendConcurrencyLimit(concurrencyLimit) -} - -func validatePromptKitLocalBackendEndpoint(endpoint string) error { - if strings.TrimSpace(endpoint) == "" { - return fmt.Errorf("promptkit.local_backend.endpoint must not be empty when set") - } - parsed, err := url.Parse(strings.TrimSpace(endpoint)) - if err != nil || - (!strings.EqualFold(parsed.Scheme, "http") && !strings.EqualFold(parsed.Scheme, "https")) || - !parsed.IsAbs() || - parsed.Hostname() == "" || - parsed.User != nil || - parsed.RawQuery != "" || - parsed.ForceQuery || - strings.Contains(endpoint, "#") { - return fmt.Errorf("promptkit.local_backend.endpoint must be an absolute HTTP or HTTPS URL with a host and no user information, query, or fragment") - } - return nil -} - -func validatePromptKitLocalBackendConcurrencyLimit(concurrencyLimit int) error { - if concurrencyLimit < 0 { - return fmt.Errorf("promptkit.local_backend.concurrency_limit must not be negative") - } - return nil -} - -func validatePromptKitTransientRetries(transientRetries int) error { - if transientRetries < 0 { - return fmt.Errorf("promptkit.transient_retries must not be negative") - } - return nil -} - func validateRequiredPath(name, value string) error { if strings.TrimSpace(value) == "" { return fmt.Errorf("%s must not be empty", name) diff --git a/internal/core/config/operational_document_test.go b/internal/core/config/operational_document_test.go index 770cd40f..fc8a3e79 100644 --- a/internal/core/config/operational_document_test.go +++ b/internal/core/config/operational_document_test.go @@ -25,7 +25,7 @@ func TestWorkerKeyNormalizationPreservesExplicitCount(t *testing.T) { } { t.Run(test.name, func(t *testing.T) { loaded, err := loadConfigSource(configkit.Bytes("workers.yml", []byte( - "version: 5\nconcurrency:\n total_llm: 4\n stage_workers: "+test.workers+"\n")), LoadOptions{}) + "version: 6\nconcurrency:\n total_llm: 4\n stage_workers: "+test.workers+"\n")), LoadOptions{}) if test.errorPath != "" { assertDocumentDiagnosticAt(t, err, test.errorPath) return @@ -52,13 +52,9 @@ func TestWorkerKeyNormalizationPreservesExplicitCount(t *testing.T) { func TestDocumentLoadAppliesOperationalDefaultsAndNormalization(t *testing.T) { t.Parallel() - loaded, err := loadDocumentSource(configkit.Bytes("document.yml", []byte(`version: 5 + loaded, err := loadDocumentSource(configkit.Bytes("document.yml", []byte(`version: 6 concurrency: total_llm: 4 -promptkit: - profile_dir: " ./profiles " - local_backend: - endpoint: " https://localhost:8080/v1 " output: directory: " ./output " cache: @@ -80,11 +76,6 @@ debug: if err != nil { t.Fatal(err) } - if loaded.Config.PromptKit.ProfileDir == nil || *loaded.Config.PromptKit.ProfileDir != filepath.Join(workingDirectory, "profiles") || - loaded.Config.PromptKit.LocalBackend == nil || loaded.Config.PromptKit.LocalBackend.Endpoint == nil || *loaded.Config.PromptKit.LocalBackend.Endpoint != "https://localhost:8080/v1" || - loaded.Config.PromptKit.LocalBackend.ConcurrencyLimit == nil || *loaded.Config.PromptKit.LocalBackend.ConcurrencyLimit != 0 { - t.Fatalf("promptkit = %#v", loaded.Config.PromptKit) - } if loaded.Config.Output.Directory == nil || *loaded.Config.Output.Directory != filepath.Join(workingDirectory, "output") || loaded.Config.Cache.ChunkPlans.Mode == nil || *loaded.Config.Cache.ChunkPlans.Mode != "refresh" || loaded.Config.Cache.ChunkPlans.Directory == nil || *loaded.Config.Cache.ChunkPlans.Directory != "" || @@ -114,7 +105,7 @@ func TestDocumentLoadDerivesWorkersAfterOverlayAndCLIOverrides(t *testing.T) { if err := os.Mkdir(overlays, 0o755); err != nil { t.Fatal(err) } - if err := os.WriteFile(main, []byte("version: 5\nconcurrency:\n total_llm: 4\n"), 0o600); err != nil { + if err := os.WriteFile(main, []byte("version: 6\nconcurrency:\n total_llm: 4\n"), 0o600); err != nil { t.Fatal(err) } if err := os.WriteFile(filepath.Join(overlays, "development.yml"), []byte("concurrency:\n total_llm: 3\n"), 0o600); err != nil { @@ -153,7 +144,7 @@ func TestDocumentLoadDerivesWorkersAfterOverlayAndCLIOverrides(t *testing.T) { func TestDocumentLoadRetainsExplicitWorkerAndRejectsInvalidOperationalValues(t *testing.T) { t.Parallel() - loaded, err := loadDocumentSource(configkit.Bytes("explicit.yml", []byte(`version: 5 + loaded, err := loadDocumentSource(configkit.Bytes("explicit.yml", []byte(`version: 6 concurrency: total_llm: 4 stage_workers: @@ -164,15 +155,11 @@ concurrency: } assertDocumentDiagnostic(t, err, configkit.CodeValidateError, "/concurrency/stage_workers/extract") - _, err = loadDocumentSource(configkit.Bytes("invalid.yml", []byte(`version: 5 + _, err = loadDocumentSource(configkit.Bytes("invalid.yml", []byte(`version: 6 concurrency: total_llm: 0 output: directory: "" -promptkit: - local_backend: - endpoint: "ftp://localhost" - concurrency_limit: -1 `)), LoadOptions{}) var loadError *configkit.LoadError if !errors.As(err, &loadError) { @@ -185,7 +172,7 @@ promptkit: } seen[diagnostic.Path.String()] = true } - for _, path := range []string{"/concurrency/total_llm", "/output/directory", "/promptkit/local_backend/endpoint", "/promptkit/local_backend/concurrency_limit"} { + for _, path := range []string{"/concurrency/total_llm", "/output/directory"} { if !seen[path] { t.Fatalf("diagnostics missing %s: %#v", path, loadError.Diagnostics()) } @@ -195,7 +182,7 @@ promptkit: func TestDocumentLoadDistinguishesRequiredAndOptionalPathValues(t *testing.T) { t.Parallel() - loaded, err := loadDocumentSource(configkit.Bytes("cache.yml", []byte(`version: 5 + loaded, err := loadDocumentSource(configkit.Bytes("cache.yml", []byte(`version: 6 cache: chunk_plans: directory: " " @@ -210,24 +197,9 @@ cache: t.Fatalf("cache directories = %#v", loaded.Config.Cache) } - _, err = loadDocumentSource(configkit.Bytes("output.yml", []byte("version: 5\noutput:\n directory: ' '\n")), LoadOptions{}) + _, err = loadDocumentSource(configkit.Bytes("output.yml", []byte("version: 6\noutput:\n directory: ' '\n")), LoadOptions{}) assertDocumentDiagnostic(t, err, configkit.CodeValidateError, "/output/directory") - _, err = loadDocumentSource(configkit.Bytes("promptkit.yml", []byte("version: 5\npromptkit:\n profile_file: null\n local_backend: {}\n")), LoadOptions{}) - assertDocumentDiagnostic(t, err, configkit.CodeResolveError, "/promptkit/profile_file") - - _, err = loadDocumentSource(configkit.Bytes("empty-source.yml", []byte("version: 5\npromptkit:\n profile_dir: ' '\n")), LoadOptions{}) - assertDocumentDiagnostic(t, err, configkit.CodeValidateError, "/promptkit/profile_dir") - - _, err = loadDocumentSource(configkit.Bytes("missing-endpoint.yml", []byte("version: 5\npromptkit:\n local_backend: {}\n")), LoadOptions{}) - assertDocumentDiagnostic(t, err, configkit.CodeValidateError, "/promptkit/local_backend/endpoint") -} - -func TestDocumentLoadRejectsNegativePromptKitTransientRetries(t *testing.T) { - t.Parallel() - - _, err := loadDocumentSource(configkit.Bytes("promptkit.yml", []byte("version: 5\npromptkit:\n transient_retries: -1\n")), LoadOptions{}) - assertDocumentDiagnostic(t, err, configkit.CodeValidateError, "/promptkit/transient_retries") } func assertDocumentDiagnostic(t *testing.T, err error, code configkit.Code, path string) { diff --git a/internal/core/config/pipeline_document_test.go b/internal/core/config/pipeline_document_test.go index b14ddd92..bfbb0894 100644 --- a/internal/core/config/pipeline_document_test.go +++ b/internal/core/config/pipeline_document_test.go @@ -16,7 +16,7 @@ func TestDocumentRejectsExplicitInvalidBranches(t *testing.T) { if slot == "output" { body = "input: {module: input}\n output: {module: output, validators: []}" } - _, err := loadConfigSource(configkit.Bytes("document.yml", []byte("version: 5\npipelines:\n session:\n "+body+"\n")), LoadOptions{}) + _, err := loadConfigSource(configkit.Bytes("document.yml", []byte("version: 6\npipelines:\n session:\n "+body+"\n")), LoadOptions{}) assertDocumentDiagnosticAt(t, err, "/pipelines/session/"+slot+"/validators") }) } @@ -27,7 +27,7 @@ func TestDocumentRejectsExplicitInvalidBranches(t *testing.T) { "{path: null, artifact: {step: previous, lane: registry}}", } { t.Run(value, func(t *testing.T) { - content := fmt.Sprintf("version: 5\npipelines:\n session:\n input: {module: input}\n artifacts:\n lane:\n extract:\n module: extract\n references:\n party: %s\n", value) + content := fmt.Sprintf("version: 6\npipelines:\n session:\n input: {module: input}\n artifacts:\n lane:\n extract:\n module: extract\n references:\n party: %s\n", value) _, err := loadConfigSource(configkit.Bytes("document.yml", []byte(content)), LoadOptions{}) path := "/pipelines/session/artifacts/lane/extract/references/party" if value == "{path: ''}" || value == "{path: ' '}" || value == "{path: null, artifact: {step: previous, lane: registry}}" { @@ -40,7 +40,7 @@ func TestDocumentRejectsExplicitInvalidBranches(t *testing.T) { func TestDocumentPreservesSupportedEmptyValidatorsAndReferenceForms(t *testing.T) { t.Parallel() - loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 5 + loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 6 pipelines: session: input: {module: input} @@ -76,7 +76,7 @@ pipelines: func TestDocumentPipelineNormalizesCanonicalIdentifiers(t *testing.T) { t.Parallel() - loaded, err := loadDocumentSource(configkit.Bytes("document.yml", []byte(`version: 5 + loaded, err := loadDocumentSource(configkit.Bytes("document.yml", []byte(`version: 6 pipelines: " session ": llm_profile: " local " @@ -127,7 +127,7 @@ func TestDocumentPipelineRejectsInvalidShapes(t *testing.T) { }{ { name: "both pipeline forms", - source: `version: 5 + source: `version: 6 pipelines: session: input: {module: seriatim} @@ -140,7 +140,7 @@ pipelines: }, { name: "empty ordered steps", - source: `version: 5 + source: `version: 6 pipelines: session: input: {module: seriatim} @@ -150,7 +150,7 @@ pipelines: }, { name: "normalized pipeline collision", - source: `version: 5 + source: `version: 6 pipelines: session: {input: {module: seriatim}} " session ": {input: {module: seriatim}} @@ -159,7 +159,7 @@ pipelines: }, { name: "duplicate lane across ordered steps", - source: `version: 5 + source: `version: 6 pipelines: session: input: {module: seriatim} @@ -173,7 +173,7 @@ pipelines: }, { name: "invalid reference union", - source: `version: 5 + source: `version: 6 pipelines: session: input: {module: seriatim} @@ -201,7 +201,7 @@ func TestDocumentPipelineRejectsInvalidBindingPlacementAndPresence(t *testing.T) }{ { name: "input validators", - source: `version: 5 + source: `version: 6 pipelines: session: input: @@ -212,7 +212,7 @@ pipelines: }, { name: "blank selected profile", - source: `version: 5 + source: `version: 6 pipelines: session: llm_profile: " " @@ -222,7 +222,7 @@ pipelines: }, { name: "null validators", - source: `version: 5 + source: `version: 6 pipelines: session: input: {module: seriatim} @@ -232,7 +232,7 @@ pipelines: }, { name: "negative retry budget", - source: `version: 5 + source: `version: 6 pipelines: session: input: {module: seriatim, retries: -1} diff --git a/internal/core/config/sequence_normalization_test.go b/internal/core/config/sequence_normalization_test.go index 52a06f22..93c399d1 100644 --- a/internal/core/config/sequence_normalization_test.go +++ b/internal/core/config/sequence_normalization_test.go @@ -47,7 +47,7 @@ func TestSequenceNormalizationPreservesRuntimeAndProvenance(t *testing.T) { t.Run(test.name, func(t *testing.T) { root := t.TempDir() path := filepath.Join(root, "config.yml") - if err := os.WriteFile(path, []byte("version: 5\npipelines:\n session:\n input: {module: seriatim}\n "+test.body+"\n"), 0o600); err != nil { + if err := os.WriteFile(path, []byte("version: 6\npipelines:\n session:\n input: {module: seriatim}\n "+test.body+"\n"), 0o600); err != nil { t.Fatal(err) } loaded, err := Load(path, LoadOptions{}) diff --git a/internal/core/config/validation.go b/internal/core/config/validation.go index 0af9a745..543be2ca 100644 --- a/internal/core/config/validation.go +++ b/internal/core/config/validation.go @@ -9,9 +9,6 @@ import ( ) func (c Config) Validate() error { - if err := validatePromptKit(c.PromptKit); err != nil { - return err - } if err := validateStateSurfaces(c); err != nil { return err } @@ -42,19 +39,6 @@ func validateStageWorkers(cfg ConcurrencyConfig) error { return validateExtractWorkerCount(extractWorkers, cfg.TotalLLM) } -func validatePromptKit(cfg PromptKitConfig) error { - if err := validatePromptKitProfileSources(cfg.ProfileDir, cfg.ProfileFile); err != nil { - return err - } - if err := validatePromptKitTransientRetries(cfg.TransientRetries); err != nil { - return err - } - if cfg.LocalBackend == nil { - return nil - } - return validatePromptKitLocalBackend(cfg.LocalBackend.Endpoint, cfg.LocalBackend.ConcurrencyLimit) -} - func validateStateSurfaces(cfg Config) error { if err := validateRequiredPath("output.directory", cfg.Output.Directory); err != nil { return err diff --git a/internal/core/config/validation_contract_test.go b/internal/core/config/validation_contract_test.go index b863c652..1f2c92d2 100644 --- a/internal/core/config/validation_contract_test.go +++ b/internal/core/config/validation_contract_test.go @@ -83,95 +83,6 @@ func TestValidateConcurrencyRules(t *testing.T) { } } -func TestValidatePromptKitSourcesAreMutuallyExclusive(t *testing.T) { - cfg := Default() - cfg.PromptKit = PromptKitConfig{ProfileDir: "./profiles", ProfileFile: "./profile.yml"} - assertValidationContains(t, cfg, "promptkit profile_dir and profile_file are mutually exclusive") -} - -func TestValidatePromptKitTransientRetries(t *testing.T) { - if got := Default().PromptKit.TransientRetries; got != defaultTransientRetries { - t.Fatalf("default transient retries = %d, want %d", got, defaultTransientRetries) - } - for _, retries := range []int{0, 4} { - cfg := Default() - cfg.PromptKit.TransientRetries = retries - if err := cfg.Validate(); err != nil { - t.Fatalf("Validate() with transient retries %d error = %v", retries, err) - } - } - negative := Default() - negative.PromptKit.TransientRetries = -1 - assertValidationContains(t, negative, "promptkit.transient_retries must not be negative") -} - -func TestValidatePromptKitLocalBackendEndpoints(t *testing.T) { - tests := []struct { - name string - endpoint string - profileSource PromptKitConfig - }{ - { - name: "HTTP endpoint with path and profile directory", - endpoint: "http://localhost:8000/v1", - profileSource: PromptKitConfig{ProfileDir: "./profiles"}, - }, - { - name: "case-insensitive HTTPS endpoint and profile file", - endpoint: "HTTPS://inference.example.test/api", - profileSource: PromptKitConfig{ProfileFile: "./profiles.yml"}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cfg := Default() - cfg.PromptKit = tt.profileSource - cfg.PromptKit.LocalBackend = &PromptKitLocalBackendConfig{ - Endpoint: tt.endpoint, - ConcurrencyLimit: 2, - } - if err := cfg.Validate(); err != nil { - t.Fatalf("Validate() error = %v", err) - } - }) - } -} - -func TestValidatePromptKitLocalBackendRejectsInvalidValues(t *testing.T) { - tests := []struct { - name string - endpoint string - concurrencyLimit int - want string - }{ - {name: "blank endpoint", endpoint: " ", want: "promptkit.local_backend.endpoint"}, - {name: "relative URL", endpoint: "localhost:8000/v1", want: "promptkit.local_backend.endpoint"}, - {name: "unsupported scheme", endpoint: "ftp://localhost/model", want: "promptkit.local_backend.endpoint"}, - {name: "missing host", endpoint: "http:///v1", want: "promptkit.local_backend.endpoint"}, - {name: "user information", endpoint: "http://user:secret@localhost/v1", want: "promptkit.local_backend.endpoint"}, - {name: "query", endpoint: "http://localhost/v1?model=example", want: "promptkit.local_backend.endpoint"}, - {name: "empty query", endpoint: "http://localhost/v1?", want: "promptkit.local_backend.endpoint"}, - {name: "fragment", endpoint: "http://localhost/v1#model", want: "promptkit.local_backend.endpoint"}, - {name: "empty fragment", endpoint: "http://localhost/v1#", want: "promptkit.local_backend.endpoint"}, - { - name: "negative concurrency", - endpoint: "http://localhost:8000/v1", - concurrencyLimit: -1, - want: "promptkit.local_backend.concurrency_limit", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cfg := Default() - cfg.PromptKit.LocalBackend = &PromptKitLocalBackendConfig{ - Endpoint: tt.endpoint, - ConcurrencyLimit: tt.concurrencyLimit, - } - assertValidationContains(t, cfg, tt.want) - }) - } -} - func TestValidateStateSurfaceRules(t *testing.T) { tests := []struct { name string diff --git a/internal/core/config/validation_policy_contract_test.go b/internal/core/config/validation_policy_contract_test.go index 4f95c3de..9037f931 100644 --- a/internal/core/config/validation_policy_contract_test.go +++ b/internal/core/config/validation_policy_contract_test.go @@ -9,7 +9,7 @@ import ( ) func TestValidationPolicyFileConfigurationIsStrictAndPresenceAware(t *testing.T) { - const valid = `version: 5 + const valid = `version: 6 pipelines: main: validation_policy: