Preheat your oven to 400°F (200°C).
Heat the olive oil in a large skillet over medium heat. Add the diced onion and sauté until translucent, about 5 minutes.
Add the minced garlic and chopped mushrooms to the skillet. Cook until the mushrooms release their moisture and begin to brown, about 8-10 minutes.
Stir in the chopped pecans and rosemary, then season with salt and pepper. Cook for an additional 2-3 minutes until well combined, then remove from heat and let cool.
Roll out the puff pastry on a floured surface to smooth it out slightly, then place it on a parchment-lined baking sheet.
Spoon the cooled mushroom mixture down the center of the puff pastry, shaping it into a log. Fold the pastry over the filling and seal the edges by pinching.
Brush the top of the pastry with the beaten egg to create a golden glaze. Optional: use a knife to make shallow slits on top for decoration.
Bake in the preheated oven for 25-30 minutes, or until the pastry is puffed and golden brown.
Let the Wellington rest for 5-10 minutes before slicing.