Derive independent glossary context and protection

This commit is contained in:
2026-11-10 17:25:08 +00:00
parent d42e2095d7
commit 89de2a7014
23 changed files with 364 additions and 173 deletions

View File

@@ -0,0 +1,27 @@
package proposal_generation
import (
"encoding/json"
"testing"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/glossary"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
)
func TestProposalContextPreservesDistinctEntries(t *testing.T) {
entries := []glossary.Entry{
{Collection: "spells", ID: "shield", Name: "Shield", Category: "spell", Description: "A spell"},
{Collection: "items", ID: "shield", Name: "Shield", Category: "item", Description: "An item"},
}
variables, err := BuildProposalVariables(&schema.Transcript{}, entries, 0, "")
if err != nil {
t.Fatal(err)
}
var decoded []glossary.Entry
if err := json.Unmarshal([]byte(variables["GlossaryJSON"]), &decoded); err != nil {
t.Fatal(err)
}
if len(decoded) != 2 || decoded[0].Category != "spell" || decoded[1].Category != "item" {
t.Fatalf("prompt entries=%+v", decoded)
}
}