Make prompt tests resilient to wording changes

This commit is contained in:
2026-11-26 03:04:54 +00:00
parent 97e9d51db0
commit fef0530533
9 changed files with 84 additions and 103 deletions

View File

@@ -17,9 +17,9 @@ func TestSpellPromptPairSharesNativeContractAndDefaultProfile(t *testing.T) {
inputs := map[string]promptkit.ArtifactRef{"guidance": promptkit.Inline("Fix the rejected cast.")}
if id == PromptID {
inputs = map[string]promptkit.ArtifactRef{
"transcript": promptkit.Inline(`{"units":[1,2]}`),
"spell_catalog": promptkit.Inline(`{"spells":[]}`),
"npc_registry": promptkit.Inline(`{"npcs":[]}`),
"transcript": promptkit.Inline(`{"sentinel":"spell-transcript-sentinel"}`),
"spell_catalog": promptkit.Inline(`{"sentinel":"spell-catalog-sentinel"}`),
"npc_registry": promptkit.Inline(`{"sentinel":"spell-npcs-sentinel"}`),
"players": promptkit.Inline(" "), "party": promptkit.Inline(" "), "glossary": promptkit.Inline(" "),
}
}
@@ -37,19 +37,24 @@ func TestSpellPromptPairSharesNativeContractAndDefaultProfile(t *testing.T) {
}
if id == PromptID {
initial = prepared
var system string
for _, message := range prepared.Messages {
if message.Role == "system" {
system += message.Content
for _, sentinel := range []string{"spell-transcript-sentinel", "spell-catalog-sentinel", "spell-npcs-sentinel"} {
var count int
for _, message := range prepared.Messages {
count += strings.Count(message.Content, sentinel)
}
if count != 1 {
t.Fatalf("input %q rendered %d times", sentinel, count)
}
}
if !strings.Contains(system, "canonical spelling exactly") || !strings.Contains(system, "in-world caster") {
t.Fatal("enduring spell constraints missing from initial system context")
}
} else {
if !reflect.DeepEqual(initial.OutputContract, prepared.OutputContract) || len(prepared.Messages) != 1 || prepared.Messages[0].Role != "user" || !strings.Contains(prepared.Messages[0].Content, "Fix the rejected cast.") {
t.Fatal("correction must supply only findings and a replacement assignment with the same contract")
}
for _, sentinel := range []string{"spell-transcript-sentinel", "spell-catalog-sentinel", "spell-npcs-sentinel"} {
if strings.Contains(prepared.Messages[0].Content, sentinel) {
t.Fatalf("correction repeated input %q", sentinel)
}
}
}
}
if len(client.requests) != 0 {