Narrow location occurrence normalizer references

This commit is contained in:
2026-08-04 13:12:46 +00:00
parent 55b188fd84
commit 5002864e88
4 changed files with 39 additions and 22 deletions

View File

@@ -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")
}