Heat the butter in a heavy-based frying pan over a medium heat. Add the mushroom, onion and garlic and fry for 4-5 minutes, or until softened. Remove from the heat and drain the mixture in a colander.
Place half of the mushroom mixture in a food processor and pulse until finely chopped, but not a purée. Spoon into a large bowl and fold in the ricotta, mashed potato, cayenne pepper, tarragon and lemon juice. Chill in the fridge for two hours, or overnight preferably.
Preheat the oven to 200C/400F/Gas 6.
Roll the puff pastry out to a 3mm/⅛in thickness and using a 15cm/6in cutter, cut out eight circles.
Place four circles of puff pastry onto a baking tray and spoon some of the chilled mushroom mixture into the centre of each circle leaving a 2.5cm/1in border.
Cover each pastry circle with the remaining pastry circles and crimp the edges with a fork. Brush all over with the beaten egg. Bake in the oven for 20 minutes.
Meanwhile for the chutney, heat some oil in a frying pan over a medium heat and fry the onion and chilli for 4-5 minutes, or until softened.
Add the sugar and vinegar and bring to boil for 10-15 minutes. Season with salt and freshly ground black pepper, then fold in the gherkins