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 scene prose has no lexical grounding.
// Package sourcerelatedness reports advisory findings when scene prose has no lexical grounding.
package sourcerelatedness
import (
@@ -16,10 +16,9 @@ import (
)
const (
Key = "extract/dnd/scene-descriptions/source_relatedness"
WarningReasonCode = "scene_description_not_near_source"
OmittedReasonCode = "scene_description_relatedness_warnings_omitted"
policy = "dnd.scene_descriptions.validator.source_relatedness.v1"
Key = "extract/dnd/scene-descriptions/source_relatedness"
ReasonCode = "scene_description_not_near_source"
policy = "dnd.scene_descriptions.validator.source_relatedness.v1"
)
var stopwords = map[string]struct{}{
@@ -66,10 +65,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
warnings = append(warnings, warning(index, "summary"))
}
}
return contracts.ValidationResult{
Approved: true,
Warnings: diagnostics.LimitWarnings(warnings, "scenes", OmittedReasonCode),
}, nil
return diagnostics.DataQualityResult(warnings)
}
func tokenSet(value string) map[string]struct{} {
@@ -105,7 +101,7 @@ func significant(token string) bool {
func warning(index int, field string) contracts.Warning {
return contracts.Warning{
Scope: fmt.Sprintf("scenes[%d].%s", index, field),
ReasonCode: WarningReasonCode,
ReasonCode: ReasonCode,
Message: "scene description " + field + " has no significant token in cited source text",
}
}