Complete shared domain contract verification

This commit is contained in:
2026-11-29 18:28:59 +00:00
parent 9dc976afaf
commit 41a5c43561
33 changed files with 126 additions and 97 deletions

View File

@@ -36,6 +36,9 @@ func New(_ Options, references ...contracts.ReferenceSet) (*Validator, error) {
if len(references) == 1 {
referenceSet = references[0]
}
if err := shared.ValidateReferenceSelections(referenceSet); err != nil {
return nil, err
}
effective, err := spellcatalog.ResolveEffectiveCatalog(referenceSet)
if err != nil {
return nil, err
@@ -106,9 +109,6 @@ func Register(registry *pipeline.ValidatorRegistry) error {
if err != nil {
return nil, err
}
if err := shared.ValidateReferenceSelections(request.References); err != nil {
return nil, err
}
return New(options, request.References)
})
}

View File

@@ -13,8 +13,8 @@ import (
spellreference "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/spells/catalog"
)
func TestValidatorApprovesCanonicalNormalizedAndOverlayAliasNames(t *testing.T) {
validator, err := New(Options{}, overlayReferences())
func TestValidatorApprovesCanonicalNormalizedAndSharedGlossaryAliasNames(t *testing.T) {
validator, err := New(Options{}, sharedGlossaryReferences())
if err != nil {
t.Fatalf("New() error = %v, want nil", err)
}
@@ -89,7 +89,7 @@ func TestValidatorDefersInvalidShape(t *testing.T) {
func TestValidatorDoesNotMutateArtifactOrCatalog(t *testing.T) {
value := spellList("Cure Wounds")
before := value
validator, err := New(Options{}, overlayReferences())
validator, err := New(Options{}, sharedGlossaryReferences())
if err != nil {
t.Fatalf("New() error = %v, want nil", err)
}
@@ -103,7 +103,7 @@ func TestValidatorDoesNotMutateArtifactOrCatalog(t *testing.T) {
t.Fatalf("Validate() = %#v and value = %#v, want approval without mutation", result, value)
}
if _, ok := validator.catalog.Lookup("Aegis of Emberfall"); !ok {
t.Fatal("catalog lost overlay canonical name after mutating returned names")
t.Fatal("catalog lost shared glossary canonical name after mutating returned names")
}
}
@@ -151,7 +151,7 @@ func validCast(name string) dnd.SpellCast {
}
}
func overlayReferences() contracts.ReferenceSet {
func sharedGlossaryReferences() contracts.ReferenceSet {
content := []byte(`{
"schema_version": "maximumdirect.glossary.v1",
"collections": {"spells": {"entries": [