Narrow location occurrence normalizer references
This commit is contained in:
@@ -38,13 +38,6 @@ const (
|
||||
var requiredCapabilities = []string{"merged"}
|
||||
var providedCapabilities = []string{"normalized"}
|
||||
|
||||
var referenceSlotDescriptions = shared.ReferenceSlotDescriptions{
|
||||
Glossary: "Optional campaign glossary reference material used only for location-occurrence disambiguation.",
|
||||
Party: "Optional party roster reference material used only for location-occurrence disambiguation.",
|
||||
Players: "Optional player list reference material used only for location-occurrence disambiguation.",
|
||||
Roster: "Deprecated alias for party roster reference material used only for location-occurrence disambiguation.",
|
||||
}
|
||||
|
||||
var _ contracts.Normalizer[dnd.LocationOccurrenceList] = (*Normalizer)(nil)
|
||||
var _ contracts.ManifestMetadataProvider = (*Normalizer)(nil)
|
||||
var _ pipeline.CheckpointFingerprintProvider = (*Normalizer)(nil)
|
||||
@@ -332,13 +325,10 @@ func duplicateWarning(retainedIndex int, removed []int) contracts.Warning {
|
||||
func occurrenceScope(index int) string { return fmt.Sprintf("occurrences[%d]", index) }
|
||||
|
||||
func referenceSlots() []contracts.ReferenceSlot {
|
||||
slots := shared.ReferenceSlots(referenceSlotDescriptions)
|
||||
slots = append(slots, contracts.ReferenceSlot{
|
||||
return []contracts.ReferenceSlot{{
|
||||
Name: LocationRegistryReferenceSlot, Description: "Required normalized location registry used only for location identity grounding, never as occurrence evidence.",
|
||||
Required: true, AcceptedMediaTypes: []string{"application/json"}, AcceptedArtifactKinds: []contracts.ArtifactKind{dnd.LocationListKind}, MaxBytes: LocationRegistryMaxBytes,
|
||||
})
|
||||
sort.Slice(slots, func(left, right int) bool { return slots[left].Name < slots[right].Name })
|
||||
return slots
|
||||
}}
|
||||
}
|
||||
|
||||
func ModuleSpec() pipeline.ModuleSpec {
|
||||
|
||||
@@ -97,25 +97,35 @@ func TestNormalizerContractsRequiredRegistryAndWarningBounds(t *testing.T) {
|
||||
t.Fatalf("New() error = %v", err)
|
||||
}
|
||||
normalizer := newNormalizer(t, registryReferences(t, registryLocations("The Mill")))
|
||||
if spec := ModuleSpec(); spec.Key != Key || spec.Stage != pipeline.StageNormalize || spec.ExecutionClass != contracts.ExecutionClassDeterministic || spec.ArtifactKind != dnd.LocationOccurrenceListKind {
|
||||
spec := ModuleSpec()
|
||||
if spec.Key != Key || spec.Stage != pipeline.StageNormalize || spec.ExecutionClass != contracts.ExecutionClassDeterministic || spec.ArtifactKind != dnd.LocationOccurrenceListKind {
|
||||
t.Fatalf("ModuleSpec() = %#v", spec)
|
||||
}
|
||||
var locationSlot contracts.ReferenceSlot
|
||||
for _, slot := range ModuleSpec().ReferenceSlots {
|
||||
if slot.Name == LocationRegistryReferenceSlot {
|
||||
locationSlot = slot
|
||||
}
|
||||
wantSlots := []contracts.ReferenceSlot{{
|
||||
Name: LocationRegistryReferenceSlot,
|
||||
Description: "Required normalized location registry used only for location identity grounding, never as occurrence evidence.",
|
||||
Required: true,
|
||||
AcceptedMediaTypes: []string{"application/json"},
|
||||
AcceptedArtifactKinds: []contracts.ArtifactKind{dnd.LocationListKind},
|
||||
MaxBytes: LocationRegistryMaxBytes,
|
||||
}}
|
||||
if !reflect.DeepEqual(spec.ReferenceSlots, wantSlots) {
|
||||
t.Fatalf("ModuleSpec().ReferenceSlots = %#v, want %#v", spec.ReferenceSlots, wantSlots)
|
||||
}
|
||||
if !locationSlot.Required || !reflect.DeepEqual(locationSlot.AcceptedArtifactKinds, []contracts.ArtifactKind{dnd.LocationListKind}) || locationSlot.MaxBytes != LocationRegistryMaxBytes {
|
||||
t.Fatalf("location slot = %#v", locationSlot)
|
||||
if got := normalizer.ReferenceSlots(); !reflect.DeepEqual(got, wantSlots) {
|
||||
t.Fatalf("ReferenceSlots() = %#v, want %#v", got, wantSlots)
|
||||
}
|
||||
registry := pipeline.NewNormalizerRegistry()
|
||||
if err := Register(registry); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, ok := registry.Spec(Key); !ok {
|
||||
registeredSpec, ok := registry.Spec(Key)
|
||||
if !ok {
|
||||
t.Fatalf("registry missing %q", Key)
|
||||
}
|
||||
if !reflect.DeepEqual(registeredSpec.ReferenceSlots, wantSlots) {
|
||||
t.Fatalf("registered reference slots = %#v, want %#v", registeredSpec.ReferenceSlots, wantSlots)
|
||||
}
|
||||
if _, err := DecodeOptions(map[string]any{"unexpected": true}); err == nil {
|
||||
t.Fatal("DecodeOptions() accepted unknown options")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user