Thanks for the suggestions everyone. I’ll start by writing to cube and rockshox and see if I can get a replacement.
In response to how I did it… Well I don’t really know. I did some easy downhill stuff at antur stiniog on Saturday, which was fine, then took it out cross country (landrover track with a rocky descent) on Sunday, which was also fine. Then I got to a road section and stopped before a give way line and it just went. I’ve had a look at some photos from the day before and there’s nothing obviously wrong at that point so I don’t really know. Curiously, a similar thing happened with the front wheel on this bike, which just randomly buckled when I was on a fire road at a trail centre a few years ago.