Prepare normalized processing plans and fixed chunks

This commit is contained in:
2026-11-27 01:15:40 +00:00
parent e761512c1c
commit 2dc057b97e
19 changed files with 315 additions and 260 deletions

View File

@@ -81,7 +81,7 @@ func loadProcessInputs(ctx context.Context, input processInput, mode commandkit.
// preparedProcess groups the output resources and the facts needed for reports.
type preparedProcess struct {
Prepared *preflight.Prepared
Prepared *preparedOutput
RunID string
Started time.Time
}
@@ -127,17 +127,17 @@ func prepareProcess(ctx context.Context, input processInput, loaded *processInpu
return renderReportBundle(processreport.Failed(failedSnapshot, primary, "initialization", failures))
}
}
var debug *preflight.DebugInput
var debug *debugInput
var warnings []error
if input.Debug.Value {
var effective bytes.Buffer
if err := loaded.Configuration.WriteEffective(&effective); err != nil {
warnings = append(warnings, err)
}
debug = &preflight.DebugInput{WorkDir: cfg.Diagnostics.WorkDir, RunID: runID, EffectiveConfig: effective.Bytes(), Metadata: diagnostics.InvocationMetadata{Operation: "process", TranscriptPath: input.Transcript, OutputPath: input.Output.Value, Overlay: input.Overlay.Value, ConfigVersion: &cfg.Version, RunID: runID, StartedAt: started}}
debug = &debugInput{WorkDir: cfg.Diagnostics.WorkDir, RunID: runID, EffectiveConfig: effective.Bytes(), Metadata: diagnostics.InvocationMetadata{Operation: "process", TranscriptPath: input.Transcript, OutputPath: input.Output.Value, Overlay: input.Overlay.Value, ConfigVersion: &cfg.Version, RunID: runID, StartedAt: started}}
}
checkedBackends := make(map[string]struct{})
prepared, err := preflight.Prepare(ctx, preflight.Input{InspectProfile: func(ctx context.Context, id string) error {
inspectProfile := func(ctx context.Context, id string) error {
profile, err := loaded.Runtime.Engine.InspectProfile(ctx, id)
if errors.Is(err, pk.ErrProfileNotFound) {
return &preflight.SelectionError{Cause: err}
@@ -157,7 +157,12 @@ func prepareProcess(ctx context.Context, input processInput, loaded *processInpu
checkedBackends[backend] = struct{}{}
}
return err
}, Config: cfg, Transcript: loaded.Source, Output: diagnostics.OutputSelection{InputTranscriptPath: input.Transcript, TranscriptPath: input.Output.Value, ReportDir: reportDir, ReportingEnabled: cfg.Reporting.Enabled, ProtectedPaths: loaded.ProtectedPaths, Stdout: stdout}, InitialReports: initial, FailedReports: failed, Debug: debug})
}
plan, err := preflight.BuildPlan(ctx, cfg, loaded.Source, inspectProfile)
if err != nil {
return nil, err
}
prepared, err := prepareOutput(ctx, plan, diagnostics.OutputSelection{InputTranscriptPath: input.Transcript, TranscriptPath: input.Output.Value, ReportDir: reportDir, ReportingEnabled: cfg.Reporting.Enabled, ProtectedPaths: loaded.ProtectedPaths, Stdout: stdout}, initial, failed, debug)
if err != nil {
return nil, err
}