Publish outputs to checked destinations and preserve failure evidence

This commit is contained in:
2026-11-16 03:52:35 +00:00
parent cea7e44232
commit b63c8af467
11 changed files with 656 additions and 336 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"crypto/rand"
"encoding/hex"
"errors"
"fmt"
"io"
"path/filepath"
@@ -43,7 +44,13 @@ func loadProcessInputs(ctx context.Context, input processInput, mode commandkit.
if err != nil {
return nil, err
}
if err := ctx.Err(); err != nil {
return nil, err
}
raw, err := coreio.ReadRequiredFile(input.Transcript, "transcript")
if ctx.Err() != nil {
return nil, errors.Join(err, ctx.Err())
}
if err != nil {
return nil, err
}
@@ -79,7 +86,10 @@ func prepareProcess(ctx context.Context, input processInput, loaded *processInpu
if cfg.Reporting.Enabled {
reportDir = cfg.Reporting.StdoutDir
if input.Output.Value != "" && !reportDirSet {
reportDir = filepath.Dir(input.Output.Value)
reportDir, _ = filepath.Split(input.Output.Value)
if reportDir == "" {
reportDir = "."
}
}
}
runID, err := generateRunID()
@@ -88,7 +98,7 @@ func prepareProcess(ctx context.Context, input processInput, loaded *processInpu
}
started := time.Now().UTC()
var initial diagnostics.ReportBundle
var failed func(error, []diagnostics.FileFailure) diagnostics.ReportBundle
var failed diagnostics.ReportRenderer
if cfg.Reporting.Enabled {
snapshot := reporting.Snapshot{RunID: runID, Status: reporting.StatusInProgress, StartedAt: started, TranscriptPath: input.Transcript, OutputPath: input.Output.Value}
for index, item := range cfg.Pipeline.Stages {
@@ -98,15 +108,14 @@ func prepareProcess(ctx context.Context, input processInput, loaded *processInpu
if err != nil {
return nil, err
}
failed = func(primary error, failures []diagnostics.FileFailure) diagnostics.ReportBundle {
failed = func(primary error, failures []diagnostics.FileFailure) (diagnostics.ReportBundle, error) {
failedSnapshot := snapshot
completed := time.Now().UTC()
failedSnapshot.CompletedAt = &completed
if primary != nil {
failedSnapshot.Errors = []reporting.ErrorRecord{{Scope: "run", Phase: "initialization", Reason: "canceled", Message: "Processing was canceled."}}
}
bundle, _ := renderReportBundle(failedOutputSnapshot(failedSnapshot, failures))
return bundle
return renderReportBundle(failedOutputSnapshot(failedSnapshot, failures))
}
}
var debug *preflight.DebugInput