Pat the shrimp very dry with paper towels. Toss with the salt and 1 tsp cornstarch and set aside while you prep the aromatics. Mince the garlic, ginger, shallots and chilies finely; a small food processor is fine for this.
Stir the ketchup, sugar, vinegar, soy sauce and water together in a small bowl so the sauce is ready to pour in one go.
Heat 1 tbsp of the oil in a wok or wide skillet over high heat until it shimmers. Add the shrimp in a single layer and sear for about 60 seconds per side, until pink on the outside but not fully cooked through in the thickest part. Transfer to a plate. They finish cooking in the sauce.
Lower the heat to medium and add the remaining 1/2 tbsp oil. Add the garlic, ginger, shallots and chilies and fry, stirring, for 2 to 3 minutes until soft and fragrant with no raw garlic smell. Stir in the sambal and soybean paste and fry for another 30 seconds.
Pour in the ketchup mixture and bring to a simmer. Let it bubble for 1 minute, then taste. It should be sweet, sour and hot in roughly equal measure. Adjust with a pinch more sugar or a splash more vinegar.
Stir the cornstarch slurry, then pour it in while stirring. Simmer for 30 seconds until the sauce is glossy and coats a spoon.
Turn the heat to low. Pour the beaten egg in a thin stream across the surface of the sauce and wait 15 seconds without stirring, then fold gently two or three times so the egg sets in soft ribbons rather than dissolving into the sauce.
Return the shrimp and any juices to the pan and toss for about 1 minute until the shrimp are just cooked through and coated. Scatter with scallions and cilantro and serve right away with steamed rice or mantou buns for the sauce.