diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 5394212..12660a7 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -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 diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go index e2d6d93..a5e02d6 100644 --- a/internal/appconfig/config.go +++ b/internal/appconfig/config.go @@ -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 } diff --git a/internal/appconfig/config_test.go b/internal/appconfig/config_test.go index 349bd8d..fcc66d3 100644 --- a/internal/appconfig/config_test.go +++ b/internal/appconfig/config_test.go @@ -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) } diff --git a/internal/appconfig/glossary_test.go b/internal/appconfig/glossary_test.go index 67eee0d..5479b64 100644 --- a/internal/appconfig/glossary_test.go +++ b/internal/appconfig/glossary_test.go @@ -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) } diff --git a/internal/appconfig/runtime_glossary_test.go b/internal/appconfig/runtime_glossary_test.go new file mode 100644 index 0000000..bec0754 --- /dev/null +++ b/internal/appconfig/runtime_glossary_test.go @@ -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) + } + }) + } +} diff --git a/internal/appconfig/secrets_test.go b/internal/appconfig/secrets_test.go index c7213e7..c4b0f1c 100644 --- a/internal/appconfig/secrets_test.go +++ b/internal/appconfig/secrets_test.go @@ -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) } diff --git a/internal/appconfig/sources_test.go b/internal/appconfig/sources_test.go index 872cbf5..54b3ee6 100644 --- a/internal/appconfig/sources_test.go +++ b/internal/appconfig/sources_test.go @@ -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) } diff --git a/internal/cli/app_wiring.go b/internal/cli/app_wiring.go index 3c18d20..bb5c2ef 100644 --- a/internal/cli/app_wiring.go +++ b/internal/cli/app_wiring.go @@ -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) { diff --git a/internal/cli/bootstrap_test.go b/internal/cli/bootstrap_test.go index 408d717..f548d35 100644 --- a/internal/cli/bootstrap_test.go +++ b/internal/cli/bootstrap_test.go @@ -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)) diff --git a/internal/cli/examples_integration_test.go b/internal/cli/examples_integration_test.go index 25737da..ba2634f 100644 --- a/internal/cli/examples_integration_test.go +++ b/internal/cli/examples_integration_test.go @@ -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) } diff --git a/internal/cli/process_ordered_integration_test.go b/internal/cli/process_ordered_integration_test.go index f255c57..1771eff 100644 --- a/internal/cli/process_ordered_integration_test.go +++ b/internal/cli/process_ordered_integration_test.go @@ -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 { diff --git a/internal/framework/llm/adapter_capacity_test.go b/internal/framework/llm/adapter_capacity_test.go index 4796551..cf08d68 100644 --- a/internal/framework/llm/adapter_capacity_test.go +++ b/internal/framework/llm/adapter_capacity_test.go @@ -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) } diff --git a/internal/framework/llm/adapter_test.go b/internal/framework/llm/adapter_test.go index 4fc4707..31e9ea7 100644 --- a/internal/framework/llm/adapter_test.go +++ b/internal/framework/llm/adapter_test.go @@ -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) } diff --git a/internal/framework/llm/conversation_test.go b/internal/framework/llm/conversation_test.go index 4d49cec..518ee1f 100644 --- a/internal/framework/llm/conversation_test.go +++ b/internal/framework/llm/conversation_test.go @@ -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) } diff --git a/internal/framework/llm/engine_sources_test.go b/internal/framework/llm/engine_sources_test.go index 6b4a98d..74acdb8 100644 --- a/internal/framework/llm/engine_sources_test.go +++ b/internal/framework/llm/engine_sources_test.go @@ -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) } diff --git a/internal/framework/llm/native_adapter_test.go b/internal/framework/llm/native_adapter_test.go index ac2ecfd..3db9ddf 100644 --- a/internal/framework/llm/native_adapter_test.go +++ b/internal/framework/llm/native_adapter_test.go @@ -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) } diff --git a/internal/framework/llm/runtime_assembly_test.go b/internal/framework/llm/runtime_assembly_test.go index 07c92cb..0c41c8c 100644 --- a/internal/framework/llm/runtime_assembly_test.go +++ b/internal/framework/llm/runtime_assembly_test.go @@ -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) } diff --git a/internal/framework/llm/runtime_inspection_test.go b/internal/framework/llm/runtime_inspection_test.go index da394c5..14508ff 100644 --- a/internal/framework/llm/runtime_inspection_test.go +++ b/internal/framework/llm/runtime_inspection_test.go @@ -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) } diff --git a/internal/framework/llm/shared_sources_test.go b/internal/framework/llm/shared_sources_test.go index 29beb92..c43f054 100644 --- a/internal/framework/llm/shared_sources_test.go +++ b/internal/framework/llm/shared_sources_test.go @@ -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) } diff --git a/internal/framework/llm/source_paths_test.go b/internal/framework/llm/source_paths_test.go index 98b3ebc..581486d 100644 --- a/internal/framework/llm/source_paths_test.go +++ b/internal/framework/llm/source_paths_test.go @@ -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) } diff --git a/internal/framework/proposal_generation/adapter_integration_test.go b/internal/framework/proposal_generation/adapter_integration_test.go index a399791..a03a4f9 100644 --- a/internal/framework/proposal_generation/adapter_integration_test.go +++ b/internal/framework/proposal_generation/adapter_integration_test.go @@ -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) } diff --git a/internal/framework/runner/cancellation_test.go b/internal/framework/runner/cancellation_test.go index 67f384b..bd3bb39 100644 --- a/internal/framework/runner/cancellation_test.go +++ b/internal/framework/runner/cancellation_test.go @@ -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) } diff --git a/internal/framework/runner/repair_test.go b/internal/framework/runner/repair_test.go index 8047542..ecdd0ad 100644 --- a/internal/framework/runner/repair_test.go +++ b/internal/framework/runner/repair_test.go @@ -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 diff --git a/internal/framework/runner/window_test.go b/internal/framework/runner/window_test.go index 3724eab..f9bb936 100644 --- a/internal/framework/runner/window_test.go +++ b/internal/framework/runner/window_test.go @@ -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) } diff --git a/internal/framework/validators/llm_integration_test.go b/internal/framework/validators/llm_integration_test.go index 63ecff0..6825a3d 100644 --- a/internal/framework/validators/llm_integration_test.go +++ b/internal/framework/validators/llm_integration_test.go @@ -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) } diff --git a/internal/prompts/registry_test.go b/internal/prompts/registry_test.go index b807f39..cacb4ef 100644 --- a/internal/prompts/registry_test.go +++ b/internal/prompts/registry_test.go @@ -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) }