Preserve operational timeouts when selecting run failures
This commit is contained in:
@@ -25,6 +25,10 @@ execution abstraction. This document records findings, not implemented fixes.
|
|||||||
|
|
||||||
## Finding 1: Retain Genuine Native Timeouts During Concurrent Error Selection
|
## Finding 1: Retain Genuine Native Timeouts During Concurrent Error Selection
|
||||||
|
|
||||||
|
**Status: Complete.** Operational deadlines participate in linear minimum
|
||||||
|
selection; sibling cancellation noise and authoritative caller cancellation are
|
||||||
|
preserved. Pipeline tests and race checks pass.
|
||||||
|
|
||||||
Priority: P2. Relevant stages: 10, 25, 37, and 46.
|
Priority: P2. Relevant stages: 10, 25, 37, and 46.
|
||||||
|
|
||||||
### Evidence And Impact
|
### Evidence And Impact
|
||||||
|
|||||||
25
internal/framework/pipeline/error_selection_test.go
Normal file
25
internal/framework/pipeline/error_selection_test.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package pipeline
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"go.maximumdirect.net/promptkit"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRunErrorSelectionPreservesOperationalDeadlines(t *testing.T) {
|
||||||
|
for _, first := range []error{context.DeadlineExceeded, fmt.Errorf("%w: %w", promptkit.ErrOperationTimeout, context.DeadlineExceeded)} {
|
||||||
|
later := errors.New("later failure")
|
||||||
|
got := selectRunError(context.Background(), []orderedRunError{{lane: 1, err: later}, {lane: 0, err: first}, {lane: -1, err: context.Canceled}})
|
||||||
|
if got != first {
|
||||||
|
t.Fatalf("selected %v, want %v", got, first)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
cancel()
|
||||||
|
if got := selectRunError(ctx, []orderedRunError{{err: errors.New("operation")}}); got != context.Canceled {
|
||||||
|
t.Fatal(got)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.maximumdirect.net/promptkit"
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/core/fileio"
|
"gitea.maximumdirect.net/eric/notarius/internal/core/fileio"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||||
@@ -404,28 +406,27 @@ func selectRunError(parent context.Context, values []orderedRunError) error {
|
|||||||
}
|
}
|
||||||
hasReal := false
|
hasReal := false
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
if !errors.Is(value.err, context.Canceled) && !errors.Is(value.err, context.DeadlineExceeded) {
|
if !isSiblingCancellation(value.err) {
|
||||||
hasReal = true
|
hasReal = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filtered := values[:0]
|
var best *orderedRunError
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
if hasReal && (errors.Is(value.err, context.Canceled) || errors.Is(value.err, context.DeadlineExceeded)) {
|
if hasReal && isSiblingCancellation(value.err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
filtered = append(filtered, value)
|
if best == nil || value.stage < best.stage || value.stage == best.stage && (value.lane < best.lane || value.lane == best.lane && value.chunk < best.chunk) {
|
||||||
|
best = &value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sort.SliceStable(filtered, func(i, j int) bool {
|
return best.err
|
||||||
if filtered[i].stage != filtered[j].stage {
|
}
|
||||||
return filtered[i].stage < filtered[j].stage
|
|
||||||
}
|
// The runner cancels siblings, but does not give them a separate deadline.
|
||||||
if filtered[i].lane != filtered[j].lane {
|
// Deadline-shaped provider/native failures remain real when the caller is active.
|
||||||
return filtered[i].lane < filtered[j].lane
|
func isSiblingCancellation(err error) bool {
|
||||||
}
|
return errors.Is(err, context.Canceled) && !errors.Is(err, promptkit.ErrOperationTimeout)
|
||||||
return filtered[i].chunk < filtered[j].chunk
|
|
||||||
})
|
|
||||||
return filtered[0].err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func mergeLaneOutput(dst *RunOutput, src RunOutput) {
|
func mergeLaneOutput(dst *RunOutput, src RunOutput) {
|
||||||
|
|||||||
Reference in New Issue
Block a user