Put the apple pieces in a large bowl with the brown sugar, vinegar, cinnamon, nutmeg and salt, and toss to combine.
Leave to macerate at room temperature for at least 30 minutes, tossing occasionally.
Strain the apples, reserving the liquid; you should have about 100 ml.
Melt the butter in a large, wide frying pan on a medium-high heat.
Add the strained apples and cook, tossing occasionally, for four to five minutes, until they begin to soften.
Pour in the reserved liquid and cook for a further three to four minutes, until the liquid reduces and a glossy caramel forms around the apples.
Stir in the miso and vanilla until evenly incorporated, then take off the heat.
Spread the filling over a tray or large plate, so it can cool quickly, then refrigerate until completely cold.
To assemble, lightly beat the egg with a generous pinch of salt and put the flour in a small dish.
Unroll one sheet of pastry, leaving it on the baking paper it comes with, and cut into 4 equal rectangles.
Keep the second sheet refrigerated while you assemble the first four pies.
Spoon about 60 g filling on one half of each pastry rectangle, leaving a 1.5 cm border around three outer edges surrounding the filling, then brush these borders lightly with egg.
Fold the uncovered half of pastry over the filling and gently press the three edges together.
Dip the tines of a fork in the flour, then use this to crimp all around the edges to seal.
Slide the four pies on their baking paper bases on to an oven tray and refrigerate while you repeat with the second pastry sheet and the rest of the filling on a second tray.
Refrigerate both trays for 20-30 minutes, until the pies are cold and firm.
Meanwhile, heat the oven to 200C (180C fan)/390F/gas mark 6.
Brush the tops of the pies with the remaining egg wash and sprinkle with demerara sugar.
Using the tip of a small, sharp knife, cut 3 slashes in the top of each pie, so the steam can escape, then bake for about 30 minutes, swapping the trays around halfway through cooking if necessary, until puffed and deeply golden.
Leave the pies on the trays for 10 minutes, then transfer to a rack.
Serve warm or at room temperature.
