I agree there is not going to be an easy fix to cover all possible scenarios, although should work where there is one rammer and multiple victims. Something clearly has to be done.
The problem comes when the "fix" itself opens up new avenues for attackers to use and creates new victims, as happened the last time Frontier tried to fix station ramming because "something" clearly had to be done.
Ramming used to be entirely legal around stations. People took advantage of this to flatten smaller ships by boosting into them with heavy ships (and if didn't kill them, hit them again). Frontier introduced the 100m/s speed limit rule in the no fire zone. This introduced the whole
new form of ramming attack where a silent running Sidewinder could cause the station to open fire on an innocent (if rather uncautious) trader in a big expensive ship. Previously, an attacker trying that would obviously just find themselves down one Sidewinder and their intended victim barely inconvenienced.
Any automated set of ramming rules will be exploitable. The more complicated it gets to avoid the "easy" exploits, the fewer players will understand how it works at all, but of course the people who specialise in ramming others to death outside stations will know them inside out, build ships to best use them, etc.
That's not to say that a fix is impossible - in fact, it's fairly straightforward: stations just need to enforce traffic control to a similar degree to that used in 21st-century airspace but with ED's excessive levels of violence, so that "intent to ram" is obvious - it's the player who's well outside their assigned traffic lane, who can be shot down long before they actually collide with anyone, and if they both were flying badly the station is fine to shoot both of them.
1) All ships must maintain a safe separation at all times. A safe separation is "at least two kilometres" not "didn't actually collide".
2) Only one ship may be interacting with traffic control in the most critical zone at any time. Ships will be queued on the launch pad and not released into the station interior, or queued at safe and separated holding zones outside the station, so that only one at a time can be going through the "mailbox traversal" process. (Stations with external docking can be a bit more efficient about this, but only a bit)
3) The station NFZ will be extended to around 20km to give sufficient space for separated holding zones. "Repeater" weapon platforms (like outposts have near them) will be positioned throughout the NFZ to ensure full coverage. Entering the NFZ at all will require a clearance request.
4) Disobeying traffic control orders by leaving your assigned zone or docking route will be a bounty-level "loitering/trespass" offence causing the station and its auxiliary weapons platforms to open fire. There will of course be additional HUD indicators and holomarkers to indicate to ships where their next waypoint is, and when it is their turn to move towards it. This will be enforced for both coming in to dock, and also for safely departing the station masslock radius before entering supercruise or hyperspace.
What's the catch? The catch is that of course this also has to apply to the 99.99999% of times players will be docking when there isn't a hostile CMDR in the same instance (because it can't suddenly switch into "proper traffic control" mode when the second player drops in, it has to be prepared in advance) and for all but the hardcore simulationists this will be a major hassle.