Classify source relatedness as data-quality advisories

This commit is contained in:
2026-08-27 15:49:53 +00:00
parent 1f1967c8d2
commit ccba2ce3f9
25 changed files with 232 additions and 189 deletions

View File

@@ -1,4 +1,4 @@
// Package sourcerelatedness warns when cited source text does not mention a location.
// Package sourcerelatedness reports advisory findings when cited source text does not mention a location.
package sourcerelatedness
import (
@@ -14,10 +14,9 @@ import (
)
const (
Key = "extract/dnd/location-registry/source_relatedness"
WarningReasonCode = "location_not_near_source"
OmittedReasonCode = "location_relatedness_warnings_omitted"
policy = "dnd.location_registry.validator.source_relatedness.v2"
Key = "extract/dnd/location-registry/source_relatedness"
ReasonCode = "location_not_near_source"
policy = "dnd.location_registry.validator.source_relatedness.v2"
)
type Options struct{}
@@ -57,11 +56,11 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
continue
}
warnings = append(warnings, contracts.Warning{
Scope: fmt.Sprintf("locations[%d]", locationIndex), ReasonCode: WarningReasonCode,
Scope: fmt.Sprintf("locations[%d]", locationIndex), ReasonCode: ReasonCode,
Message: fmt.Sprintf("Location %s was not found in cited source text", diagnostics.Quote(location.Name)),
})
}
return contracts.ValidationResult{Approved: true, Warnings: diagnostics.LimitWarnings(warnings, "locations", OmittedReasonCode)}, nil
return diagnostics.DataQualityResult(warnings)
}
func Spec() pipeline.ValidatorSpec {