Cook lentils according to instructions on package.
Heat 2 tablespoons of the oil in a large skillet over medium heat. Add the diced onion and carrot and pinches of salt and pepper and cook until they begin to soften, about 3 minutes. Add the mushrooms, another pinch of salt, and cook until soft, stirring only occasionally, about 8 more minutes.
Stir in the most of the rosemary (saving some for garnish). Stir in the garlic, then add the balsamic vinegar and soy sauce and stir to incorporate. Add the diced tomatoes, lentils, tomato paste, sage, and fresh cherry tomatoes. Add in the extra 3 tablespoons of olive oil, and stir.
Reduce the heat and simmer for 20 to 30 minutes. If the sauce is too thick, add water, ⅓ cup at a time, to thin. Season to taste.
Bring a large pot of salted water to a boil. Prepare the spaghetti according to the instructions on the package, cooking until al dente. Drain.
Top spaghetti with sauce. Top with fresh basil, rosemary, and shavings of pecorino cheese.