Speaking truth to power has always been a high-risk strategy in China. Its rulers tend to prefer flattery, and writers who forget this do so at their peril. China's "grand historian" - 2,000 years ago - was one of many who have paid a terrible price.
"Among defilements, none is so great as castration. Any man who continues to live having suffered such a punishment is accounted as a nothing."
The man who wrote those words is by no means a nothing today. In a nation obsessed by its history, Sima Qian was the first and some say the greatest historian.
Wind back two millennia. It is 99 BC. On China's northern frontier, imperial forces have surrendered to barbarians. At court, the news is greeted with shock. The emperor is raging.
But an upstart official defies court etiquette by speaking up for the defeated general.
"He is a man with many famous victories to his credit, a man far above the ordinary, while these courtiers - whose sole concern has been preserving themselves and their families - seize on one mistake. I felt sick at heart to see it," writes Sima Qian in a letter to a friend afterwards.
The general had committed treason by surrendering. And Sima Qian had committed treason by defending him.
"None of my friends came to my aid, none of my colleagues spoke a word on my behalf," he writes.
There is an interrogation. Sima Qian tells his friend his body is not made of wood or stone. "I was alone with my inquisitors, shut in the darkness of my cell."
At the end he is offered an unenviable choice - death or castration. To his contemporaries, death was the only honourable option but Sima Qian had a bigger audience in mind than the Chinese court of the 1st Century BC. He was writing a history of humanity for posterity.
Sima Qian's father had been court historian before him and had started the project. On his sickbed, with both of them in tears, the father extracted from the son a promise to complete the epic work.
So he chose castration.
"If I had followed custom and submitted to execution, how would it have made a difference greater than the loss of a strand of hair from a herd of oxen or the life of a solitary ant?" he wrote.
"A man has only one death. That death may be as weighty as Mount Tai or it may be as light as a goose feather. It all depends on the way he uses it."
But neither in the letter nor in his autobiography can Sima Qian bring himself to describe the horror of castration. He talks instead of going down to the "silkworm chamber".
It was already well known that a castrated man could easily die from blood loss or infection so after mutilation the victims were kept like silkworms in a warm, draught-free room.
Sima Qian never recovered from the humiliation.
"I look at myself now, mutilated in body and living in vile disgrace. Every time I think of this shame I find myself drenched in sweat."
But he also wrote that if, as a result of his sacrifice, his work ended up being handed down to men who would appreciate it, reaching villages and great cities, then he would have no regrets even after suffering 1,000 mutilations.
If only he could have seen the future as well as he saw the past.
In today's China, Sima Qian's book, The Records of the Grand Historian, is regarded as the grandest history of them all. What Herodotus is to Europeans, so Sima Qian is to Chinese.
What is special about Sima Qian's history is that, even when he wrote about the court, it was not just flattery. Here is his verdict on an emperor from the Shang dynasty 1,000 years earlier:
"Emperor Zhou's disposition was sharp, his discernment was keen, and his physical strength excelled that of other people. He fought ferocious animals with his bare hands. He considered everyone beneath him. He was fond of wine, licentious in pleasure and doted on women…
"He then ordered his Music Master to compose new licentious music and depraved songs. By a pool filled with wine, through meat hanging like a forest, he made naked men and women chase one another and engage in drinking long into the night."
The emperor had critics turned into mincemeat, and nobles who were not up for the party roasted alive.
Zhou was a good illustration of a theory Sima Qian had about dynastic change, as Frances Wood, curator of the Chinese collection at the British Library, explains.
"He introduced the idea… that dynasties begin with the very virtuous and noble founder, and then they continue through a series of rulers until they come to a bad last ruler, and he is so morally depraved that he is overthrown."
No suprises - Zhou was the last of the Shang dynasty.
Sima Qian thought the purpose of history was to teach rulers how to govern well.
By contrast, China's current government - like every other Chinese government I can think of - sees it as a means of legitimising its rule.
"History is totally political in China, and I think it always has been," says Frances Wood.
Just look, she says, at the fate of historians in 20th Century China.
"Somebody who actually became deputy mayor of Peking, Wu Han, was a very important historian who had written about the first Ming emperor.
"The first Ming emperor… in 1368, he's often been compared with Mao Tse-Tung, because he was a charismatic bandit leader who, in his last years, went pretty crazy and paranoid. So you have Wu Han writing that history in the 1950s, which was a very dangerous thing to do, because Mao was already beginning to totter into paranoia."
For criticising the present by writing about the past, Wu Han was arrested. He died in prison in 1969.
Last year China re-opened its national museum, lauded as the world's biggest museum under one roof. It is hugely popular, but it illustrates just how much history is a pick-and-mix for China's rulers. They leave out the bits that do not do them credit and - masters of selective memory - they big up the moments they are proud of.
So instead of the tens of millions who died in Mao's Great Leap forward and the Cultural Revolution, you get China's first nuclear test in 1964, or a celebration of the reform era after Mao's death.
A panel as you exit the museum spells out the key message: "Since the founding of the Communist Party of China 90 years ago, under the strong leadership of the Party, our great nation has successively achieved many historic changes… Socialism is the only way to save China, and reform and opening up is the only way to develop China."
I am sure Sima Qian would hope someone like him is sitting unnoticed in a quiet corner writing a more nuanced history of this period, even if it can only be published when the powerful have passed on.
This, in fact, is how The Records of the Grand Historian saw the light of day.
After his death, his daughter risked her own safety to hide his secret history. And two emperors later, his grandson took another risk in revealing the book's existence. The rest, as they say, is history.
Translation of The Grand Scribe's Records by William Nienhauser. Letter to Ren An by Burton Watson.