Pour the oil into a wide heavy sauté pan and heat over medium-high heat until the oil is shimmering and almost smoking. Add the onions and garlic and cook, stirring with a wooden spoon, until softened but not browned, about 4 minutes. Add the mushrooms, season with salt and a few grinds of black pepper, and cook, stirring, until the begin to give off their liquid, about 5 minutes, adding more oil if the pan becomes too dry.
Stir in the tomato paste, stirring to coat the mushrooms, and cook until it turns a shade darker, about, about 2 minutes. Stir in the rosemary, sage, and red pepper flakes.
Pour in the wine, bring to a simmer, and simmer until it has evaporated, about 5 minutes. Stir in the stock and bring it to a simmer, then lower the heat, partially cover the pan, and let simmer, stirring occasionally, until the sauce is thick enough to coat the back of a wooden spoon, about 1 hour. The sauce can be cooled and refrigerated in an airtight container for up to 3 days; reheat gently before proceeding.
Meanwhile, about 20 minutes before the sauce is ready, fill a large pot 2/3 full with water and salt it liberally. Bring to a boil over high heat. Add the pasta and cook until al dente, about 4 minutes for fresh, or 9 minutes for dried. Drain the pasta and add it to the sauce. Toss well.
Divide pasta and sauce among plates, layering pasta pieces with mushrooms and sauce. Shave some cheese over top and a few more grinds of black pepper.