After much experimenting and testing, I've come to the following conclusion: stuff it.
I tried changing "BattleInterface.c", replacing the "RefreshBattleInterface(false)" under "if(bYesUpdateCommand)" with "RefreshBattleInterface(true)". This did indeed trigger "CheckInitialFlagRelations" more often and the fort logged me after the Sail-To. Unfortunately it also had the side effect of fouling up the payroll ship incident, in which Santiago fort once again failed to log me as being in the CastelF, so when I went away and returned it reported that it remembered me being in a Shnyava2 which I no longer had. When I returned "BattleInterface.c" to the way it had previously been and re-ran the payroll ship attack, Santiago fort correctly logged me as being in the CastelF.
But the problem about the fort failing to log you if you teleport to port may not actually be a problem. The once-per-minute update does indeed trigger "CheckInitialFlagRelations", which has some very useful implications.
Current status, then:
If you start on worldmap, move close to the port and switch to 3D sailing, you're in visual range of the fort right away and it logs you correctly.
If you start outside visual range and then direct-sail to the port, either by being away from the port when you switch to 3D sailing or by direct-sailing the whole way from another island, the once-per-minute update makes the fort log you.
If you start outside visual range and then teleport (Sail-To) the port, and either you have a hostile flag or the fort detects your false flag, it will attack. Unless you're in something teeny which is blown out of the water in one salvo, the battle will take long enough for the once-per-minute update to get you.
If you start outside visual range and then teleport to the port, and the fort doesn't recognise your false flag, you'll get in safely. But if the fort can't get you on the way in then it will get you on the way out, because when you've finished doing whatever you came here to do and return to sea, you'll do so at short range to the fort, which then gets to log you properly. If it remembers you as hostile then you'll get into port safely but won't get out again - how's that for making hostile ports dangerous?
(If you want an in-game explanation, it takes time to search all the paperwork generated by keeping detailed records of every ship to visit the port. If you teleported from beyond visual range right into port and then docked, the fort has no time to search those records. By the time you've finished your business and return to sea, the fort
has searched its records and if one of them is about you then the fort now knows who you are.)
So as far as I'm concerned, job done.