Share a source index across each pipeline run

This commit is contained in:
2026-11-26 01:34:51 +00:00
parent 4b03a439cb
commit 6345727601
10 changed files with 127 additions and 13 deletions

View File

@@ -9,7 +9,6 @@ import (
"path"
"path/filepath"
"strings"
"sync"
"time"
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
@@ -66,8 +65,8 @@ type RunInput struct {
stepID string
references map[referenceTargetKey]contracts.ReferenceSet
referenceReuseEligibility map[referenceTargetKey]bool
// Shared by operation decoders, but built only when a cache hit needs it.
cacheSourceIndex func() source.DocumentIndex
// Shared read-only by extraction jobs and cache decoders for this run.
sourceIndex *source.DocumentIndex
}
type RunOutput struct {
@@ -168,9 +167,8 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
if err := source.ValidateDocument(doc); err != nil {
return failOutput(output), fmt.Errorf("validate source document: %w", err)
}
input.cacheSourceIndex = sync.OnceValue(func() source.DocumentIndex {
return source.NewDocumentIndex(doc)
})
index := source.NewDocumentIndex(doc)
input.sourceIndex = &index
if err := writeDebugTimed(debugRecorder, "source/output.json", debugTimedEnvelope{
Stage: "source",