I think it's not "randomly" but better treat it like being random.
I suppose e.g. every new connection attempt increases the cid value (got a LOT failed reconnection attempts these days, and one recent connection had a cid value > 1000).
That could be possible, too lazy to count my reconnects. But in early versions it wasn't counting like this (I know because my treebar worked perfectly :P)
Btw, sorry.. I think I posted it in the wrong subforum, maybe it could be moved to bugs? (unless I'm wrong)