Make the dough: Put the flour in a food processor. With the motor running, pour in the beaten eggs and pulse until the dough gathers around the blades. Turn out the dough and pat into a rectangle. Wrap in plastic wrap and set aside 30 minutes at room temperature.
Meanwhile, make the filling: Pulse the leeks, bacon and carrots in a food processor until finely chopped. Transfer to a skillet; add 1 cup water and cook over medium heat, stirring, until evaporated, about 7 minutes. Add the nutmeg, 1/2 teaspoon salt and 1/4 teaspoon pepper. Increase the heat to medium high; cook until the vegetables start to brown, about 4 minutes. Transfer to a bowl, stir in the parsley and let cool. Mix in the ricotta, gruyere and egg yolks; cover and chill until ready to make the ravioli.
Dust the dough with flour and cut into 6 pieces. Pat 1 piece of dough into a 4-by-2-inch rectangle (keep the rest covered with plastic wrap). Feed a wide side through a pasta machine at the thickest setting. Continue to feed the dough through the machine, reducing the thickness setting each time, until the pasta is about /16 inch thick. Lay the pasta sheet on cornmeal-dusted parchment paper and cover with a kitchen towel. Repeat with the remaining dough.
Line a baking sheet with parchment and dust with cornmeal. Uncover 1 sheet of dough; lay out with a long side facing you (keep the remaining sheets covered). Place small mounds of filling, about 2 inches apart, in a line along the bottom edge. Brush the top half of the sheet with water and fold the dough over to cover the filling; press around each mound to seal. Cut into squares with a pizza wheel or chef's knife; transfer to the baking sheet. Repeat with the remaining dough and filling. If not using immediately, wrap the baking sheet in plastic and freeze for up to 3 days.
Make the sauce: Melt 3 tablespoons butter in a large skillet over medium-high heat. Add the mushrooms, season with salt and cook, stirring, until tender, about 4 minutes. Add the scallions and garlic; cook, stirring, 1 more minute. Add the tomatoes and cook 4 more minutes. Remove from the heat and stir in the basil and parsley.
Cook the ravioli: Bring 3 inches of salted water to a boil in a large pot. Add the ravioli in batches and cook until tender, 8 to 10 minutes. Remove with a slotted spoon and transfer to a baking sheet (reserve the cooking water). Cover the ravioli loosely with foil to keep warm.
Add 1 1/2 cups of the ravioli cooking water to the sauce, bring to a simmer and cook until slightly thickened, 2 to 3 minutes. Swirl in the remaining 2 tablespoons butter and season with salt and pepper. Divide the ravioli among plates; top with the sauce.