Share the source index with validators
This commit is contained in:
@@ -16,10 +16,16 @@ type CitationResolver struct {
|
||||
|
||||
// NewCitationResolver prepares citation resolution for doc.
|
||||
func NewCitationResolver(doc *source.SourceDocument) (*CitationResolver, error) {
|
||||
return NewCitationResolverForSource(doc, nil)
|
||||
}
|
||||
|
||||
// NewCitationResolverForSource reuses an optional read-only index for doc's
|
||||
// unchanged source snapshot. Standalone callers may omit the index.
|
||||
func NewCitationResolverForSource(doc *source.SourceDocument, index *source.DocumentIndex) (*CitationResolver, error) {
|
||||
if doc == nil {
|
||||
return nil, fmt.Errorf("source document must not be nil")
|
||||
}
|
||||
return &CitationResolver{doc: doc, index: source.NewDocumentIndex(doc)}, nil
|
||||
return &CitationResolver{doc: doc, index: DocumentIndexForSource(doc, index)}, nil
|
||||
}
|
||||
|
||||
// CitedText resolves cited source ranges in document order, including each
|
||||
|
||||
@@ -75,6 +75,35 @@ func TestNewCitationResolverRejectsNilDocument(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCitationResolverForSourceUsesCurrentLayoutWithOptionalIndex(t *testing.T) {
|
||||
for _, supplied := range []bool{false, true} {
|
||||
for _, units := range [][]source.SourceUnit{
|
||||
{{ID: 40, Text: "first"}, {ID: 10, Text: "second"}},
|
||||
{{ID: 10, Text: "second"}, {ID: 40, Text: "first"}},
|
||||
} {
|
||||
doc := &source.SourceDocument{ID: "same-source", Units: units}
|
||||
var index *source.DocumentIndex
|
||||
if supplied {
|
||||
built := source.NewDocumentIndex(doc)
|
||||
index = &built
|
||||
}
|
||||
resolver, err := NewCitationResolverForSource(doc, index)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
refs := []source.SourceRef{{SourceID: doc.ID, StartUnitID: units[0].ID, EndUnitID: units[1].ID}}
|
||||
want := units[0].Text + "\n" + units[1].Text
|
||||
if got, err := resolver.CitedText(refs); err != nil || got != want {
|
||||
t.Fatalf("supplied=%t CitedText() = %q, %v; want %q", supplied, got, err, want)
|
||||
}
|
||||
refs[0].StartUnitID = 999
|
||||
if _, err := resolver.CitedText(refs); err == nil {
|
||||
t.Fatal("unknown endpoint was accepted")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCitationResolverUsesSourceOrderAndPreservesEmptyText(t *testing.T) {
|
||||
doc := &source.SourceDocument{ID: "session", Units: []source.SourceUnit{
|
||||
{ID: 40, Text: "first"}, {ID: 10, Text: ""}, {ID: 70, Text: "third"}, {ID: 20, Text: "last"},
|
||||
|
||||
@@ -21,10 +21,16 @@ func NewSourceRefOrder(doc *source.SourceDocument) SourceRefOrder {
|
||||
// NewSourceRefOrderForSource uses a borrowed whole-source index when provided.
|
||||
// The caller must supply an index for doc; otherwise one is built locally.
|
||||
func NewSourceRefOrderForSource(doc *source.SourceDocument, index *source.DocumentIndex) SourceRefOrder {
|
||||
return NewSourceRefOrderFromIndex(DocumentIndexForSource(doc, index))
|
||||
}
|
||||
|
||||
// DocumentIndexForSource borrows the supplied whole-source snapshot, or builds
|
||||
// one locally when omitted. A supplied index must match doc's unchanged ID/order.
|
||||
func DocumentIndexForSource(doc *source.SourceDocument, index *source.DocumentIndex) source.DocumentIndex {
|
||||
if index != nil {
|
||||
return NewSourceRefOrderFromIndex(*index)
|
||||
return *index
|
||||
}
|
||||
return NewSourceRefOrder(doc)
|
||||
return source.NewDocumentIndex(doc)
|
||||
}
|
||||
|
||||
// NewSourceRefOrderFromIndex captures source identity and unit positions from
|
||||
|
||||
@@ -34,7 +34,7 @@ func (v *Validator) ExecutionClass() contracts.ExecutionClass {
|
||||
}
|
||||
|
||||
func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationRequest[dnd.CombatTurnList]) (contracts.ValidationResult, error) {
|
||||
if err := Validate(req.Source, req.Value); err != nil {
|
||||
if err := validate(req.Source, req.SourceIndex, req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: false, ReasonCode: ReasonCode, Message: err.Error(), CorrectionGuidance: "Return combat turns in transcript order, without duplicate turns, using consistent contextual combatant names and evidence for each turn."}, nil
|
||||
}
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
@@ -43,10 +43,14 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
// Validate checks only invariants owned by normalized combat-turn output. A
|
||||
// shape or source-reference failure is deliberately deferred to its owner.
|
||||
func Validate(doc *source.SourceDocument, value dnd.CombatTurnList) error {
|
||||
return validate(doc, nil, value)
|
||||
}
|
||||
|
||||
func validate(doc *source.SourceDocument, sourceIndex *source.DocumentIndex, value dnd.CombatTurnList) error {
|
||||
if combatshape.Validate(value) != nil {
|
||||
return nil
|
||||
}
|
||||
index := source.NewDocumentIndex(doc)
|
||||
index := shared.DocumentIndexForSource(doc, sourceIndex)
|
||||
if !sourceRefsValid(index, value) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if req.Stage == string(pipeline.StageExtract) {
|
||||
coverage = shared.NewChunkCoverage(req.Chunk)
|
||||
}
|
||||
issues, corrections := sourceRefIssues(source.NewDocumentIndex(req.Source), req.Source, coverage, req.Stage == string(pipeline.StageExtract), req.Value)
|
||||
issues, corrections := sourceRefIssues(shared.DocumentIndexForSource(req.Source, req.SourceIndex), req.Source, coverage, req.Stage == string(pipeline.StageExtract), req.Value)
|
||||
if len(issues) == 0 {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if combatshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if enemyeventshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
if !allSourceRefsValid(index, req.Value) {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := enemyeventshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
var coverage shared.ChunkCoverage
|
||||
if req.Stage == string(pipeline.StageExtract) {
|
||||
coverage = shared.NewChunkCoverage(req.Chunk)
|
||||
|
||||
@@ -33,7 +33,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if enemyeventshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (v *Validator) ExecutionClass() contracts.ExecutionClass {
|
||||
}
|
||||
|
||||
func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationRequest[dnd.ItemOccurrenceList]) (contracts.ValidationResult, error) {
|
||||
if err := Validate(req.Source, req.Value); err != nil {
|
||||
if err := validate(req.Source, req.SourceIndex, req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: false, ReasonCode: ReasonCode, Message: err.Error(), CorrectionGuidance: "Return item occurrences in canonical transcript order, without duplicate occurrences, using consistent contextual item names and valid event transitions."}, nil
|
||||
}
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
@@ -41,10 +41,14 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
// Validate checks only invariants introduced by item-occurrence normalization.
|
||||
// Shape and source-reference failures remain owned by their earlier validators.
|
||||
func Validate(doc *source.SourceDocument, value dnd.ItemOccurrenceList) error {
|
||||
return validate(doc, nil, value)
|
||||
}
|
||||
|
||||
func validate(doc *source.SourceDocument, sourceIndex *source.DocumentIndex, value dnd.ItemOccurrenceList) error {
|
||||
if itemoccurrenceshape.Validate(value) != nil {
|
||||
return nil
|
||||
}
|
||||
index := source.NewDocumentIndex(doc)
|
||||
index := shared.DocumentIndexForSource(doc, sourceIndex)
|
||||
if !sourceRefsValid(index, value) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
@@ -37,7 +36,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if itemoccurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
var coverage shared.ChunkCoverage
|
||||
if req.Stage == string(pipeline.StageExtract) {
|
||||
coverage = shared.NewChunkCoverage(req.Chunk)
|
||||
|
||||
@@ -35,7 +35,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if itemoccurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
@@ -37,7 +36,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := itemshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
coverage := shared.NewChunkCoverage(req.Chunk)
|
||||
issues := make([]string, 0)
|
||||
var corrections diagnostics.Corrections
|
||||
|
||||
@@ -33,7 +33,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := itemshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if occurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
if !allSourceRefsValid(index, req.Value) {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
@@ -37,7 +36,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if occurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
coverage := shared.NewChunkCoverage(req.Chunk)
|
||||
issues := make([]string, 0)
|
||||
var corrections diagnostics.Corrections
|
||||
|
||||
@@ -33,7 +33,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if occurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
@@ -37,7 +36,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := locationshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
coverage := shared.NewChunkCoverage(req.Chunk)
|
||||
issues := make([]string, 0)
|
||||
var corrections diagnostics.Corrections
|
||||
|
||||
@@ -33,7 +33,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := locationshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if occurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
if !allSourceRefsValid(index, req.Value) {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
@@ -37,7 +36,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if occurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
coverage := shared.NewChunkCoverage(req.Chunk)
|
||||
issues := make([]string, 0)
|
||||
var corrections diagnostics.Corrections
|
||||
|
||||
@@ -33,7 +33,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if occurrenceshape.Validate(req.Value) != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
@@ -36,7 +35,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := npcshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
var coverage shared.ChunkCoverage
|
||||
if req.Stage == string(pipeline.StageExtract) {
|
||||
coverage = shared.NewChunkCoverage(req.Chunk)
|
||||
|
||||
@@ -32,7 +32,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := npcshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"go.maximumdirect.net/promptkit"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
nativecapture "gitea.maximumdirect.net/eric/notarius/internal/framework/capture"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
@@ -107,7 +106,7 @@ func validateRequest(ctx context.Context, req contracts.TypedValidationRequest[d
|
||||
if req.Chunk.SourceID != req.Source.ID {
|
||||
return contracts.LLMInputMaterial{}, dnd.SceneDescription{}, validatorErrorf("current chunk source ID %q does not match source %q", req.Chunk.SourceID, req.Source.ID)
|
||||
}
|
||||
if err := source.NewDocumentIndex(req.Source).ValidateRef(req.Chunk.Ref); err != nil {
|
||||
if err := shared.DocumentIndexForSource(req.Source, req.SourceIndex).ValidateRef(req.Chunk.Ref); err != nil {
|
||||
return contracts.LLMInputMaterial{}, dnd.SceneDescription{}, validatorErrorf("validate current chunk source range: %w", err)
|
||||
}
|
||||
if err := sceneShapeError(req.Value); err != nil {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -34,7 +35,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if len(scenefacts.Check(req.Value)) != 0 {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
if !sourceRefsValid(index, req.Value) {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if req.Stage == string(pipeline.StageExtract) && req.Chunk == nil {
|
||||
issues = append(issues, "current extraction chunk must not be nil")
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
for sceneIndex, scene := range req.Value.Scenes {
|
||||
prefix := fmt.Sprintf("scenes[%d]", sceneIndex)
|
||||
if err := index.ValidateRef(scene.SourceRef); err != nil {
|
||||
|
||||
@@ -42,7 +42,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if len(scenefacts.Check(req.Value)) != 0 {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
@@ -35,7 +34,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := spellshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
index := shared.DocumentIndexForSource(req.Source, req.SourceIndex)
|
||||
var coverage shared.ChunkCoverage
|
||||
if req.Stage == string(pipeline.StageExtract) {
|
||||
coverage = shared.NewChunkCoverage(req.Chunk)
|
||||
|
||||
@@ -32,7 +32,7 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if err := spellshape.Validate(req.Value); err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
resolver, err := shared.NewCitationResolver(req.Source)
|
||||
resolver, err := shared.NewCitationResolverForSource(req.Source, req.SourceIndex)
|
||||
if err != nil {
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user