Reproducing my own post.
The core issue here is how flexibility worked and how fluid (not in a marriage, endogamous definition of fluidity, but in how castes could move up and down the economic classes as either a group or as individuals).
The Varna system was, before the British Raj, a fluid and reasonably mobile system with no artificial barriers to said mobility. Essentially, Professions were not hereditary, nor were there any rules limiting marriages within these classes (though each regional grouping evolved an endogamous marriage pattern), or taboos on whom one could eat with (2) or indeed as Al Beruni notes in Al Beruni's India(3), rules against living together in communal lodgings and homes.
To give you but one example of how the caste system worked pre and post British era, I would like to refer you to the movements on the caste hierarchy seen amongst the Nadar castes of Tamil Nadu.
As traced extensively in Rule by Numbers: Governmentality in Colonial India (4), the Nadars were, pre British not a unified trading class as they would become post British -note here, when I say pre and post British, while there have been many British steps to stratify and codify castes, the pivotal moment was the British Caste based census of 1901, headed by one Risley - you can read his thoughts on castes in his work, the People of India (5).
The Nadar caste today are a powerful, united trader caste in Tamil Nadu - they were toddy tappers by trade in the 18th century, yet, as an example of how fluid castes could be pre British era, pockets of Nadars in provinces 100-150 kms away were also powerful landlords and within the Nadar grouping, they adopted mores of the other economically powerful castes (wealth and power determined upper and lower castes, pre British India) while the poorer groups of the Nadars aka the Toddy tappers adopted the mores and conventions of the poorer castes. So within the same caste, across a space of just 100 kms, there was a lot of variation in the socio economic status of the Nadars. There was no uniform "trading Nadar caste" as it would be post say the 1850's and accelerated post 1901. Yet another grouping of Nadars who lived in the Madurai region (a district during the British administration that was roughly the size of say modern Israel) were even more powerful administrators and chieftains of the short lived Nayaka Kingdoms based out of Madurai. So as you can see, in a region roughly the size of modern Greece, you had one major caste grouping, but within which you had a large spread of economic standing. In modern terms, within the Nadar caste you had the lowest castes, upper middle and richest castes. Each of these sub groupings didn't have a uniform cultural system, but simply adapted the mores and conventions of the highest economic group in their region.
This in a nutshell is how caste mobility and fluidity worked. There are many more such examples I could provide, the Konds of Orissa, the Khatris of modern day Haryana, the Vellalars and Mukulothevars of Tamil Nadu on how each caste had a lot of fluidity and mobility driven solely by its socio economic status. Take the Vellalars for instance, they had a storied lineage in the Northern and Southern parts of Tamil Nadu during the Chola and Pandya periods (TN during this period would have been roughly the size of modern France+Belgium+Netherlands combined), acting as governors, administrators and generals. At the same time, in the central parts of TN, they were groups of landed small scale farmers and also groups of landless peasants. Similar to the Nadars, there was no uniform cultural more or segregation of the Vellalar caste, rather each regional grouping adopted the conventions of whatever upwardly mobile class in their region.
You would have also noticed one key point here - professions and lack of barriers thereof. A Nadar or a Vellalar could, pre British be anything from a landless peasant to an administrator in a royal court to a powerful landlord. There are even some, imo extreme theories that all the Tamil castes, including the Brahmins and Kshatriya castes actually are an offshoot of a very early sub division (going back to the pre sangam era) of the original vellalar caste who then sub divided into 5 broad groupings which then over time sub divided more. (6) To summarise though the example of the Nadars pre British era. There existed one broad Nadar caste, within this caste there were multiple groupings, driven by the socio economic status of each grouping. Each grouping was bound to its immediate geography with little to no social cohesion as a whole. However as seen by the rich Nadars, each localised grouping was mobile and could go up and down the economic (not caste) ladder
Part 2,
This then raises the question, what changed?
To continue on with the Nadar caste, the British for reasons known only to them made them a Kshatriya caste. Back to the topic at hand, the British deemed the Nadars a "kshatriya" caste, and British missionaries had great success in converting them. These two factors stratified the Nadars - with access to the British missionaries and the large numbers that joined the British / Indian army, they gained access to British levers of power (the all powerful Nadar association even pledged their loyalty to the British crown in 1920, and the Indian leader Kamaraj Nadar was pelted with stones when he said that this was not a patriotic thing to do) with this, many of them went into trade and business, they also then adopted the mores of what they thought were north Indian kshatriyas, and started oppressing (like in Punjab) the British deemed landless peasant castes, and within a 100 years had become and remain to this day an extremely powerful, economically very strong caste. All this meant a much much greater "caste cohesion" as opposed to say the local village level cohesion of all castes, and unified the nadars as one unit at a state level. Even the Nadar migration (from scattered pockets all over the state) to a few key cities happened because of their close ties to the British and the trade they were slowly starting to control.
It would be pertinent to point out the intra rather than inter caste conflicts - Nadar toddy tappers usually worked for one Nadar owner / master. As this guy gained scale, he would, using village laws (mahasabhas) file suit against another nadar owner who had control over x number of toddy plantations, and try and muscle into his territory (legally), so the caste conflict was within and not discriminatory, but based on the legal systems of pre British India. These groups were notoriously endogamous as each self sustained unit of Nadar owner + x number of climbers usually married within the fold, and didn't even marry into other Nadar families.(4)
If you go back in time and study say, the caste systems of the Chola period, they didn't even have the traditional varna system. They instead had the Kai (hand) system, comprising of the Vadangai and Ilangai (right and left) (7) - with the former comprising of agricultural trades and the later being the artisans. Now, initially, during the early Chola era, the agriculture oriented guilds were the more prosperous groups, but over time, with increased temple construction, and increased trade fostered eventually by the take over of most of South India by the Vijayanagara, we see the artisan group grow in stature and power, and this caused conflict (economic, not physical, secterian warfare) between these two groups. The rights granted to the agri castes by traditional Tamil society were increasingly abrogated by the Artisan groups (I oversimply the groups as there were a total of 98 sub castes in these two broad groupings, going into details would be out of scope for this discussion).
Cynthia Talbot (8) explicitly even states that there is no evidence of a stratified caste system during the Chola period. She goes onto establish that in Medieval Andhra (a neighbouring state of TN), there was no stratified caste system, and that even names did not reflect castes, and that the name of a donor or benefactor was the sole marker of wealth and power.
At this juncture, I must also point out that the one social grouping, caste that was fairly rigid in entry barriers and the "subsidies" provided by states was the Brahmin caste. They alone (as established by Cynthia Talbot in this case) (8), used and had the rights to use certain nomenclature that show cased them as persons learned in the scriptures. Additionally, a study across empires and time, be it the Mauryan or the Cholas or the Kakatiyas (and many others), we see a common trend wherein Brahmins were definitely exempt from taxes, and also most law books had lesser punishments for Brahmins, even if the nature of the crimes committed were the same. The reasoning behind this is that Brahmins were the only caste prohibited by many codexes to either earn a living from trade or bear arms, and to make up for these restrictions, states provided exemptions to them. In a very rough example, I would equate the case of the Brahmins with the Flamen Dialis of ancient Rome - as the state put restrictions on both these groups, the state also subsidized their living.
Another example of caste mobility would be in how kings from "lower" aka poorer social groupings, like say the Nandas or even Shivaji, took power, and then in a clear cut case of mobility, simply had Brahmins pronounce them Kshatriya and thus instantly legitimizing their rule.
While I am not very familiar with European guilds (aside from a brief read of Diocletian reforms and some scattered reading on the feudal set up of medieval Europe), the key difference seems to be the rigidity in taking up new professions or mobility across groups - for instance, a serf could not become a land owner (disclaimer, not my area of expertise, so if incorrect, please do point out), whereas a landless lower Indian group could and often was in positions of power in different parts of the same province even.
Happy to address any follow up questions.
Sources,
(1) Nicholas Dirks’ Castes of Mind,
(2) Al Beruni’s India (PDF sources freely available),
(3) Penguin History of Early India by Romila Thapar,
(4) Rule by Numbers: Governmentality in Colonial India by U Kalpagam,
(5) People of India by Herbert Risley (PDF sources freely available),
(6) Religion, Caste and Nation in South India: Maraimalai Adigal, the Neo-Saivite Movement and Tamil Nationalism by Ravi Vaithees,
(7) South India Under the Cholas by Subburayalu,
(8) Precolonial India in Practice: Society, Region, and Identity in Medieval Andhra by Cynthia Talbot
In addition to these, I would recommend,
The rise of Islam and the Bengal frontier, 1204–1760 by Richard Eaton
Caste, Society and Politics in India from the Eighteenth Century to the Modern Age by Susan Bayly,
India and the British by Douglas Peers
OP imperialism is rather vague, Mughal Imperialism? Gupta imperialism? Vijayanagara?
Or are you wanting to know how British rule impacted the caste system?
If you can clarify, I will respond accordingly.