35 lines
1.5 KiB
Go
35 lines
1.5 KiB
Go
package domain
|
|
|
|
import "git.cin.su/m/Assistant/contracts/world"
|
|
|
|
import "sort"
|
|
|
|
func ValidateObject(value world.WorldObject) error { return value.Validate() }
|
|
|
|
func ValidateKindDefinition(value world.WorldObjectKindDefinition) error { return value.Validate() }
|
|
|
|
func ValidateAlias(value world.WorldAlias) error { return value.Validate() }
|
|
|
|
func ValidateFacetDefinition(value world.FacetDefinition) error { return value.Validate() }
|
|
|
|
func ValidateRelationDefinition(value world.RelationDefinition) error { return value.Validate() }
|
|
|
|
func ValidateResolution(value world.IdentityResolutionDecisionRecord) error { return value.Validate() }
|
|
|
|
func ValidateLineage(value world.WorldLineage) error { return value.Validate() }
|
|
|
|
// ResolveCandidates deliberately refuses to merge an ambiguous result. A
|
|
// caller may persist the returned UNRESOLVED decision and later re-evaluate it
|
|
// with additional evidence.
|
|
func ResolveCandidates(candidates []world.IdentityResolutionCandidate, minimumConfidence int64) (world.ResolutionDecision, []world.IdentityResolutionCandidate) {
|
|
ordered := append([]world.IdentityResolutionCandidate(nil), candidates...)
|
|
sort.SliceStable(ordered, func(i, j int) bool { return ordered[i].Confidence > ordered[j].Confidence })
|
|
if len(ordered) == 0 || ordered[0].Confidence < minimumConfidence {
|
|
return world.ResolutionUnresolved, ordered
|
|
}
|
|
if len(ordered) > 1 && ordered[0].Confidence == ordered[1].Confidence {
|
|
return world.ResolutionUnresolved, ordered
|
|
}
|
|
return world.ResolutionSame, ordered[:1]
|
|
}
|