Use native prepared previews and correct diagnostic references

This commit is contained in:
2026-11-26 04:08:40 +00:00
parent fcd7cffd18
commit b790cc73ca
9 changed files with 81 additions and 107 deletions

View File

@@ -122,11 +122,9 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
if err != nil {
return nil, fmt.Errorf("trim: resolve run-local bounds output path: %w", err)
}
boundsStdoutLogPath := filepath.Join(paths.LogsDir, "scriptorium.bounds.stdout.log")
boundsStderrLogPath := filepath.Join(paths.LogsDir, "scriptorium.bounds.stderr.log")
boundsGeneratedConfigPath := filepath.Join(paths.ConfigDir, "scriptorium.bounds.generated.yml")
if runLayout.Enabled {
boundsStdoutLogPath = filepath.Join(runLayout.LogsDir, "scriptorium.bounds.stdout.log")
boundsStderrLogPath = filepath.Join(runLayout.LogsDir, "scriptorium.bounds.stderr.log")
boundsGeneratedConfigPath = filepath.Join(runLayout.ConfigDir, "scriptorium.bounds.generated.yml")
}
@@ -159,11 +157,9 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
if err != nil {
return nil, fmt.Errorf("trim: resolve run-local bounds render output path: %w", err)
}
renderStdoutLogPath := filepath.Join(paths.LogsDir, "scriptorium.bounds.render.stdout.log")
renderStderrLogPath := filepath.Join(paths.LogsDir, "scriptorium.bounds.render.stderr.log")
renderGeneratedConfigPath := filepath.Join(paths.ConfigDir, "scriptorium.bounds.render.generated.yml")
if runLayout.Enabled {
renderStdoutLogPath = filepath.Join(runLayout.LogsDir, "scriptorium.bounds.render.stdout.log")
renderStderrLogPath = filepath.Join(runLayout.LogsDir, "scriptorium.bounds.render.stderr.log")
renderGeneratedConfigPath = filepath.Join(runLayout.ConfigDir, "scriptorium.bounds.render.generated.yml")
}
@@ -177,7 +173,6 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
InputPaths: inputPaths,
Vars: vars,
OutputPath: renderOutputPath,
StdoutLogPath: renderStdoutLogPath,
StderrLogPath: renderStderrLogPath,
GeneratedConfigPath: renderGeneratedConfigPath,
Timeout: boundsTimeout,
@@ -200,10 +195,9 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
return nil, fmt.Errorf("trim: bounds render diagnostics %q invalid json: %w", finalRenderOutputPath, err)
}
logPaths = append(logPaths, renderStdoutLogPath, renderStderrLogPath)
logPaths = append(logPaths, renderStderrLogPath)
generatedConfigs = append(generatedConfigs, renderGeneratedConfigPath)
metadata["bounds_render_output_path"] = finalRenderOutputPath
metadata["bounds_render_stdout_log_path"] = renderStdoutLogPath
metadata["bounds_render_stderr_log_path"] = renderStderrLogPath
metadata["bounds_render_generated_config_path"] = renderGeneratedConfigPath
metadata["bounds_render_adapter_exit_code"] = renderRes.ExitCode
@@ -223,7 +217,6 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
InputPaths: inputPaths,
Vars: vars,
OutputPath: boundsOutputPath,
StdoutLogPath: boundsStdoutLogPath,
StderrLogPath: boundsStderrLogPath,
GeneratedConfigPath: boundsGeneratedConfigPath,
Timeout: boundsTimeout,
@@ -233,11 +226,10 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
if boundsRunErr != nil {
if boundsRes.ValidationFailed {
return nil, fmt.Errorf(
"trim: scriptorium bounds validation failed (prompt_id=%q, output_path=%q, exit_code=%d, stdout_log=%q, stderr_log=%q): %w",
"trim: scriptorium bounds validation failed (prompt_id=%q, output_path=%q, exit_code=%d, stderr_log=%q): %w",
boundsReq.PromptID,
boundsReq.OutputPath,
boundsRes.ExitCode,
coalesceString(boundsRes.StdoutLogPath, boundsReq.StdoutLogPath),
coalesceString(boundsRes.StderrLogPath, boundsReq.StderrLogPath),
boundsRunErr,
)
@@ -273,7 +265,7 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
trimAction = "trim"
}
logPaths = append(logPaths, boundsStdoutLogPath, boundsStderrLogPath)
logPaths = append(logPaths, boundsStderrLogPath)
generatedConfigs = append(generatedConfigs, boundsGeneratedConfigPath)
metadata["bounds_confidence"] = boundsPayload.Confidence
metadata["trim_action"] = trimAction
@@ -282,7 +274,6 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
metadata["warnings"] = boundsPayload.Warnings
metadata["keep_selector"] = keepSelector
metadata["run_bounds_output_path"] = finalBoundsOutputPath
metadata["bounds_stdout_log_path"] = boundsStdoutLogPath
metadata["bounds_stderr_log_path"] = boundsStderrLogPath
metadata["bounds_generated_config_path"] = boundsGeneratedConfigPath
metadata["bounds_adapter_exit_code"] = boundsRes.ExitCode
@@ -292,7 +283,6 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
metadata["bounds_adapter_profile_id"] = boundsRes.ProfileID
metadata["bounds_adapter_output_path"] = boundsRes.OutputPath
metadata["bounds_adapter_generated_config"] = boundsRes.GeneratedConfigPath
metadata["bounds_adapter_stdout_log_path"] = boundsRes.StdoutLogPath
metadata["bounds_adapter_stderr_log_path"] = boundsRes.StderrLogPath
if boundsRes.Metadata != nil {
metadata["bounds_adapter_metadata"] = boundsRes.Metadata