Place the unpeeled potatoes in a large pot, cover with cold water, add a pinch of salt, and simmer gently until a knife slides through the centers, about 35–45 minutes.
Drain the potatoes, let them steam-dry for 3 minutes, peel while warm, then pass them through a potato ricer onto a clean work surface.
Spread the riced potato into a thin layer and let it cool until warm, not hot, so the egg will not scramble.
Sprinkle the potato with salt, drizzle over the beaten egg, then scatter most of the flour over the top.
Fold and press the mixture together with a bench scraper or light hands, adding only enough remaining flour to form a soft dough; do not knead hard.
Divide the dough into 4 pieces, roll each piece into a rope about 2 cm / ¾ in thick, then cut into 2.5 cm / 1 in pillows.
Roll each pillow over a gnocchi board or fork to make ridges, then place on a floured tray in a single layer.
Make the pesto by blending basil, 30 g / 1 oz pine nuts, Parmesan, Pecorino, garlic, lemon zest, and olive oil until glossy but still fresh and green.
Toast the remaining 20 g / 0.7 oz pine nuts in a dry pan over medium-low heat until golden and fragrant, then set aside.
Boil a large pot of salted water, cook the gnocchi in batches, and lift them out with a slotted spoon 20–30 seconds after they float.
Loosen the pesto in a wide bowl with a splash of hot cooking water, add the gnocchi, and toss gently off the heat until coated.
Plate immediately with toasted pine nuts, extra Parmesan, basil leaves, and a thin drizzle of olive oil.