Heat butter in a frying pan and fry mushrooms, onion, and garlic for 5 minutes until soft.
Drain the mixture in a colander.
Pulse half the mixture in a food processor until finely chopped.
Fold chopped mixture, ricotta, potato, cayenne, tarragon, and lemon juice into a bowl.
Chill the filling in the fridge for at least two hours or overnight.
Preheat the oven to 200°C.
Roll puff pastry to 3mm thickness and cut into eight 15cm circles.
Place four circles on a tray and spoon filling onto centers, leaving a 2.5cm border.
Top with remaining circles, crimp edges with a fork, and brush with beaten egg.
Bake the pastries for 20 minutes.
Fry red onion and chilli in oil for 5 minutes until softened.
Add sugar and vinegar, then boil for 15 minutes before folding in gherkins and seasoning.
Serve the baked pastries alongside the warm chutney.