Make prompt tests resilient to wording changes
This commit is contained in:
@@ -12,15 +12,14 @@ import (
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func TestRegistryExtractionPromptPairsRetainDomainRulesAndContracts(t *testing.T) {
|
||||
func TestRegistryExtractionPromptPairsRetainInputsAndContracts(t *testing.T) {
|
||||
_, engine := loadNativeAssets(t)
|
||||
for _, test := range []struct {
|
||||
family, instruction string
|
||||
rules []string
|
||||
}{
|
||||
{"npc", "Revise the NPC citations.", []string{"proper name or a stable, individually distinguishing", "factual third-party mention", "Exclude human players"}},
|
||||
{"item", "Revise the item citations.", []string{"named unique items", "concrete reusable item types", "currency denomination", "generic weapons", "Do not use capitalization as an eligibility test"}},
|
||||
{"location", "Revise the location citations.", []string{"stable proper name or unique in-world designation", "the room", "Do not use capitalization as an eligibility test"}},
|
||||
{"npc", "Revise the NPC citations."},
|
||||
{"item", "Revise the item citations."},
|
||||
{"location", "Revise the location citations."},
|
||||
} {
|
||||
t.Run(test.family, func(t *testing.T) {
|
||||
id := "notarius/dnd." + test.family + "_registry"
|
||||
@@ -47,23 +46,15 @@ func TestRegistryExtractionPromptPairsRetainDomainRulesAndContracts(t *testing.T
|
||||
first.StructuredOutput == nil || correction.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, correction.OutputContract) {
|
||||
t.Fatal("registry prompt pair lost native schema/defaults")
|
||||
}
|
||||
var system, all string
|
||||
var all string
|
||||
for _, message := range first.Messages {
|
||||
all += message.Content
|
||||
if message.Role == "system" {
|
||||
system += message.Content
|
||||
}
|
||||
if strings.Contains(message.Content, "registry-transcript") || strings.Contains(message.Content, "registry-players") {
|
||||
if message.CacheControl == nil || message.CacheControl.Type != promptkit.CacheControlEphemeral {
|
||||
t.Fatal("fixed input cache hint lost")
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, rule := range append(test.rules, "Transcript units are the only evidence", "Use the most specific supported in-world") {
|
||||
if !strings.Contains(strings.Join(strings.Fields(system), " "), rule) {
|
||||
t.Fatalf("missing enduring domain rule %q", rule)
|
||||
}
|
||||
}
|
||||
for _, input := range []string{"registry-transcript", "registry-players", "registry-party", "registry-glossary"} {
|
||||
if strings.Count(all, input) != 1 {
|
||||
t.Fatalf("fixed input not rendered once: %q", input)
|
||||
|
||||
Reference in New Issue
Block a user