Preheat the oven to 200°C, fan 180°C, gas 6. Set aside 125g pastry for making the lid. On a lightly floured surface, roll out the remaining pastry to the thickness of a £1 coin.
Line a 23cm springform cake tin with the pastry, leaving a little hanging over the edge. Prick the base all over with a fork, then line the tin with baking parchment and fill with baking beans or uncooked rice. Chill for at least 20 minutes, until firm to the touch.
Place the tin on a baking tray and bake for 15 minutes. Remove the beans or rice and parchment, then return the tin to the oven for a further 5–8 minutes, until golden. Set aside to cool slightly. Trim off any excess pastry with a small, sharp knife and sprinkle with the semolina to absorb any excess moisture.
Meanwhile, boil the potatoes for 2–3 minutes. Add the onions to the pan and simmer for a further 2–3 minutes, until both the potatoes and onions are just tender. Drain well and place in a large bowl.
Melt 25g butter in a saucepan, then add the flour and mix well to form a paste. Gradually add the milk, whisking continuously until smooth and thick. Pour the sauce over the potatoes and onions, season with salt and freshly ground black pepper and mix together.
Fry the apple slices in the remaining 25g butter until just starting to colour. Sprinkle over the muscovado sugar and fry for a further minute to melt the sugar and caramelise the apples.
Arrange the apples in an even layer in the pastry case. Spoon in half the potato and onion mixture, then sprinkle over half the sage and half the ham, and season with salt and freshly ground black pepper. Repeat until all the ingredients have been used, then pour over the cider, ensuring it doesn’t bubble over the sides of the pie.
Roll out the reserved pastry to make a lid, setting aside a piece to make leaves. Brush the edges of the pastry case with egg, place the lid on top and pinch the edges together to seal. Cut a cross in the centre, decorate with the pastry leaves and brush with beaten egg.
Bake for 1 hour, until the top is crisp and golden. Set aside to cool for 10–15 minutes before removing from the tin. Cut into wedges to serve.