Social insect colonies are a byproduct of simple instinctive behaviors triggered by chemicals and gradients, including pheromones, humidity, temperature, air currents, etc. Furthermore, individuals can specialize to favor some stimuli over other. This specialization often comes with physiological changes. That's how you can have larvae-minders or guard ants.
That's also how an individual can be an efficient piece of a gigantic organisation without having to understand it.
What you would need for a supercolony like the one you describe is a two-layer system of specialization: one that describes the colony an individual belongs to (the role of the colony in the supercolony) and one that describes its role inside this colony. You basically have two choices:
- The individuals have evolved to exhibit this double specialization at birth or
- You have a two-layer pheromone "language" that can generate such meta behaviors.
In the first case, there would have been some massive evolutionary pressure to render normal colonies unable to survive and necessitate extreme redundancy for any task. Some causes could be:
- Foraging is extremely difficult because food sources appear far from the nest, in large quantities but spoil very quickly if not collected.
- Insect's predators are extremely efficient and kill more that required for their sustenance (maybe because of a side-effect of their defense mechanism against their own predators). The reason for this is to limit the population of predators so that they don't eradicate the insects.
- Insects are extremely fragile and short-lived but very efficient at reproduction and can survive through cannibalism. So, for instance, a foraging group would "eat itself" on the way to a food source, maybe even producing new members on the way. This would require that such food runs have a positive energy output for the whole supercolony. It could be linked to the first cause above.
The second case (two layers of pheromones) could emerge in different circumstances:
- The environment changes very rapidly, requiring rapid redeployment of resources inside the supercolony. The emphasis of this dynamic system would be on how easily colonies can exchange members to adapt to this changes.
- For some reason, specialization is much costlier than among Earth's social insect and all insects in the supercolony have basically the same physiology. They have special storage spaces in their body where they can keep second-level chemicals that determine their current role (the role-colony they belong to). Within that meta-role, they act as normal members, which would allow for, for instance, queen-foragers or a queen-queen in a "queen colony."
This last paragraph is about an important point: the colony shouldn't be seen as just members of the supercolony. If this organizational structure is required, it means that having individual insects inside a role-colony is a positive trait which, at first glance, indicates the importance of colonies' adaptability and fluidity. Maybe colony size is important in this super colony, smaller groups handling different tasks than larger ones (like a small scouting colony to find food sources versus a larger one to find nest extensions). They would recruit and shed members as part of their behaviors, as their tasks change. Merging and splitting colonies could be a very dynamic way of handling reversible specialization (e.g. a scouting group with a high population of warriors is suited for patrolling the territory's borders). A lot of potential here! :)
An interesting twist would be to combine the two ideas, tying the emergence and re-emergence of higher order pheromones to environmental changes. New types of colonies could appear inside the supercolony to deal with new challenges.
Greg Egan wrote beautifully about such a species in Incandescence, which I recommend heartily if you're into hard SF.