Make prompt tests resilient to wording changes
This commit is contained in:
@@ -40,17 +40,9 @@ func TestCombatPromptPairPreservesNativeContractAndFixedGrounding(t *testing.T)
|
|||||||
if first.SelectedProfileID != "notarius/dnd-extraction" || first.SelectedProfileID != next.SelectedProfileID || first.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, next.OutputContract) {
|
if first.SelectedProfileID != "notarius/dnd-extraction" || first.SelectedProfileID != next.SelectedProfileID || first.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, next.OutputContract) {
|
||||||
t.Fatal("combat native pair lost its schema/default profile")
|
t.Fatal("combat native pair lost its schema/default profile")
|
||||||
}
|
}
|
||||||
var system, all string
|
var all string
|
||||||
for _, message := range first.Messages {
|
for _, message := range first.Messages {
|
||||||
all += message.Content
|
all += message.Content
|
||||||
if message.Role == "system" {
|
|
||||||
system += message.Content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, principle := range []string{"Unmatched actors remain permitted.", "Exclude initiative setup without a turn", "Transcript units are the only evidence", "legendary_action", "lair_action"} {
|
|
||||||
if !strings.Contains(strings.Join(strings.Fields(system), " "), principle) {
|
|
||||||
t.Fatalf("missing enduring rule %q", principle)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for _, marker := range []string{"combat-transcript-marker", "combat-npc-marker", "combat-party-marker"} {
|
for _, marker := range []string{"combat-transcript-marker", "combat-npc-marker", "combat-party-marker"} {
|
||||||
if strings.Count(all, marker) != 1 {
|
if strings.Count(all, marker) != 1 {
|
||||||
|
|||||||
@@ -151,16 +151,15 @@ func TestRegistryNormalizationPromptPairsRetainTheirNativeContracts(t *testing.T
|
|||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
id string
|
id string
|
||||||
guidance string
|
guidance string
|
||||||
rules []string
|
|
||||||
}{
|
}{
|
||||||
{"notarius/dnd.npc_registry.normalize", "Preserve distinct individuals.", []string{"same individual", "unadorned proper name"}},
|
{"notarius/dnd.npc_registry.normalize", "Preserve distinct individuals."},
|
||||||
{"notarius/dnd.location_registry.normalize", "Keep parent and child places separate.", []string{"same physical place", "parent and child places"}},
|
{"notarius/dnd.location_registry.normalize", "Keep parent and child places separate."},
|
||||||
} {
|
} {
|
||||||
t.Run(test.id, func(t *testing.T) {
|
t.Run(test.id, func(t *testing.T) {
|
||||||
initial, err := engine.PrepareExecution(context.Background(), promptkit.RunRequest{
|
initial, err := engine.PrepareExecution(context.Background(), promptkit.RunRequest{
|
||||||
PromptID: test.id, APIKey: "test-only", Inputs: map[string]promptkit.ArtifactRef{
|
PromptID: test.id, APIKey: "test-only", Inputs: map[string]promptkit.ArtifactRef{
|
||||||
"candidates": promptkit.Inline(`{"candidate_number_range":{"first":1,"last":2},"candidates":[]}`),
|
"candidates": promptkit.Inline(`{"sentinel":"normalization-candidates-sentinel"}`),
|
||||||
"transcript": promptkit.Inline(`{"windows":[]}`),
|
"transcript": promptkit.Inline(`{"sentinel":"normalization-transcript-sentinel"}`),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -180,20 +179,15 @@ func TestRegistryNormalizationPromptPairsRetainTheirNativeContracts(t *testing.T
|
|||||||
first.StructuredOutput == nil || next.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, next.OutputContract) {
|
first.StructuredOutput == nil || next.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, next.OutputContract) {
|
||||||
t.Fatal("normalization pair lost its shared native defaults/output contract")
|
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) {
|
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")
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,25 +2,32 @@ package assets_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"io/fs"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"go.maximumdirect.net/promptkit"
|
"go.maximumdirect.net/promptkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExtractionPromptComposition(t *testing.T) {
|
func TestExtractionPromptComposition(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
transcriptSentinel = "shared-transcript-sentinel"
|
transcriptSentinel = "shared-transcript-sentinel"
|
||||||
playersSentinel = "shared-players-sentinel"
|
playersSentinel = "shared-players-sentinel"
|
||||||
partySentinel = "shared-party-sentinel"
|
partySentinel = "shared-party-sentinel"
|
||||||
glossarySentinel = "shared-glossary-sentinel"
|
glossarySentinel = "shared-glossary-sentinel"
|
||||||
npcSentinel = "npc-registry-sentinel"
|
npcSentinel = "npc-registry-sentinel"
|
||||||
catalogSentinel = "spell-catalog-sentinel"
|
catalogSentinel = "spell-catalog-sentinel"
|
||||||
evidenceSentinel = "Transcript units are the only evidence"
|
|
||||||
endpointOrderSentinel = "according to transcript order"
|
|
||||||
combatPolicySentinel = "substantive active combat materially organizes the"
|
|
||||||
)
|
)
|
||||||
_, engine := loadNativeAssets(t)
|
_, engine := loadNativeAssets(t)
|
||||||
|
evidence, err := fs.ReadFile(assets.FS(), "dnd/shared/prompts/common-dnd-extraction-evidence.md")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
combatPolicy, err := fs.ReadFile(assets.FS(), "dnd/shared/prompts/common-dnd-scene-combat-policy.md")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
commonInputs := map[string]promptkit.ArtifactRef{
|
commonInputs := map[string]promptkit.ArtifactRef{
|
||||||
"transcript": promptkit.InlineWithURI("file:///session.json", `{"sentinel":"`+transcriptSentinel+`"}`),
|
"transcript": promptkit.InlineWithURI("file:///session.json", `{"sentinel":"`+transcriptSentinel+`"}`),
|
||||||
"players": promptkit.Inline(playersSentinel),
|
"players": promptkit.Inline(playersSentinel),
|
||||||
@@ -28,26 +35,26 @@ func TestExtractionPromptComposition(t *testing.T) {
|
|||||||
"glossary": promptkit.Inline(glossarySentinel),
|
"glossary": promptkit.Inline(glossarySentinel),
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
promptID string
|
promptID string
|
||||||
inputs map[string]promptkit.ArtifactRef
|
inputs map[string]promptkit.ArtifactRef
|
||||||
suffixGroups [][]string
|
suffixGroups [][]string
|
||||||
middleSentinel string
|
scenePolicy bool
|
||||||
}{
|
}{
|
||||||
{name: "npcs", promptID: "notarius/dnd.npc_registry", inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}},
|
{name: "npcs", promptID: "notarius/dnd.npc_registry", inputs: commonInputs},
|
||||||
{name: "locations", promptID: "notarius/dnd.location_registry", inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}},
|
{name: "locations", promptID: "notarius/dnd.location_registry", inputs: commonInputs},
|
||||||
{name: "item occurrences", promptID: "notarius/dnd.item_occurrences", inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
{name: "item occurrences", promptID: "notarius/dnd.item_occurrences", inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
||||||
"item_registry": promptkit.Inline(`{"items":[{"id":"item-registry-sentinel","name":"Torch"}]}`),
|
"item_registry": promptkit.Inline(`{"items":[{"id":"item-registry-sentinel","name":"Torch"}]}`),
|
||||||
}), suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {"item-registry-sentinel"}}},
|
}), suffixGroups: [][]string{{"item-registry-sentinel"}}},
|
||||||
{name: "item registry", promptID: "notarius/dnd.item_registry", inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}},
|
{name: "item registry", promptID: "notarius/dnd.item_registry", inputs: commonInputs},
|
||||||
{name: "scene descriptions", promptID: "notarius/dnd.scene_descriptions", inputs: commonInputs, middleSentinel: combatPolicySentinel},
|
{name: "scene descriptions", promptID: "notarius/dnd.scene_descriptions", inputs: commonInputs, scenePolicy: true},
|
||||||
{
|
{
|
||||||
name: "combat turns",
|
name: "combat turns",
|
||||||
promptID: "notarius/dnd.combat_turns",
|
promptID: "notarius/dnd.combat_turns",
|
||||||
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
||||||
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
|
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
|
||||||
}),
|
}),
|
||||||
suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {npcSentinel}},
|
suffixGroups: [][]string{{npcSentinel}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "enemy events",
|
name: "enemy events",
|
||||||
@@ -58,7 +65,6 @@ func TestExtractionPromptComposition(t *testing.T) {
|
|||||||
"npc_occurrences": promptkit.Inline(`{"sentinel":"npc-occurrences-sentinel"}`),
|
"npc_occurrences": promptkit.Inline(`{"sentinel":"npc-occurrences-sentinel"}`),
|
||||||
}),
|
}),
|
||||||
suffixGroups: [][]string{
|
suffixGroups: [][]string{
|
||||||
{evidenceSentinel, endpointOrderSentinel},
|
|
||||||
{npcSentinel},
|
{npcSentinel},
|
||||||
{"combat-turns-sentinel", "npc-occurrences-sentinel"},
|
{"combat-turns-sentinel", "npc-occurrences-sentinel"},
|
||||||
},
|
},
|
||||||
@@ -69,7 +75,7 @@ func TestExtractionPromptComposition(t *testing.T) {
|
|||||||
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
||||||
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
|
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
|
||||||
}),
|
}),
|
||||||
suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {npcSentinel}},
|
suffixGroups: [][]string{{npcSentinel}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "location occurrences",
|
name: "location occurrences",
|
||||||
@@ -77,7 +83,7 @@ func TestExtractionPromptComposition(t *testing.T) {
|
|||||||
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
|
||||||
"location_registry": promptkit.Inline(`{"sentinel":"location-registry-sentinel"}`),
|
"location_registry": promptkit.Inline(`{"sentinel":"location-registry-sentinel"}`),
|
||||||
}),
|
}),
|
||||||
suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {"location-registry-sentinel"}},
|
suffixGroups: [][]string{{"location-registry-sentinel"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "spells",
|
name: "spells",
|
||||||
@@ -86,7 +92,7 @@ func TestExtractionPromptComposition(t *testing.T) {
|
|||||||
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
|
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
|
||||||
"spell_catalog": promptkit.Inline(`{"sentinel":"` + catalogSentinel + `"}`),
|
"spell_catalog": promptkit.Inline(`{"sentinel":"` + catalogSentinel + `"}`),
|
||||||
}),
|
}),
|
||||||
suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {npcSentinel}, {catalogSentinel}},
|
suffixGroups: [][]string{{npcSentinel}, {catalogSentinel}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,12 +111,24 @@ func TestExtractionPromptComposition(t *testing.T) {
|
|||||||
prepared := handle.Details()
|
prepared := handle.Details()
|
||||||
transcriptIndex := renderedInputMessageIndex(t, prepared.Messages, transcriptSentinel)
|
transcriptIndex := renderedInputMessageIndex(t, prepared.Messages, transcriptSentinel)
|
||||||
referenceIndex := renderedInputMessageIndex(t, prepared.Messages, playersSentinel)
|
referenceIndex := renderedInputMessageIndex(t, prepared.Messages, playersSentinel)
|
||||||
|
for _, sentinel := range []string{partySentinel, glossarySentinel} {
|
||||||
|
if index := renderedInputMessageIndex(t, prepared.Messages, sentinel); index != referenceIndex {
|
||||||
|
t.Fatalf("reference %q rendered at message %d, want %d", sentinel, index, referenceIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
if referenceIndex >= transcriptIndex {
|
if referenceIndex >= transcriptIndex {
|
||||||
t.Fatalf("campaign references rendered at message %d, want before transcript message %d", referenceIndex, transcriptIndex)
|
t.Fatalf("campaign references rendered at message %d, want before transcript message %d", referenceIndex, transcriptIndex)
|
||||||
}
|
}
|
||||||
assertEphemeralCache(t, prepared.Messages, referenceIndex)
|
assertEphemeralCache(t, prepared.Messages, referenceIndex)
|
||||||
assertEphemeralCache(t, prepared.Messages, transcriptIndex)
|
assertEphemeralCache(t, prepared.Messages, transcriptIndex)
|
||||||
previousIndex := transcriptIndex
|
shared := evidence
|
||||||
|
if testCase.scenePolicy {
|
||||||
|
shared = combatPolicy
|
||||||
|
}
|
||||||
|
previousIndex := renderedInputMessageIndex(t, prepared.Messages, strings.TrimSpace(string(shared)))
|
||||||
|
if previousIndex <= transcriptIndex || prepared.Messages[previousIndex].Role != "system" {
|
||||||
|
t.Fatal("shared system message must follow the transcript")
|
||||||
|
}
|
||||||
for _, group := range testCase.suffixGroups {
|
for _, group := range testCase.suffixGroups {
|
||||||
groupIndex := -1
|
groupIndex := -1
|
||||||
for _, sentinel := range group {
|
for _, sentinel := range group {
|
||||||
@@ -127,12 +145,6 @@ func TestExtractionPromptComposition(t *testing.T) {
|
|||||||
previousIndex = groupIndex
|
previousIndex = groupIndex
|
||||||
}
|
}
|
||||||
instructionIndex := len(prepared.Messages) - 1
|
instructionIndex := len(prepared.Messages) - 1
|
||||||
if testCase.middleSentinel != "" {
|
|
||||||
policyIndex := renderedInputMessageIndex(t, prepared.Messages, testCase.middleSentinel)
|
|
||||||
if policyIndex <= transcriptIndex || policyIndex >= instructionIndex {
|
|
||||||
t.Fatalf("combat policy rendered at message %d, want after transcript message %d and before instructions message %d", policyIndex, transcriptIndex, instructionIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if instructionIndex <= previousIndex {
|
if instructionIndex <= previousIndex {
|
||||||
t.Fatalf("instructions rendered at message %d, want after lane input message %d", instructionIndex, previousIndex)
|
t.Fatalf("instructions rendered at message %d, want after lane input message %d", instructionIndex, previousIndex)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,14 @@ import (
|
|||||||
"go.maximumdirect.net/promptkit"
|
"go.maximumdirect.net/promptkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRegistryExtractionPromptPairsRetainDomainRulesAndContracts(t *testing.T) {
|
func TestRegistryExtractionPromptPairsRetainInputsAndContracts(t *testing.T) {
|
||||||
_, engine := loadNativeAssets(t)
|
_, engine := loadNativeAssets(t)
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
family, instruction string
|
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"}},
|
{"npc", "Revise the NPC citations."},
|
||||||
{"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"}},
|
{"item", "Revise the item citations."},
|
||||||
{"location", "Revise the location citations.", []string{"stable proper name or unique in-world designation", "the room", "Do not use capitalization as an eligibility test"}},
|
{"location", "Revise the location citations."},
|
||||||
} {
|
} {
|
||||||
t.Run(test.family, func(t *testing.T) {
|
t.Run(test.family, func(t *testing.T) {
|
||||||
id := "notarius/dnd." + test.family + "_registry"
|
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) {
|
first.StructuredOutput == nil || correction.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, correction.OutputContract) {
|
||||||
t.Fatal("registry prompt pair lost native schema/defaults")
|
t.Fatal("registry prompt pair lost native schema/defaults")
|
||||||
}
|
}
|
||||||
var system, all string
|
var all string
|
||||||
for _, message := range first.Messages {
|
for _, message := range first.Messages {
|
||||||
all += message.Content
|
all += message.Content
|
||||||
if message.Role == "system" {
|
|
||||||
system += message.Content
|
|
||||||
}
|
|
||||||
if strings.Contains(message.Content, "registry-transcript") || strings.Contains(message.Content, "registry-players") {
|
if strings.Contains(message.Content, "registry-transcript") || strings.Contains(message.Content, "registry-players") {
|
||||||
if message.CacheControl == nil || message.CacheControl.Type != promptkit.CacheControlEphemeral {
|
if message.CacheControl == nil || message.CacheControl.Type != promptkit.CacheControlEphemeral {
|
||||||
t.Fatal("fixed input cache hint lost")
|
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"} {
|
for _, input := range []string{"registry-transcript", "registry-players", "registry-party", "registry-glossary"} {
|
||||||
if strings.Count(all, input) != 1 {
|
if strings.Count(all, input) != 1 {
|
||||||
t.Fatalf("fixed input not rendered once: %q", input)
|
t.Fatalf("fixed input not rendered once: %q", input)
|
||||||
|
|||||||
@@ -97,19 +97,11 @@ func TestSceneDescriptionPromptPairRetainsPolicyAndFixedInputs(t *testing.T) {
|
|||||||
if first.SelectedProfileID != "notarius/dnd-extraction" || first.SelectedProfileID != next.SelectedProfileID || first.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, next.OutputContract) {
|
if first.SelectedProfileID != "notarius/dnd-extraction" || first.SelectedProfileID != next.SelectedProfileID || first.StructuredOutput == nil || !reflect.DeepEqual(first.OutputContract, next.OutputContract) {
|
||||||
t.Fatal("scene pair lost schema/defaults")
|
t.Fatal("scene pair lost schema/defaults")
|
||||||
}
|
}
|
||||||
var system, all string
|
var all string
|
||||||
for _, message := range first.Messages {
|
for _, message := range first.Messages {
|
||||||
all += message.Content
|
all += message.Content
|
||||||
if message.Role == "system" {
|
|
||||||
system += message.Content
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for _, rule := range []string{"complete chunk is the evidence boundary", "substantive active combat materially organizes the", "must not invent a proper noun"} {
|
for _, material := range []string{"scene-description-transcript", "scene-description-player"} {
|
||||||
if !strings.Contains(strings.Join(strings.Fields(system), " "), rule) {
|
|
||||||
t.Fatalf("missing enduring rule %q", rule)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, material := range []string{"scene-description-transcript", "scene-description-player", "substantive active combat materially organizes the"} {
|
|
||||||
if strings.Count(all, material) != 1 {
|
if strings.Count(all, material) != 1 {
|
||||||
t.Fatalf("fixed input/policy repeated: %q", material)
|
t.Fatalf("fixed input/policy repeated: %q", material)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -594,6 +594,10 @@ choice, not a reason to add locks everywhere or promise universal thread safety.
|
|||||||
|
|
||||||
**Assessment:** Test-maintenance weakness; original P3.
|
**Assessment:** Test-maintenance weakness; original P3.
|
||||||
|
|
||||||
|
**Status:** Resolved. Prompt tests exercise supplied inputs, native contracts,
|
||||||
|
shared asset placement, cache hints, and follow-up routing without pinning prose.
|
||||||
|
The targeted asset, reconciliation, and extraction suites pass.
|
||||||
|
|
||||||
**Source:** [TEST-005](08-testing.md#test-005--prompt-tests-contain-prose-change-detectors).
|
**Source:** [TEST-005](08-testing.md#test-005--prompt-tests-contain-prose-change-detectors).
|
||||||
|
|
||||||
Several asset/module tests require literal prose fragments; composition tests
|
Several asset/module tests require literal prose fragments; composition tests
|
||||||
|
|||||||
@@ -866,6 +866,8 @@ Update relevant canonical-input explanations.
|
|||||||
|
|
||||||
## Stage 32 — Replace Prompt-Prose Change Detectors
|
## Stage 32 — Replace Prompt-Prose Change Detectors
|
||||||
|
|
||||||
|
**Completed.**
|
||||||
|
|
||||||
**Coverage:** CAT-026. **Prerequisites:** prior operation/capture work settled.
|
**Coverage:** CAT-026. **Prerequisites:** prior operation/capture work settled.
|
||||||
|
|
||||||
Inspect asset registry/scene/combat/package/composition, reconciliation, and spell
|
Inspect asset registry/scene/combat/package/composition, reconciliation, and spell
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func TestNativeReconciliationPromptPairPreparesOffline(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
correction := CorrectionRequest(CorrectionPromptID, "test-profile", "session-1", []string{"Use only candidate numbers in the supplied range.", "Preserve distinct entities."})
|
correction := CorrectionRequest(CorrectionPromptID, "test-profile", "session-1", []string{"guidance-one-sentinel", "guidance-two-sentinel"})
|
||||||
if len(correction.Inputs) != 1 {
|
if len(correction.Inputs) != 1 {
|
||||||
t.Fatal("correction regenerated fixed evidence")
|
t.Fatal("correction regenerated fixed evidence")
|
||||||
}
|
}
|
||||||
@@ -37,23 +37,12 @@ func TestNativeReconciliationPromptPairPreparesOffline(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
first = prepared
|
first = prepared
|
||||||
var system string
|
|
||||||
for _, message := range prepared.Messages {
|
|
||||||
if message.Role == "system" {
|
|
||||||
system += message.Content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, rule := range []string{"candidate_number_range", "not candidate numbers", "do not copy candidate names", "Preserve distinct entities"} {
|
|
||||||
if !strings.Contains(system, rule) {
|
|
||||||
t.Fatalf("missing enduring system principle %q", rule)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if !reflect.DeepEqual(first.OutputContract, prepared.OutputContract) || len(prepared.Messages) != 1 || prepared.Messages[0].Role != "user" {
|
if !reflect.DeepEqual(first.OutputContract, prepared.OutputContract) || len(prepared.Messages) != 1 || prepared.Messages[0].Role != "user" {
|
||||||
t.Fatal("correction changed native contract or supplied more than a follow-up assignment")
|
t.Fatal("correction changed native contract or supplied more than a follow-up assignment")
|
||||||
}
|
}
|
||||||
text := prepared.Messages[0].Content
|
text := prepared.Messages[0].Content
|
||||||
if !strings.Contains(text, "Use only candidate numbers") || !strings.Contains(text, "complete replacement proposal") {
|
if strings.Count(text, "guidance-one-sentinel") != 1 || strings.Count(text, "guidance-two-sentinel") != 1 {
|
||||||
t.Fatal("correction lost findings or assignment")
|
t.Fatal("correction lost findings or assignment")
|
||||||
}
|
}
|
||||||
for _, material := range preparation.Materials() {
|
for _, material := range preparation.Materials() {
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ func TestSpellPromptPairSharesNativeContractAndDefaultProfile(t *testing.T) {
|
|||||||
inputs := map[string]promptkit.ArtifactRef{"guidance": promptkit.Inline("Fix the rejected cast.")}
|
inputs := map[string]promptkit.ArtifactRef{"guidance": promptkit.Inline("Fix the rejected cast.")}
|
||||||
if id == PromptID {
|
if id == PromptID {
|
||||||
inputs = map[string]promptkit.ArtifactRef{
|
inputs = map[string]promptkit.ArtifactRef{
|
||||||
"transcript": promptkit.Inline(`{"units":[1,2]}`),
|
"transcript": promptkit.Inline(`{"sentinel":"spell-transcript-sentinel"}`),
|
||||||
"spell_catalog": promptkit.Inline(`{"spells":[]}`),
|
"spell_catalog": promptkit.Inline(`{"sentinel":"spell-catalog-sentinel"}`),
|
||||||
"npc_registry": promptkit.Inline(`{"npcs":[]}`),
|
"npc_registry": promptkit.Inline(`{"sentinel":"spell-npcs-sentinel"}`),
|
||||||
"players": promptkit.Inline(" "), "party": promptkit.Inline(" "), "glossary": promptkit.Inline(" "),
|
"players": promptkit.Inline(" "), "party": promptkit.Inline(" "), "glossary": promptkit.Inline(" "),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,19 +37,24 @@ func TestSpellPromptPairSharesNativeContractAndDefaultProfile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if id == PromptID {
|
if id == PromptID {
|
||||||
initial = prepared
|
initial = prepared
|
||||||
var system string
|
for _, sentinel := range []string{"spell-transcript-sentinel", "spell-catalog-sentinel", "spell-npcs-sentinel"} {
|
||||||
for _, message := range prepared.Messages {
|
var count int
|
||||||
if message.Role == "system" {
|
for _, message := range prepared.Messages {
|
||||||
system += message.Content
|
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 {
|
} 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.") {
|
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")
|
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 {
|
if len(client.requests) != 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user