Load native PromptKit settings through application configuration version six
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user