I found, what I believe to be the code in your platoon.lua for when/whether to update a commander.
However it only seems to check proximity of enemy units and self-distance from base (safety)
I would add an additional check, if any shield has been built at base to put the unit under the shield (I was trying to figure if you had a function for that) before attempting update.
I have seen some situations where many units are approaching, launching missiles or firing at a no-self shield or self repair commander during self update.
Also are there any functions where you can check terrain vs weapon firing track? Example: tank firing into a hill when trying to hit a unit theoretically in range. Or a defense turret trying to hit an approaching unit, but firing is direct and unit is down a slope and can only be hit by missiles/rockets or trajectory weapons.