Coat a baking pan with a little olive oil. Cover the bottom of the pan with a layer of your soft polenta (leaving the directions for polenta prep out, but follow the recipe on your polenta). Allow it to firm up while you prepare the spaghetti squash and tomatoes.
While any of these steps can be done well in advance of the final casserole compilation, they also work fine in order. As you wait for each element to roast, talk to your friends, have a glass of wine, or read a poem. Slice tomatoes thinly and put on wax paper on a baking tray and roast for 10 minutes until dry, but not completely dehydrated.
Cut spaghetti squash in half longwise, and scoop out the seeds from the middle. A few fibers remaining is fine, but it's easier to get the seeds out first.
Cover a baking sheet with a little bit of olive oil, and put both halves of the spaghetti squash face down. Put this in the oven for 40 minutes. Remove, check if the squash separates into strands when you scoop a small section. If not, cook for a few minutes longer. Once cooked, scoop out all of the "spaghetti" from the squash into a medium sized bowl.
Slice onions into rounds and mince garlic. Saute together until onions are translucent.
Mix spaghetti squash, tomato sauce, basil and ricotta cheese. Pour mixture on top of polenta layer. Cover in parmesan cheese (optional). Cook for 10 minutes.
Layer onions on top. Layer tomato slices on top of this. Sprinkle rock salt on top. Broil for 5 minutes.