Cook Lentils: Fill a medium pot with salted water. Add lentils. Bring to a simmer over high heat. Once simmering, reduce heat to medium-low. Cook for 18-20 min, until lentils are tender. Drain lentils well, shaking off excess liquid.
Make Flax Egg: Meanwhile, in a small bowl, combine ground flax seeds and ⅓ cup water. Stir to combine. Set aside to thicken, about 10 mins.
When lentils are close to being done, preheat oven to 375F.
Saute Vegetables: In a large pan, heat 1 tbsp oil over medium heat. When the pan is hot, add onion, celery, carrots and mushrooms. Season with salt and pepper. Cook for 6-8 min, stirring occasionally, until tender. Add garlic, tomato paste, ketchup, thyme, oregano, rosemary, basil and cayenne (if using). Cook for another 1-2 min, stirring often, until fragrant and toasted. Off heat, stir in soy sauce or tamari.
Combine Filling: To a food processor, add oats. Pulse oats until ground into a flour. Add walnuts. Pulse a few times, until they are the size of small peas, but still have texture. Add flax mixture, cooked lentils. Pulse again. You still want to see some lentils, but it’s key to break some of the lentils down. Add lentil mixture to pan with veggies, stir until well combined. Season with salt and pepper, to taste.
Add Mixture to Pan: Lightly grease and line a loaf pan with parchment paper so it hangs over the edges. This will make removal much easier. Press mixture evenly and firmly into the pan, smoothing the top.
Prepare Glaze: In a small bowl, combine ketchup, tomato paste, maple syrup and balsamic vinegar. Spread in an even layer over the loaf.
Bake Loaf: Cover loaf with foil. Bake for 30 min. Uncover and bake for another 15 min.
Slice and Serve: Let cool in pan for at least 30 minutes before removing. The longer it cools, the better the loaf will hold together. Let cool longer if you have time. Slice into 8 portions and serve.