Include glossary guidance in proposal conversations

This commit is contained in:
2026-11-26 18:22:52 +00:00
parent 20db09bd2a
commit e0445abe48
15 changed files with 82 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"reflect"
"strings"
"testing"
"gitea.maximumdirect.net/eric/audita/v4/internal/core/chunking"
@@ -95,24 +96,31 @@ func TestResolveModuleRunSpecs(t *testing.T) {
func TestResolveGlossaryInstructions(t *testing.T) {
cfg := &config.Config{
GlossaryCollections: map[string]config.GlossaryCollection{
"one": {Instruction: "First"}, "two": {Instruction: "Second"}, "protected": {Instruction: "Protection only"},
"one": {Instruction: "First {{literal}}"}, "two": {Instruction: "Second"}, "protected": {Instruction: "Protection only"}, "empty": {},
},
Pipeline: config.Pipeline{Stages: []config.Stage{
{Module: "grammar", Glossaries: []string{"two", "one"}, ProtectedTerms: []string{"protected"}},
{Module: "grammar", Glossaries: []string{"two", "one"}, ProtectedTerms: []string{"protected"}},
{Module: "grammar", Glossaries: []string{"two", "empty", "one"}, ProtectedTerms: []string{"protected"}},
{Module: "grammar", Glossaries: []string{"two", "empty", "one"}, ProtectedTerms: []string{"protected"}},
{Module: "grammar", Glossaries: []string{"one"}, ProtectedTerms: []string{"protected"}},
}},
}
specs := ResolveModuleRunSpecs(cfg)
want := []GlossaryInstruction{{Collection: "two", Text: "Second"}, {Collection: "one", Text: "First"}}
want := []GlossaryInstruction{{Collection: "two", Text: "Second"}, {Collection: "empty"}, {Collection: "one", Text: "First {{literal}}"}}
for _, spec := range specs[:2] {
if !reflect.DeepEqual(spec.GlossaryInstructions, want) {
t.Fatalf("instructions = %+v, want %+v", spec.GlossaryInstructions, want)
}
}
if !reflect.DeepEqual(specs[2].GlossaryInstructions, want[1:]) {
if !reflect.DeepEqual(specs[2].GlossaryInstructions, want[2:]) {
t.Fatalf("specific selection = %+v", specs[2].GlossaryInstructions)
}
if err := specs[0].PrepareGlossary(); err != nil {
t.Fatal(err)
}
block := specs[0].GlossaryVariables.InstructionsBlock
if !strings.Contains(block, "two") || !strings.Contains(block, "one") || !strings.Contains(block, "First {{literal}}") || strings.Index(block, "Second") > strings.Index(block, "First") || strings.Contains(block, "empty") || strings.Contains(block, "Protection only") {
t.Fatalf("instruction block = %q", block)
}
}
func TestSectionMetadataFromSection(t *testing.T) {