Assuming the following, I have rank 4-night realm, a staff that gives me +1, a ring that gives me +1, a robe granting another +2 and I cast in the regio +1

Does this mean that I can cast a mastered spell solo of magnitude 18 (total rank x 2 for mastered) or magnitude 12? (Triple base level)

I may have this all wrong but I am unsure whether the triple cap is applied before or after mastery.

I cannot find the answer on the forum or at least one that I understand.

Your maximum effective Lore is 3 times your actual Lore. So in your example, you are effective Lore 9, which means you can contribute a maximum of 9 mana.

For a mastered ritual, you can then hit up to magnitude 18 solo, because each mana you contribute counts for 2 magnitude.

Mastery comes into play last. You should work out everything in terms of “number of mana crystals I can use”, and then convert that into magnitude at the very end - either 1 magnitude per mana without mastery, or 2 magnitudes per mana with mastery.