Preheat the oven to 350 degrees F. Line a loaf pan with parchment.
In a medium skillet, heat the olive oil over medium heat. Add the onions, walnuts and garlic and cook, stirring occasionally, until the onions are softened, about 5 minutes.
Meanwhile, combine the apple, celery, and carrots in a food processor and pulse until finely chopped (or finely chop with a knife). Add to the skillet and continue to cook, stirring occasionally, for 5 minutes.
Meanwhile, combine the flaxseed and water in a small bowl. Stir and let sit for 3 to 5 minutes.
Combine the lentils and quinoa in the food processor. Pulse until incorporated, but still chunky. Transfer to a large bowl. Add the apple-walnut mixture, oat flour, flaxseed mixture, thyme, rosemary, sage, and salt. Gently mix to combine, then transfer to the prepared loaf pan.
Stir to combine the ketchup and cranberry sauce in a small bowl. Spread half over the loaf with a basting brush or spoon. Reserve the rest for serving.
Bake until the loaf is heated through and the glaze starts to caramelize, about 1 hour and 15 minutes. Remove from the oven and let the loaf rest for 10 to 15 minutes, then serve with the remaining sauce.