TL;DR
Add a user settable tag/id value to trains that can be read from train stops through the circuit network.What ?
I propose adding a numeric tag value to trains which works similar to the existing train id, but is settable by the user and remains stable through things like changing train composition, rebuilding destroyed trains etc. The value would be tied to the trains schedule, so in cases where two trains get joined the same logic that's already used to decide which schedule the new train keeps would also decide which tag value the resulting train gets. When copy+pasting settings between trains the tag would be copied over along with the train schedule and color.When a train is connected to a train stop, the tag value of the train would be readable from the train stop through a signal on the circuit network, similar to how you can already read the train id. The signal used for the train tag would be configurable on the train stop itself, again similar to the train id.
The game itself wouldn't take any measures to keep train tags unique (in fact it can't in light of how the tag should be handled in cases of train modifications as outlined above). If a player wants unique tags, then they have to make sure of that themselves. That (and the fact that the term "train id" is already in use) is why I call it a "tag" and not an "id".
The tag value should be readable/writable for mods.
Why ?
If you want to implement special handling for specific trains at a train stop using the circuit network the only way (barring mods) to do so at the moment is by using the existing game assigned train id. The problem with that is that this train id isn't very stable. Each time something changes the train composition (parts of the train getting destroyed, replacing wagons/locomotives with upgraded modded versions, mods like Clusterio "teleporting" trains between surfaces/cluster nodes etc.) the train id changes. Each time that happens you have to manually go through all relevant train stops to update id values in the circuit network. The proposed train tag would provide a way to identify trains that would be stable over time.In addition to that the tag could potentially also be useful for certain mods that have to keep track of specific trains (for example TSM or LTN). At the moment that's typically done through the train id as well, which leads to problems like losing track of scheduled deliveries in case something causes the train id to change. A mod wanting to track a train could set its own unique tag value on the train to identify it. Of course in case of multiple mods doing this it would be up to the user/mod authors to make sure that they don't interfere with each other (or are properly marked as incompatible).