Load native PromptKit settings through application configuration version six

This commit is contained in:
2026-11-21 22:42:35 +00:00
parent bd30e86c0d
commit cc14a7a5cc
21 changed files with 210 additions and 485 deletions

View File

@@ -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: