2026-08-05 19:27:49 +00:00
package itemregistry
import (
"context"
"strings"
"testing"
"time"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
2026-10-04 12:29:55 +00:00
"gitea.maximumdirect.net/eric/notarius/internal/testsupport/promptkitfixture"
2026-08-05 19:27:49 +00:00
"gitea.maximumdirect.net/eric/promptkit"
)
func TestRegisterPromptAssetsPreparesItemPrompt ( t * testing . T ) {
registry := llm . NewAssetRegistry ( )
if err := RegisterPromptAssets ( registry ) ; err != nil {
t . Fatalf ( "RegisterPromptAssets() error = %v" , err )
}
2026-10-04 12:29:55 +00:00
engine := promptkitfixture . NewEngine ( t , registry , promptkit . Config { Timeout : time . Second } , map [ string ] promptkit . ProfileConfig {
"item-test-profile" : promptkitfixture . Profile ( "http://127.0.0.1:1/v1" , "item-test-model" ) ,
} )
2026-08-05 19:27:49 +00:00
prepared , err := engine . Prepare ( context . Background ( ) , promptkit . RunRequest { PromptID : PromptID , PromptVersion : SchemaVersion , ProfileID : "item-test-profile" , Inputs : map [ string ] promptkit . ArtifactRef {
"transcript" : promptkit . Inline ( ` { "units":[ { "sentinel":"item-transcript"}]} ` ) , "players" : promptkit . Inline ( "item-player" ) , "party" : promptkit . Inline ( " " ) , "glossary" : promptkit . Inline ( " " ) ,
} } )
if err != nil {
t . Fatalf ( "Prepare() error = %v" , err )
}
if prepared . PromptID != PromptID || prepared . OutputContract . SchemaPath != "dnd_item_registry_llm.v1.json" {
t . Fatalf ( "prepared prompt = %#v, want item prompt identity and schema wiring" , prepared )
}
content := make ( [ ] string , len ( prepared . Messages ) )
for index , message := range prepared . Messages {
content [ index ] = message . Content
}
rendered := strings . Join ( content , "\n" )
for _ , policy := range [ ] string { "named unique items" , "concrete reusable item types" , "currency denomination" , "loot" , "generic weapons" , "Do not use capitalization as an eligibility test" } {
if ! strings . Contains ( rendered , policy ) {
t . Fatalf ( "rendered prompt omits item eligibility policy %q" , policy )
}
}
}