Make prompt tests resilient to wording changes
This commit is contained in:
@@ -151,16 +151,15 @@ func TestRegistryNormalizationPromptPairsRetainTheirNativeContracts(t *testing.T
|
||||
for _, test := range []struct {
|
||||
id string
|
||||
guidance string
|
||||
rules []string
|
||||
}{
|
||||
{"notarius/dnd.npc_registry.normalize", "Preserve distinct individuals.", []string{"same individual", "unadorned proper name"}},
|
||||
{"notarius/dnd.location_registry.normalize", "Keep parent and child places separate.", []string{"same physical place", "parent and child places"}},
|
||||
{"notarius/dnd.npc_registry.normalize", "Preserve distinct individuals."},
|
||||
{"notarius/dnd.location_registry.normalize", "Keep parent and child places separate."},
|
||||
} {
|
||||
t.Run(test.id, func(t *testing.T) {
|
||||
initial, err := engine.PrepareExecution(context.Background(), promptkit.RunRequest{
|
||||
PromptID: test.id, APIKey: "test-only", Inputs: map[string]promptkit.ArtifactRef{
|
||||
"candidates": promptkit.Inline(`{"candidate_number_range":{"first":1,"last":2},"candidates":[]}`),
|
||||
"transcript": promptkit.Inline(`{"windows":[]}`),
|
||||
"candidates": promptkit.Inline(`{"sentinel":"normalization-candidates-sentinel"}`),
|
||||
"transcript": promptkit.Inline(`{"sentinel":"normalization-transcript-sentinel"}`),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -180,20 +179,15 @@ func TestRegistryNormalizationPromptPairsRetainTheirNativeContracts(t *testing.T
|
||||
first.StructuredOutput == nil || next.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, next.OutputContract) {
|
||||
t.Fatal("normalization pair lost its shared native defaults/output contract")
|
||||
}
|
||||
var system string
|
||||
for _, message := range first.Messages {
|
||||
if message.Role == "system" {
|
||||
system += message.Content
|
||||
}
|
||||
}
|
||||
for _, rule := range append(test.rules, "candidate_number_range", "start_unit_id", "canonical_candidate_number") {
|
||||
if !strings.Contains(system, rule) {
|
||||
t.Fatalf("missing enduring system principle %q", rule)
|
||||
}
|
||||
}
|
||||
if len(next.Messages) != 1 || next.Messages[0].Role != "user" || !strings.Contains(next.Messages[0].Content, test.guidance) {
|
||||
t.Fatal("correction did not supply only the findings and replacement assignment")
|
||||
}
|
||||
for _, sentinel := range []string{"normalization-candidates-sentinel", "normalization-transcript-sentinel"} {
|
||||
renderedInputMessageIndex(t, first.Messages, sentinel)
|
||||
if strings.Contains(next.Messages[0].Content, sentinel) {
|
||||
t.Fatalf("correction repeated input %q", sentinel)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user