Compose runtime glossary files with native configuration
This commit is contained in:
@@ -81,6 +81,8 @@ Acceptance:
|
||||
|
||||
## Stage 2: Implement the shared runtime-file acquisition bridge
|
||||
|
||||
Status: Complete.
|
||||
|
||||
Work:
|
||||
|
||||
1. Extend `internal/appconfig.Load` with a small options value containing the
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/responseschema"
|
||||
@@ -30,6 +31,23 @@ type Config struct {
|
||||
PromptKit pk.Settings `yaml:"promptkit"`
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
Overlay string
|
||||
Overrides []ck.Override
|
||||
GlossaryFiles []string
|
||||
}
|
||||
|
||||
type Acquisition struct {
|
||||
*ck.Result[Config]
|
||||
GlossarySources []string
|
||||
}
|
||||
|
||||
// GlossaryInputError identifies failures in the separate runtime input load.
|
||||
type GlossaryInputError struct{ Err error }
|
||||
|
||||
func (e *GlossaryInputError) Error() string { return e.Err.Error() }
|
||||
func (e *GlossaryInputError) Unwrap() error { return e.Err }
|
||||
|
||||
const glossaryImports = `config:
|
||||
imports:
|
||||
- path: glossary.yml
|
||||
@@ -71,7 +89,7 @@ func Definition() ck.Definition[Config] {
|
||||
}
|
||||
|
||||
// Load composes built-in resources and optional companions with the selected input.
|
||||
func Load(ctx context.Context, input ck.Input, overlay string, overrides ...ck.Override) (*ck.Result[Config], *ck.SecretsReport, error) {
|
||||
func Load(ctx context.Context, input ck.Input, options Options) (*Acquisition, *ck.SecretsReport, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -83,6 +101,38 @@ func Load(ctx context.Context, input ck.Input, overlay string, overrides ...ck.O
|
||||
return nil, report, err
|
||||
}
|
||||
input.Source = prepared
|
||||
var glossarySources []string
|
||||
overrides := append([]ck.Override(nil), options.Overrides...)
|
||||
if len(options.GlossaryFiles) > 0 {
|
||||
inputs := make([]ck.Input, len(options.GlossaryFiles))
|
||||
for i, path := range options.GlossaryFiles {
|
||||
absolute, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return nil, report, &GlossaryInputError{Err: err}
|
||||
}
|
||||
inputs[i] = ck.Input{Source: ck.File(absolute), Imports: true}
|
||||
}
|
||||
underlays := make([]ck.Underlay, 0, len(inputs)-1)
|
||||
for _, item := range inputs[:len(inputs)-1] {
|
||||
underlays = append(underlays, ck.Underlay{Inputs: []ck.Input{item}})
|
||||
}
|
||||
glossaries, err := ck.LoadLayered(inputs[len(inputs)-1], ck.LayeredOptions[map[string]any]{
|
||||
Definition: ck.Definition[map[string]any]{SequenceIdentities: []ck.SequenceIdentity{config.GlossaryEntryIdentity(nil)}},
|
||||
Underlays: underlays,
|
||||
})
|
||||
if canceled := ctx.Err(); canceled != nil {
|
||||
return nil, report, errors.Join(err, canceled)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, report, &GlossaryInputError{Err: err}
|
||||
}
|
||||
for _, source := range glossaries.Sources() {
|
||||
if source.Kind == ck.SourceKindFile {
|
||||
glossarySources = append(glossarySources, source.Path)
|
||||
}
|
||||
}
|
||||
overrides = append(overrides, ck.Override{Path: ck.Keys("glossary_collections"), Value: glossaries.Config, Flag: "--glossary-file"})
|
||||
}
|
||||
embedded, err := pk.FilesystemInputs("Audita embedded prompts", prompts.Filesystem(), prompts.AssetRoot)
|
||||
if err != nil {
|
||||
return nil, report, &AssetError{Err: fmt.Errorf("discover embedded prompts: %w", err)}
|
||||
@@ -99,7 +149,7 @@ func Load(ctx context.Context, input ck.Input, overlay string, overrides ...ck.O
|
||||
input.Imports = true
|
||||
result, err := ck.LoadLayered(input, ck.LayeredOptions[Config]{
|
||||
Definition: Definition(),
|
||||
Overlay: overlay,
|
||||
Overlay: options.Overlay,
|
||||
Overrides: overrides,
|
||||
Underlays: []ck.Underlay{
|
||||
pk.BundledOpenRouterUnderlay(),
|
||||
@@ -113,5 +163,8 @@ func Load(ctx context.Context, input ck.Input, overlay string, overrides ...ck.O
|
||||
if canceled := ctx.Err(); canceled != nil {
|
||||
return nil, report, errors.Join(err, canceled)
|
||||
}
|
||||
return result, report, err
|
||||
if err != nil {
|
||||
return nil, report, err
|
||||
}
|
||||
return &Acquisition{Result: result, GlossarySources: glossarySources}, report, nil
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestLoadCombinesApplicationAndPromptSettings(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "selected")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, Options{Overlay: "selected"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func TestLoadWithoutMainDoesNotDiscoverCompanions(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(dir)
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, "")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ party:
|
||||
`)
|
||||
write("shared/extra.yml", "lore:\n entries:\n - id: hero\n name: Ancient\n category: lore\n")
|
||||
write("glossary/nested/spells.yaml", "spells:\n entries:\n - id: bolt\n name: Bolt\n category: spell\n aliases: [Spark]\n plural: Bolts\n extra: {rank: 2}\n")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, Options{})
|
||||
if err != nil {
|
||||
t.Fatalf("%v: %+v", err, err.(*ck.LoadError).Diagnostics())
|
||||
}
|
||||
@@ -67,7 +67,7 @@ party:
|
||||
if got := result.Config.Application.GlossaryCollections["lore"].Entries; len(got) != 1 || got[0].ID != "hero" {
|
||||
t.Fatalf("lore=%+v", got)
|
||||
}
|
||||
discovered, _, err := Load(context.Background(), ck.Input{Source: ck.SearchConfig("audita", ck.SearchDirectory(dir))}, "")
|
||||
discovered, _, err := Load(context.Background(), ck.Input{Source: ck.SearchConfig("audita", ck.SearchDirectory(dir))}, Options{})
|
||||
if err != nil || len(discovered.Config.Application.GlossaryCollections["party"].Entries) != 2 {
|
||||
t.Fatalf("discovered glossary: %+v %v", discovered, err)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestGlossaryValidationAndPeerConflicts(t *testing.T) {
|
||||
"glossary_collections:\n x:\n entries:\n - {id: 'id with spaces', name: N, category: C}\n",
|
||||
} {
|
||||
write(main, data)
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, ""); err != nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, Options{}); err != nil {
|
||||
t.Fatalf("valid %q: %v", data, err)
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ func TestGlossaryValidationAndPeerConflicts(t *testing.T) {
|
||||
"glossary_collections:\n x:\n entries:\n - {id: x, name: N, category: C, plural: ''}\n",
|
||||
} {
|
||||
write(main, data)
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, ""); err == nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, Options{}); err == nil {
|
||||
t.Fatalf("accepted %q", data)
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func TestGlossaryValidationAndPeerConflicts(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
write(filepath.Join(dir, "glossary", "other.yml"), "x:\n entries:\n - {id: same, name: Two, category: C}\n")
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, ""); err == nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, Options{}); err == nil {
|
||||
t.Fatal("peer conflict accepted")
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ func TestGlossaryUnderlaySkipsAbsentMain(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(dir)
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, "")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
136
internal/appconfig/runtime_glossary_test.go
Normal file
136
internal/appconfig/runtime_glossary_test.go
Normal file
@@ -0,0 +1,136 @@
|
||||
package appconfig
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
ck "go.maximumdirect.net/configkit"
|
||||
)
|
||||
|
||||
func TestRuntimeGlossaryComposition(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
files := map[string]string{
|
||||
"main.yml": `version: 3
|
||||
glossary_collections:
|
||||
party:
|
||||
instruction: Keep the configured guidance
|
||||
entries: [{id: configured, name: Configured, category: person}]
|
||||
reference:
|
||||
entries: [{id: reference, name: Reference, category: lore}]
|
||||
`,
|
||||
"overlays/selected.yml": `glossary_collections:
|
||||
party:
|
||||
entries: [{id: overlay, name: Overlay, category: person}]
|
||||
`,
|
||||
"first.yml": `config:
|
||||
imports: [{path: imported.yml, required: true}]
|
||||
party:
|
||||
entries:
|
||||
- {id: shared, name: Old, category: person, aliases: [Former]}
|
||||
- {id: retained, name: Retained, category: person}
|
||||
`,
|
||||
"imported.yml": `other:
|
||||
entries: [{id: imported, name: Imported, category: lore}]
|
||||
`,
|
||||
"last.yml": `party:
|
||||
entries:
|
||||
- {id: shared, name: New, category: person, note: kept}
|
||||
`,
|
||||
}
|
||||
for name, contents := range files {
|
||||
path := filepath.Join(dir, name)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte(contents), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
paths := []string{filepath.Join(dir, "first.yml"), filepath.Join(dir, "last.yml")}
|
||||
acquired, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "main.yml"))}, Options{Overlay: "selected", GlossaryFiles: paths})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
collections := acquired.Config.Application.GlossaryCollections
|
||||
party := collections["party"]
|
||||
if party.Instruction != "Keep the configured guidance" || len(party.Entries) != 2 {
|
||||
t.Fatalf("party = %+v", party)
|
||||
}
|
||||
if party.Entries[0].ID != "shared" || party.Entries[0].Name != "New" || len(party.Entries[0].Aliases) != 0 || party.Entries[0].Extra["note"] != "kept" || party.Entries[1].ID != "retained" {
|
||||
t.Fatalf("entries = %+v", party.Entries)
|
||||
}
|
||||
if len(collections["reference"].Entries) != 1 || len(collections["other"].Entries) != 1 {
|
||||
t.Fatalf("collections = %+v", collections)
|
||||
}
|
||||
for _, name := range []string{"first.yml", "last.yml", "imported.yml"} {
|
||||
path := filepath.Join(dir, name)
|
||||
if !slices.Contains(acquired.GlossarySources, path) {
|
||||
t.Errorf("missing source %s: %v", path, acquired.GlossarySources)
|
||||
}
|
||||
for _, source := range acquired.Sources() {
|
||||
if source.Path == path {
|
||||
t.Errorf("preliminary source leaked into final result: %s", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
info, ok := acquired.Metadata().Lookup(ck.Keys("glossary_collections", "party", "entries"))
|
||||
if !ok || info.Origin.Layer != ck.LayerCLI {
|
||||
t.Fatalf("origin = %+v", info)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeGlossaryLoadErrors(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
main := filepath.Join(dir, "main.yml")
|
||||
if err := os.WriteFile(main, []byte("version: 3\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
malformed := filepath.Join(dir, "bad.yml")
|
||||
if err := os.WriteFile(malformed, []byte("party: [\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, path := range []string{malformed, filepath.Join(dir, "missing.yml")} {
|
||||
_, report, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, Options{GlossaryFiles: []string{path}})
|
||||
var inputErr *GlossaryInputError
|
||||
var loadErr *ck.LoadError
|
||||
if !errors.As(err, &inputErr) || !errors.As(err, &loadErr) || report == nil {
|
||||
t.Fatalf("path %s: report=%v error=%v", path, report, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeGlossaryPresence(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name, body string
|
||||
wantInstruction string
|
||||
wantEntries int
|
||||
}{
|
||||
{"omitted", "party: {}\n", "original", 1},
|
||||
{"empty", "party: {instruction: '', entries: []}\n", "", 0},
|
||||
{"null entries", "party: {entries: null}\n", "original", 0},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
main := filepath.Join(dir, "main.yml")
|
||||
incoming := filepath.Join(dir, "input.yml")
|
||||
if err := os.WriteFile(main, []byte("glossary_collections:\n party:\n instruction: original\n entries: [{id: a, name: A, category: C}]\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(incoming, []byte(tc.body), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, _, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, Options{GlossaryFiles: []string{incoming}})
|
||||
if err != nil {
|
||||
t.Fatalf("%v: %+v", err, err.(*ck.LoadError).Diagnostics())
|
||||
}
|
||||
party := got.Config.Application.GlossaryCollections["party"]
|
||||
if party.Instruction != tc.wantInstruction || len(party.Entries) != tc.wantEntries {
|
||||
t.Fatalf("party = %+v", party)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ func TestLoadBootstrapsSecrets(t *testing.T) {
|
||||
if err := os.WriteFile(main, []byte("version: 3\nconfig:\n secrets_dir: secrets\n secrets_overwrite: true\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, report, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
result, report, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -39,14 +39,14 @@ func TestLoadRetainsBootstrapErrorAndCancellation(t *testing.T) {
|
||||
if err := os.WriteFile(main, []byte("version: 3\nconfig:\n secrets_dir: missing\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, report, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
result, report, err := Load(context.Background(), ck.Input{Source: ck.File(main)}, Options{})
|
||||
var secretsErr *ck.SecretsError
|
||||
if result != nil || report == nil || !errors.As(err, &secretsErr) {
|
||||
t.Fatalf("result=%v report=%v error=%v", result, report, err)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
result, _, err = Load(ctx, ck.Input{Source: ck.File(main)}, "")
|
||||
result, _, err = Load(ctx, ck.Input{Source: ck.File(main)}, Options{})
|
||||
if result != nil || !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("result=%v error=%v", result, err)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func TestLoadReusesPreparedMainSnapshot(t *testing.T) {
|
||||
if err := os.WriteFile(main, []byte("version: 3\ncontext:\n description: changed\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: prepared, Filesystem: &ck.FilesystemContext{Root: dir}}, "")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: prepared, Filesystem: &ck.FilesystemContext{Root: dir}}, Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestMainContextImportsAndOverlay(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "main.yml"))}, "selected", ck.Override{Path: ck.Keys("context", "description"), Value: "override", Flag: "--description"})
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "main.yml"))}, Options{Overlay: "selected", Overrides: []ck.Override{{Path: ck.Keys("context", "description"), Value: "override", Flag: "--description"}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -51,10 +51,10 @@ func TestMainContextImportsAndOverlay(t *testing.T) {
|
||||
if !found {
|
||||
t.Fatal("main source missing")
|
||||
}
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "main.yml"))}, "missing"); err == nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "main.yml"))}, Options{Overlay: "missing"}); err == nil {
|
||||
t.Fatal("missing overlay accepted")
|
||||
}
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, "selected"); err == nil {
|
||||
if _, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, Options{Overlay: "selected"}); err == nil {
|
||||
t.Fatal("overlay without context accepted")
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,11 @@ func TestDiscoveryAndSelectedFailure(t *testing.T) {
|
||||
first, second := t.TempDir(), t.TempDir()
|
||||
search := ck.Searches(ck.SearchDirectory(first), ck.SearchDirectory(second))
|
||||
load := func() (*ck.Result[Config], error) {
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.SearchConfig("audita", search)}, "")
|
||||
return result, err
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.SearchConfig("audita", search)}, Options{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Result, nil
|
||||
}
|
||||
result, err := load()
|
||||
if err != nil {
|
||||
@@ -105,7 +108,7 @@ func TestOverlayUsesMainDirectoryWithinWiderRoot(t *testing.T) {
|
||||
if err := os.WriteFile(filepath.Join(dir, "overlays", "local.yml"), []byte("context:\n description: project\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml")), Filesystem: &ck.FilesystemContext{Root: root}}, "local")
|
||||
result, _, err := Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml")), Filesystem: &ck.FilesystemContext{Root: root}}, Options{Overlay: "local"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -40,8 +40,11 @@ func loadApplication(ctx context.Context, selection ckconfig.Selection, _ struct
|
||||
} else {
|
||||
source = ck.SearchConfig("audita", ck.Searches(ck.WorkingDirectory(), ck.UserConfigDirectory(), ck.UnixSystemDirectories()))
|
||||
}
|
||||
loaded, report, err := appconfig.Load(ctx, ck.Input{Source: source}, selection.Overlay.Value, selection.Overrides...)
|
||||
return loaded, reportBootstrap(ctx, report, err)
|
||||
loaded, report, err := appconfig.Load(ctx, ck.Input{Source: source}, appconfig.Options{Overlay: selection.Overlay.Value, Overrides: selection.Overrides})
|
||||
if err != nil {
|
||||
return nil, reportBootstrap(ctx, report, err)
|
||||
}
|
||||
return loaded.Result, reportBootstrap(ctx, report, nil)
|
||||
}
|
||||
|
||||
func loadPromptEngine(ctx context.Context, selection ckconfig.Selection, input struct{}, state *invocationState) (*pk.Engine, error) {
|
||||
|
||||
@@ -37,8 +37,11 @@ func TestBootstrapConfigurationOutcomes(t *testing.T) {
|
||||
loads := 0
|
||||
load := func(ctx context.Context, selection ckconfig.Selection, _, _ struct{}) (*ck.Result[appconfig.Config], error) {
|
||||
loads++
|
||||
result, report, err := appconfig.Load(ctx, ck.Input{Source: ck.File(selection.Config.Value)}, "")
|
||||
return result, reportBootstrap(ctx, report, err)
|
||||
result, report, err := appconfig.Load(ctx, ck.Input{Source: ck.File(selection.Config.Value)}, appconfig.Options{})
|
||||
if err != nil {
|
||||
return nil, reportBootstrap(ctx, report, err)
|
||||
}
|
||||
return result.Result, reportBootstrap(ctx, report, nil)
|
||||
}
|
||||
scope := withBootstrapContext(ckconfig.FromConfigKit("app", "Application settings", load))
|
||||
command := ckconfig.Command(ckconfig.Suite[struct{}, struct{}]{Scopes: []ckconfig.Scope[struct{}, struct{}]{scope}})
|
||||
@@ -87,7 +90,7 @@ func TestBootstrapPreservesJoinedCancellation(t *testing.T) {
|
||||
if err := os.WriteFile(main, []byte("version: 3\nconfig:\n secrets_dir: missing\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, report, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
_, report, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, appconfig.Options{})
|
||||
joined := errors.Join(err, context.Canceled)
|
||||
wrapped := reportBootstrap(context.Background(), report, joined)
|
||||
var native *ck.SecretsError
|
||||
@@ -110,7 +113,7 @@ func TestPromptBootstrapFailureReportsTerminalDetails(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
load := func(ctx context.Context, selection ckconfig.Selection, _, _ struct{}) (*pk.Engine, error) {
|
||||
_, report, err := appconfig.Load(ctx, ck.Input{Source: ck.File(selection.Config.Value)}, "")
|
||||
_, report, err := appconfig.Load(ctx, ck.Input{Source: ck.File(selection.Config.Value)}, appconfig.Options{})
|
||||
return nil, reportBootstrap(ctx, report, err)
|
||||
}
|
||||
suite := withPromptBootstrapContext(ckprompt.FromEngine(load))
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
|
||||
t.Setenv("AUDITA_EXAMPLE_KEY", "")
|
||||
main = filepath.Join(dir, "config.yml")
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, tc.overlay)
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, appconfig.Options{Overlay: tc.overlay})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
|
||||
mu.Unlock()
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(`{"model":"fixture","choices":[{"message":{"role":"assistant","content":"{\"corrections\":[]}"}}]}`)), Request: r}, nil
|
||||
})
|
||||
engine, err := llm.NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
engine, err := llm.NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
inputs := &processInputs{Configuration: loaded, Runtime: engine, Source: source}
|
||||
inputs := &processInputs{Configuration: loaded.Result, Runtime: engine, Source: source}
|
||||
prepared, err := prepareProcess(context.Background(), processInput{Transcript: filepath.Join(root, tc.dir, "transcript.json")}, inputs, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -157,11 +157,11 @@ func TestExamplePromptEditIsCapturedOnNextLoad(t *testing.T) {
|
||||
}
|
||||
}
|
||||
inspect := func() string {
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
engine, err := llm.NewRuntime(context.Background(), loaded, nil)
|
||||
engine, err := llm.NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -101,11 +101,11 @@ pipeline:
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ pipeline:
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
inputs := &processInputs{Configuration: loaded, Runtime: runtime, Source: source}
|
||||
inputs := &processInputs{Configuration: loaded.Result, Runtime: runtime, Source: source}
|
||||
loaded.Config.Application.Diagnostics.WorkDir = dir
|
||||
loaded.Config.Application.Reporting.StdoutDir = dir
|
||||
prepared, err := prepareProcess(context.Background(), processInput{Transcript: filepath.Join(dir, "transcript.json"), Debug: commandkit.Supplied[bool]{Value: true}}, inputs, &bytes.Buffer{})
|
||||
@@ -213,14 +213,14 @@ func TestRecoverableModelFailureKeepsNormalizedTranscript(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
transport := controlledTransport(func(r *http.Request) (*http.Response, error) {
|
||||
return &http.Response{StatusCode: http.StatusServiceUnavailable, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(`{"error":{"message":"temporarily unavailable"}}`)), Request: r}, nil
|
||||
})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func TestRecoverableModelFailureKeepsNormalizedTranscript(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
inputs := &processInputs{Configuration: loaded, Runtime: runtime, Source: source}
|
||||
inputs := &processInputs{Configuration: loaded.Result, Runtime: runtime, Source: source}
|
||||
loaded.Config.Application.Reporting.StdoutDir = dir
|
||||
prepared, err := prepareProcess(context.Background(), processInput{Transcript: filepath.Join(dir, "transcript.json")}, inputs, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
@@ -256,7 +256,7 @@ func TestMalformedPermissivePromptKeepsLaterWork(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -281,7 +281,7 @@ func TestMalformedPermissivePromptKeepsLaterWork(t *testing.T) {
|
||||
body := fmt.Sprintf(`{"model":%q,"choices":[{"message":{"content":%s}}]}`, request.Model, encoded)
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -289,7 +289,7 @@ func TestMalformedPermissivePromptKeepsLaterWork(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
inputs := &processInputs{Configuration: loaded, Runtime: runtime, Source: source}
|
||||
inputs := &processInputs{Configuration: loaded.Result, Runtime: runtime, Source: source}
|
||||
loaded.Config.Application.Reporting.StdoutDir = dir
|
||||
prepared, err := prepareProcess(context.Background(), processInput{Transcript: filepath.Join(dir, "transcript.json")}, inputs, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
|
||||
@@ -24,11 +24,11 @@ func capacityFixture(t *testing.T, resources string, transport http.RoundTripper
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func adapterFixtureWithPrompt(t *testing.T, replies []reply, retries, repairs in
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func adapterFixtureWithPrompt(t *testing.T, replies []reply, retries, repairs in
|
||||
}
|
||||
return &http.Response{StatusCode: step.status, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
runtime, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestRoleClientCoordinatesIndependentRepairConversations(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func TestRoleClientCoordinatesIndependentRepairConversations(t *testing.T) {
|
||||
body := fmt.Sprintf(`{"model":%q,"choices":[{"message":{"content":%s}}]}`, req.Model, content)
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
runtime, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func TestCoordinatedRepairUsesReplacementAndCountsStructuralRepair(t *testing.T)
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func TestCoordinatedRepairUsesReplacementAndCountsStructuralRepair(t *testing.T)
|
||||
body := fmt.Sprintf(`{"model":"fixture","choices":[{"message":{"content":%s}}]}`, content)
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
runtime, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ func TestEngineCapturesAutomaticPromptSources(t *testing.T) {
|
||||
write("prompts.yml", "collections:\n audita:\n prompts:\n - id: modules.grammar.proposal\n messages:\n - role: user\n content_file: message.txt\n output:\n format: text\n validation_mode: none\n")
|
||||
write("message.txt", "first")
|
||||
write("prompts/nested/extra.yml", "prompts:\n - id: extra\n messages:\n - role: user\n content: extra\n output:\n format: text\n validation_mode: none\n")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
first, err := NewRuntime(context.Background(), loaded, nil)
|
||||
first, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func TestEngineCapturesAutomaticPromptSources(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
write("message.txt", "second")
|
||||
second, err := NewRuntime(context.Background(), loaded, nil)
|
||||
second, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -70,11 +70,11 @@ func TestEngineCapturesAutomaticPromptSources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEngineWithoutMainUsesEmbeddedPrompts(t *testing.T) {
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.NoSource()}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.NoSource()}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -103,11 +103,11 @@ func TestEngineCapturesInheritedMessageAndRejectsPeerConflicts(t *testing.T) {
|
||||
write("shared/catalog.yml", "prompts:\n - id: parent\n messages:\n - role: user\n content_file: instruction.md\n output:\n format: text\n validation_mode: none\n")
|
||||
write("shared/instruction.md", "inherited content")
|
||||
write("prompts/child.yml", "prompts:\n - id: child\n extends: {id: parent}\n")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func TestEngineCapturesInheritedMessageAndRejectsPeerConflicts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
write("prompts/duplicate.yml", "prompts:\n - id: parent\n messages:\n - role: user\n content: duplicate\n output:\n format: text\n validation_mode: none\n")
|
||||
if _, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, ""); err == nil || appconfig.IsAssetError(err) {
|
||||
if _, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{}); err == nil || appconfig.IsAssetError(err) {
|
||||
t.Fatalf("peer conflict classification: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -144,12 +144,12 @@ func TestEngineUsesRecordedContextWithWiderRoot(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source := ck.SearchConfig("audita", ck.SearchDirectory(project))
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: source, Filesystem: &ck.FilesystemContext{Root: root}}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: source, Filesystem: &ck.FilesystemContext{Root: root}}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(t.TempDir())
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -181,11 +181,11 @@ func TestEngineResolvesLinkedPromptMessageBesideDefinition(t *testing.T) {
|
||||
if err := os.Symlink("defs/resources.yml", filepath.Join(root, "prompts.yml")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(root, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(root, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -211,11 +211,11 @@ func TestRepairPromptReplacementUsesMessageFile(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestRoleClientUsesSelectedNativeCredential(t *testing.T) {
|
||||
if err := os.WriteFile(filepath.Join(dir, "prompts.yml"), []byte(document), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func TestRoleClientUsesSelectedNativeCredential(t *testing.T) {
|
||||
}
|
||||
return nil, providerErr
|
||||
})}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, httpClient)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, httpClient)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestRoleClientExecutionBudgetsAndFailureClasses(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func TestRoleClientExecutionBudgetsAndFailureClasses(t *testing.T) {
|
||||
if err := os.WriteFile(filepath.Join(promptDir, "grammar.yml"), prompt, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
selected, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
selected, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func TestRoleClientExecutionBudgetsAndFailureClasses(t *testing.T) {
|
||||
body := fmt.Sprintf(`{"model":"test-model","choices":[{"message":{"content":%s}}]}`, payload)
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})}
|
||||
runtime, err := NewRuntime(context.Background(), selected, httpClient)
|
||||
runtime, err := NewRuntime(context.Background(), selected.Result, httpClient)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func TestRoleClientExecutionBudgetsAndFailureClasses(t *testing.T) {
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func TestRoleClientsShareBackendCapacity(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func TestRoleClientsShareBackendCapacity(t *testing.T) {
|
||||
body := `{"model":"one","choices":[{"message":{"content":"{\"corrections\":[]}"}}]}`
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
runtime, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func TestRoleClientRetriesFollowRequestBudget(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -231,7 +231,7 @@ func TestRoleClientRetriesFollowRequestBudget(t *testing.T) {
|
||||
}
|
||||
return &http.Response{StatusCode: status, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
runtime, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -259,7 +259,7 @@ func TestNativeCredentialSelectionAndOptionalAbsence(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -269,7 +269,7 @@ func TestNativeCredentialSelectionAndOptionalAbsence(t *testing.T) {
|
||||
body := `{"model":"fixture","choices":[{"message":{"content":"{\"corrections\":[]}"}}]}`
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
runtime, err := NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestRuntimeCapturesShippedPromptsAndHonorsCancellation(t *testing.T) {
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.NoSource()}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.NoSource()}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func (r rejectingTransport) RoundTrip(*http.Request) (*http.Response, error) {
|
||||
}
|
||||
|
||||
func TestRuntimeInspectionDoesNotRequireCredentialsOrProvider(t *testing.T) {
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.NoSource()}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.NoSource()}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ func TestRuntimeCapturesSharedSources(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(project, "config.yml")), Filesystem: &ck.FilesystemContext{Root: root}}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(project, "config.yml")), Filesystem: &ck.FilesystemContext{Root: root}}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ func TestRuntimeTracksCapturedConfigurationAndInheritedMessageFiles(t *testing.T
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := NewRuntime(context.Background(), loaded, nil)
|
||||
runtime, err := NewRuntime(context.Background(), loaded.Result, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ func TestRepairedProposalStillFacesDomainChecks(t *testing.T) {
|
||||
if err := os.WriteFile(filepath.Join(dir, "prompts.yml"), []byte("profiles:\n - {id: base, endpoint: 'https://example.invalid/v1', model: local-model, api_key_required: false}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -56,12 +56,12 @@ func TestValidatorFailureCancelsActiveAndPendingProviderWork(t *testing.T) {
|
||||
if err := os.WriteFile(filepath.Join(dir, "prompts.yml"), []byte(resources), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
transport := &cancelTransport{entered: make(chan struct{}, 3)}
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -488,13 +488,13 @@ func (c *repairClient) Coordinate(ctx context.Context, _ *structuredoutput.Excha
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(dir, "config.yml"))}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var selected *structuredoutput.Request
|
||||
initial := true
|
||||
runtime, err := llm.NewRuntime(ctx, loaded, &http.Client{Transport: repairTransport(func(*http.Request) (*http.Response, error) {
|
||||
runtime, err := llm.NewRuntime(ctx, loaded.Result, &http.Client{Transport: repairTransport(func(*http.Request) (*http.Response, error) {
|
||||
content := `{"corrections":[]}`
|
||||
if initial {
|
||||
initial = false
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestLaterSectionsValidateWhileEarlierProposalUsesSharedBackend(t *testing.T
|
||||
if err := os.WriteFile(filepath.Join(dir, "prompts.yml"), []byte(resources), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(path)}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(path)}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestLaterSectionsValidateWhileEarlierProposalUsesSharedBackend(t *testing.T
|
||||
wire := fmt.Sprintf(`{"choices":[{"message":{"content":%s}}]}`, content)
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(wire))}, nil
|
||||
})}
|
||||
runtime, err := llm.NewRuntime(ctx, loaded, client)
|
||||
runtime, err := llm.NewRuntime(ctx, loaded.Result, client)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ func testValidationClient(t *testing.T, transport http.RoundTripper) structuredo
|
||||
if err := os.WriteFile(filepath.Join(dir, "prompts.yml"), []byte("profiles:\n - {id: base, endpoint: 'https://example.invalid/v1', model: local-model, api_key_required: false}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded, &http.Client{Transport: transport})
|
||||
runtime, err := llm.NewRuntime(context.Background(), loaded.Result, &http.Client{Transport: transport})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func fixtureEngine(t *testing.T) *pk.Engine {
|
||||
if err := os.WriteFile(main, []byte("version: 3\npromptkit:\n profiles:\n - id: fixture\n endpoint: https://example.invalid/v1\n model: fixture-model\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, "")
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, appconfig.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user