You've already communicated this to your spouse, and this is no longer the problem you're having. Your spouse is likely upset because the way they want to express their affection for you clashes with how you prefer to receive affection.
Based on the question, it seems that you've already conveyed this information to your spouse, and you believe they understand it. But it seems that your spouse is having trouble putting the information to use. When they forget your preference/need (or willfully disregard it, I'm not sure how much it matters on this precise issue), they touch you unexpectedly and you become doubly upset: the unexpected touch itself bothers you, and you feel that they should know better and have failed you.
But try thinking about it from your spouse's perspective. Many people (though by no means all) enjoy physical touch as a sign of affection and intimacy. It sounds like this describes your spouse. So they probably aren't wanting to upset you, they are wanting to express their affection for you in a way that suits the intimacy of your relationship. The behaviors aren't about you, directly, they are about your spouse expressing their feelings towards you.
When you react negatively, especially very negatively (such as a "violent" reaction) the primary sentiment they are feeling is probably that their well-intended affection has been rejected, followed by some hurt because their well-intended affection has made you very angry and unhappy. It's especially hard when it's a "reflexive" behavior, one that your spouse initiates because it "feels appropriate" and is not necessarily a carefully considered action.
1.
What I have found to be most important in a case like this is to replace the affection your spouse is trying to express/experience through the unexpected touching with other behaviors that can satisfy that same need. Saying "never do this to me, ever", by itself, just removes a portion of affectionate interaction from the relationship. That sort of thing can do a lot to make a relationship feel shallower. Instead, you might make a point of giving your spouse a hug from behind sometimes. It won't be unexpected for you, and as your spouse presumably doesn't mind unexpected touch from you there won't be any negative element to it.
Importantly, because you are in effect expecting your spouse to change their behavior to suit an arbitrary need you have, you should be prepared to make some compensating effort. That may include expressing more affection than you normally might, and in ways you ordinarily might not.
2.
On the other side of the coin, it can help a lot to give your spouse a "pre-approved" way to show affection for you. Simply saying "never do this to me, ever" not only deprives your spouse of some of their normal ways of expressing their affection for you, it also doesn't give them any alternatives. Since, as described above, I think it likely that your spouse is trying to express their affection for you, giving some guidance on other ways they can do that may help prevent hurt feelings.
The specifics will have to be determined by you, but presenting something like
[Spouse], I love getting hugs from you! But, as we've talked about before, a surprise hug really upsets me-- the surprise causes an unpleasant physical reaction for me, and it makes my anxiety skyrocket. If you could announce an incoming hug, and then make sure I acknowledge that I know it's on the way, those factors go away, and we can hug any time.
reiterates that you like the hugs, and it's only the surprise that you don't like. It also gives a clear guideline for a way that your spouse can express affection without incident via hugging. Critically, it gives guidance for how your spouse can hug you with confidence beyond "unless I'm aware you're gonna do it", which is a bit on the vague side. (For context, consider that your spouse has indicated they feel that you should be so comfortable around them that you expect touch from them at any time, implying that you should always be aware if they are nearby).
Another thing to consider:
In the question you indicate that you used to deal with unexpected touch differently, by dismissing it at the cost of your "energy levels". Now you've connected the experience to an autism diagnosis, and this awareness alone has changed how you respond. I can't tell you what you think or feel, so I can't assess how appropriate this switch is or how possible it is to adjust it at all.
But if you were able to "handle it" better in the past, even at some short-term cost to yourself, it may be worth using some of that same capacity to tolerate unexpected touch to give your spouse more options than 100% compliance at all times or total failure. Especially if your spouse knew you before the diagnosis (as seems to be the case from the timeline in the question), and has some already-established patterns that include more unanticipated affection (even if they didn't understand what they were subjecting you to).
I'm glad that you know more about how and why the unexpected touching upsets you, and it's good that that knowledge can help you improve your life. But it's not clear to me why that better understanding has suddenly made you less capable of enduring the touching. Again, only you can know if this is possible, but if you can afford your spouse a bit more tolerance, it would go a long way towards avoiding hurt feelings.
Personal experience:
I have OCD, which imposes a lot of arbitrary limits on what I "can" do or experience without anxiety spiraling quickly out of control. As examples, when it's humid I have a hard time with skin-to-skin contact (it makes me feel filthy); I don't like having saliva on my face (from a person kissing me, from a dog licking me, etc.). My significant other is aware of most of the limitations that come up (we've been together a long time), but she likes to express affection physically and these limitations can be hard for her. This includes feeling hurt when her affections aren't received in the way she intended them to be.
It's long been an issue that she feels I "wipe off" her kisses. I've explained many, many times that that's not a thing (a kiss is not an enduring physical presence to be kept or removed), and that it is 100% about the saliva on my skin (kissing my shoulder through my shirt prompts no such reaction). But she still has a "gut reaction" that the action is a rejection of her kisses. So if I need to wipe my face, I try to step out of the room to do it.
We've reached a balance. It took a while for new habits to set in (for both of us), but she now often wipes her lips before a kiss (no drying needed for me), and understands (intellectually) that if she forgets or it is not effective that I am not rejecting the gesture, just fulfilling an arbitrary need that I have to keep calm. More affectionate gestures from me have also helped her to feel a similar degree of affection in our relationship overall, so the sense of her affections being rejected has decreased a lot.
There are other examples as well. Overall I've learned that the existence of my condition defines a lot about how I need to go about things but does not entitle me to others' perfect compliance at all times with my arbitrary preferences/needs.