Preserve completed diagnostics when pipeline lanes fail
This commit is contained in:
@@ -220,10 +220,10 @@ func (r *Runner) run(ctx context.Context, input RunInput) (output runState, err
|
||||
}
|
||||
}
|
||||
chunkResult, err := r.runChunkPlan(ctx, input, doc, sourceInput, sessionID)
|
||||
appendDiagnosticGroups(&output, chunkResult.diagnostics)
|
||||
if err != nil {
|
||||
return failOutput(output), err
|
||||
}
|
||||
appendDiagnosticGroups(&output, chunkResult.diagnostics)
|
||||
if debugRecorder.Enabled() {
|
||||
chunkDebugPayload := map[string]any{
|
||||
"cache_mode": input.pipeline.ChunkControls.Cache,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
@@ -98,14 +99,18 @@ func (r *Runner) runChunkPlan(ctx context.Context, input RunInput, doc *source.S
|
||||
produced, err := ExecuteOperation(ctx, operation, func(ctx context.Context) (contracts.PreparedOperation[source.ChunkPlan], error) {
|
||||
return chunker.PrepareChunk(ctx, contracts.ChunkInput{Source: doc, SourceInput: sourceInput.Clone(), SessionID: sessionID, References: CloneReferenceSet(target.references), LLMProfile: input.pipeline.Chunk.LLMProfile, Metadata: metadata})
|
||||
})
|
||||
var resultErr error
|
||||
result.diagnostics, resultErr = operationDiagnosticGroups(produced.Diagnostics, cacheDiagnostics, produced.Assessment, produced.Outcome, origin, nil)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("chunk source with %q: %w", chunker.Key(), err)
|
||||
return result, errors.Join(fmt.Errorf("chunk source with %q: %w", chunker.Key(), err), resultErr)
|
||||
}
|
||||
if resultErr != nil {
|
||||
return result, resultErr
|
||||
}
|
||||
plan, chunks, err := validateAndMaterializeChunkPlan(doc, produced.Value)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("materialize final chunk plan: %w", err)
|
||||
}
|
||||
result.plan, result.chunks, result.accepted, result.outcome = &plan, chunks, true, produced.Outcome
|
||||
result.diagnostics, err = operationDiagnosticGroups(produced.Diagnostics, cacheDiagnostics, produced.Assessment, produced.Outcome, origin, nil)
|
||||
return result, err
|
||||
return result, nil
|
||||
}
|
||||
|
||||
241
internal/framework/pipeline/runner_completed_diagnostics_test.go
Normal file
241
internal/framework/pipeline/runner_completed_diagnostics_test.go
Normal file
@@ -0,0 +1,241 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
func diagnosticResult(index int) erasedTypedResult {
|
||||
diagnostic := producerDiagnostic(fmt.Sprintf("chunk-%d", index), "completed")
|
||||
diagnostic.Disposition = contracts.DiagnosticDispositionWarning
|
||||
diagnostic.Category = contracts.DiagnosticCategoryDegradation
|
||||
return erasedTypedResult{Value: codecNotes{}, Diagnostics: []contracts.ProducerDiagnostic{diagnostic}}
|
||||
}
|
||||
|
||||
func diagnosticChunkIndexes(t *testing.T, output RunOutput) []int {
|
||||
t.Helper()
|
||||
if len(output.Diagnostics.Groups) != 1 {
|
||||
t.Fatalf("diagnostic groups = %#v, want one", output.Diagnostics.Groups)
|
||||
}
|
||||
group := output.Diagnostics.Groups[0]
|
||||
if group.OccurrenceCount != len(group.Samples) {
|
||||
t.Fatalf("diagnostic count = %d, samples = %#v", group.OccurrenceCount, group.Samples)
|
||||
}
|
||||
indexes := make([]int, 0, len(group.Samples))
|
||||
for _, sample := range group.Samples {
|
||||
if sample.ChunkIndex == nil {
|
||||
t.Fatalf("sample has no chunk index: %#v", sample)
|
||||
}
|
||||
indexes = append(indexes, *sample.ChunkIndex)
|
||||
}
|
||||
return indexes
|
||||
}
|
||||
|
||||
func TestRunnerRetainsDiagnosticWhenLaterChunkFails(t *testing.T) {
|
||||
prepared := preparedOrderedPipeline(t, 2, orderedLaneSpec{"notes", "notes"}, orderedLaneSpec{"later", "notes"})
|
||||
encoder := &countingOrderedOutput{}
|
||||
prepared.output = encoder
|
||||
failure := errors.New("extract failed")
|
||||
installExtractOperation(prepared, 0, func(_ context.Context, request contracts.ExtractionInput) (erasedTypedResult, error) {
|
||||
if request.Chunk.Index == 1 {
|
||||
return erasedTypedResult{}, failure
|
||||
}
|
||||
return diagnosticResult(request.Chunk.Index), nil
|
||||
})
|
||||
var laterCalls atomic.Int32
|
||||
prepared.Steps[1].lanes[0].typed.extract = func(context.Context, any, contracts.ExtractionInput, ExecutionContext[any]) (erasedTypedResult, error) {
|
||||
laterCalls.Add(1)
|
||||
return erasedTypedResult{}, nil
|
||||
}
|
||||
output, err := New().Run(context.Background(), RunInput{Prepared: prepared, RawInput: []byte("input"), Workers: 1})
|
||||
if !errors.Is(err, failure) {
|
||||
t.Fatalf("Run() error = %v, want extraction failure", err)
|
||||
}
|
||||
if got := diagnosticChunkIndexes(t, output); !reflect.DeepEqual(got, []int{0}) {
|
||||
t.Fatalf("diagnostic chunks = %v, want [0]", got)
|
||||
}
|
||||
if len(output.OutputFiles) != 0 || encoder.calls.Load() != 0 || laterCalls.Load() != 0 {
|
||||
t.Fatalf("incomplete lane published or continued: files=%v encoder=%d later=%d", output.OutputFiles, encoder.calls.Load(), laterCalls.Load())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerRetainsSparseReverseDiagnosticsAfterFailure(t *testing.T) {
|
||||
prepared := preparedOrderedPipeline(t, 3, orderedLaneSpec{"notes", "notes"})
|
||||
started, finished := make(chan int, 3), make(chan int, 3)
|
||||
releases := []chan struct{}{make(chan struct{}), make(chan struct{}), make(chan struct{})}
|
||||
failure := errors.New("extract failed")
|
||||
installExtractOperation(prepared, 0, func(ctx context.Context, request contracts.ExtractionInput) (erasedTypedResult, error) {
|
||||
index := request.Chunk.Index
|
||||
started <- index
|
||||
select {
|
||||
case <-releases[index]:
|
||||
case <-ctx.Done():
|
||||
return erasedTypedResult{}, ctx.Err()
|
||||
}
|
||||
defer func() { finished <- index }()
|
||||
if index == 1 {
|
||||
return diagnosticResult(index), failure
|
||||
}
|
||||
return diagnosticResult(index), nil
|
||||
})
|
||||
type result struct {
|
||||
output RunOutput
|
||||
err error
|
||||
}
|
||||
done := make(chan result, 1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
joined := false
|
||||
defer func() {
|
||||
cancel()
|
||||
if !joined {
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Error("runner did not stop")
|
||||
}
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
output, err := New().Run(ctx, RunInput{Prepared: prepared, RawInput: []byte("input"), Workers: 3})
|
||||
done <- result{output, err}
|
||||
}()
|
||||
wait := func(ch <-chan int) int {
|
||||
t.Helper()
|
||||
select {
|
||||
case value := <-ch:
|
||||
return value
|
||||
case result := <-done:
|
||||
joined = true
|
||||
t.Fatalf("runner stopped before handshake: %v", result.err)
|
||||
case <-ctx.Done():
|
||||
t.Fatal("worker handshake timed out")
|
||||
}
|
||||
return -1
|
||||
}
|
||||
seen := map[int]bool{}
|
||||
for range 3 {
|
||||
seen[wait(started)] = true
|
||||
}
|
||||
if len(seen) != 3 {
|
||||
t.Fatalf("started chunks = %v", seen)
|
||||
}
|
||||
for _, index := range []int{2, 0} {
|
||||
close(releases[index])
|
||||
if got := wait(finished); got != index {
|
||||
t.Fatalf("finished chunk = %d, want %d", got, index)
|
||||
}
|
||||
}
|
||||
close(releases[1])
|
||||
var got result
|
||||
select {
|
||||
case got = <-done:
|
||||
joined = true
|
||||
case <-ctx.Done():
|
||||
t.Fatal("runner did not finish")
|
||||
}
|
||||
if !errors.Is(got.err, failure) {
|
||||
t.Fatalf("Run() error = %v, want extraction failure", got.err)
|
||||
}
|
||||
if indexes := diagnosticChunkIndexes(t, got.output); !reflect.DeepEqual(indexes, []int{0, 1, 2}) {
|
||||
t.Fatalf("diagnostic chunks = %v, want [0 1 2]", indexes)
|
||||
}
|
||||
if len(got.output.OutputFiles) != 0 {
|
||||
t.Fatalf("incomplete lane published files: %#v", got.output.OutputFiles)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerRetainsMergeDiagnosticsWhenNormalizeFails(t *testing.T) {
|
||||
prepared := preparedOrderedPipeline(t, 1, orderedLaneSpec{"notes", "notes"})
|
||||
lane := &prepared.Steps[0].lanes[0]
|
||||
failure := errors.New("normalize failed")
|
||||
lane.typed.merge = func(context.Context, any, contracts.MergeInput[any], ExecutionContext[any]) (erasedTypedResult, error) {
|
||||
return erasedTypedResult{Value: codecNotes{}, Diagnostics: []contracts.ProducerDiagnostic{producerDiagnostic("merge", "completed")}}, nil
|
||||
}
|
||||
lane.typed.normalize = func(context.Context, any, contracts.NormalizeInput[any], ExecutionContext[any]) (erasedTypedResult, error) {
|
||||
return erasedTypedResult{Diagnostics: []contracts.ProducerDiagnostic{producerDiagnostic("normalize", "failed")}}, failure
|
||||
}
|
||||
encoder := &countingOrderedOutput{}
|
||||
prepared.output = encoder
|
||||
output, err := New().Run(context.Background(), RunInput{Prepared: prepared, RawInput: []byte("input")})
|
||||
if !errors.Is(err, failure) {
|
||||
t.Fatalf("Run() error = %v, want normalize failure", err)
|
||||
}
|
||||
if len(output.Diagnostics.Groups) != 2 || output.Diagnostics.Groups[0].Origin.Stage != contracts.DiagnosticOriginStageMerge || output.Diagnostics.Groups[1].Origin.Stage != contracts.DiagnosticOriginStageNormalize {
|
||||
t.Fatalf("diagnostic groups = %#v, want merge then normalize", output.Diagnostics.Groups)
|
||||
}
|
||||
if len(output.OutputFiles) != 0 || encoder.calls.Load() != 0 {
|
||||
t.Fatal("incomplete lane published output")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerDrainsCompletedDiagnosticsOnCancellation(t *testing.T) {
|
||||
prepared := preparedOrderedPipeline(t, 2, orderedLaneSpec{"notes", "notes"})
|
||||
started := make(chan int, 2)
|
||||
completed := make(chan struct{})
|
||||
installExtractOperation(prepared, 0, func(ctx context.Context, request contracts.ExtractionInput) (erasedTypedResult, error) {
|
||||
started <- request.Chunk.Index
|
||||
if request.Chunk.Index == 0 {
|
||||
defer close(completed)
|
||||
return diagnosticResult(0), nil
|
||||
}
|
||||
<-ctx.Done()
|
||||
return diagnosticResult(1), ctx.Err()
|
||||
})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
type result struct {
|
||||
output RunOutput
|
||||
err error
|
||||
}
|
||||
done := make(chan result, 1)
|
||||
joined := false
|
||||
defer func() {
|
||||
cancel()
|
||||
if !joined {
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Error("runner did not stop after cancellation")
|
||||
}
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
output, err := New().Run(ctx, RunInput{Prepared: prepared, RawInput: []byte("input"), Workers: 2})
|
||||
done <- result{output, err}
|
||||
}()
|
||||
for range 2 {
|
||||
select {
|
||||
case <-started:
|
||||
case <-ctx.Done():
|
||||
t.Fatal("workers did not start")
|
||||
}
|
||||
}
|
||||
select {
|
||||
case <-completed:
|
||||
case <-ctx.Done():
|
||||
t.Fatal("first worker did not complete")
|
||||
}
|
||||
cancel()
|
||||
var got result
|
||||
select {
|
||||
case got = <-done:
|
||||
joined = true
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("runner did not drain")
|
||||
}
|
||||
if !errors.Is(got.err, context.Canceled) {
|
||||
t.Fatalf("Run() error = %v, want cancellation", got.err)
|
||||
}
|
||||
if indexes := diagnosticChunkIndexes(t, got.output); !reflect.DeepEqual(indexes, []int{0, 1}) {
|
||||
t.Fatalf("diagnostic chunks = %v, want [0 1]", indexes)
|
||||
}
|
||||
if len(got.output.OutputFiles) != 0 {
|
||||
t.Fatal("cancelled lane published output")
|
||||
}
|
||||
}
|
||||
@@ -17,20 +17,19 @@ import (
|
||||
)
|
||||
|
||||
type laneExtractState struct {
|
||||
fallbackCount int
|
||||
index int
|
||||
prepared preparedLaneExecutor
|
||||
reuseEligible bool
|
||||
values []erasedExtractArtifact
|
||||
diagnostics []contracts.DiagnosticGroup
|
||||
results map[int]extractJobResult
|
||||
remaining int
|
||||
failed bool
|
||||
fallbackCount int
|
||||
index int
|
||||
prepared preparedLaneExecutor
|
||||
reuseEligible bool
|
||||
values []erasedExtractArtifact
|
||||
completedGroups map[int][]contracts.DiagnosticGroup
|
||||
results map[int]extractJobResult
|
||||
remaining int
|
||||
failed bool
|
||||
}
|
||||
|
||||
type finalizedExtractResults struct {
|
||||
accepted []erasedExtractArtifact
|
||||
diagnostics []contracts.DiagnosticGroup
|
||||
reuseEligible bool
|
||||
}
|
||||
|
||||
@@ -74,6 +73,14 @@ func (r *Runner) runLanes(parent context.Context, input RunInput, step PreparedP
|
||||
input: input, doc: doc,
|
||||
sourceInput: sourceInput, sessionID: sessionID, chunks: chunks, states: states,
|
||||
})
|
||||
// Coordinator-owned groups survive failed or incomplete lane continuations.
|
||||
for lane, state := range states {
|
||||
var groups []contracts.DiagnosticGroup
|
||||
for index := range chunks {
|
||||
groups = append(groups, state.completedGroups[index]...)
|
||||
}
|
||||
completedOutputs[lane].diagnosticGroups = append(groups, completedOutputs[lane].diagnosticGroups...)
|
||||
}
|
||||
mergeCompletedLanes(&output, completedOutputs)
|
||||
if err := selectRunError(parent, runErrors); err != nil {
|
||||
return output, err
|
||||
@@ -87,7 +94,7 @@ func initializeLaneStates(input RunInput, step PreparedPipelineStep, chunks []so
|
||||
if prepared.typed == nil {
|
||||
return nil, fmt.Errorf("typed lane %q executor is not prepared", prepared.resolved.ID)
|
||||
}
|
||||
states[i] = &laneExtractState{index: i, prepared: prepared, reuseEligible: !input.reuseIneligible && referenceTargetReuseEligible(input, prepared.resolved.ExtractReferences), remaining: len(chunks), results: make(map[int]extractJobResult, len(chunks))}
|
||||
states[i] = &laneExtractState{index: i, prepared: prepared, reuseEligible: !input.reuseIneligible && referenceTargetReuseEligible(input, prepared.resolved.ExtractReferences), remaining: len(chunks), results: make(map[int]extractJobResult, len(chunks)), completedGroups: make(map[int][]contracts.DiagnosticGroup)}
|
||||
}
|
||||
return states, nil
|
||||
}
|
||||
@@ -240,6 +247,7 @@ func (e *laneEngine) receiveResult(result laneJobResult) {
|
||||
func (e *laneEngine) handleExtractResult(result extractJobResult) {
|
||||
state := e.states[result.laneIndex]
|
||||
state.remaining--
|
||||
state.completedGroups[result.chunkIndex] = result.diagnostics
|
||||
if result.err != nil {
|
||||
state.failed = true
|
||||
e.runErrors = append(e.runErrors, orderedRunError{stage: 0, lane: state.index, chunk: result.chunkIndex, err: result.err})
|
||||
@@ -302,8 +310,12 @@ func (r *Runner) runExtractJob(ctx context.Context, input RunInput, doc *source.
|
||||
var cacheDiagnostics []contracts.ProducerDiagnostic
|
||||
operation.Cache = artifactProducerCache(input, typed, lane.ExtractExecutionClass, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageExtract, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Extract.Module}, doc, &chunk, &cacheDiagnostics)
|
||||
extracted, err := typed.extract(ctx, typed.extractor, contracts.ExtractionInput{Source: doc, SourceIndex: input.sourceIndex, Chunk: &chunk, SourceInput: target.sourceInput.Clone(), SessionID: sessionID, References: CloneReferenceSet(references), LLMProfile: lane.Extract.LLMProfile, Metadata: metadata}, operation)
|
||||
result.diagnostics, result.err = operationDiagnosticGroups(extracted.Diagnostics, cacheDiagnostics, extracted.Assessment, extracted.Outcome, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageExtract, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Extract.Module}, &chunk)
|
||||
if err != nil {
|
||||
result.err = fmt.Errorf("extract lane %q chunk %q: %w", lane.ID, chunk.ID, err)
|
||||
result.err = errors.Join(fmt.Errorf("extract lane %q chunk %q: %w", lane.ID, chunk.ID, err), result.err)
|
||||
return result
|
||||
}
|
||||
if result.err != nil {
|
||||
return result
|
||||
}
|
||||
value, outcome := extracted.Value, extracted.Outcome
|
||||
@@ -313,11 +325,6 @@ func (r *Runner) runExtractJob(ctx context.Context, input RunInput, doc *source.
|
||||
return result
|
||||
}
|
||||
capturedArtifact, result.outcome = stored, outcome
|
||||
result.diagnostics, err = operationDiagnosticGroups(extracted.Diagnostics, cacheDiagnostics, extracted.Assessment, outcome, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageExtract, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Extract.Module}, &chunk)
|
||||
if err != nil {
|
||||
result.err = err
|
||||
return result
|
||||
}
|
||||
result.value = erasedExtractArtifact{LaneID: lane.ID, ExtractorKey: lane.Extract.Module, SourceID: doc.ID, ChunkID: chunk.ID, ChunkIndex: chunk.Index, ChunkRef: chunk.Ref, Value: value, artifact: stored}
|
||||
result.outcome = outcome
|
||||
return result
|
||||
@@ -328,7 +335,6 @@ func finalizeLaneExtract(state *laneExtractState) {
|
||||
for index := 0; index < len(state.results); index++ {
|
||||
result := state.results[index]
|
||||
state.values = append(state.values, result.value)
|
||||
state.diagnostics = append(state.diagnostics, result.diagnostics...)
|
||||
if !result.outcome.ReuseEligible {
|
||||
state.reuseEligible = false
|
||||
}
|
||||
@@ -343,10 +349,8 @@ func (r *Runner) continueLane(ctx context.Context, input RunInput, doc *source.S
|
||||
local := laneOutput{runState: runState{RunOutput: RunOutput{FallbackCount: state.fallbackCount}}}
|
||||
results := finalizedExtractResults{
|
||||
accepted: state.values,
|
||||
diagnostics: state.diagnostics,
|
||||
reuseEligible: state.reuseEligible,
|
||||
}
|
||||
local.diagnosticGroups = append(local.diagnosticGroups, contracts.CloneDiagnosticCollection(contracts.DiagnosticCollection{Groups: results.diagnostics}).Groups...)
|
||||
if input.Debug != nil && input.Debug.Enabled() {
|
||||
if err := writeDebugTimed(input.Debug, path.Join("extract", fileio.EncodePathComponent(lane.ID), "input.json"), debugTimedEnvelope{Stage: string(StageExtract), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Extract.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"source": sourceCaptureProjection(input.sourceEvidence, doc), "chunks": debugSourceChunkEnvelopes(chunks), "metadata": input.Metadata}}); err != nil {
|
||||
return local, &laneRunError{stage: StageExtract, err: err}
|
||||
|
||||
@@ -12,7 +12,7 @@ func operationDiagnosticGroups(diagnostics, cacheDiagnostics []contracts.Produce
|
||||
}
|
||||
cacheGroups, err := promoteProducerDiagnostics(cacheDiagnostics, origin, chunk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return groups, err
|
||||
}
|
||||
groups = append(groups, cacheGroups...)
|
||||
if outcome.Disposition == contracts.ProducerFallback {
|
||||
@@ -32,7 +32,7 @@ func operationDiagnosticGroups(diagnostics, cacheDiagnostics []contracts.Produce
|
||||
validatorOrigin.ValidatorKey = finding.ValidatorName
|
||||
validatorGroups, err := promoteProducerDiagnostics(finding.Result.Diagnostics, validatorOrigin, chunk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return groups, err
|
||||
}
|
||||
groups = append(groups, validatorGroups...)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"time"
|
||||
@@ -107,8 +108,13 @@ func (r *Runner) runMergeStage(ctx context.Context, input RunInput, doc *source.
|
||||
var cacheDiagnostics []contracts.ProducerDiagnostic
|
||||
operation.Cache = artifactProducerCache(input, typed, lane.MergeExecutionClass, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageMerge, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Merge.Module}, doc, nil, &cacheDiagnostics)
|
||||
produced, err := typed.merge(ctx, typed.merger, contracts.MergeInput[any]{Source: doc, LaneID: lane.ID, ExtractOutputs: inputs, SourceInput: sourceInput.Clone(), SessionID: sessionID, References: CloneReferenceSet(references), LLMProfile: lane.Merge.LLMProfile, Metadata: metadata}, operation)
|
||||
diagnostics, diagnosticErr := operationDiagnosticGroups(produced.Diagnostics, cacheDiagnostics, produced.Assessment, produced.Outcome, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageMerge, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Merge.Module}, nil)
|
||||
appendDiagnosticGroups(output, diagnostics)
|
||||
if err != nil {
|
||||
return state, fmt.Errorf("merge lane %q: %w", lane.ID, err)
|
||||
return state, errors.Join(fmt.Errorf("merge lane %q: %w", lane.ID, err), diagnosticErr)
|
||||
}
|
||||
if diagnosticErr != nil {
|
||||
return state, diagnosticErr
|
||||
}
|
||||
value := produced.Value
|
||||
outcome = produced.Outcome
|
||||
@@ -116,11 +122,6 @@ func (r *Runner) runMergeStage(ctx context.Context, input RunInput, doc *source.
|
||||
if err != nil {
|
||||
return state, fmt.Errorf("encode merge lane %q: %w", lane.ID, err)
|
||||
}
|
||||
diagnostics, err := operationDiagnosticGroups(produced.Diagnostics, cacheDiagnostics, produced.Assessment, outcome, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageMerge, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Merge.Module}, nil)
|
||||
if err != nil {
|
||||
return state, err
|
||||
}
|
||||
appendDiagnosticGroups(output, diagnostics)
|
||||
if outcome.Disposition == contracts.ProducerFallback {
|
||||
output.FallbackCount++
|
||||
}
|
||||
@@ -163,8 +164,13 @@ func (r *Runner) runNormalizeStage(ctx context.Context, input RunInput, doc *sou
|
||||
var cacheDiagnostics []contracts.ProducerDiagnostic
|
||||
operation.Cache = artifactProducerCache(input, typed, lane.NormalizeExecutionClass, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageNormalize, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Normalize.Module}, doc, nil, &cacheDiagnostics)
|
||||
produced, err := typed.normalize(ctx, typed.normalizer, contracts.NormalizeInput[any]{Source: doc, LaneID: lane.ID, MergeOutput: contracts.MergeArtifact[any]{LaneID: merged.LaneID, MergerKey: merged.MergerKey, SourceID: merged.SourceID, Value: merged.Value}, SourceInput: sourceInput.Clone(), SessionID: sessionID, References: CloneReferenceSet(references), LLMProfile: lane.Normalize.LLMProfile, Metadata: metadata}, operation)
|
||||
diagnostics, diagnosticErr := operationDiagnosticGroups(produced.Diagnostics, cacheDiagnostics, produced.Assessment, produced.Outcome, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageNormalize, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Normalize.Module}, nil)
|
||||
appendDiagnosticGroups(output, diagnostics)
|
||||
if err != nil {
|
||||
return state, fmt.Errorf("normalize lane %q: %w", lane.ID, err)
|
||||
return state, errors.Join(fmt.Errorf("normalize lane %q: %w", lane.ID, err), diagnosticErr)
|
||||
}
|
||||
if diagnosticErr != nil {
|
||||
return state, diagnosticErr
|
||||
}
|
||||
value := produced.Value
|
||||
outcome = produced.Outcome
|
||||
@@ -172,11 +178,6 @@ func (r *Runner) runNormalizeStage(ctx context.Context, input RunInput, doc *sou
|
||||
if err != nil {
|
||||
return state, fmt.Errorf("encode normalize lane %q: %w", lane.ID, err)
|
||||
}
|
||||
diagnostics, err := operationDiagnosticGroups(produced.Diagnostics, cacheDiagnostics, produced.Assessment, outcome, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageNormalize, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Normalize.Module}, nil)
|
||||
if err != nil {
|
||||
return state, err
|
||||
}
|
||||
appendDiagnosticGroups(output, diagnostics)
|
||||
if outcome.Disposition == contracts.ProducerFallback {
|
||||
output.FallbackCount++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user