Okay, so I observed an AI for about 50 years just to see what is going on and I've solved at least part of the mystery.
There appear to be a number of reason why the AI is bad at upgrading starbases.
However, the primary reason is that it will only consider upgrading them when there is excess Starbase Capacity. This means that there are only brief windows of opportunity for starbases to get upgraded. For example when it gets supremacy. Also, if it upgrades enough outposts into starbases before upgrading anything it won't upgrade. So for example if starbase capacity is 8/10 and it builds just 1 starport, it can still upgrade. However as soon as it starts to build that second starport, it will stop considering any more new upgrades to existing starports.
Here is a video I took where I gave the AI a tech that boosted its starbase capacity by 2 and then watched what happened.
On top of that there are resource requirements which I don't fully understand beyond the basics.
1. It has to have surplus energy income
2. It has to have a certain amount of alloy stockpiles
Regarding alloy stockpiles (expenditures), depending on whats going on the AI adjusts what percent of that stockpile gets allocated to ship building, starbases, and upgrades. While observing, you can view the AI's expenditures by typing debugtooltip in console, and then letting it run for a day.
The amount of alloy expenditures allocated to starbases appear to play a role in what gets upgraded. If it's too low I think it will only upgrade outposts. Starhold cost 500 alloy so it needs 500 in expenditures to even consider upgrading it during that brief window when it can even upgrade in the first place. I believe that 500 alloy number is modified by the supremacy tradition that lowers starbase upgrade cost, however it is not lowered by difficulty modifiers that lower starbase upgrade cost.
Furthermore I'm not certain, but I also think that the amount of alloy you need to trigger an upgrade is based on the highest tech starbase you can build. So instead of 500, it might be 1250. Again not sure.
You'll notice in the picture that "ship upgrades" is taking an awful lot of alloy expenditures. This is yet one more problem that is making it difficult on the AI. Basically, when the AI is at max fleet cap and not at war, it super-prioritizes spending alloy on upgrading ships. HOWEVER there are two problems:
1. It does not go away even if you have nothing to upgrade. This makes it that much harder to build up the alloy expenditures dedicated to starbases. Only wars make it temporarily go away.
2. THE AI IS EVEN WORSE AT UPGRADING SHIPS THAN IT IS AT UPGRADING STARBASES.
I'm fairly certain the culprit in all this is a problem with the economic minister. However that file does not appear to be moddable so I don't know what to do.
TL;DR
- AI doesn't upgrade starbases unless it has starbase capacity open and hasn't already queued up enough level 1 starbases to max it out.
- AI doesn't upgrade if it doesn't also have enough alloy stockpiles and energy income dedicated to starbases.
- Alloy stockpiles necessary to upgrade are hard to get because ship upgrades take too much expenditures
- AI rarely upgrades ships and the ship upgrade expenditure doesn't go away even if there is nothing to upgrade
- When it does go away in times of war, ship building expenditure gets a huge boost