Update evidence context output coverage

This commit is contained in:
2026-08-09 19:45:21 +00:00
parent 071a78ae22
commit 449b506804
4 changed files with 35 additions and 45 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"sync"
"testing"
@@ -71,20 +72,17 @@ func TestLocationRegistryHandoffProducesOccurrencesAndEvidence(t *testing.T) {
if err != nil {
t.Fatalf("Decode(evidence context) error = %v", err)
}
if !locationEvidenceHasLane(evidence, "locations") || !locationEvidenceHasLane(evidence, "occurrences") {
t.Fatalf("evidence context = %#v, want registry and occurrence evidence from their own artifacts", evidence)
if actual := locationEvidenceUnitIDs(evidence); !reflect.DeepEqual(actual, []int{1, 2, 3, 4, 5}) {
t.Fatalf("evidence context = %#v, want deduplicated registry and occurrence source-unit evidence", evidence)
}
}
func locationEvidenceHasLane(document evidencecontext.Document, laneID string) bool {
for _, context := range document.Contexts {
for _, reference := range context.EvidenceRefs {
if reference.LaneID == laneID {
return true
}
}
func locationEvidenceUnitIDs(document evidencecontext.Document) []int {
ids := make([]int, len(document))
for index, unit := range document {
ids[index] = unit.ID
}
return false
return ids
}
func TestLocationOccurrenceConsumerDoesNotRunAfterRejectedRegistry(t *testing.T) {

View File

@@ -279,22 +279,8 @@ func TestProductionDNDOutputPublishesSelectedEvidenceContext(t *testing.T) {
if err != nil {
t.Fatalf("Decode(evidence context) error = %v", err)
}
if !reflect.DeepEqual(value.SelectedLanes, []string{"combat", "npc_registry", "spells"}) {
t.Fatalf("selected lanes = %#v, want configured production lanes without scene descriptions", value.SelectedLanes)
}
if len(value.Contexts) != 2 || len(value.Contexts[0].Units) != 1 || len(value.Contexts[1].Units) != 1 || value.Contexts[0].Units[0].ID != 10 || value.Contexts[1].Units[0].ID != 20 {
t.Fatalf("evidence contexts = %#v, want source-position union with non-monotonic unit IDs", value.Contexts)
}
firstRefs := value.Contexts[0].EvidenceRefs
if len(firstRefs) != 3 || firstRefs[0].LaneID != "combat" || firstRefs[1].LaneID != "npc_registry" || firstRefs[2].LaneID != "spells" {
t.Fatalf("first context evidence = %#v, want overlapping selected lane references", firstRefs)
}
for _, context := range value.Contexts {
for _, reference := range context.EvidenceRefs {
if reference.LaneID == "scene-descriptions" {
t.Fatalf("evidence refs = %#v, want scene descriptions excluded by allowlist", value.Contexts)
}
}
if actual := evidenceUnitIDs(value); !reflect.DeepEqual(actual, []int{10, 20}) {
t.Fatalf("evidence units = %#v, want deduplicated source-position union without scene descriptions", actual)
}
}
@@ -312,11 +298,19 @@ func TestProductionDNDOutputCanExplicitlySelectSceneDescriptionEvidence(t *testi
if err != nil {
t.Fatalf("Decode(evidence context) error = %v", err)
}
if !reflect.DeepEqual(value.SelectedLanes, []string{"scene-descriptions"}) || len(value.Contexts) == 0 || len(value.Contexts[0].EvidenceRefs) == 0 || value.Contexts[0].EvidenceRefs[0].LaneID != "scene-descriptions" {
t.Fatalf("evidence context = %#v, want explicitly selected scene-description evidence", value)
if len(value) == 0 {
t.Fatalf("evidence context = %#v, want explicitly selected scene-description source units", value)
}
}
func evidenceUnitIDs(value evidencecontext.Document) []int {
ids := make([]int, len(value))
for index, unit := range value {
ids[index] = unit.ID
}
return ids
}
func TestGroundedPipelineSkipsCombatForExactNarrativeScene(t *testing.T) {
registries := productionNPCRegistries(t)
configValue := loadGroundedPipelineConfig(t)