During his tenure as an official, Confucius was meticulous in his work, treated others with humility and propriety (Li), and cooperated harmoniously with other ministers. He achieved notable success not only in diplomacy but also in domestic governance, bringing the entire State of Lu to a state where doors need not be closed at night and lost items were never picked up by others. After the Jiagu Alliance, Duke Ding of Lu grew increasingly trustful of Confucius. On one occasion, the Duke asked him: "How should a ruler employ his ministers, and how should ministers serve their ruler?" Confucius replied: "A ruler should employ his ministers according to Li (ritual propriety), and ministers should serve their ruler with Zhong (loyalty/devotion)." In this answer, Confucius pointed out, on one hand, that the exercise of sovereign power is not unlimited; it must operate within the bounds of Li and according to its regulations. The ruler's position has always been supreme, and the lack of oversight and checks inevitably leads to the abuse of power and, subsequently, corruption and decay. Thus, Confucius proposed using Li to constrain the exercise of power. On the other hand, this statement indicates that if the ruler treats his ministers in accordance with Li, then ministers must also devote themselves fully and loyally to the ruler. Confucius also clearly expressed his own stance through this. Therefore, after hearing this, Duke Ding of Lu trusted and valued Confucius even more. Ji Huanzi (a powerful minister of Lu) also placed great trust in Confucius and followed his advice without question.
In the eleventh year of Duke Ding of Lu (499 BCE), Duke Ding announced that Confucius, entrusted by Ji Huanzi (head of the Ji family), would act as acting prime minister to participate in state affairs, granting Confucius the important position of "acting as prime minister." In the twelfth year of Duke Ding (498 BCE), to strengthen the ducal house and restrain the Three Huan families (the three hereditary ministers Ji Sun, Shu Sun, and Meng Sun, so called because they were grandsons of Duke Huan of Lu; at the time, the Lu government was effectively in their hands, while some of their stewards controlled them to varying degrees), Confucius cited the ancient rule "a minister's household should not store armor, nor should a town have walls over a hundred zhi in height" and proposed the "Dismantle the Three Cities" plan, which involved demolishing the cities built by the Three Huan families and disbanding their private armies, thereby legitimately weakening their power. He implemented this through Zi Lu (disciple of Confucius, serving as steward of the Ji family). By exploiting the conflict between the Three Huan families and their stewards, Ji Sun and Shu Sun agreed to dismantle their respective fiefs, Fei and Hou. Shu Sun first removed Hou City smoothly, but when it came to Ji's Fei City, it met strong resistance from Gongshan Buni (a steward of the Ji family). Gongshan Buni and Shusun (a steward of the Shu Sun family) joined forces, leading Fei residents to attack the Lu capital, attempting a "siege of Wei to rescue Zhao" tactic. Caught off guard, Duke Ding of Lu fled in panic into the Ji family mansion, climbing to the Ji Wuzi platform. After entering Qufu, the Fei people rushed to the Ji family palace, surrounding it and launching a fierce assault. Confucius arrived promptly by Duke Ding's side, commanding generals Shen Juxu and Le Qi to lead elite troops in a counterattack; the Fei people were defeated and fled. Confucius led the army in pursuit, defeating the Fei forces at Gumi (in present-day Sishui County, Shandong). Gongshan Buni hastily fled to Qi for refuge, and Fei City was finally demolished. When Confucius planned to dismantle Cheng City next, Meng Sun was incited by his steward Gonglian Chufu to oppose the dismantling. Duke Ding of Lu besieged it but failed to take it; Confucius's plan was thwarted, and the "Dismantle the Three Cities" action was abandoned halfway.
