Huangdi (), translated into English as Emperor, was the superlative title held by monarchs of China who ruled various imperial regimes in Chinese history. In traditional Chinese political theory, the emperor was considered the Son of Heaven and the autocrat of all under Heaven. Under the Han dynasty, Confucianism replaced Legalism as the official political theory and succession in most cases theoretically followed agnatic primogeniture. The lineage of emperors descended from a paternal family line constituted a dynasty. The absolute authority of the emperor came with a variety of governing duties and moral obligations; failure to uphold these was thought to remove the dynasty's Mandate of Heaven and to justify its overthrow. In practice, emperors sometimes avoided the strict rules of succession and dynasties' ostensible "failures" were detailed in official histories written by their successful replacements. The power of the emperor was also limited by the imperial bureaucracy, which was staffed by scholar-officials and in some dynasties eunuchs. An emperor was also constrained by filial obligations to his ancestors' policies and dynastic traditions, such as those first detailed in the Ming dynasty's Ancestral Instructions. Chinese sovereign During the Zhou dynasty (c. 1046 BC – 256 BC), Chinese feudal rulers with power over their particular fiefdoms were called gong (公) but, as the power of the Shang and Zhou kings (, mod. wang) waned, the dukes began to usurp that title for themselves. In 221 BCE, after the then-king of Qin completed the conquest of the various kingdoms of the Warring States period, he adopted a new title to reflect his prestige as a ruler greater than the rulers before him. He called himself Shi Huangdi, the First Emperor. Before this, Huang (皇) and Di (帝) were the nominal "titles" of eight rulers of Chinese mythology or prehistory: The three Huang (, "august, sovereign") were godly rulers credited with feats like ordering the sky and forming the first humans out of clay; the five Di (帝, , also often translated as "emperor" but also meaning "the God of Heaven") were cultural heroes credited with the invention of agriculture, clothing, astrology, music, etc.