Promote native Notarius lane products
This commit is contained in:
37
internal/app/extract_fallback_test.go
Normal file
37
internal/app/extract_fallback_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/stage"
|
||||
)
|
||||
|
||||
func TestExtractionFallbackCountInExecutionResults(t *testing.T) {
|
||||
for _, reused := range []bool{false, true} {
|
||||
t.Run(map[bool]string{false: "executed", true: "reused"}[reused], func(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
var selected stage.Stage = resultStage{name: "extract", result: &stage.StageResult{Metadata: map[string]any{"completion": map[string]any{"fallback_count": 3}}}}
|
||||
if reused {
|
||||
store := &manifest.LocalStore{}
|
||||
seed := manifest.New(cfg.Session.SessionID, time.Now().UTC())
|
||||
seed.MarkStageSucceeded("extract", time.Now().UTC(), nil)
|
||||
seed.Stages["extract"].Metadata = map[string]any{"completion": map[string]any{"fallback_count": 3}}
|
||||
if err := store.Save(context.Background(), manifestPathFor(cfg), seed); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runs := 0
|
||||
selected = resumeCheckingStage{name: "extract", validation: stage.Resumable(), runs: &runs}
|
||||
}
|
||||
summary, err := executeStages(context.Background(), cfg, []stage.Stage{selected}, RunOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(summary.StageResults) != 1 || summary.StageResults[0].FallbackCount != 3 {
|
||||
t.Fatalf("stage results = %#v", summary.StageResults)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,11 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
|
||||
default:
|
||||
result.Outcome = "completed"
|
||||
}
|
||||
if selected.Name() == "extract" && (result.Outcome == "completed" || result.Outcome == "reused") {
|
||||
if record := runtime.manifest.Stages["extract"]; record != nil {
|
||||
result.FallbackCount = stage.ExtractionFallbackCount(record.Metadata)
|
||||
}
|
||||
}
|
||||
if outcome.executed {
|
||||
runtime.executed = append(runtime.executed, selected.Name())
|
||||
}
|
||||
@@ -332,6 +337,7 @@ func mapResultOutputs(stageName string, result *stage.StageResult, runID string)
|
||||
ProducerRunID: producerRunID,
|
||||
RemoteKey: ref.RemoteKey,
|
||||
Checksum: ref.Checksum,
|
||||
Size: ref.Size,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,11 @@ import (
|
||||
|
||||
// RunStageResult describes this invocation's work, independently of prior state.
|
||||
type RunStageResult struct {
|
||||
Name string `json:"name"`
|
||||
Attempted bool `json:"attempted"`
|
||||
Outcome string `json:"outcome"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Attempted bool `json:"attempted"`
|
||||
Outcome string `json:"outcome"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
FallbackCount int `json:"fallback_count,omitempty"`
|
||||
}
|
||||
|
||||
// RunArtifact identifies durable output evidence without exposing manifest internals.
|
||||
|
||||
Reference in New Issue
Block a user