Assemble collection resources by qualified ID
This commit is contained in:
@@ -111,23 +111,26 @@ func TestListIdentitiesPreserveContextErrorsWithoutPartialResults(t *testing.T)
|
||||
|
||||
func TestListIdentitiesUseEffectiveLayeredMembership(t *testing.T) {
|
||||
underlay := configkit.Input{Source: configkit.Mapping("consumer defaults", map[string]any{
|
||||
"profiles": map[string]any{
|
||||
"base/profile": map[string]any{"endpoint": "https://example.test/v1", "model": "base-model"},
|
||||
"child/profile": map[string]any{"extends": "base/profile"},
|
||||
"overlay/profile": map[string]any{"endpoint": "https://example.test/v1", "model": "old-model"},
|
||||
},
|
||||
"collections": map[string]any{"shared": map[string]any{
|
||||
"profiles": map[string]any{
|
||||
"base": map[string]any{"endpoint": "https://example.test/v1", "model": "base-model"},
|
||||
"child": map[string]any{"extends": "base"},
|
||||
"overlay": map[string]any{"endpoint": "https://example.test/v1", "model": "old-model"},
|
||||
},
|
||||
"prompts": map[string]any{
|
||||
"prompt": promptDefinitionWithVersion("v1", listingContractPrompt()),
|
||||
},
|
||||
}},
|
||||
"prompts": map[string]any{
|
||||
"shared/prompt": promptDefinitionWithVersion("v1", listingContractPrompt()),
|
||||
"underlay-only": promptDefinitionWithVersion("v1", listingContractPrompt()),
|
||||
},
|
||||
})}
|
||||
main := configkit.Input{Source: configkit.Mapping("application overlay", map[string]any{
|
||||
"profiles": map[string]any{
|
||||
"overlay/profile": map[string]any{"model": "effective-model"},
|
||||
},
|
||||
"collections": map[string]any{"shared": map[string]any{"profiles": map[string]any{
|
||||
"overlay": map[string]any{"model": "effective-model"},
|
||||
}}},
|
||||
"prompts": map[string]any{
|
||||
"shared/prompt": promptDefinitionWithVersion("v2", listingContractPrompt()),
|
||||
"main-only": promptDefinitionWithVersion("v3", listingContractPrompt()),
|
||||
"main-only": promptDefinitionWithVersion("v3", listingContractPrompt()),
|
||||
},
|
||||
})}
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{
|
||||
@@ -143,24 +146,24 @@ func TestListIdentitiesUseEffectiveLayeredMembership(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, id := range []string{
|
||||
"base/profile", "child/profile", "overlay/profile",
|
||||
"shared/base", "shared/child", "shared/overlay",
|
||||
"promptkit-openrouter-standard", "promptkit-openrouter-auto",
|
||||
} {
|
||||
if !containsListingProfile(profiles, id) {
|
||||
t.Errorf("profile listing %#v does not include %q", profiles, id)
|
||||
}
|
||||
}
|
||||
for _, id := range []string{"base/profile", "child/profile", "overlay/profile"} {
|
||||
for _, id := range []string{"shared/base", "shared/child", "shared/overlay"} {
|
||||
if got := countListingProfile(profiles, id); got != 1 {
|
||||
t.Errorf("profile %q appears %d times, want 1", id, got)
|
||||
}
|
||||
}
|
||||
|
||||
overlay, err := engine.InspectProfile(context.Background(), "overlay/profile")
|
||||
overlay, err := engine.InspectProfile(context.Background(), "shared/overlay")
|
||||
if err != nil || overlay == nil || overlay.EffectiveModelParams.Model != "effective-model" {
|
||||
t.Fatalf("overlay profile did not resolve to its effective definition: (%+v, %v)", overlay, err)
|
||||
}
|
||||
child, err := engine.InspectProfile(context.Background(), "child/profile")
|
||||
child, err := engine.InspectProfile(context.Background(), "shared/child")
|
||||
if err != nil || child == nil || child.EffectiveModelParams.Model != "base-model" {
|
||||
t.Fatalf("inherited child profile did not resolve its effective definition: (%+v, %v)", child, err)
|
||||
}
|
||||
@@ -171,13 +174,13 @@ func TestListIdentitiesUseEffectiveLayeredMembership(t *testing.T) {
|
||||
}
|
||||
wantPrompts := []promptkit.PromptIdentity{
|
||||
{ID: "main-only", Version: stringPointerForTest("v3")},
|
||||
{ID: "shared/prompt", Version: stringPointerForTest("v2")},
|
||||
{ID: "shared/prompt", Version: stringPointerForTest("v1")},
|
||||
{ID: "underlay-only", Version: stringPointerForTest("v1")},
|
||||
}
|
||||
if !reflect.DeepEqual(prompts, wantPrompts) {
|
||||
t.Fatalf("effective prompt identities = %#v, want %#v", prompts, wantPrompts)
|
||||
}
|
||||
if got := countListingPrompt(prompts, "shared/prompt", "v2"); got != 1 {
|
||||
if got := countListingPrompt(prompts, "shared/prompt", "v1"); got != 1 {
|
||||
t.Fatalf("overlaid prompt identity appears %d times, want 1", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user