Chop the onion and cook in some oil until soft. Dice two garlic cloves, add these to the pan with the tomatoes and season with salt and pepper.
Cook for 30 minutes then purée with a stick blender.
Place the pine nuts on an oven proof tray and toast in a hot oven for about 4 minutes.
Put the pine nuts, flour, xanthan, rosemary and sage into a blender, season with salt and pepper and pulse roughly.
Finely chop the chilli and remaining garlic. Add these to the blender with the drained beans and pulse roughly.
Shape into 12 balls and shallow or deep fry them in hot oil until brown all over.
Bring a large pan of salted water to a rapid boil and cook the pasta as per instructions on the back of the packet.
Drain the pasta and serve with the meatballs and sauce.