This sounds familiar. While we don't get the physical violence to this extent, we have done in the past.
It sounds like frustration was the trigger, perhaps coupled with Obsessive Compulsive Disorder (OCD) in his determination to get his friend to visit somehow. It's the extent of the determination and the degree to which problem-solving is applied, without the clear thinking needed to get some sort of balance. And your response was to block him at every possibility he suggested - it would have seemed to him that you were determined to oppose him for opposition's sake, rather than you had rational reasons for your objections.
It's an "Explosive Child" situation. I don't think it's the medications, I think this is the sort of thing that will keep happening despite everything you try to do, because despite the medications, the therapy and everything else, he DOES have problems underneath it all and they still exist. The medications etc cannot eliminate them, they only mask them.
It sounds like you have a really amazing boy there. He's bright, he's smart, he wants to follow the rules but he also gets a strong sense of desperation to have what he feels he NEEDS. That desperation is driven by a combination of impulsivity, anxiety and a certain amount of Obsessive Compulsive Disorder (OCD) coming into the mix - he kept trying to find ways in which his friend could still visit.
What could you have done differently? I'm not sure. It's holiday time for you, so could his friend have come for a sleepover? Or is M more unreliable in the evenings and you don't want to risk problems in front of friends?
Another possibility - would friend's mother have agreed, given that the visit would have been so short? By ringing friend's mother to get her input, SHE may well have vetoed friend visiting, so you would not be the obstacle here. Friend's mother probably wouldn't have been either, because our kids are hardest on us because we are always the ones throwing up obstacles in front of them.
Something else you could have tried - a compromise. Explain to M that a very short visit isn't much fun, but a longer visit say, next day - a lot more fun. Letting him get on the phone to invite friend over the next day could have softened it. If you're sure it wouldn't have helped, then you're looking at Obsessive Compulsive Disorder (OCD) again, unless you can drag out of him WHY he had to have friend visit last night. Something he had to tell him? Show him? Give him?
For a lot of these kids, it's about control. They need to have some control over their own lives. That doesn't mean they are determined to undermine your authority, that is not their main objective. However, it will seem like it is if you try to deal with it by always trying to have your word as law, your say as the final answer. That is red rag to a bull, with these kids.
What you do is change from being their obstacle, to their helper. Give them choices, YOU also try to find a compromise that YOU are happy with (such as invite friend for a long visit next day; or find out WHY it's so important for M and maybe allow a five minute visit if the vital need can be accomplished in that time and the other mother is OK with it).
An example - you want your child to wear warm clothes in winter, but your child insists on HIS choice of clothing. So instead of pulling out a sweater of your choice for him to wear, you say, "You choose a sweater to wear today."
I need difficult child 3 to clean his teeth. I saw that his toothbrush is in appalling condition. But instead of me going out and buying him any old toothbrush, I tell him to choose one he likes. There is more chance he will use a toothbrush he has chosen, and my ultimate aim - get him to use it - is achieved.
I'm not saying you should reward such bad behaviour, but a lot of what Ross Greene is about is heading this stuff off at the pass. Turn off the meltdown before it happens.
In this case, you had ample warning that he was getting more desperate. You need to have some sort of plan in place, to help him regain control of himself. Helping him find a compromise you can all be happy with is a start. Sometimes asking him why the visit is so important can also sidetrack the immediate desperation as well as give you some vital information.
And the other big problem - sometimes we end up punishing the behaviour that we helped trigger.
Another example from my own childhood - I had been chosen by my school as one of two students to give a speech at a neighbouring school. We lived a long way out of town and I relied on my father to drive me there. I had told my parents but they forgot. My father was late home from work and I was getting anxious about possibly not getting to the neighbouring school on time. My mother was getting angry at my impatience, began to lecture me about taking my father for granted. I know now, she was probably anxious for his safety.
My sister lived next door and her husband offered to drive me there. He only had to drive me to the other girl's home, her father was going to drive us both there and due to the difficulties, they even offered to have me stay over and go to school with their daughter next morning. By this time my mother was angry with me and told me I wasn't to go, because I had failed in my responsibility to properly give them warning of my need to go. So even though I had the offer of transport, accommodation and (I thought) I had the problem solved, BECAUSE she was now angry with me for arguing about whether I had told them or not, I was to be punished. The fact that she had been helping me rehearse my speech seemed to slip her mind. I suspect she did remember that I had told them, but I hadn't made sure I kept reminding them, but the BIG thing - she had given an ultimatum (probably in the heat of the moment) and had backed herself into a corner.
I didn't melt down (I don't think) but I did go visit my sister and cried on her shoulder for a few hours. And next day at school - I was snubbed by the teachers, for failing to show up without notice. I had absolutely no excuse they would accept, for what parent would fail to permit their child to represent the school? I clearly was not as responsible as the teachers had believed; nor was I truthful, in their eyes. My excuse simply didn't seem plausible.
My parents would have been horrified if they'd realised what they did that night. It went against everything they had ever taught me about responsibility, punctuality, organisation. But they also had a problem with accepting help from anybody and this also was a factor, I believe.
I was not a difficult child, not in that respect. But this was a huge problem which, in some ways, is similar to your son's. He had his own reason which FOR HIM was vital. In the cold light of day it probably wasn't so important - that's the Obsessive Compulsive Disorder (OCD), they get hold of an idea and can't let it go. But we need to be careful to not paint ourselves into a corner, and to not insist on being the authoritative figure, first and foremost. We need to listen, to think, to show them that we are doing this, and try to compromise. A shouting match needs two people. If the child shouts and the parent does not, it calms down a lot faster. And it's when they are calm, even if it has to be the next day, that we talk it out here.
I hope you can get to the bottom of what set your son off. it does sound like he's been making good progress lately.
by the way, has Pervasive Developmental Disorder (PDD) been thoroughly looked at in him?