Compose application assets in one strict group
This commit is contained in:
@@ -30,7 +30,11 @@ ConfigKit remediation was completed before this work set; it is not outstanding.
|
|||||||
|
|
||||||
## Finding 1 — Compose Registered Application Assets In One Strict Group
|
## Finding 1 — Compose Registered Application Assets In One Strict Group
|
||||||
|
|
||||||
Priority: P2. Category: architecture/correctness gap. Status: open.
|
Priority: P2. Category: architecture/correctness gap. Status: complete.
|
||||||
|
|
||||||
|
Completed 2026-11-18: combined application filesystem inputs into one strict
|
||||||
|
underlay, retaining their independent contexts. Added conflict/operator-overlay
|
||||||
|
coverage; LLM, CLI, and module suites pass, including source-relative content tests.
|
||||||
|
|
||||||
Evidence:
|
Evidence:
|
||||||
|
|
||||||
|
|||||||
@@ -101,21 +101,25 @@ func (r *AssetRegistry) FallbackProfileDigest() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PromptKitConfigurationSources returns the registered prompt and fallback
|
// PromptKitConfigurationSources returns the registered prompt and fallback
|
||||||
// profile assets as native PromptKit underlay groups. Schema assets remain a
|
// profile assets in one strict native PromptKit underlay. Schema assets remain a
|
||||||
// separate PromptKit option because they are runtime validation resources.
|
// separate PromptKit option because they are runtime validation resources.
|
||||||
func (r *AssetRegistry) PromptKitConfigurationSources() (promptkit.ConfigurationSources, []promptkit.Option, error) {
|
func (r *AssetRegistry) PromptKitConfigurationSources() (promptkit.ConfigurationSources, []promptkit.Option, error) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("asset registry must not be nil")
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("asset registry must not be nil")
|
||||||
}
|
}
|
||||||
underlays, err := promptKitFilesystemUnderlays(r.prompts, "notarius-prompts")
|
inputs, err := promptKitFilesystemInputs(r.prompts, "notarius-prompts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare prompt configuration sources: %w", err)
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare prompt configuration sources: %w", err)
|
||||||
}
|
}
|
||||||
profiles, err := promptKitFilesystemUnderlays(r.fallbackProfiles, "notarius-fallback-profiles")
|
profiles, err := promptKitFilesystemInputs(r.fallbackProfiles, "notarius-fallback-profiles")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare fallback profile configuration sources: %w", err)
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare fallback profile configuration sources: %w", err)
|
||||||
}
|
}
|
||||||
underlays = append(underlays, profiles...)
|
inputs = append(inputs, profiles...)
|
||||||
|
var underlays []configkit.Underlay
|
||||||
|
if len(inputs) != 0 {
|
||||||
|
underlays = []configkit.Underlay{{Inputs: inputs}}
|
||||||
|
}
|
||||||
schemaFS, err := r.SchemaFS()
|
schemaFS, err := r.SchemaFS()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare schema assets: %w", err)
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare schema assets: %w", err)
|
||||||
@@ -125,18 +129,16 @@ func (r *AssetRegistry) PromptKitConfigurationSources() (promptkit.Configuration
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptKitFilesystemUnderlays(sources []AssetSource, label string) ([]configkit.Underlay, error) {
|
func promptKitFilesystemInputs(sources []AssetSource, label string) ([]configkit.Input, error) {
|
||||||
underlays := make([]configkit.Underlay, 0, len(sources))
|
var selected []configkit.Input
|
||||||
for index, source := range sources {
|
for index, source := range sources {
|
||||||
inputs, err := promptkit.FilesystemInputs(fmt.Sprintf("%s-%d", label, index), source.FS, source.Root)
|
inputs, err := promptkit.FilesystemInputs(fmt.Sprintf("%s-%d", label, index), source.FS, source.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("select filesystem inputs: %w", err)
|
return nil, fmt.Errorf("select filesystem inputs: %w", err)
|
||||||
}
|
}
|
||||||
if len(inputs) != 0 {
|
selected = append(selected, inputs...)
|
||||||
underlays = append(underlays, configkit.Underlay{Inputs: inputs})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return underlays, nil
|
return selected, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *AssetRegistry) fallbackProfileAssets() (fs.FS, string, bool, error) {
|
func (r *AssetRegistry) fallbackProfileAssets() (fs.FS, string, bool, error) {
|
||||||
|
|||||||
@@ -1,54 +1,53 @@
|
|||||||
package llm
|
package llm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"testing/fstest"
|
"testing/fstest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPromptKitConfigurationSourcesKeepsNativeFilesystemGroups(t *testing.T) {
|
func TestApplicationAssetsComposeStrictlyBeforeOperatorOverlay(t *testing.T) {
|
||||||
registry := NewAssetRegistry()
|
for _, conflict := range []bool{false, true} {
|
||||||
for index, name := range []string{"first", "second"} {
|
t.Run(fmt.Sprint("conflict=", conflict), func(t *testing.T) {
|
||||||
files := fstest.MapFS{
|
registry := NewAssetRegistry()
|
||||||
"prompts/prompt.yaml": {Data: []byte("prompts: {}\n")},
|
for _, id := range []string{"first", "second"} {
|
||||||
}
|
if conflict {
|
||||||
if err := registry.RegisterPromptFS(files, "."); err != nil {
|
id = "first"
|
||||||
t.Fatalf("register prompt source %d (%s): %v", index, name, err)
|
}
|
||||||
}
|
files := fstest.MapFS{"profiles.yaml": {Data: []byte(fmt.Sprintf("profiles:\n %s:\n backend: openrouter\n model: openai/gpt-5.6-luna\n", id))}}
|
||||||
}
|
if err := registry.RegisterFallbackProfileFS(files, "."); err != nil {
|
||||||
fallbackProfiles := fstest.MapFS{
|
t.Fatal(err)
|
||||||
"profiles.yaml": {Data: []byte("profiles: {}\n")},
|
}
|
||||||
}
|
}
|
||||||
if err := registry.RegisterFallbackProfileFS(fallbackProfiles, "."); err != nil {
|
operator := filepath.Join(t.TempDir(), "operator.yml")
|
||||||
t.Fatal(err)
|
if err := os.WriteFile(operator, []byte("profiles:\n first:\n api_key_required: false\n"), 0600); err != nil {
|
||||||
}
|
t.Fatal(err)
|
||||||
schemas := fstest.MapFS{"schema.json": {Data: []byte(`{"type":"object"}`)}}
|
}
|
||||||
if err := registry.RegisterSchemaFS(schemas, "."); err != nil {
|
inspector, err := NewPromptKitProfileInspector(PromptKitProfileInspectorConfig{Assets: registry, Source: PromptKitProfileSourceConfig{ProfileFile: operator}})
|
||||||
t.Fatal(err)
|
if conflict {
|
||||||
}
|
if err == nil {
|
||||||
|
t.Fatal("conflicting application profiles were silently overlaid")
|
||||||
sources, options, err := registry.PromptKitConfigurationSources()
|
}
|
||||||
if err != nil {
|
return
|
||||||
t.Fatal(err)
|
}
|
||||||
}
|
if err != nil {
|
||||||
if sources.Main != nil {
|
t.Fatal(err)
|
||||||
t.Fatalf("maintained sources unexpectedly set a main input: %+v", sources.Main)
|
}
|
||||||
}
|
for _, id := range []string{"first", "second"} {
|
||||||
if len(sources.Underlays) != 3 {
|
profile, err := inspector.InspectProfile(context.Background(), id)
|
||||||
t.Fatalf("underlays = %d, want two prompt groups and one profile group", len(sources.Underlays))
|
if err != nil {
|
||||||
}
|
t.Fatal(err)
|
||||||
for index, underlay := range sources.Underlays {
|
}
|
||||||
if len(underlay.Inputs) != 1 {
|
if profile.Model != "openai/gpt-5.6-luna" || profile.BackendID != "openrouter" {
|
||||||
t.Fatalf("underlay %d has %d inputs, want 1", index, len(underlay.Inputs))
|
t.Fatalf("profile = %#v", profile)
|
||||||
}
|
}
|
||||||
input := underlay.Inputs[0]
|
if id == "first" && profile.CredentialRequired {
|
||||||
if input.Imports {
|
t.Fatal("operator overlay was not applied")
|
||||||
t.Fatalf("maintained input %d unexpectedly enables imports", index)
|
}
|
||||||
}
|
}
|
||||||
if input.Filesystem == nil || input.Filesystem.FS == nil {
|
})
|
||||||
t.Fatalf("maintained input %d has no native filesystem context", index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(options) != 1 {
|
|
||||||
t.Fatalf("runtime options = %d, want one schema option", len(options))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user