Move scene shape facts into the scene family
This commit is contained in:
@@ -190,6 +190,10 @@ source identity/range, and downstream invariants. It cannot fabricate a
|
||||
kind/title/summary, emit an invalid empty list, or retrieve an earlier candidate.
|
||||
Codec-valid empty collections are supported for the list extraction families,
|
||||
but do not generalize to every producer.
|
||||
The [scene family checks](../../internal/modules/dnd/scenedescriptions/checks.go)
|
||||
report field facts shared by normalization and validators; the selectable shape
|
||||
adapter owns extraction cardinality and corrective guidance. The durable codec
|
||||
shares the kind predicate but retains its own whitespace and source-range rules.
|
||||
|
||||
[Combat semantics](../../internal/modules/dnd/validate/scenedescriptions/combat_semantics/validator.go)
|
||||
is an opt-in independent combat/noncombat review of scene-local transcript input,
|
||||
|
||||
@@ -467,6 +467,12 @@ still be linear. Protect literal domain outputs, not comparator call counts.
|
||||
|
||||
### CAT-020 — Reusable Scene Rules Are Owned By A Selectable Validator Adapter
|
||||
|
||||
**Status:** Resolved. Family-owned checks report field facts for normalization
|
||||
and sibling validators; the shape adapter retains cardinality, classification,
|
||||
and guidance. The codec shares only the identical kind predicate. Literal tests
|
||||
cover nil/empty, kind, whitespace, references, and cardinality, and the specified
|
||||
scene family, codec, normalizer, and validator suites pass.
|
||||
|
||||
**Assessment:** Family cohesion/refactoring opportunity; original medium.
|
||||
|
||||
**Source:** [BND-003](11-boundaries.md#bnd-003--scene-domain-rules-live-inside-a-selectable-validator-package).
|
||||
|
||||
@@ -759,6 +759,12 @@ full tests/vet/build at this milestone. Update internal flow docs.
|
||||
|
||||
## Stage 27 — Move Scene Checks To Their Family
|
||||
|
||||
**Completed.** Family-owned checks return field facts for scene normalization
|
||||
and sibling validators; the selectable adapter retains extraction cardinality
|
||||
and corrective guidance. The codec shares only the common kind predicate and
|
||||
keeps its distinct whitespace/range acceptance. Literal fact and codec tests and
|
||||
the specified family, normalizer, codec, and validator suites pass.
|
||||
|
||||
**Coverage:** CAT-020. **Prerequisites:** preceding stage order.
|
||||
|
||||
Extract pure reusable scene checks from shape adapter; migrate normalizer/sibling
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/candidatejson"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/sourcerange"
|
||||
scenefacts "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/scenedescriptions"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -91,7 +92,7 @@ func validate(value dnd.SceneDescriptionList) error {
|
||||
if strings.TrimSpace(scene.ID) == "" {
|
||||
return fmt.Errorf("%s.id must not be empty", prefix)
|
||||
}
|
||||
if !validSceneKind(scene.Kind) {
|
||||
if !scenefacts.ValidKind(scene.Kind) {
|
||||
return fmt.Errorf("%s.kind must be supported", prefix)
|
||||
}
|
||||
if strings.TrimSpace(scene.Title) == "" {
|
||||
@@ -109,12 +110,3 @@ func validate(value dnd.SceneDescriptionList) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validSceneKind(value dnd.SceneKind) bool {
|
||||
switch value {
|
||||
case dnd.SceneKindCombat, dnd.SceneKindNarrative, dnd.SceneKindRecap, dnd.SceneKindMeta:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,22 @@ func TestCodecCandidatePreservesValidatorOwnedValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodecAllowsNonblankUntrimmedFields(t *testing.T) {
|
||||
value := validList()
|
||||
value.Scenes[0].ID = " id "
|
||||
value.Scenes[0].Title = " title "
|
||||
value.Scenes[0].Summary = " summary "
|
||||
value.Scenes[0].SourceRef.SourceID = " source "
|
||||
encoded, err := New().Encode(value)
|
||||
if err != nil {
|
||||
t.Fatalf("Encode() error = %v, want untrimmed nonblank values accepted", err)
|
||||
}
|
||||
decoded, err := New().Decode(encoded)
|
||||
if err != nil || !reflect.DeepEqual(decoded, value) {
|
||||
t.Fatalf("Decode() = %#v, %v", decoded, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodecRejectsInvalidDurableRangesWhileCandidatesPreserveThem(t *testing.T) {
|
||||
codec := New()
|
||||
for _, test := range []struct {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
scenefacts "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/scenedescriptions"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared/diagnostics"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/validate/scenedescriptions/shape"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -81,8 +81,8 @@ func normalizeList(input dnd.SceneDescriptionList, doc *source.SourceDocument) (
|
||||
originalTitle, originalSummary := scene.Title, scene.Summary
|
||||
scene.Title = strings.TrimSpace(scene.Title)
|
||||
scene.Summary = strings.TrimSpace(scene.Summary)
|
||||
if err := shape.Validate(dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{scene}}); err != nil {
|
||||
return dnd.SceneDescriptionList{}, nil, fmt.Errorf("scenes[%d]: %w", sceneIndex, err)
|
||||
if facts := scenefacts.Check(dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{scene}}); len(facts) != 0 {
|
||||
return dnd.SceneDescriptionList{}, nil, fmt.Errorf("scenes[%d]: %s", sceneIndex, describeShapeFacts(scene, facts))
|
||||
}
|
||||
if err := documentIndex.ValidateRef(scene.SourceRef); err != nil {
|
||||
return dnd.SceneDescriptionList{}, nil, fmt.Errorf("scenes[%d].source_ref: %s", sceneIndex, diagnostics.Truncate(err.Error()))
|
||||
@@ -146,6 +146,26 @@ func normalizeList(input dnd.SceneDescriptionList, doc *source.SourceDocument) (
|
||||
return dnd.SceneDescriptionList{Scenes: unique}, findings, nil
|
||||
}
|
||||
|
||||
func describeShapeFacts(scene dnd.SceneDescription, facts []scenefacts.Issue) string {
|
||||
issues := make([]string, 0, len(facts))
|
||||
for _, fact := range facts {
|
||||
prefix := fmt.Sprintf("scenes[%d]", fact.Index)
|
||||
switch fact.Field {
|
||||
case scenefacts.ID:
|
||||
issues = append(issues, prefix+".id must be non-empty and trimmed")
|
||||
case scenefacts.Kind:
|
||||
issues = append(issues, prefix+".kind is unsupported: "+diagnostics.Quote(string(scene.Kind)))
|
||||
case scenefacts.Title:
|
||||
issues = append(issues, prefix+".title must be non-empty and trimmed")
|
||||
case scenefacts.Summary:
|
||||
issues = append(issues, prefix+".summary must be non-empty and trimmed")
|
||||
case scenefacts.SourceRef:
|
||||
issues = append(issues, prefix+".source_ref must have a trimmed source ID and positive unit IDs")
|
||||
}
|
||||
}
|
||||
return diagnostics.Aggregate("invalid scene description shape", issues)
|
||||
}
|
||||
|
||||
func sceneScope(index int) string { return fmt.Sprintf("scenes[%d]", index) }
|
||||
|
||||
func identical(left, right dnd.SceneDescription) bool {
|
||||
|
||||
69
internal/modules/dnd/scenedescriptions/checks.go
Normal file
69
internal/modules/dnd/scenedescriptions/checks.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Package scenedescriptions owns reusable scene-description facts.
|
||||
package scenedescriptions
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
)
|
||||
|
||||
type Field string
|
||||
|
||||
const (
|
||||
ScenesMissing Field = "scenes_missing"
|
||||
ScenesEmpty Field = "scenes_empty"
|
||||
ID Field = "id"
|
||||
Kind Field = "kind"
|
||||
Title Field = "title"
|
||||
Summary Field = "summary"
|
||||
SourceRef Field = "source_ref"
|
||||
)
|
||||
|
||||
// Issue identifies a malformed field; Index is -1 for the list itself.
|
||||
type Issue struct {
|
||||
Index int
|
||||
Field Field
|
||||
}
|
||||
|
||||
// Check reports shape facts without choosing a validator policy or guidance.
|
||||
func Check(value dnd.SceneDescriptionList) []Issue {
|
||||
var issues []Issue
|
||||
if value.Scenes == nil {
|
||||
issues = append(issues, Issue{Index: -1, Field: ScenesMissing})
|
||||
} else if len(value.Scenes) == 0 {
|
||||
issues = append(issues, Issue{Index: -1, Field: ScenesEmpty})
|
||||
}
|
||||
for index, scene := range value.Scenes {
|
||||
if !nonblankTrimmed(scene.ID) {
|
||||
issues = append(issues, Issue{Index: index, Field: ID})
|
||||
}
|
||||
if !ValidKind(scene.Kind) {
|
||||
issues = append(issues, Issue{Index: index, Field: Kind})
|
||||
}
|
||||
if !nonblankTrimmed(scene.Title) {
|
||||
issues = append(issues, Issue{Index: index, Field: Title})
|
||||
}
|
||||
if !nonblankTrimmed(scene.Summary) {
|
||||
issues = append(issues, Issue{Index: index, Field: Summary})
|
||||
}
|
||||
if !nonblankTrimmed(scene.SourceRef.SourceID) || scene.SourceRef.StartUnitID <= 0 || scene.SourceRef.EndUnitID <= 0 {
|
||||
issues = append(issues, Issue{Index: index, Field: SourceRef})
|
||||
}
|
||||
}
|
||||
return issues
|
||||
}
|
||||
|
||||
func nonblankTrimmed(value string) bool {
|
||||
return strings.TrimSpace(value) != "" && value == strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
// ValidKind is shared with the durable codec, whose other checks intentionally
|
||||
// differ from the selectable shape validator.
|
||||
func ValidKind(value dnd.SceneKind) bool {
|
||||
switch value {
|
||||
case dnd.SceneKindCombat, dnd.SceneKindNarrative, dnd.SceneKindRecap, dnd.SceneKindMeta:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
38
internal/modules/dnd/scenedescriptions/checks_test.go
Normal file
38
internal/modules/dnd/scenedescriptions/checks_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package scenedescriptions
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
)
|
||||
|
||||
func TestCheckReportsSceneFieldFacts(t *testing.T) {
|
||||
valid := dnd.SceneDescription{ID: "id", Kind: dnd.SceneKindNarrative, Title: "Title", Summary: "Summary", SourceRef: source.SourceRef{SourceID: "source", StartUnitID: 2, EndUnitID: 1}}
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
value dnd.SceneDescriptionList
|
||||
want []Issue
|
||||
}{
|
||||
{"missing", dnd.SceneDescriptionList{}, []Issue{{-1, ScenesMissing}}},
|
||||
{"empty", dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{}}, []Issue{{-1, ScenesEmpty}}},
|
||||
{"valid reversed range is a separate check", dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{valid}}, nil},
|
||||
{"multiple valid scenes", dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{valid, valid}}, nil},
|
||||
{"all invalid fields", dnd.SceneDescriptionList{Scenes: []dnd.SceneDescription{{ID: " id ", Kind: "other", Title: " ", Summary: " untrimmed ", SourceRef: source.SourceRef{SourceID: " source ", StartUnitID: 0, EndUnitID: 1}}}}, []Issue{{0, ID}, {0, Kind}, {0, Title}, {0, Summary}, {0, SourceRef}}},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if got := Check(test.value); !reflect.DeepEqual(got, test.want) {
|
||||
t.Fatalf("Check() = %#v, want %#v", got, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, kind := range []dnd.SceneKind{dnd.SceneKindCombat, dnd.SceneKindNarrative, dnd.SceneKindRecap, dnd.SceneKindMeta} {
|
||||
if !ValidKind(kind) {
|
||||
t.Fatalf("ValidKind(%q) = false", kind)
|
||||
}
|
||||
}
|
||||
if ValidKind(" narrative ") || ValidKind("") {
|
||||
t.Fatal("accepted unsupported kind")
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"go.maximumdirect.net/promptkit"
|
||||
@@ -13,8 +14,9 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
scenefacts "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/scenedescriptions"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/validate/scenedescriptions/shape"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared/diagnostics"
|
||||
)
|
||||
|
||||
const Key = "extract/dnd/scene-descriptions/combat_semantics"
|
||||
@@ -108,7 +110,7 @@ func validateRequest(ctx context.Context, req contracts.TypedValidationRequest[d
|
||||
if err := source.NewDocumentIndex(req.Source).ValidateRef(req.Chunk.Ref); err != nil {
|
||||
return contracts.LLMInputMaterial{}, dnd.SceneDescription{}, validatorErrorf("validate current chunk source range: %w", err)
|
||||
}
|
||||
if err := shape.ValidateForStage(req.Value, req.Stage); err != nil {
|
||||
if err := sceneShapeError(req.Value); err != nil {
|
||||
return contracts.LLMInputMaterial{}, dnd.SceneDescription{}, validatorErrorf("validate scene description shape: %w", err)
|
||||
}
|
||||
scene := req.Value.Scenes[0]
|
||||
@@ -121,6 +123,40 @@ func validateRequest(ctx context.Context, req contracts.TypedValidationRequest[d
|
||||
return sourceInput, scene, nil
|
||||
}
|
||||
|
||||
func sceneShapeError(value dnd.SceneDescriptionList) error {
|
||||
var issues []string
|
||||
if len(value.Scenes) > 1 {
|
||||
issues = append(issues, "extraction must contain exactly one scene")
|
||||
}
|
||||
for _, fact := range scenefacts.Check(value) {
|
||||
if fact.Field == scenefacts.ScenesMissing {
|
||||
issues = append(issues, "scenes must be present")
|
||||
continue
|
||||
}
|
||||
if fact.Field == scenefacts.ScenesEmpty {
|
||||
issues = append(issues, "scenes must not be empty")
|
||||
continue
|
||||
}
|
||||
prefix := fmt.Sprintf("scenes[%d]", fact.Index)
|
||||
switch fact.Field {
|
||||
case scenefacts.ID:
|
||||
issues = append(issues, prefix+".id must be non-empty and trimmed")
|
||||
case scenefacts.Kind:
|
||||
issues = append(issues, prefix+".kind is unsupported: "+diagnostics.Quote(string(value.Scenes[fact.Index].Kind)))
|
||||
case scenefacts.Title:
|
||||
issues = append(issues, prefix+".title must be non-empty and trimmed")
|
||||
case scenefacts.Summary:
|
||||
issues = append(issues, prefix+".summary must be non-empty and trimmed")
|
||||
case scenefacts.SourceRef:
|
||||
issues = append(issues, prefix+".source_ref must have a trimmed source ID and positive unit IDs")
|
||||
}
|
||||
}
|
||||
if len(issues) == 0 {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("%s", diagnostics.Aggregate("invalid scene description shape", issues))
|
||||
}
|
||||
|
||||
func unavailable(cause error) error {
|
||||
return &contracts.ValidationUnavailableError{Cause: validatorErrorf("native assessment unavailable: %w", cause)}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
scenefacts "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/scenedescriptions"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared/diagnostics"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/validate/scenedescriptions/shape"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,7 +32,7 @@ func (v *Validator) ExecutionClass() contracts.ExecutionClass {
|
||||
}
|
||||
|
||||
func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationRequest[dnd.SceneDescriptionList]) (contracts.ValidationResult, error) {
|
||||
if shape.Validate(req.Value) != nil {
|
||||
if len(scenefacts.Check(req.Value)) != 0 {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
scenefacts "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/scenedescriptions"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared/diagnostics"
|
||||
)
|
||||
|
||||
@@ -42,53 +43,41 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
func Validate(value dnd.SceneDescriptionList) error { return validate(value, false) }
|
||||
|
||||
func ValidateForStage(value dnd.SceneDescriptionList, stage string) error {
|
||||
return validate(value, stage == string(pipeline.StageExtract))
|
||||
}
|
||||
|
||||
func validate(value dnd.SceneDescriptionList, exactlyOne bool) error {
|
||||
issues, _ := assess(value, exactlyOne)
|
||||
if len(issues) == 0 {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("%s", diagnostics.Aggregate("invalid scene description shape", issues))
|
||||
}
|
||||
|
||||
func assess(value dnd.SceneDescriptionList, exactlyOne bool) ([]string, diagnostics.Corrections) {
|
||||
issues := make([]string, 0)
|
||||
var issues []string
|
||||
var corrections diagnostics.Corrections
|
||||
if value.Scenes == nil {
|
||||
issues = append(issues, "scenes must be present")
|
||||
corrections.Add("scene", "Return one scene description for the supplied extraction chunk.", "")
|
||||
} else if len(value.Scenes) == 0 {
|
||||
issues = append(issues, "scenes must not be empty")
|
||||
corrections.Add("scene", "Return one scene description for the supplied extraction chunk.", "")
|
||||
} else if exactlyOne && len(value.Scenes) != 1 {
|
||||
facts := scenefacts.Check(value)
|
||||
if exactlyOne && len(value.Scenes) > 0 && len(value.Scenes) != 1 {
|
||||
issues = append(issues, "extraction must contain exactly one scene")
|
||||
corrections.Add("scene", "Return exactly one scene description for the supplied extraction chunk.", "")
|
||||
}
|
||||
for index, scene := range value.Scenes {
|
||||
prefix := fmt.Sprintf("scenes[%d]", index)
|
||||
for _, fact := range facts {
|
||||
if fact.Field == scenefacts.ScenesMissing || fact.Field == scenefacts.ScenesEmpty {
|
||||
message := "scenes must be present"
|
||||
if fact.Field == scenefacts.ScenesEmpty {
|
||||
message = "scenes must not be empty"
|
||||
}
|
||||
issues = append(issues, message)
|
||||
corrections.Add("scene", "Return one scene description for the supplied extraction chunk.", "")
|
||||
continue
|
||||
}
|
||||
scene := value.Scenes[fact.Index]
|
||||
prefix := fmt.Sprintf("scenes[%d]", fact.Index)
|
||||
record := fmt.Sprintf("Affected scene titled %s with kind %s, citing %s.", diagnostics.Quote(strings.TrimSpace(scene.Title)), diagnostics.Quote(string(scene.Kind)), diagnostics.SourceRefRange(scene.SourceRef))
|
||||
if strings.TrimSpace(scene.ID) == "" || scene.ID != strings.TrimSpace(scene.ID) {
|
||||
switch fact.Field {
|
||||
case scenefacts.ID:
|
||||
issues = append(issues, prefix+".id must be non-empty and trimmed")
|
||||
corrections.Add("scene", "Return exactly one scene description for the supplied extraction chunk.", record)
|
||||
}
|
||||
if !ValidKind(scene.Kind) {
|
||||
case scenefacts.Kind:
|
||||
issues = append(issues, prefix+".kind is unsupported: "+diagnostics.Quote(string(scene.Kind)))
|
||||
corrections.Add("kind", "Set `kind` to exactly one of `combat`, `narrative`, `recap`, or `meta`.", record)
|
||||
}
|
||||
if strings.TrimSpace(scene.Title) == "" || scene.Title != strings.TrimSpace(scene.Title) {
|
||||
case scenefacts.Title:
|
||||
issues = append(issues, prefix+".title must be non-empty and trimmed")
|
||||
corrections.Add("title", "Provide a concise, nonblank, trimmed title grounded in the supplied scene transcript.", record)
|
||||
}
|
||||
if strings.TrimSpace(scene.Summary) == "" || scene.Summary != strings.TrimSpace(scene.Summary) {
|
||||
case scenefacts.Summary:
|
||||
issues = append(issues, prefix+".summary must be non-empty and trimmed")
|
||||
corrections.Add("summary", "Provide a concise, nonblank, trimmed summary grounded in the supplied scene transcript.", record)
|
||||
}
|
||||
if strings.TrimSpace(scene.SourceRef.SourceID) == "" || scene.SourceRef.SourceID != strings.TrimSpace(scene.SourceRef.SourceID) || scene.SourceRef.StartUnitID <= 0 || scene.SourceRef.EndUnitID <= 0 {
|
||||
case scenefacts.SourceRef:
|
||||
issues = append(issues, prefix+".source_ref must have a trimmed source ID and positive unit IDs")
|
||||
corrections.Add("scene", "Return exactly one scene description for the supplied extraction chunk.", record)
|
||||
}
|
||||
@@ -96,15 +85,6 @@ func assess(value dnd.SceneDescriptionList, exactlyOne bool) ([]string, diagnost
|
||||
return issues, corrections
|
||||
}
|
||||
|
||||
func ValidKind(value dnd.SceneKind) bool {
|
||||
switch value {
|
||||
case dnd.SceneKindCombat, dnd.SceneKindNarrative, dnd.SceneKindRecap, dnd.SceneKindMeta:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func Spec() pipeline.ValidatorSpec {
|
||||
return pipeline.ValidatorSpec{Key: Key, ExecutionClass: contracts.ExecutionClassDeterministic}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
scenefacts "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/scenedescriptions"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared/diagnostics"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/validate/scenedescriptions/shape"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -31,7 +31,7 @@ func (v *Validator) ExecutionClass() contracts.ExecutionClass {
|
||||
}
|
||||
|
||||
func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationRequest[dnd.SceneDescriptionList]) (contracts.ValidationResult, error) {
|
||||
if shape.ValidateForStage(req.Value, req.Stage) != nil {
|
||||
if len(scenefacts.Check(req.Value)) != 0 || (req.Stage == string(pipeline.StageExtract) && len(req.Value.Scenes) != 1) {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
issues := make([]string, 0)
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
scenefacts "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/scenedescriptions"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared/diagnostics"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/validate/scenedescriptions/shape"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -40,7 +40,7 @@ func (v *Validator) ExecutionClass() contracts.ExecutionClass {
|
||||
}
|
||||
|
||||
func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationRequest[dnd.SceneDescriptionList]) (contracts.ValidationResult, error) {
|
||||
if shape.Validate(req.Value) != nil {
|
||||
if len(scenefacts.Check(req.Value)) != 0 {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
|
||||
Reference in New Issue
Block a user