Report completed runs through native presentation and preserve failure outcomes
This commit is contained in:
@@ -12,6 +12,21 @@ import (
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
// SelectionError identifies an absent configured native resource. Callers can
|
||||
// distinguish this invalid selection from unavailable inspection or cancellation
|
||||
// without inspecting diagnostic text or the kit's private lookup causes.
|
||||
type SelectionError struct{ Cause error }
|
||||
|
||||
func (err *SelectionError) Error() string { return err.Cause.Error() }
|
||||
func (err *SelectionError) Unwrap() error { return err.Cause }
|
||||
|
||||
func resourceFinding(err error) error {
|
||||
if !errors.Is(err, context.Canceled) && !errors.Is(err, context.DeadlineExceeded) && (errors.Is(err, promptkit.ErrPromptNotFound) || errors.Is(err, promptkit.ErrProfileNotFound)) {
|
||||
return &SelectionError{Cause: err}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// RequiresEngine reports selected model work, including nested validators.
|
||||
// Deterministic pipelines need no engine merely to validate their composition.
|
||||
func RequiresEngine(resolved pipeline.ResolvedPipeline) bool {
|
||||
@@ -69,7 +84,7 @@ func Validate(ctx context.Context, resolved pipeline.ResolvedPipeline, catalog p
|
||||
}
|
||||
if profile != "" {
|
||||
if _, err := engine.InspectProfile(ctx, profile); err != nil {
|
||||
findings = append(findings, fmt.Errorf("%s profile %q: %w", scope, profile, err))
|
||||
findings = append(findings, resourceFinding(fmt.Errorf("%s profile %q: %w", scope, profile, err)))
|
||||
}
|
||||
}
|
||||
for _, id := range prompts {
|
||||
@@ -78,7 +93,7 @@ func Validate(ctx context.Context, resolved pipeline.ResolvedPipeline, catalog p
|
||||
}
|
||||
prompt, err := engine.InspectPrompt(ctx, id)
|
||||
if err != nil {
|
||||
findings = append(findings, fmt.Errorf("%s prompt %q: %w", scope, id, err))
|
||||
findings = append(findings, resourceFinding(fmt.Errorf("%s prompt %q: %w", scope, id, err)))
|
||||
continue
|
||||
}
|
||||
if profile != "" {
|
||||
@@ -90,7 +105,7 @@ func Validate(ctx context.Context, resolved pipeline.ResolvedPipeline, catalog p
|
||||
continue
|
||||
}
|
||||
if _, err := engine.InspectProfile(ctx, *prompt.DefaultProfileID); err != nil {
|
||||
findings = append(findings, fmt.Errorf("%s prompt %q default profile %q: %w", scope, id, *prompt.DefaultProfileID, err))
|
||||
findings = append(findings, resourceFinding(fmt.Errorf("%s prompt %q default profile %q: %w", scope, id, *prompt.DefaultProfileID, err)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user