Several stupid things make it only a 7 for me.
First, that, given the experimental nature of the M5 and that this is a "live fire" exercise, the Enterprise's weapons should have been modified in such a fashion that they can't fire at anything more than "thud" strength. In Top Gun exercises the planes are not loaded with live ammo. They could have established that Scotty pulled some components out of of the phasers to reduce them to 1/1000th power, but M5 is so smart it figures out how to route power into the systems by some unconventional means, etc., and show it thinks WAY outside the box and cannot be controlled.
Second, M5 destroying the Woden. How do you go from "this unit must survive" to "go out of my way to blow up anything and everything in space, even when it's not even approaching me"? If M5 has Daystrom's engrams, sense of self-importance, and, maybe even sense of injustice of "lessers" building off his work, I could maybe see it lashing out at any other computer controlled "competitor", but no one ever discusses the WHY M5 would do something so pointless.
Third, Wesley. He's written as an idiot, i.e. thinking Kirk is responsible for what the M5 is doing, given he knows a) Kirk personally, that b) M5 is an experimental system, and c) they forced most of Kirk's crew off the ship, leaving him short-handed. The first conclusion he ought to have come to when hit with full phasers is that M5 was malfunctioning, then, when no one shut it off, assumed that M5 had incapacitated or killed the crew.
Finally, realistically there should be a hundred ways Scotty could sabotage the ship to stop M5, including using a phaser to damage critical components, but, instead, they let M5 be another magical computer which can do anything. I'd have bought it if M5 trapped the whole crew in the top of the saucer and Scotty had to blow his way through 20 bulkheads to even get near a critical system. That would have been even more dramatic, as he runs out of time and Kirk is forced to deploy his trademark logic-fu on M5's Achilles heel.
Great character stuff tho, and exciting in the last act. Just wish it was a little smarter.