Prepare shared context for all D&D extractors

This commit is contained in:
2026-11-29 18:13:45 +00:00
parent e0554209f0
commit 03e4c0d64d
22 changed files with 189 additions and 176 deletions

View File

@@ -93,8 +93,8 @@ func TestRunnerPassesPartyAndGlossaryReferencesToDNDSpellsPrompt(t *testing.T) {
raw := readDNDSpellsFixture(t)
resolved := resolveDNDSpellsPipeline(t)
resolved.ResolvedPipeline.Steps[0].ArtifactLanes[0].ExtractReferences.ReferenceSet = dndSpellsReferenceSet(
"Aria: party cleric\nBorin: fighter",
"Fire Bolt: evocation cantrip",
`{"schema_version":"maximumdirect.rpg.party.v1","characters":{"a":{"character":{"name":"Aria","classes":[{"name":"cleric"}]},"player":{"name":"Alice"}},"b":{"character":{"name":"Borin","classes":[{"name":"fighter"}]}}}}`,
`{"schema_version":"maximumdirect.glossary.v1","collections":{"campaign":{"entries":[{"id":"f","name":"Fire Bolt","category":"spell","description":"evocation cantrip"}]}}}`,
)
llmClient := &fakeSpellsLLMClient{
response: extractionResponse{
@@ -122,7 +122,7 @@ func TestRunnerPassesPartyAndGlossaryReferencesToDNDSpellsPrompt(t *testing.T) {
t.Fatalf("LLM calls = %d, want 1", len(llmClient.requests))
}
request := llmClient.requests[0]
for _, value := range []string{"Aria: party cleric\nBorin: fighter", "Fire Bolt: evocation cantrip"} {
for _, value := range []string{"cleric", "fighter", "Alice", "evocation cantrip"} {
if !strings.Contains(nativePromptText(request), value) {
t.Fatalf("rendered prompt omitted %q", value)
}
@@ -197,10 +197,10 @@ func dndSpellsReferenceSet(party string, glossary string) contracts.ReferenceSet
Items: []contracts.ReferenceItem{
{
SlotName: "party",
MediaType: "text/plain; charset=utf-8",
MediaType: "application/json",
Content: []byte(party),
Digest: "sha256:party",
Origin: contracts.ReferenceOrigin{Type: "file", URI: "file:///tmp/party.txt"},
Origin: contracts.ReferenceOrigin{Type: "file", URI: "file:///tmp/party.json"},
SizeBytes: int64(len(party)),
BindingSource: contracts.ReferenceBindingSourceConfig,
},
@@ -213,10 +213,10 @@ func dndSpellsReferenceSet(party string, glossary string) contracts.ReferenceSet
Items: []contracts.ReferenceItem{
{
SlotName: "glossary",
MediaType: "text/plain; charset=utf-8",
MediaType: "application/json",
Content: []byte(glossary),
Digest: "sha256:glossary",
Origin: contracts.ReferenceOrigin{Type: "file", URI: "file:///tmp/glossary.txt"},
Origin: contracts.ReferenceOrigin{Type: "file", URI: "file:///tmp/glossary.json"},
SizeBytes: int64(len(glossary)),
BindingSource: contracts.ReferenceBindingSourceConfig,
},