To make the pastry, process the flour, custard powder, icing sugar and butter in a food processor until the mixture resembles fine breadcrumbs. Add egg yolk and 1 tablespoon chilled water and process until dough just comes together. Shape into a disc. Cover with plastic wrap and place in the fridge for 30 mins to rest.
Preheat oven to 200C. Reserve one-third of the dough. Roll the remaining dough on a floured surface to a 5mm-thick disc. Line base and side of a 22cm-round fluted tart pan with removable base with pastry. Trim edge, reserving excess pastry. Place in fridge for 15 mins to rest.
Meanwhile, to make the caramel sauce, place sugar in a saucepan over medium heat. Cook, stirring, for 5-7 mins or until sugar dissolves and caramelises. Remove from heat. Add cream, butter and salt. Return to a low heat. Cook, stirring, for 3-4 mins or until the caramel boils and thickens. Set aside to cool.
Combine apple and lemon juice in a bowl. Add brown sugar, flour, cinnamon, allspice and nutmeg. Arrange one-third of the apple mixture over the pastry case. Drizzle with 1 1/2 tablespoons of the caramel sauce. Continue layering with half the remaining apple and drizzle with 1 1/2 tablespoons caramel sauce. Top with remaining apple.
Roll reserved pastry on a floured surface to a 3mm-thick disc. Cut into 3cm x 22cm strips. Arrange strips, cutting to fit, in a lattice pattern over the apple mixture. Place in the fridge for 15 mins to chill.
Place pie on a baking tray. Brush pastry with egg and sprinkle with raw sugar. Bake for 30 mins or until golden. Set aside to cool slightly. Serve with vanilla ice-cream and remaining caramel sauce.