Cook the lentils. Bring some water to a boil in a saucepan and lightly salt the water. Once boiling, add the lentils. Reduce the heat to a simmer and cook the lentils for just 7 to 10 minutes. Note: The point is to slightly undercook the lentils: they should be mostly cooked but not fully cooked with a distinct bite, as they’ll get cooked later. Drain the lentils thoroughly. Measure out 8 ounces or 227g (it should be just about all the lentils). Meanwhile, toast the walnuts. Add to a dry skillet over medium-low heat and toast for 4 to 5 minutes until they smell toasty and are darker in color. Or toast in a 350ºF/175ºC oven on a sheet pan for 8 minutes.
Add the toasted walnuts to a food processor. Blend briefly until you have fine crumbs, but don’t over-process, or it will start to turn into walnut butter. Add chopped mushrooms and blend a few times, followed by a few pulses until mushrooms are very finely chopped. Add the cooked lentils to the food processor and pulse again again until the lentils are just partially blended. Set this mixture aside. Heat the oil in a deep saute pan over medium-high heat. Once hot, add the onion and season with a pinch of salt. Cook until softened and golden, 8 to 10 minutes. Add the garlic, cinnamon stick, thyme, cloves, chile flakes, and tomato paste, and cook for a few minutes. Add in the lentil "meat" and break up with a wooden spoon. Cook for a few minutes, until it gets some browning and a bit crispy, about 5 minutes.
Pour in the wine and deglaze the pan, scraping up any browned bits. Cook until the smell of alcohol burns off, about 3 to 5 minutes.
Pour in the tomatoes, 1 ½ teaspoons kosher salt, several cracks of pepper, bay leaf, and mushroom powder. Bring to a boil, then reduce the heat to a simmer. Simmer until the sauce thickens and the liquid has evaporated, 8 to 10 minutes, or until it looks like a thick meat sauce the liquid has evaporated.
Take off the heat, and remove the bay leaf and cinnamon. Stir in the basil. Taste, adding a pinch or two of sugar if needed to balance the acidity of the tomatoes. Season to taste with salt and pepper.