package pipeline import ( "errors" "fmt" "strings" "go.maximumdirect.net/promptkit" ) // NativeValidationError describes a completed native content check that did // not pass. It is distinct from a native operational error such as failure to // prepare or run validation. type NativeValidationError struct { Validation promptkit.ValidationResult } func (e *NativeValidationError) Error() string { if len(e.Validation.Errors) == 0 { return "native output did not satisfy its contract" } return fmt.Sprintf("native output did not satisfy its contract: %s", strings.Join(e.Validation.Errors, "; ")) } // CheckNativeResult preserves an actual native error and rejects an absent or // structurally unusable result before any domain interpretation takes place. func CheckNativeResult(result *promptkit.RunResult, err error) error { if err != nil { return err } if result == nil { return errors.New("native execution returned no result") } if result.Validation.Status == promptkit.ValidationFailed || !result.Validation.IsValid { validation := result.Validation validation.Errors = append([]string(nil), validation.Errors...) return &NativeValidationError{Validation: validation} } return nil }